+ // setting the values that come in an ENV variable as defaults - ves-heartbeat-period
+ int vesHeartbeatPeriod = getIntFromString(getenv("VesHeartbeatPeriod"), 0);
+
+ sr_val_t value = { 0 };
+ value.type = SR_UINT32_T;
+ value.data.uint32_val = vesHeartbeatPeriod;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/notification-config/ves-heartbeat-period",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = ves_heartbeat_period_changed(vesHeartbeatPeriod);
+ if (SR_ERR_OK != rc) {
+ printf("Error by ves_heartbeat_period_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - is-netconf-available
+
+ int isNetconfAvailable = 1;
+
+ char *isNetconfAvailablString = getenv("IsNetconfAvailable");
+ if (isNetconfAvailablString != NULL)
+ {
+ if (strcmp(isNetconfAvailablString, "false") == 0)
+ {
+ isNetconfAvailable = 0;
+ }
+ }
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_BOOL_T;
+ value.data.bool_val = isNetconfAvailable;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/notification-config/is-netconf-available",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = is_netconf_available_changed(isNetconfAvailable);
+ if (SR_ERR_OK != rc) {
+ printf("Error by is_netconf_available_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - is-ves-available
+
+ int isVesAvailable = 1;
+
+ char *isVesAvailablString = getenv("IsVesAvailable");
+ if (isVesAvailablString != NULL)
+ {
+ if (strcmp(isVesAvailablString, "false") == 0)
+ {
+ isVesAvailable = 0;
+ }
+ }
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_BOOL_T;
+ value.data.bool_val = isVesAvailable;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/notification-config/is-ves-available",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = is_ves_available_changed(isVesAvailable);
+ if (SR_ERR_OK != rc) {
+ printf("Error by is_ves_available_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - ves-endpoint-port
+
+ int vesEndpointPort = getIntFromString(getenv("VesEndpointPort"), 8080);
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_UINT16_T;
+ value.data.uint16_val = vesEndpointPort;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/ves-endpoint-details/ves-endpoint-port",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = ves_port_changed(vesEndpointPort);
+ if (SR_ERR_OK != rc) {
+ printf("Error by ves_port_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - ves-endpoint-ip
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_STRING_T;
+ value.data.string_val = getenv("VesEndpointIp");
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/ves-endpoint-details/ves-endpoint-ip",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = ves_ip_changed(getenv("VesEndpointIp"));
+ if (SR_ERR_OK != rc) {
+ printf("Error by ves_ip_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - ssh-connections
+
+ int sshConnections = getIntFromString(getenv("SshConnections"), 1);
+
+ rc = ssh_connections_changed(sshConnections);
+ if (SR_ERR_OK != rc) {
+ printf("Error by ssh_connections_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - tls-connections
+
+ int tlsConnections = getIntFromString(getenv("TlsConnections"), 0);
+
+ rc = tls_connections_changed(tlsConnections);
+ if (SR_ERR_OK != rc) {
+ printf("Error by tls_connections_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ if (strcmp(getenv("K8S_DEPLOYMENT"), "true") == 0)
+ {
+ rc = send_k8s_extend_port();
+ if (rc != SR_ERR_OK)
+ {
+ printf("Could not send the number of ports to k8s cluster\n");
+ }
+ }
+
+ // setting the values that come in an ENV variable as defaults - controller-ip
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_STRING_T;
+ value.data.string_val = getenv("ControllerIp");
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/controller-details/controller-ip",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = controller_ip_changed(getenv("ControllerIp"));
+ if (SR_ERR_OK != rc) {
+ printf("Error by controller_ip_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - controller-port
+
+ int controllerPort = getIntFromString(getenv("ControllerPort"), 8181);
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_UINT16_T;
+ value.data.uint16_val = controllerPort;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/controller-details/controller-port",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = controller_port_changed(controllerPort);
+ if (SR_ERR_OK != rc) {
+ printf("Error by controller_port_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - netconf-call-home-port
+
+ int netconfCallHomePort = getIntFromString(getenv("NetconfCallHomePort"), 6666);
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_UINT16_T;
+ value.data.uint16_val = netconfCallHomePort;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/controller-details/netconf-call-home-port",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = controller_netconf_call_home_port_changed(netconfCallHomePort);
+ if (SR_ERR_OK != rc) {
+ printf("Error by controller_netconf_call_home_port_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - controller-username
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_STRING_T;
+ value.data.string_val = getenv("ControllerUsername");
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/controller-details/controller-username",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = controller_username_changed(getenv("ControllerUsername"));
+ if (SR_ERR_OK != rc) {
+ printf("Error by controller_username_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - controller-password
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_STRING_T;
+ value.data.string_val = getenv("ControllerPassword");
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/controller-details/controller-password",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = controller_password_changed(getenv("ControllerPassword"));
+ if (SR_ERR_OK != rc) {
+ printf("Error by controller_password_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ // setting the values that come in an ENV variable as defaults - netconf-call-home
+
+ int netconfCallHome = 1;
+
+ char *netconfCallHomeString = getenv("NetconfCallHome");
+ if (netconfCallHomeString != NULL)
+ {
+ if (strcmp(netconfCallHomeString, "false") == 0)
+ {
+ netconfCallHome = 0;
+ }
+ }
+
+ value = (const sr_val_t) { 0 };
+ value.type = SR_BOOL_T;
+ value.data.bool_val = netconfCallHome;
+ rc = sr_set_item(session, "/network-topology-simulator:simulator-config/netconf-call-home",
+ &value, SR_EDIT_DEFAULT);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_set_item: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ rc = netconf_call_home_changed(netconfCallHome);
+ if (SR_ERR_OK != rc) {
+ printf("Error by netconf_call_home_changed: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+
+ //commit the changes that we have done until now
+ rc = sr_commit(session);
+ if (SR_ERR_OK != rc) {
+ printf("Error by sr_commit: %s\n", sr_strerror(rc));
+ goto cleanup;
+ }
+