1 /*************************************************************************
3 * Copyright 2020 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
20 #include "nts_utils.h"
21 #include "utils/log_utils.h"
22 #include "utils/sys_utils.h"
23 #include "core/framework.h"
24 #include "core/session.h"
25 #include "core/xpath.h"
31 cJSON* ves_create_common_event_header(const char *domain, const char *event_type, const char *hostname, int port, const char *priority, int seq_id) {
38 long useconds = get_microseconds_since_epoch();
40 asprintf(&eventId, "%s-%d", event_type, seq_id);
42 log_error("asprintf failed\n");
46 cJSON *common_event_header = cJSON_CreateObject();
47 if(common_event_header == 0) {
48 log_error("could not create JSON object\n");
53 if(cJSON_AddStringToObject(common_event_header, "domain", domain) == 0) {
54 log_error("cJSON AddStringToObject error\n");
56 cJSON_Delete(common_event_header);
60 if(cJSON_AddStringToObject(common_event_header, "eventId", eventId) == 0) {
61 log_error("cJSON AddStringToObject error\n");
63 cJSON_Delete(common_event_header);
69 if(cJSON_AddStringToObject(common_event_header, "eventName", event_type) == 0) {
70 log_error("cJSON AddStringToObject error\n");
71 cJSON_Delete(common_event_header);
75 if(cJSON_AddNumberToObject(common_event_header, "sequence", (double)(seq_id)) == 0) {
76 log_error("cJSON AddNumberToObject error\n");
77 cJSON_Delete(common_event_header);
81 if(cJSON_AddStringToObject(common_event_header, "priority", priority) == 0) {
82 log_error("cJSON AddStringToObject error\n");
83 cJSON_Delete(common_event_header);
87 if(cJSON_AddStringToObject(common_event_header, "reportingEntityId", "") == 0) {
88 log_error("cJSON AddStringToObject error\n");
89 cJSON_Delete(common_event_header);
93 char source_name[512];
95 sprintf(source_name, "%s-%d", hostname, port);
98 sprintf(source_name, "%s", hostname);
101 if(cJSON_AddStringToObject(common_event_header, "reportingEntityName", source_name) == 0) {
102 log_error("cJSON AddStringToObject error\n");
103 cJSON_Delete(common_event_header);
107 if(cJSON_AddStringToObject(common_event_header, "sourceId", "") == 0) {
108 log_error("cJSON AddStringToObject error\n");
109 cJSON_Delete(common_event_header);
113 if(cJSON_AddStringToObject(common_event_header, "sourceName", source_name) == 0) {
114 log_error("cJSON AddStringToObject error\n");
115 cJSON_Delete(common_event_header);
119 if(cJSON_AddNumberToObject(common_event_header, "startEpochMicrosec", (double)(useconds)) == 0) {
120 log_error("cJSON AddNumberToObject error\n");
121 cJSON_Delete(common_event_header);
125 if(cJSON_AddNumberToObject(common_event_header, "lastEpochMicrosec", (double)(useconds)) == 0) {
126 log_error("cJSON AddNumberToObject error\n");
127 cJSON_Delete(common_event_header);
131 if(cJSON_AddStringToObject(common_event_header, "nfNamingCode", "sdn controller") == 0) {
132 log_error("cJSON AddStringToObject error\n");
133 cJSON_Delete(common_event_header);
137 if(cJSON_AddStringToObject(common_event_header, "nfVendorName", "sdn") == 0) {
138 log_error("cJSON AddStringToObject error\n");
139 cJSON_Delete(common_event_header);
143 if(cJSON_AddStringToObject(common_event_header, "timeZoneOffset", "+00:00") == 0) {
144 log_error("cJSON AddStringToObject error\n");
145 cJSON_Delete(common_event_header);
149 if(cJSON_AddStringToObject(common_event_header, "version", "4.1") == 0) {
150 log_error("cJSON AddStringToObject error\n");
151 cJSON_Delete(common_event_header);
155 if(cJSON_AddStringToObject(common_event_header, "vesEventListenerVersion", framework_environment.ves_endpoint.common_header_version) == 0) {
156 log_error("cJSON AddStringToObject error\n");
157 cJSON_Delete(common_event_header);
161 return common_event_header;
164 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) {
171 long useconds = get_microseconds_since_epoch();
173 asprintf(&eventId, "%s-%d", event_type, seq_id);
175 log_error("asprintf failed\n");
179 cJSON *common_event_header = cJSON_CreateObject();
180 if(common_event_header == 0) {
181 log_error("could not create JSON object\n");
186 if(cJSON_AddStringToObject(common_event_header, "domain", domain) == 0) {
187 log_error("cJSON AddStringToObject error\n");
189 cJSON_Delete(common_event_header);
193 if(cJSON_AddStringToObject(common_event_header, "eventId", eventId) == 0) {
194 log_error("cJSON AddStringToObject error\n");
196 cJSON_Delete(common_event_header);
203 asprintf(&eventName, "ves-stndDefined-%s", event_type);
205 log_error("asprintf failed\n");
209 if(cJSON_AddStringToObject(common_event_header, "eventName", eventName) == 0) {
210 log_error("cJSON AddStringToObject error\n");
211 cJSON_Delete(common_event_header);
217 if(cJSON_AddStringToObject(common_event_header, "eventType", event_type) == 0) {
218 log_error("cJSON AddStringToObject error\n");
219 cJSON_Delete(common_event_header);
223 if(cJSON_AddNumberToObject(common_event_header, "sequence", (double)(seq_id)) == 0) {
224 log_error("cJSON AddNumberToObject error\n");
225 cJSON_Delete(common_event_header);
229 if(cJSON_AddStringToObject(common_event_header, "priority", priority) == 0) {
230 log_error("cJSON AddStringToObject error\n");
231 cJSON_Delete(common_event_header);
235 if(cJSON_AddStringToObject(common_event_header, "reportingEntityId", "") == 0) {
236 log_error("cJSON AddStringToObject error\n");
237 cJSON_Delete(common_event_header);
241 char source_name[512];
243 sprintf(source_name, "%s-%d", hostname, port);
246 sprintf(source_name, "%s", hostname);
249 if(cJSON_AddStringToObject(common_event_header, "reportingEntityName", source_name) == 0) {
250 log_error("cJSON AddStringToObject error\n");
251 cJSON_Delete(common_event_header);
255 if(cJSON_AddStringToObject(common_event_header, "sourceId", "") == 0) {
256 log_error("cJSON AddStringToObject error\n");
257 cJSON_Delete(common_event_header);
261 if(cJSON_AddStringToObject(common_event_header, "sourceName", source_name) == 0) {
262 log_error("cJSON AddStringToObject error\n");
263 cJSON_Delete(common_event_header);
267 if(cJSON_AddNumberToObject(common_event_header, "startEpochMicrosec", (double)(useconds)) == 0) {
268 log_error("cJSON AddNumberToObject error\n");
269 cJSON_Delete(common_event_header);
273 if(cJSON_AddNumberToObject(common_event_header, "lastEpochMicrosec", (double)(useconds)) == 0) {
274 log_error("cJSON AddNumberToObject error\n");
275 cJSON_Delete(common_event_header);
279 if(cJSON_AddStringToObject(common_event_header, "nfNamingCode", "sdn controller") == 0) {
280 log_error("cJSON AddStringToObject error\n");
281 cJSON_Delete(common_event_header);
285 if(cJSON_AddStringToObject(common_event_header, "nfVendorName", "sdn") == 0) {
286 log_error("cJSON AddStringToObject error\n");
287 cJSON_Delete(common_event_header);
291 if(cJSON_AddStringToObject(common_event_header, "timeZoneOffset", "+00:00") == 0) {
292 log_error("cJSON AddStringToObject error\n");
293 cJSON_Delete(common_event_header);
297 if(cJSON_AddStringToObject(common_event_header, "version", "4.1") == 0) {
298 log_error("cJSON AddStringToObject error\n");
299 cJSON_Delete(common_event_header);
303 if(cJSON_AddStringToObject(common_event_header, "vesEventListenerVersion", "7.2.1") == 0) {
304 log_error("cJSON AddStringToObject error\n");
305 cJSON_Delete(common_event_header);
309 if(cJSON_AddStringToObject(common_event_header, "stndDefinedNamespace", stnd_defined_namespace) == 0) {
310 log_error("cJSON AddStringToObject error\n");
311 cJSON_Delete(common_event_header);
315 if(cJSON_AddStringToObject(common_event_header, "nfcNamingCode", "NFC") == 0) {
316 log_error("cJSON AddStringToObject error\n");
317 cJSON_Delete(common_event_header);
321 return common_event_header;
326 nts_mount_point_addressing_method_t nts_mount_point_addressing_method_get(sr_session_ctx_t *current_session) {
329 nts_mount_point_addressing_method_t ret = UNKNOWN_MAPPING;
332 bool session_started = false;
333 if(current_session == 0) {
334 rc = sr_session_start(session_connection, SR_DS_RUNNING, ¤t_session);
335 if(rc != SR_ERR_OK) {
336 log_error("could not start sysrepo session\n");
339 session_started = true;
343 rc = sr_get_item(current_session, NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, 0, &value);
344 if(rc == SR_ERR_OK) {
345 if(strcmp(value->data.enum_val, "host-mapping") == 0) {
349 ret = DOCKER_MAPPING;
354 if(session_started) {
355 rc = sr_session_stop(current_session);
356 if(rc != SR_ERR_OK) {
357 log_error("could not stop sysrepo session\n");
365 // checkAS authentication via certificate not supported yet
366 ves_details_t *ves_endpoint_details_get(sr_session_ctx_t *current_session, const char *custom_path) {
370 bool session_started = false;
371 if(current_session == 0) {
372 rc = sr_session_start(session_connection, SR_DS_RUNNING, ¤t_session);
373 if(rc != SR_ERR_OK) {
374 log_error("could not start sysrepo session\n");
377 session_started = true;
380 struct lyd_node *data = 0;
383 if(custom_path == 0) {
384 if(framework_arguments.nts_mode == NTS_MODE_MANAGER) {
385 xpath_to_get = NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH;
388 xpath_to_get = NTS_NF_VES_ENDPOINT_CONFIG_XPATH;
392 xpath_to_get = (char *)custom_path;
395 rc = sr_get_subtree(current_session, xpath_to_get, 0, &data);
396 if(rc != SR_ERR_OK) {
397 log_error("could not get value for xPath=%s from the running datastore\n", xpath_to_get);
398 if(session_started) {
399 sr_session_stop(current_session);
404 if(session_started) {
405 rc = sr_session_stop(current_session);
406 if(rc != SR_ERR_OK) {
407 log_error("could not stop sysrepo session\n");
413 if(data->child == 0) {
414 log_error("ves-endpoint probably not set yet\n", xpath_to_get);
419 ves_details_t *ret = (ves_details_t *)malloc(sizeof(ves_details_t));
421 log_error("malloc failed\n");
429 ret->auth_method = 0;
433 struct lyd_node *chd = 0;
434 LY_TREE_FOR(data->child, chd) {
435 const char *val = ((const struct lyd_node_leaf_list *)chd)->value_str;
437 if(strcmp(chd->schema->name, "ves-endpoint-protocol") == 0) {
438 ret->protocol = strdup(val);
440 else if(strcmp(chd->schema->name, "ves-endpoint-ip") == 0) {
441 ret->ip = strdup(val);
443 else if(strcmp(chd->schema->name, "ves-endpoint-port") == 0) {
444 ret->port = ((const struct lyd_node_leaf_list *)chd)->value.uint16;
446 else if(strcmp(chd->schema->name, "ves-endpoint-auth-method") == 0) {
447 ret->auth_method = strdup(val);
449 else if(strcmp(chd->schema->name, "ves-endpoint-username") == 0) {
450 ret->username = strdup(val);
452 else if(strcmp(chd->schema->name, "ves-endpoint-password") == 0) {
453 ret->password = strdup(val);
458 if (strstr(ret->ip, ":")) {
460 asprintf(&ret->url, "%s://[%s]:%d/eventListener/v7", ret->protocol, ret->ip, ret->port);
463 if (framework_environment.ves_endpoint.port_absent == true) {
464 // hostname addressing with port missing
465 asprintf(&ret->url, "%s://%s/eventListener/v7", ret->protocol, ret->ip);
468 // normal addressing with IP and Port
469 asprintf(&ret->url, "%s://%s:%d/eventListener/v7", ret->protocol, ret->ip, ret->port);
474 if((ret->protocol == 0) || (ret->ip == 0) || (ret->auth_method == 0) || (ret->username == 0) || (ret->password == 0) || (ret->url == 0)) {
477 free(ret->auth_method);
488 void ves_details_free(ves_details_t *instance) {
491 free(instance->protocol);
494 free(instance->auth_method);
495 free(instance->username);
496 free(instance->password);
501 // checkAS authentication via certificate not supported yet
502 controller_details_t *controller_details_get(sr_session_ctx_t *current_session) {
506 bool session_started = false;
507 if(current_session == 0) {
508 rc = sr_session_start(session_connection, SR_DS_RUNNING, ¤t_session);
509 if(rc != SR_ERR_OK) {
510 log_error("could not start sysrepo session\n");
513 session_started = true;
516 struct lyd_node *data = 0;
519 if(framework_arguments.nts_mode == NTS_MODE_MANAGER) {
520 xpath_to_get = NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH;
523 xpath_to_get = NTS_NF_SDN_CONTROLLER_CONFIG_XPATH;
526 rc = sr_get_subtree(current_session, xpath_to_get, 0, &data);
527 if(rc != SR_ERR_OK) {
528 log_error("could not get value for xPath=%s from the running datastore\n", xpath_to_get);
529 if(session_started) {
530 sr_session_stop(current_session);
535 if(session_started) {
536 rc = sr_session_stop(current_session);
537 if(rc != SR_ERR_OK) {
538 log_error("could not stop sysrepo session\n");
544 if(data->child == 0) {
545 log_error("sdn-controller probably not set yet\n");
550 controller_details_t *ret = (controller_details_t *)malloc(sizeof(controller_details_t));
552 log_error("malloc failed\n");
560 ret->nc_callhome_ip = 0;
561 ret->nc_callhome_port = 0;
562 ret->auth_method = 0;
566 ret->auth_method = strdup("basic");
568 struct lyd_node *chd = 0;
569 LY_TREE_FOR(data->child, chd) {
570 const char *val = ((const struct lyd_node_leaf_list *)chd)->value_str;
572 if(strcmp(chd->schema->name, "controller-protocol") == 0) {
573 ret->protocol = strdup(val);
575 else if(strcmp(chd->schema->name, "controller-ip") == 0) {
576 ret->ip = strdup(val);
578 else if(strcmp(chd->schema->name, "controller-port") == 0) {
579 ret->port = ((const struct lyd_node_leaf_list *)chd)->value.uint16;
581 else if(strcmp(chd->schema->name, "controller-netconf-call-home-ip") == 0) {
582 ret->nc_callhome_ip = strdup(val);
584 else if(strcmp(chd->schema->name, "controller-netconf-call-home-port") == 0) {
585 ret->nc_callhome_port = ((const struct lyd_node_leaf_list *)chd)->value.uint16;
587 else if(strcmp(chd->schema->name, "controller-username") == 0) {
588 ret->username = strdup(val);
590 else if(strcmp(chd->schema->name, "controller-password") == 0) {
591 ret->password = strdup(val);
596 if (strstr(ret->ip, ":")) {
598 asprintf(&ret->base_url, "%s://[%s]:%d", ret->protocol, ret->ip, ret->port);
601 if (framework_environment.sdn_controller.port_absent == true) {
602 // hostname without port addressing
603 asprintf(&ret->base_url, "%s://%s", ret->protocol, ret->ip);
606 // normal IP and Port addressing
607 asprintf(&ret->base_url, "%s://%s:%d", ret->protocol, ret->ip, ret->port);
611 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)) {
614 free(ret->nc_callhome_ip);
615 free(ret->auth_method);
626 void controller_details_free(controller_details_t *instance) {
629 free(instance->protocol);
631 free(instance->nc_callhome_ip);
632 free(instance->base_url);
633 free(instance->auth_method);
634 free(instance->username);
635 free(instance->password);
639 int nts_vercmp(const char *ver1, const char *ver2) {
644 int v1 = 0, v2 = 0, v3 = 0;
645 while(ver1[i] && (ver1[i] != '.')) {
653 while(ver1[i] && (ver1[i] != '.')) {
661 while(ver1[i] && (ver1[i] != '.')) {
670 int V1 = 0, V2 = 0, V3 = 0;
672 while(ver2[i] && (ver2[i] != '.')) {
680 while(ver2[i] && (ver2[i] != '.')) {
688 while(ver2[i] && (ver2[i] != '.')) {
720 int nts_utils_populate_info(sr_session_ctx_t *current_session, const char *function_type) {
721 assert(current_session);
722 assert(function_type);
724 bool manager = (strcmp(function_type, "NTS_FUNCTION_TYPE_MANAGER") == 0);
728 //setup sdn-controller defaults
729 if(strlen(framework_environment.sdn_controller.protocol)) {
731 rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-protocol", (const char*)framework_environment.sdn_controller.protocol, 0, 0);
734 rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-protocol", (const char*)framework_environment.sdn_controller.protocol, 0, 0);
736 if(rc != SR_ERR_OK) {
737 log_error("sr_set_item_str failed\n");
738 return NTS_ERR_FAILED;
742 if(strlen(framework_environment.sdn_controller.ip)) {
744 rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-ip", (const char*)framework_environment.sdn_controller.ip, 0, 0);
747 rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-ip", (const char*)framework_environment.sdn_controller.ip, 0, 0);
749 if(rc != SR_ERR_OK) {
750 log_error("sr_set_item_str failed\n");
751 return NTS_ERR_FAILED;
755 sprintf(int_to_str, "%d", framework_environment.sdn_controller.port);
757 rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-port", (const char*)int_to_str, 0, 0);
760 rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-port", (const char*)int_to_str, 0, 0);
762 if(rc != SR_ERR_OK) {
763 log_error("sr_set_item_str failed\n");
764 return NTS_ERR_FAILED;
767 if(strlen(framework_environment.sdn_controller.callhome_ip)) {
769 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);
772 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);
774 if(rc != SR_ERR_OK) {
775 log_error("sr_set_item_str failed\n");
776 return NTS_ERR_FAILED;
780 sprintf(int_to_str, "%d", framework_environment.sdn_controller.callhome_port);
782 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);
785 rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-netconf-call-home-port", (const char*)int_to_str, 0, 0);
787 if(rc != SR_ERR_OK) {
788 log_error("sr_set_item_str failed\n");
789 return NTS_ERR_FAILED;
792 if(strlen(framework_environment.sdn_controller.username)) {
794 rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-username", (const char*)framework_environment.sdn_controller.username, 0, 0);
797 rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-username", (const char*)framework_environment.sdn_controller.username, 0, 0);
799 if(rc != SR_ERR_OK) {
800 log_error("sr_set_item_str failed\n");
801 return NTS_ERR_FAILED;
805 if(strlen(framework_environment.sdn_controller.password)) {
807 rc = sr_set_item_str(current_session, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH"/controller-password", (const char*)framework_environment.sdn_controller.password, 0, 0);
810 rc = sr_set_item_str(current_session, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH"/controller-password", (const char*)framework_environment.sdn_controller.password, 0, 0);
812 if(rc != SR_ERR_OK) {
813 log_error("sr_set_item_str failed\n");
814 return NTS_ERR_FAILED;
818 //setup ves-endpoint details
819 if(strlen(framework_environment.ves_endpoint.protocol)) {
821 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-protocol", (const char*)framework_environment.ves_endpoint.protocol, 0, 0);
824 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-protocol", (const char*)framework_environment.ves_endpoint.protocol, 0, 0);
826 if(rc != SR_ERR_OK) {
827 log_error("sr_set_item_str failed\n");
828 return NTS_ERR_FAILED;
832 if(strlen(framework_environment.ves_endpoint.ip)) {
834 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-ip", (const char*)framework_environment.ves_endpoint.ip, 0, 0);
837 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-ip", (const char*)framework_environment.ves_endpoint.ip, 0, 0);
839 if(rc != SR_ERR_OK) {
840 log_error("sr_set_item_str failed\n");
841 return NTS_ERR_FAILED;
845 sprintf(int_to_str, "%d", framework_environment.ves_endpoint.port);
847 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-port", (const char*)int_to_str, 0, 0);
850 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-port", (const char*)int_to_str, 0, 0);
852 if(rc != SR_ERR_OK) {
853 log_error("sr_set_item_str failed\n");
854 return NTS_ERR_FAILED;
857 if(strlen(framework_environment.ves_endpoint.auth_method)) {
859 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-auth-method", (const char*)framework_environment.ves_endpoint.auth_method, 0, 0);
862 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-auth-method", (const char*)framework_environment.ves_endpoint.auth_method, 0, 0);
864 if(rc != SR_ERR_OK) {
865 log_error("sr_set_item_str failed\n");
866 return NTS_ERR_FAILED;
870 if(strlen(framework_environment.ves_endpoint.username)) {
872 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-username", (const char*)framework_environment.ves_endpoint.username, 0, 0);
875 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-username", (const char*)framework_environment.ves_endpoint.username, 0, 0);
877 if(rc != SR_ERR_OK) {
878 log_error("sr_set_item_str failed\n");
879 return NTS_ERR_FAILED;
883 if(strlen(framework_environment.ves_endpoint.password)) {
885 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-password", (const char*)framework_environment.ves_endpoint.password, 0, 0);
888 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-password", (const char*)framework_environment.ves_endpoint.password, 0, 0);
890 if(rc != SR_ERR_OK) {
891 log_error("sr_set_item_str failed\n");
892 return NTS_ERR_FAILED;
896 if(strlen(framework_environment.ves_endpoint.certificate)) {
898 rc = sr_set_item_str(current_session, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-certificate", (const char*)framework_environment.ves_endpoint.certificate, 0, 0);
901 rc = sr_set_item_str(current_session, NTS_NF_VES_ENDPOINT_CONFIG_XPATH"/ves-endpoint-certificate", (const char*)framework_environment.ves_endpoint.certificate, 0, 0);
903 if(rc != SR_ERR_OK) {
904 log_error("sr_set_item_str failed\n");
905 return NTS_ERR_FAILED;
909 if(manager == false) {
910 //presence containers
911 rc = sr_set_item_str(current_session, NTS_NF_FAULT_GENERATION_SCHEMA_XPATH, 0, 0, 0);
912 if(rc != SR_ERR_OK) {
913 log_error("sr_set_item_str failed\n");
914 return NTS_ERR_FAILED;
917 rc = sr_set_item_str(current_session, NTS_NF_NETCONF_SCHEMA_XPATH, 0, 0, 0);
918 if(rc != SR_ERR_OK) {
919 log_error("sr_set_item_str failed\n");
920 return NTS_ERR_FAILED;
923 rc = sr_set_item_str(current_session, NTS_NF_VES_SCHEMA_XPATH, 0, 0, 0);
924 if(rc != SR_ERR_OK) {
925 log_error("sr_set_item_str failed\n");
926 return NTS_ERR_FAILED;
930 //also set the network-function module for easy identifying the function type
931 rc = sr_set_item_str(current_session, NTS_NF_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH, function_type, 0, 0);
932 if(rc != SR_ERR_OK) {
933 log_error("sr_set_item_str failed\n");
934 return NTS_ERR_FAILED;
937 //mount-point-addressing-method
938 rc = sr_set_item_str(current_session, NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, framework_environment.nts.nf_mount_point_addressing_method, 0, 0);
939 if(rc != SR_ERR_OK) {
940 log_error("sr_set_item_str failed\n");
941 return NTS_ERR_FAILED;
945 rc = sr_apply_changes(current_session, 0, 0);
946 if(rc != SR_ERR_OK) {
947 log_error("sr_apply_changes failed: %s\n", sr_strerror(rc));
948 return NTS_ERR_FAILED;