Add simulator improvements.
[sim/o1-interface.git] / ntsimulator / yang / nts-manager / network-topology-simulator.yang
1 module network-topology-simulator {
2   yang-version 1.1;
3   namespace "urn:onf:params:xml:ns:yang:network-topology-simulator";
4   prefix network-topology-simulator;
5
6   import ietf-inet-types {
7     prefix inet;
8   }
9
10   organization
11     "Melacon";
12   contact
13     "Web: <https://github.com/Melacon>
14      Editors:  Alex Stancu
15                <mailto:stancu.liviualex@gmail.com>";
16   description
17     "This module contains a collection of YANG definitions for managing the Network Topology Simulator.";
18
19 revision 2020-05-14 {
20     description
21       "New RPC for generic NETCONF notification generation.";
22     reference
23       "O-RAN SC SIM project";
24   }
25   revision 2020-04-22 {
26     description
27       "Add configuration for number of SSH and TLS connections exposed by each simulated device.";
28     reference
29       "O-RAN SC SIM project";
30   }
31   revision 2020-04-13 {
32     description
33       "Change fault-notification-delay-period to leaf-list.";
34     reference
35       "O-RAN SC SIM project";
36   }
37   revision 2020-04-10 {
38     description
39       "Add notification count in status.";
40     reference
41       "O-RAN SC SIM project";
42   }
43   revision 2019-10-25 {
44     description
45       "Modify notifications. Add VES message configuration options.";
46     reference
47       "O-RAN SC SIM project";
48   }
49   revision 2019-06-07 {
50     description
51       "Modify controller details.";
52     reference
53       "O-RAN SC SIM project";
54   }
55   revision 2019-03-07 {
56     description
57       "Initial version";
58     reference
59       "O-RAN SC SIM project";
60   }
61
62   typedef operational-state-type {
63     type enumeration {
64       enum not-specified {
65         description
66           "none";
67       }
68       enum running {
69         description
70           "none";
71       }
72       enum created {
73         description
74           "none";
75       }
76       enum exited {
77         description
78           "none";
79       }
80     }
81     description
82       "The operation state of the simulated device.";
83   }
84
85   typedef authentication-method-type {
86     type enumeration {
87       enum no-auth {
88         description
89           "no security (http)";
90       }
91       enum cert-only {
92         description
93           "auth by certificate (https)";
94       }
95       enum basic-auth {
96         description
97           "auth by basic auth username and password (https)";
98       }
99       enum cert-basic-auth {
100         description
101           "auth by certificate and basic auth username / password (https)";
102       }
103     }
104     description
105       "The authentication method for VES messaging.";
106   }
107
108   typedef percent {
109     type decimal64 {
110       fraction-digits 2;
111       range "0 .. 100";
112     }
113     description
114       "Percentage";
115   }
116
117   grouping controller-details-type-g {
118     leaf controller-ip {
119       type inet:ip-address;
120       description
121         "The IP Address of the SDN Controller.";
122     }
123     leaf controller-port {
124       type inet:port-number;
125       description
126         "The Port of the SDN Controller.";
127     }
128     leaf netconf-call-home-port {
129       type inet:port-number;
130       description
131         "The NETCONF Call Home Port of the SDN Controller.";      
132     }
133     leaf controller-username {
134       type string;
135       description
136         "The Username of the SDN Controller.";
137     }
138     leaf controller-password {
139       type string;
140       description
141         "The Password of the SDN Controller.";
142     }
143     description
144       "none";
145   }
146
147   grouping simulated-devices-type-g {
148     leaf uuid {
149       type string;
150       description
151         "The UUID of the simulated device.";
152     }
153     leaf device-ip {
154       type string;
155       description
156         "The IP Address of the simulated device.";
157     }
158     leaf-list device-port {
159       type uint32;
160       description
161         "A NETCONF endpoint (port) of the simulated device.";
162     }
163     leaf is-mounted {
164       type boolean;
165       description
166         "Specifies if the simulated device is mounted in the SDN Controller.";
167     }
168     leaf operational-state {
169       type operational-state-type;
170       description
171         "Specifies the operational state of the simulated device.";
172     }
173     description
174       "none";
175   }
176
177   grouping notification-count-per-severity-g {
178     leaf normal {
179     type uint32;
180     description
181     "The number of normal notifications.";
182     }
183     leaf warning {
184     type uint32;
185     description
186     "The number of warning notifications.";
187     }
188     leaf minor {
189     type uint32;
190     description
191     "The number of minor notifications.";
192     }
193     leaf major {
194     type uint32;
195     description
196     "The number of major notifications.";
197     }
198     leaf critical {
199     type uint32;
200     description
201     "The number of normal notifications.";
202     }
203     description
204       "none";
205   }
206
207   container simulator-config {
208     presence "Enables NTS configuration.";
209     description
210       "Configuration container of the simulator.";
211     leaf simulated-devices {
212       type uint32;
213       default "0";
214       description
215         "The number of devices to be simulated.";
216     }
217     leaf mounted-devices {
218       type uint32;
219       must ". <= ../simulated-devices" {
220           error-message "The number of mounted devices cannot be greater that the number of simulated devices";
221       }
222       default "0";
223       description
224         "The number of devices to be mounted in ODL. The configured number should not exceed the number of mounted devices.";
225     }
226     leaf netconf-call-home {
227         type boolean;
228         default "false";
229         description
230           "Configuration of NETCONF Call Home feature. If set to 'true', the device will use the SDN controller details and try to connect to it via Call Home.";
231     }
232     container notification-config {
233       leaf-list fault-notification-delay-period {
234         type uint32;
235         min-elements 1;
236         max-elements 99;
237         ordered-by user;
238         description
239           "Defines a pattern of generating notifications, represented by the amount of time between two generated fault notifications. The pattern is circular, it restarts at the beginning after all the leaf-list items are being used.
240           E.g.: if the leaf-list contains three items: 4, 8 and 10, then a fault-notification will be generated, then after 4 seconds a new notification will be generaed, then after 8 seconds, then after 10 seconds, then again after 4 seconds etc.";
241       }
242       leaf ves-heartbeat-period {
243         type uint32;
244         default "0";
245         description
246           "Interval in seconds between two VES heartbeat messages. If the attribute is set to 0, heartbeat messages are not generated.";
247       }
248       leaf is-netconf-available {
249         type boolean;
250         default "true";
251         description
252           "If set to 'true', NETCONF notifications will be generated.";
253       }
254       leaf is-ves-available {
255         type boolean;
256         default "true";
257         description
258           "If set to 'true', VES messages will be generated.";
259       }
260       description
261         "none";
262     }
263     container controller-details {
264       uses controller-details-type-g;
265       description
266         "The connectivity details of the SDN Controller where we want to mount our simulated devices.";
267     }
268     container ves-endpoint-details {
269       must 'ves-registration = "false" or ../mounted-devices = 0' {
270         error-message "VES registration cannot be active while devices are still mounted to ODL not via VES.";
271       }
272       leaf ves-endpoint-ip {
273         type inet:ip-address;
274         description
275           "The IP Address of the VES Endpoint.";
276       }
277       leaf ves-endpoint-port {
278         type inet:port-number;
279         description
280           "The Port of the VES Endpoint.";
281       }
282       leaf ves-endpoint-auth-method {
283         type authentication-method-type;
284         default "no-auth";
285         description
286           "The type of the authentication to be used with the VES Endpoint.";
287       }
288       leaf ves-endpoint-username {
289         when "../ves-endpoint-auth-method = 'basic-auth' or ../ves-endpoint-auth-method = 'cert-basic-auth'";
290         type string;
291         description
292           "The Username to be used to authenticate to the VES Endpoint.";
293       }
294       leaf ves-endpoint-password {
295         when "../ves-endpoint-auth-method = 'basic-auth' or ../ves-endpoint-auth-method = 'cert-basic-auth'";
296         type string;
297         description
298           "The Password to be used to authenticate to the VES Endpoint.";
299       }
300       leaf ves-endpoint-certificate {
301         when "../ves-endpoint-auth-method = 'cert-only' or ../ves-endpoint-auth-method = 'cert-basic-auth'";
302         type string;
303         description
304           "The Certificate to be used to authenticate to the VES Endpoint.";
305       }
306       leaf ves-registration {
307         type boolean;
308         default "false";
309         description
310           "If this is set to 'True', the simulated devices will automatically send a pnfRegistration VES message when they start. This cannot be set to 'True' if we already have 'mounted-devices' greater that 0, because we already mounted the devices directly to ODL.";
311       }
312       description
313         "none";
314     }
315   }
316   container simulator-status {
317     config false;
318     container simulation-usage-details {
319       config false;
320       leaf running-simulated-devices {
321         type uint32;
322         description
323           "The current number of running simulated devices.";
324       }
325       leaf running-mounted-devices {
326         type uint32;
327         description
328           "The current number of running simulated devices that are mounted in ODL.";
329       }
330       leaf ssh-connections {
331         type uint32;
332         description
333           "The number of SSH connections that are exposed by each simulated device. This can be set through the ENV variable SshConnections when starting the NTS Manager.";
334       }
335       leaf tls-connections {
336         type uint32;
337         description
338           "The number of TLS connections that are exposed by each simulated device. This can be set through the ENV variable TlsConnections when starting the NTS Manager.";
339       }
340       leaf base-netconf-port {
341         type uint32;
342         default "30000";
343         description
344           "The starting port number for the NETCONF connections exposed.";
345       }
346       leaf cpu-usage {
347         type percent;
348         description
349           "Specifies the CPU load generated by this simulated device.";
350       }
351       leaf mem-usage {
352         type uint32;
353         description
354           "Specifies the RAM in MB used by this simulated device.";
355       }
356       description
357         "The details about the simulation, including resources consumed.";
358     }
359     container notification-count {
360         config false;
361         container total-ves-notifications {
362             config false;
363             uses  notification-count-per-severity-g;
364             description
365               "The total number of VES notifications that were sent by all the simulated devices managed by this NTS Manager instance.";
366         }
367         container total-netconf-notifications {
368             config false;
369             uses  notification-count-per-severity-g;
370             description
371               "The total number of NETCONF notifications that were sent by all the simulated devices managed by this NTS Manager instance.";
372         }
373         description 
374           "The total number of notifications sent by the devices managed by this NTS Manager instance.";
375         
376     }
377     list simulated-devices-list {
378       key "uuid";
379       config false;
380       uses simulated-devices-type-g;
381       container notification-count {
382         config false;
383         container ves-notifications {
384             config false;
385             uses  notification-count-per-severity-g;
386             description
387               "The total number of VES notifications that were sent by this simulated device.";
388         }
389         container netconf-notifications {
390             config false;
391             uses  notification-count-per-severity-g;
392             description
393               "The total number of NETCONF notifications that were sent by this simulated device.";
394         }
395         description 
396           "The total number of notifications sent by this simulated device.";
397         
398     }
399       description
400         "The list of the devices that are currently simulated.";
401     }
402     description
403       "State data container of the simulator.";
404   }
405
406   grouping notification-job-g {
407       leaf device-id {
408         type string;
409         mandatory true;
410         description
411           "Device to invoke the NETCONF notification. If it is not present, all simulated devices would invoke the notification.";
412       }
413       leaf yang-module-name {
414         type string;
415         mandatory true;
416         description
417           "Name of the YANG module containing the notification to be invoked.";
418       }
419       leaf notification-object {
420           type string;
421           mandatory true;
422           description
423             "A JSON string containing the notification object to be sent by the device.";
424       }
425       description
426         "Notification job object class.";
427   }
428
429   rpc restart-simulation {
430     description
431       "Operation to restart all the simulated devices with the new configuration of the simulator.";
432   }
433
434   rpc add-key-pair-to-odl {
435     description
436       "Operation to add a key pair signed by the NTS to OpenDaylight, such that it can connect to devices using TLS.";
437   }
438
439   rpc invoke-notification {
440     description
441       "Operation to generate a NETCONF notification from a device.";
442     input {
443       uses notification-job-g;
444     }
445     output {
446       leaf status {
447           type enumeration {
448             enum SUCCESS {
449             description
450                 "This means that the RPC was successfully invoked.";
451             }
452             enum ERROR {
453             description
454                 "This means that an error was encountered when invoking the notification.";
455             }
456           }
457         mandatory true;
458         description
459           "The status of the RPC.";
460       }
461     }
462   }
463 }