return common_event_header;
}
+cJSON* ves_create_common_event_header_721(const char *domain, const char *event_type, const char *hostname, int port, const char *priority, int seq_id, const char *stnd_defined_namespace) {
+ assert(domain);
+ assert(event_type);
+ assert(hostname);
+ assert(priority);
+
+ char *eventId = 0;
+ long useconds = get_microseconds_since_epoch();
+
+ asprintf(&eventId, "%s-%d", event_type, seq_id);
+ if(eventId == 0) {
+ log_error("asprintf failed\n");
+ return 0;
+ }
+
+ cJSON *common_event_header = cJSON_CreateObject();
+ if(common_event_header == 0) {
+ log_error("could not create JSON object\n");
+ free(eventId);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "domain", domain) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ free(eventId);
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "eventId", eventId) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ free(eventId);
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ free(eventId);
+
+ char *eventName = 0;
+ asprintf(&eventName, "ves-stndDefined-%s", event_type);
+ if(eventId == 0) {
+ log_error("asprintf failed\n");
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "eventName", eventName) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ free(eventName);
+ return 0;
+ }
+ free(eventName);
+
+ if(cJSON_AddStringToObject(common_event_header, "eventType", event_type) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddNumberToObject(common_event_header, "sequence", (double)(seq_id)) == 0) {
+ log_error("cJSON AddNumberToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "priority", priority) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "reportingEntityId", "") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ char source_name[512];
+ if(port) {
+ sprintf(source_name, "%s-%d", hostname, port);
+ }
+ else {
+ sprintf(source_name, "%s", hostname);
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "reportingEntityName", source_name) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "sourceId", "") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "sourceName", source_name) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddNumberToObject(common_event_header, "startEpochMicrosec", (double)(useconds)) == 0) {
+ log_error("cJSON AddNumberToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddNumberToObject(common_event_header, "lastEpochMicrosec", (double)(useconds)) == 0) {
+ log_error("cJSON AddNumberToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "nfNamingCode", "sdn controller") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "nfVendorName", "sdn") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "timeZoneOffset", "+00:00") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "version", "4.1") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "vesEventListenerVersion", "7.2.1") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "stndDefinedNamespace", stnd_defined_namespace) == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ if(cJSON_AddStringToObject(common_event_header, "nfcNamingCode", "NFC") == 0) {
+ log_error("cJSON AddStringToObject error\n");
+ cJSON_Delete(common_event_header);
+ return 0;
+ }
+
+ return common_event_header;
+}
+
+
+
nts_mount_point_addressing_method_t nts_mount_point_addressing_method_get(sr_session_ctx_t *current_session) {
assert_session();
}
// checkAS authentication via certificate not supported yet
-ves_details_t *ves_endpoint_details_get(sr_session_ctx_t *current_session) {
+ves_details_t *ves_endpoint_details_get(sr_session_ctx_t *current_session, const char *custom_path) {
assert_session();
int rc;
struct lyd_node *data = 0;
char *xpath_to_get;
- if(framework_arguments.nts_mode == NTS_MODE_MANAGER) {
- xpath_to_get = NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH;
+ if(custom_path == 0) {
+ if(framework_arguments.nts_mode == NTS_MODE_MANAGER) {
+ xpath_to_get = NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH;
+ }
+ else {
+ xpath_to_get = NTS_NF_VES_ENDPOINT_CONFIG_XPATH;
+ }
}
else {
- xpath_to_get = NTS_NF_VES_ENDPOINT_CONFIG_XPATH;
+ xpath_to_get = (char *)custom_path;
}
rc = sr_get_subtree(current_session, xpath_to_get, 0, &data);
// normal addressing with IP and Port
asprintf(&ret->url, "%s://%s:%d/eventListener/v7", ret->protocol, ret->ip, ret->port);
}
-
+
}
-
+
if((ret->protocol == 0) || (ret->ip == 0) || (ret->auth_method == 0) || (ret->username == 0) || (ret->password == 0) || (ret->url == 0)) {
free(ret->protocol);
free(ret->ip);
ret->protocol = 0;
ret->ip = 0;
ret->port = 0;
+ ret->nc_callhome_ip = 0;
ret->nc_callhome_port = 0;
ret->auth_method = 0;
ret->username = 0;
else if(strcmp(chd->schema->name, "controller-port") == 0) {
ret->port = ((const struct lyd_node_leaf_list *)chd)->value.uint16;
}
+ else if(strcmp(chd->schema->name, "controller-netconf-call-home-ip") == 0) {
+ ret->nc_callhome_ip = strdup(val);
+ }
else if(strcmp(chd->schema->name, "controller-netconf-call-home-port") == 0) {
ret->nc_callhome_port = ((const struct lyd_node_leaf_list *)chd)->value.uint16;
}
}
}
- if((ret->protocol == 0) || (ret->ip == 0) || (ret->auth_method == 0) || (ret->username == 0) || (ret->password == 0) || (ret->base_url == 0)) {
+ if((ret->protocol == 0) || (ret->ip == 0) || (ret->nc_callhome_ip == 0) || (ret->auth_method == 0) || (ret->username == 0) || (ret->password == 0) || (ret->base_url == 0)) {
free(ret->protocol);
free(ret->ip);
+ free(ret->nc_callhome_ip);
free(ret->auth_method);
free(ret->username);
free(ret->password);
free(instance->protocol);
free(instance->ip);
+ free(instance->nc_callhome_ip);
free(instance->base_url);
free(instance->auth_method);
free(instance->username);
return NTS_ERR_FAILED;
}
+ if(strlen(framework_environment.sdn_controller.callhome_ip)) {
+ if(manager) {
+ rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-netconf-call-home-ip", (const char*)framework_environment.sdn_controller.callhome_ip, 0, 0);
+ }
+ else {
+ rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-netconf-call-home-ip", (const char*)framework_environment.sdn_controller.callhome_ip, 0, 0);
+ }
+ if(rc != SR_ERR_OK) {
+ log_error("sr_set_item_str failed\n");
+ return NTS_ERR_FAILED;
+ }
+ }
+
sprintf(int_to_str, "%d", framework_environment.sdn_controller.callhome_port);
if(manager) {
rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-netconf-call-home-port", (const char*)int_to_str, 0, 0);