X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fsrc%2Fntsimulator-manager%2Fsimulator-operations.c;h=f734307030ed6b54d5fd3ce957f5763558ff7f91;hb=610985b805c2b5c730bbc247ccbf76dd624792d0;hp=872513af9647e0c4234947fdd26fabcd59b2a01f;hpb=29ce368a8b49cb41f3a1640581ff9958ea50ad8c;p=sim%2Fo1-interface.git diff --git a/ntsimulator/src/ntsimulator-manager/simulator-operations.c b/ntsimulator/src/ntsimulator-manager/simulator-operations.c index 872513a..f734307 100644 --- a/ntsimulator/src/ntsimulator-manager/simulator-operations.c +++ b/ntsimulator/src/ntsimulator-manager/simulator-operations.c @@ -1,9 +1,19 @@ -/* - * simulator-operations.c - * - * Created on: Mar 9, 2019 - * Author: parallels - */ +/************************************************************************* +* +* Copyright 2019 highstreet technologies GmbH and others +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +***************************************************************************/ #include "simulator-operations.h" #include "sysrepo.h" @@ -82,8 +92,8 @@ static cJSON* get_docker_container_bindings(void) curl_easy_reset(curl); set_curl_common_info(); - char url[100]; - sprintf(url, "http:/v%s/containers/NTS_Manager/json", getenv("DOCKER_ENGINE_VERSION")); + char url[200]; + sprintf(url, "http:/v%s/containers/%s/json", getenv("DOCKER_ENGINE_VERSION"), getenv("HOSTNAME")); curl_easy_setopt(curl, CURLOPT_URL, url); @@ -243,6 +253,12 @@ static char* create_docker_container_curl(int base_netconf_port, cJSON* managerB return NULL; } + if (cJSON_AddStringToObject(labels, "NTS_Manager", getenv("HOSTNAME")) == NULL) + { + printf("Could not create JSON object: NTS Manager\n"); + return NULL; + } + cJSON *env_variables_array = cJSON_CreateArray(); if (env_variables_array == NULL) { @@ -418,7 +434,7 @@ static int send_mount_device_instance_ssh(char *url, char *credentials, char *de curl_easy_setopt(curl_odl, CURLOPT_URL, url_for_curl); - char post_data_xml[1000]; + char post_data_xml[1500]; sprintf(post_data_xml, "" @@ -429,6 +445,11 @@ static int send_mount_device_instance_ssh(char *url, char *credentials, char *de "%s" "false" "120" + "false" + "1.5" + "20000" + "100" + "2000" "", device_name, device_port, getenv("NTS_IP"), device_port, "netconf", "netconf"); @@ -471,7 +492,7 @@ static int send_mount_device_instance_tls(char *url, char *credentials, char *de curl_easy_setopt(curl_odl, CURLOPT_URL, url_for_curl); - char post_data_xml[1000]; + char post_data_xml[1500]; sprintf(post_data_xml, "" @@ -487,6 +508,11 @@ static int send_mount_device_instance_tls(char *url, char *credentials, char *de "%d" "false" "120" + "false" + "1.5" + "20000" + "100" + "2000" "", device_name, device_port, getenv("NTS_IP"), "netconf", device_port); @@ -882,6 +908,12 @@ int stop_device(device_stack_t *theStack) printf("Could not kill and remove docker container with uuid=\"%s\"\n", last_id); } + rc = removeDeviceEntryFromStatusFile(last_id); + if (rc != SR_ERR_OK) + { + printf("Could not remove entry from status file for uuid=\"%s\"\n", last_id); + } + pop_device(theStack); return SR_ERR_OK; @@ -1001,6 +1033,7 @@ int get_docker_containers_operational_state_curl(device_stack_t *theStack) if (rc != SR_ERR_OK) { printf("Could not set the operational state for the device with uuid=\"%s\"\n", container_id_short); + return SR_ERR_OPERATION_FAILED; } } } @@ -1043,7 +1076,7 @@ char* get_docker_container_resource_stats(device_stack_t *theStack) return NULL; /* return with exit code indicating success. */ } -int notification_delay_period_changed(int period) +int notification_delay_period_changed(sr_val_t *val, size_t count) { char *stringConfiguration = readConfigFileInString(); @@ -1072,26 +1105,60 @@ int notification_delay_period_changed(int period) if (!cJSON_IsObject(notifConfig)) { printf("Configuration JSON is not as expected: notification-config is not an object"); - free(jsonConfig); + cJSON_Delete(jsonConfig); return SR_ERR_OPERATION_FAILED; } cJSON *faultNotifDelay = cJSON_GetObjectItemCaseSensitive(notifConfig, "fault-notification-delay-period"); - if (!cJSON_IsNumber(faultNotifDelay)) + if (!cJSON_IsArray(faultNotifDelay)) { - printf("Configuration JSON is not as expected: fault-notification-delay-period is not an object"); - free(jsonConfig); + printf("Configuration JSON is not as expected: fault-notification-delay-period is not an array."); + cJSON_Delete(jsonConfig); return SR_ERR_OPERATION_FAILED; } - //we set the value of the fault-notification-delay-period object - cJSON_SetNumberValue(faultNotifDelay, period); + cJSON_DeleteItemFromObject(notifConfig, "fault-notification-delay-period"); + + faultNotifDelay = NULL; + + faultNotifDelay = cJSON_CreateArray(); + if (faultNotifDelay == NULL) + { + cJSON_Delete(jsonConfig); + return SR_ERR_OPERATION_FAILED; + } + cJSON_AddItemToObject(notifConfig, "fault-notification-delay-period", faultNotifDelay); + + if (val != NULL && count > 0) + { + cJSON *arrayEntry = NULL; + for (size_t i=0; i