/
nso-netbox.yang
286 lines (235 loc) · 6.78 KB
/
nso-netbox.yang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
module nso-netbox {
namespace "http://learning.cisco.com/nso-netbox";
prefix nso-netbox;
yang-version 1.1;
import ietf-inet-types {
prefix inet;
}
import tailf-common {
prefix tailf;
}
import tailf-ncs {
prefix ncs;
}
description
"This will be an NSO package for interacting with NetBox as a source of truth.";
revision 2021-03-05 {
description
"Initial package";
}
revision 2021-03-23 {
description
"Add support for NetBox VM-Roles in addition to Device Types.";
}
list netbox-server {
description "NetBox server instance.";
key name;
leaf name {
tailf:info "Friendly name for NetBox server.";
type string;
}
choice server-address {
case dns {
leaf fqdn {
tailf:info "DNS Name for NetBox server";
type inet:domain-name;
}
}
case ip {
leaf address {
tailf:info "IP address for NetBox server";
type inet:ipv4-address;
}
}
}
leaf url {
tailf:info "Crafted URL for NetBox server";
type string;
config false;
tailf:cdb-oper { tailf:persistent true; }
}
leaf port {
tailf:info "TCP Port NetBox server listening on";
type uint16 {
range "0 .. 65535";
}
default 443;
}
leaf protocol {
tailf:info "HTTP or HTTPS used to connect to NetBox";
type enumeration {
enum http;
enum https;
}
default https;
}
leaf api-token {
tailf:info "API Token for interacting with NetBox Server.";
type tailf:aes-cfb-128-encrypted-string;
}
action verify-status {
tailf:actionpoint netbox-verify-status;
tailf:info "Perform a status check that the NetBox server is reachable.";
output {
leaf output { type string; }
leaf success { type boolean; }
}
}
uses ncs:service-data;
ncs:servicepoint nso-netbox-server-servicepoint;
}
list netbox-inventory {
description "Definition of a NetBox lookup of devices/vms to add to NSO as devices.";
key name;
leaf name {
tailf:info "Name for this set of devices.";
type string;
}
leaf auth-group {
tailf:info "The authgroup to use for this set of devices.";
type leafref {
path "/ncs:devices/ncs:authgroups/ncs:group/ncs:name";
}
mandatory true;
}
leaf connection-protocol {
tailf:info "The type of connection protocol to connect to the device with.";
type enumeration {
enum ssh;
enum telnet;
enum http;
enum https;
}
default ssh;
}
leaf bypass-certificate-verification {
tailf:info "Whether to verify keys for SSL type connections. A setting of 'true' is equivalent to 'verify = False'";
type boolean;
default true;
}
leaf admin-state {
tailf:info "The admin-state to add devices to NSO in.";
type enumeration {
enum config-locked;
enum locked;
enum southbound-locked;
enum unlocked;
}
}
leaf update-nso-devices {
tailf:info "Whether to add/update the NSO devices based on this query. If false, inventory can be used for verifications.";
type boolean;
default false;
}
leaf netbox-server {
tailf:info "The NetBox Server to query for this inventory lookup.";
type leafref {
path "/nso-netbox:netbox-server/name";
}
mandatory true;
}
leaf-list site {
tailf:info "Name of a NetBox Site to limit query to.";
type string;
}
leaf-list tenant {
tailf:info "Name of a NetBox Tenant to limit query to.";
type string;
}
list device-type {
tailf:info "NetBox Device Types to include in the inventory.";
key model;
leaf model {
tailf:info "The Model Name for the Device-Type.";
type string;
}
leaf ned {
tailf:info "The NED to use for this device type.";
type string;
tailf:non-strict-leafref {
path "/ncs:packages/ncs:package/ncs:build-info/ncs:package/ncs:name";
}
mandatory true;
}
}
leaf-list device-role {
tailf:info "Name of a NetBox Device Role to limit query to.";
type string;
}
list vm-role {
tailf:info "NetBox VM Roles to include in the inventory. Explicit vm-role -> NED definitions required.";
key role;
leaf role {
tailf:info "The name of the VM Role to include.";
type string;
}
leaf ned {
tailf:info "The NED to use for this VM Role.";
type string;
tailf:non-strict-leafref {
path "/ncs:packages/ncs:package/ncs:build-info/ncs:package/ncs:name";
}
mandatory true;
}
}
// Constraint - each inventory must have at least 1 device-type or vm-role defined
must "count(device-type) + count(vm-role) >= 1" {
error-message "Every netbox-inventory must have at least 1 device-type or vm-role defined.";
}
uses ncs:service-data;
ncs:servicepoint nso-netbox-inventory-servicepoint;
action verify-inventory {
tailf:actionpoint netbox-inventory-verify;
tailf:info "Verify that the NetBox Devices for the Inventory are present in NSO as Devices.";
output {
leaf output { type string; }
leaf success { type boolean; }
}
}
action build-inventory {
tailf:actionpoint netbox-inventory-build;
tailf:info "Deploy NSO devices based on the NetBox Devices for the described query.";
input {
leaf commit {
tailf:info "Whether to commit/merge the changes to the devices into NSO.";
type boolean;
default false;
}
}
output {
leaf output { type string; }
leaf success { type boolean; }
}
}
action connect-inventory {
tailf:actionpoint netbox-inventory-connect;
tailf:info "Establish connection to each inventory device and optionally sync-from.";
input {
leaf sync-from {
tailf:info "Whether to perform a sync-from on devices.";
type boolean;
default false;
}
}
output {
leaf output { type string; }
leaf success { type boolean; }
}
}
action remove-inventory {
tailf:actionpoint netbox-inventory-remove;
tailf:info "Remove NSO devices based on the NetBox Devices for the described query.";
input {
leaf commit {
tailf:info "Whether to commit/merge the changes to the devices into NSO.";
type boolean;
default false;
}
}
output {
leaf output { type string; }
leaf success { type boolean; }
}
}
}
}