|
56 | 56 | ], |
57 | 57 | secrets=[], |
58 | 58 | tenancy=["tenants", "tenant_groups"], |
59 | | - virtualization=["clusters"], |
| 59 | + virtualization=["cluster_groups", "cluster_types", "clusters", "virtual_machines"], |
60 | 60 | ) |
61 | 61 |
|
62 | 62 | # Used to normalize data for the respective query types used to find endpoints |
63 | 63 | QUERY_TYPES = dict( |
64 | 64 | cluster="name", |
| 65 | + cluster_group="slug", |
| 66 | + cluster_type="slug", |
65 | 67 | device="name", |
66 | 68 | device_role="slug", |
67 | 69 | device_type="slug", |
|
96 | 98 | # Specifies keys within data that need to be converted to ID and the endpoint to be used when queried |
97 | 99 | CONVERT_TO_ID = dict( |
98 | 100 | cluster="clusters", |
| 101 | + cluster_group="cluster_groups", |
| 102 | + cluster_type="cluster_types", |
99 | 103 | device="devices", |
100 | 104 | device_role="device_roles", |
101 | 105 | device_type="device_types", |
|
125 | 129 | tenant_group="tenant_groups", |
126 | 130 | untagged_vlan="vlans", |
127 | 131 | virtual_machine="virtual_machines", |
| 132 | + virtual_machine_role="device_roles", |
128 | 133 | vlan="vlans", |
129 | 134 | vlan_group="vlan_groups", |
130 | 135 | vlan_role="roles", |
|
133 | 138 |
|
134 | 139 | ENDPOINT_NAME_MAPPING = { |
135 | 140 | "aggregates": "aggregate", |
| 141 | + "clusters": "cluster", |
| 142 | + "cluster_groups": "cluster_group", |
| 143 | + "cluster_types": "cluster_type", |
136 | 144 | "device_bays": "device_bay", |
137 | 145 | "devices": "device", |
138 | 146 | "device_roles": "device_role", |
|
153 | 161 | "sites": "site", |
154 | 162 | "tenants": "tenant", |
155 | 163 | "tenant_groups": "tenant_group", |
| 164 | + "virtual_machines": "virtual_machine", |
156 | 165 | "vlans": "vlan", |
157 | 166 | "vlan_groups": "vlan_group", |
158 | 167 | "vrfs": "vrf", |
|
256 | 265 |
|
257 | 266 | INTF_MODE = {"access": 100, "tagged": 200, "tagged all": 300} |
258 | 267 |
|
| 268 | +VIRTUAL_MACHINE_STATUS = dict(offline=0, active=1, staged=3) |
| 269 | + |
| 270 | +# This is used when attempting to search for existing endpoints |
259 | 271 | ALLOWED_QUERY_PARAMS = { |
260 | 272 | "aggregate": set(["prefix", "rir"]), |
| 273 | + "cluster": set(["name", "type"]), |
| 274 | + "cluster_group": set(["slug"]), |
| 275 | + "cluster_type": set(["slug"]), |
261 | 276 | "device_bay": set(["name", "device"]), |
262 | 277 | "device": set(["name"]), |
263 | 278 | "device_role": set(["slug"]), |
|
287 | 302 | "tenant": set(["name"]), |
288 | 303 | "tenant_group": set(["name"]), |
289 | 304 | "untagged_vlan": set(["name", "site", "vlan_group", "tenant"]), |
| 305 | + "virtual_machine": set(["name", "cluster"]), |
290 | 306 | "vlan": set(["name", "site", "tenant"]), |
291 | 307 | "vlan_group": set(["slug", "site"]), |
292 | 308 | "vrf": set(["name", "tenant"]), |
293 | 309 | } |
294 | 310 |
|
295 | 311 | QUERY_PARAMS_IDS = set( |
296 | | - ["device", "group", "rir", "vrf", "site", "vlan_group", "tenant"] |
| 312 | + ["cluster", "device", "group", "rir", "vrf", "site", "vlan_group", "tenant", "type"] |
297 | 313 | ) |
298 | 314 |
|
299 | 315 | # This is used when converting static choices to an ID value acceptable to Netbox API |
|
306 | 322 | "racks": [{"status": RACK_STATUS, "outer_unit": RACK_UNIT, "type": RACK_TYPE}], |
307 | 323 | "services": [{"protocol": SERVICE_PROTOCOL}], |
308 | 324 | "sites": [{"status": SITE_STATUS}], |
| 325 | + "virtual_machines": [{"status": VIRTUAL_MACHINE_STATUS, "face": FACE_ID}], |
309 | 326 | "vlans": [{"status": VLAN_STATUS}], |
310 | 327 | } |
311 | 328 |
|
312 | 329 | # This is used to map non-clashing keys to Netbox API compliant keys to prevent bad logic in code for similar keys but different modules |
313 | 330 | CONVERT_KEYS = { |
| 331 | + "cluster_type": "type", |
| 332 | + "cluster_group": "group", |
314 | 333 | "parent_region": "parent", |
315 | 334 | "prefix_role": "role", |
316 | 335 | "rack_group": "group", |
317 | 336 | "rack_role": "role", |
318 | 337 | "tenant_group": "group", |
| 338 | + "virtual_machine_role": "role", |
319 | 339 | "vlan_role": "role", |
320 | 340 | "vlan_group": "group", |
321 | 341 | } |
322 | 342 |
|
323 | 343 | # This is used to dynamically conver name to slug on endpoints requiring a slug |
324 | 344 | SLUG_REQUIRED = { |
| 345 | + "cluster_groups", |
| 346 | + "cluster_types", |
325 | 347 | "device_roles", |
326 | 348 | "ipam_roles", |
327 | 349 | "rack_groups", |
|
0 commit comments