f61784e677d3f923940563878e85553c0bd3da11
[sim/o1-interface.git] / ntsimulator / src / ntsimulator-manager / simulator-operations.h
1 /*
2  * simulator-operations.h
3  *
4  *  Created on: Mar 9, 2019
5  *      Author: parallels
6  */
7
8 #ifndef SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_
9 #define SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_
10
11 #include <curl/curl.h>
12 #include <stdlib.h>
13 #include <stdbool.h>
14 #include <stdio.h>
15
16 #include "sysrepo.h"
17 #include "sysrepo/values.h"
18
19 #include <cjson/cJSON.h>
20
21 #define CURL_MEM_SIZE 2048
22
23
24 /**
25  * Storing the device information
26 */
27
28 typedef struct device {
29         char *device_id;
30         int netconf_port;
31         bool is_mounted;
32         char *operational_state;
33         struct device *next;
34 } device_t;
35
36 typedef struct device_stack {
37         device_t *head;
38         size_t stack_size;
39 } device_stack_t;
40
41 #define URL_AND_CREDENTIALS_MAX_LEN 400
42
43 typedef struct controller
44 {
45         char url[URL_AND_CREDENTIALS_MAX_LEN];
46         char credentials[URL_AND_CREDENTIALS_MAX_LEN];
47         char url_for_keystore_add[URL_AND_CREDENTIALS_MAX_LEN];
48         char url_for_private_key_add[URL_AND_CREDENTIALS_MAX_LEN];
49         char url_for_trusted_ca_add[URL_AND_CREDENTIALS_MAX_LEN];
50 } controller_t;
51
52
53 device_stack_t *new_device_stack(void);
54 void push_device(device_stack_t *theStack, char *dev_id, int port);
55 void pop_device(device_stack_t *theStack);
56 int get_netconf_port_next(device_stack_t *theStack);
57 int get_netconf_port_base(void);
58 char *get_id_last_device(device_stack_t *theStack);
59 int get_current_number_of_devices(device_stack_t *theStack);
60 int get_current_number_of_mounted_devices(device_stack_t *theStack);
61
62
63 /**
64  * cURL utilities
65 */
66
67 struct MemoryStruct {
68   char *memory;
69   size_t size;
70 };
71
72 int _init_curl(void);
73 int cleanup_curl(void);
74
75 int _init_curl_odl(void);
76 int cleanup_curl_odl(void);
77
78 int start_device(device_stack_t *theStack);
79 int stop_device(device_stack_t *theStack);
80
81 int mount_device(device_stack_t *theStack, controller_t controller_details);
82 int unmount_device(device_stack_t *theStack, controller_t controller_details);
83
84 char* get_docker_container_operational_state(device_stack_t *theStack, char *container_id);
85 int get_docker_containers_operational_state_curl(device_stack_t *theStack);
86
87 char* get_docker_container_resource_stats();
88
89 int notification_delay_period_changed(int period);
90 int ves_heartbeat_period_changed(int period);
91 int ves_ip_changed(char *new_ip);
92 int ves_port_changed(int new_port);
93 int ves_registration_changed(cJSON_bool new_bool);
94 int is_netconf_available_changed(cJSON_bool new_bool);
95 int is_ves_available_changed(cJSON_bool new_bool);
96
97
98
99 int add_key_pair_to_odl(controller_t *controller_list, int controller_list_size);
100
101
102 #endif /* SRC_NTSIMULATOR_MANAGER_SIMULATOR_OPERATIONS_H_ */