1 /*************************************************************************
3 * Copyright 2019 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 ***************************************************************************/
18 #ifndef SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_
19 #define SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_
21 #include <curl/curl.h>
27 #include "sysrepo/values.h"
29 #include <cjson/cJSON.h>
31 #define CURL_MEM_SIZE 2048
35 * Storing the device information
38 typedef struct device {
43 char *operational_state;
47 typedef struct device_stack {
52 #define URL_AND_CREDENTIALS_MAX_LEN 400
54 typedef struct controller
56 char url[URL_AND_CREDENTIALS_MAX_LEN];
57 char credentials[URL_AND_CREDENTIALS_MAX_LEN];
58 char url_for_keystore_add[URL_AND_CREDENTIALS_MAX_LEN];
59 char url_for_private_key_add[URL_AND_CREDENTIALS_MAX_LEN];
60 char url_for_trusted_ca_add[URL_AND_CREDENTIALS_MAX_LEN];
64 device_stack_t *new_device_stack(void);
65 void push_device(device_stack_t *theStack, char *dev_id, int port, int dev_num);
66 void pop_device(device_stack_t *theStack);
67 int get_netconf_port_next(device_stack_t *theStack);
68 int get_netconf_port_base(void);
69 int get_device_number_next(device_stack_t *theStack);
70 char *get_id_last_device(device_stack_t *theStack);
71 int get_current_number_of_devices(device_stack_t *theStack);
72 int get_current_number_of_mounted_devices(device_stack_t *theStack);
85 int cleanup_curl(void);
87 int _init_curl_odl(void);
88 int cleanup_curl_odl(void);
90 int _init_curl_k8s(void);
91 int cleanup_curl_k8s(void);
93 int start_device(device_stack_t *theStack);
94 int stop_device(device_stack_t *theStack);
96 int mount_device(device_stack_t *theStack, controller_t controller_details);
97 int unmount_device(device_stack_t *theStack, controller_t controller_details);
99 char* get_docker_container_operational_state(device_stack_t *theStack, char *container_id);
100 int get_docker_containers_operational_state_curl(device_stack_t *theStack);
102 char* get_docker_container_resource_stats();
104 int notification_delay_period_changed(sr_val_t *val, size_t count);
105 int ves_heartbeat_period_changed(int period);
106 int ves_ip_changed(char *new_ip);
107 int ves_port_changed(int new_port);
108 int ves_registration_changed(cJSON_bool new_bool);
109 int is_netconf_available_changed(cJSON_bool new_bool);
110 int is_ves_available_changed(cJSON_bool new_bool);
111 int ssh_connections_changed(int number);
112 int tls_connections_changed(int number);
115 int add_key_pair_to_odl(controller_t *controller_list, int controller_list_size);
117 int send_k8s_scale(int number_of_devices);
118 int send_k8s_extend_port(void);
120 #endif /* SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_ */