0
# Device and Infrastructure Management (DCIM)
1
2
Physical and virtual network infrastructure management including devices, locations, racks, cables, power, and device components. Provides comprehensive modeling of network hardware and connectivity.
3
4
## Capabilities
5
6
### Location Management
7
8
Hierarchical organization of physical locations and sites.
9
10
```python { .api }
11
class Location:
12
"""
13
Physical locations/sites in a hierarchical structure.
14
15
Attributes:
16
name (str): Location name
17
location_type (LocationType): Type of location
18
parent (Location): Parent location in hierarchy
19
description (str): Location description
20
physical_address (str): Physical address
21
shipping_address (str): Shipping address
22
latitude (float): GPS latitude
23
longitude (float): GPS longitude
24
contact_name (str): Primary contact name
25
contact_phone (str): Contact phone number
26
contact_email (str): Contact email address
27
"""
28
29
class LocationType:
30
"""
31
Location type definitions (site, building, floor, room, etc.).
32
33
Attributes:
34
name (str): Type name
35
description (str): Type description
36
nestable (bool): Whether locations of this type can be nested
37
parent (LocationType): Parent type in hierarchy
38
"""
39
```
40
41
### Rack Management
42
43
Physical rack organization and space management.
44
45
```python { .api }
46
class Rack:
47
"""
48
Equipment racks for mounting devices.
49
50
Attributes:
51
name (str): Rack name
52
location (Location): Rack location
53
rack_group (RackGroup): Rack group assignment
54
tenant (Tenant): Tenant assignment
55
status (Status): Operational status
56
serial (str): Serial number
57
asset_tag (str): Asset tag
58
type (str): Rack type
59
width (int): Rack width in units
60
u_height (int): Rack height in units
61
desc_units (bool): Whether units are numbered descending
62
outer_width (int): Outer width in millimeters
63
outer_depth (int): Outer depth in millimeters
64
outer_unit (str): Unit of measurement
65
mounting_depth (int): Mounting depth in millimeters
66
"""
67
68
class RackGroup:
69
"""
70
Rack grouping for organization.
71
72
Attributes:
73
name (str): Group name
74
location (Location): Location
75
parent (RackGroup): Parent group
76
description (str): Group description
77
"""
78
79
class RackReservation:
80
"""
81
Rack space reservations.
82
83
Attributes:
84
rack (Rack): Associated rack
85
units (list): Reserved rack units
86
created (datetime): Creation date
87
user (User): User who created reservation
88
tenant (Tenant): Tenant assignment
89
description (str): Reservation description
90
"""
91
```
92
93
### Device Management
94
95
Network device definitions and management.
96
97
```python { .api }
98
class Manufacturer:
99
"""
100
Hardware manufacturers.
101
102
Attributes:
103
name (str): Manufacturer name
104
description (str): Manufacturer description
105
"""
106
107
class Platform:
108
"""
109
Device platforms/operating systems.
110
111
Attributes:
112
name (str): Platform name
113
manufacturer (Manufacturer): Associated manufacturer
114
napalm_driver (str): NAPALM driver name
115
napalm_args (dict): NAPALM driver arguments
116
description (str): Platform description
117
"""
118
119
class DeviceFamily:
120
"""
121
Device family grouping.
122
123
Attributes:
124
name (str): Family name
125
description (str): Family description
126
"""
127
128
class DeviceType:
129
"""
130
Device type definitions/templates.
131
132
Attributes:
133
model (str): Device model name
134
manufacturer (Manufacturer): Device manufacturer
135
device_family (DeviceFamily): Device family
136
part_number (str): Part number
137
u_height (int): Height in rack units
138
is_full_depth (bool): Whether device is full depth
139
subdevice_role (str): Subdevice role
140
front_image (ImageField): Front panel image
141
rear_image (ImageField): Rear panel image
142
comments (str): Comments
143
"""
144
145
class Device:
146
"""
147
Physical network devices.
148
149
Attributes:
150
name (str): Device name
151
device_type (DeviceType): Device type
152
device_role (Role): Device role
153
tenant (Tenant): Tenant assignment
154
platform (Platform): Device platform
155
serial (str): Serial number
156
asset_tag (str): Asset tag
157
location (Location): Device location
158
rack (Rack): Rack assignment
159
position (int): Rack position
160
face (str): Rack face (front/rear)
161
status (Status): Operational status
162
primary_ip4 (IPAddress): Primary IPv4 address
163
primary_ip6 (IPAddress): Primary IPv6 address
164
cluster (Cluster): Cluster membership
165
virtual_chassis (VirtualChassis): Virtual chassis membership
166
vc_position (int): Virtual chassis position
167
vc_priority (int): Virtual chassis priority
168
comments (str): Comments
169
local_context_data (dict): Local configuration context
170
"""
171
172
class DeviceRedundancyGroup:
173
"""
174
Device redundancy groups for high availability.
175
176
Attributes:
177
name (str): Group name
178
status (Status): Group status
179
description (str): Group description
180
comments (str): Comments
181
"""
182
```
183
184
### Device Controllers
185
186
Controller management for network devices.
187
188
```python { .api }
189
class Controller:
190
"""
191
Device controllers (wireless controllers, SDN controllers, etc.).
192
193
Attributes:
194
name (str): Controller name
195
controller_device (Device): Physical controller device
196
controller_device_redundancy_group (DeviceRedundancyGroup): Redundancy group
197
role (Role): Controller role
198
tenant (Tenant): Tenant assignment
199
platform (Platform): Controller platform
200
status (Status): Operational status
201
description (str): Controller description
202
location (Location): Controller location
203
"""
204
205
class ControllerManagedDeviceGroup:
206
"""
207
Groups of devices managed by controllers.
208
209
Attributes:
210
name (str): Group name
211
controller (Controller): Managing controller
212
status (Status): Group status
213
description (str): Group description
214
weight (int): Group weight/priority
215
"""
216
```
217
218
### Device Components
219
220
Network interfaces and other device components.
221
222
```python { .api }
223
class Interface:
224
"""
225
Network interfaces on devices.
226
227
Attributes:
228
device (Device): Parent device
229
name (str): Interface name
230
label (str): Interface label
231
type (str): Interface type
232
enabled (bool): Whether interface is enabled
233
lag (Interface): Link aggregation group parent
234
mtu (int): Maximum transmission unit
235
mac_address (str): MAC address
236
speed (int): Interface speed in Kbps
237
duplex (str): Duplex setting
238
wwn (str): World Wide Name
239
mgmt_only (bool): Management only interface
240
description (str): Interface description
241
mode (str): Interface mode (access/tagged/trunk)
242
untagged_vlan (VLAN): Untagged VLAN
243
tagged_vlans (list): Tagged VLANs
244
vrf (VRF): VRF assignment
245
ip_addresses (list): Assigned IP addresses
246
"""
247
248
class BaseInterface:
249
"""Base interface functionality for common interface operations."""
250
251
class ConsolePort:
252
"""
253
Console ports on devices.
254
255
Attributes:
256
device (Device): Parent device
257
name (str): Port name
258
label (str): Port label
259
type (str): Port type
260
speed (int): Port speed
261
description (str): Port description
262
"""
263
264
class ConsoleServerPort:
265
"""
266
Console server ports.
267
268
Attributes:
269
device (Device): Parent device
270
name (str): Port name
271
label (str): Port label
272
type (str): Port type
273
speed (int): Port speed
274
description (str): Port description
275
"""
276
277
class PowerPort:
278
"""
279
Device power ports.
280
281
Attributes:
282
device (Device): Parent device
283
name (str): Port name
284
label (str): Port label
285
type (str): Port type
286
maximum_draw (int): Maximum power draw in watts
287
allocated_draw (int): Allocated power draw in watts
288
description (str): Port description
289
"""
290
291
class PowerOutlet:
292
"""
293
Power outlets on devices.
294
295
Attributes:
296
device (Device): Parent device
297
name (str): Outlet name
298
label (str): Outlet label
299
type (str): Outlet type
300
power_port (PowerPort): Associated power port
301
feed_leg (str): Power feed leg
302
description (str): Outlet description
303
"""
304
305
class DeviceBay:
306
"""
307
Modular device bays.
308
309
Attributes:
310
device (Device): Parent device
311
name (str): Bay name
312
label (str): Bay label
313
description (str): Bay description
314
installed_device (Device): Installed child device
315
"""
316
317
class ModuleBay:
318
"""
319
Module bays for modular components.
320
321
Attributes:
322
device (Device): Parent device
323
name (str): Bay name
324
label (str): Bay label
325
description (str): Bay description
326
"""
327
328
class FrontPort:
329
"""
330
Front panel ports for structured cabling.
331
332
Attributes:
333
device (Device): Parent device
334
name (str): Port name
335
label (str): Port label
336
type (str): Port type
337
rear_port (RearPort): Associated rear port
338
rear_port_position (int): Rear port position
339
description (str): Port description
340
"""
341
342
class RearPort:
343
"""
344
Rear panel ports for structured cabling.
345
346
Attributes:
347
device (Device): Parent device
348
name (str): Port name
349
label (str): Port label
350
type (str): Port type
351
positions (int): Number of positions
352
description (str): Port description
353
"""
354
355
class InventoryItem:
356
"""
357
Inventory item tracking.
358
359
Attributes:
360
device (Device): Parent device
361
parent (InventoryItem): Parent inventory item
362
name (str): Item name
363
label (str): Item label
364
manufacturer (Manufacturer): Item manufacturer
365
part_id (str): Part identifier
366
serial (str): Serial number
367
asset_tag (str): Asset tag
368
discovered (bool): Whether item was auto-discovered
369
description (str): Item description
370
"""
371
```
372
373
### Cabling and Connections
374
375
Physical cable management and connection tracking.
376
377
```python { .api }
378
class Cable:
379
"""
380
Physical cable connections between devices.
381
382
Attributes:
383
termination_a (object): A-side termination
384
termination_b (object): B-side termination
385
type (str): Cable type
386
status (Status): Cable status
387
tenant (Tenant): Tenant assignment
388
label (str): Cable label
389
color (str): Cable color
390
length (float): Cable length
391
length_unit (str): Length unit
392
description (str): Cable description
393
"""
394
395
class CablePath:
396
"""
397
Cable path tracking for end-to-end connectivity.
398
399
Attributes:
400
origin (object): Path origin
401
destination (object): Path destination
402
path (list): List of cable segments in path
403
is_active (bool): Whether path is active
404
is_split (bool): Whether path is split
405
"""
406
407
class CableTermination:
408
"""
409
Cable termination points.
410
411
Attributes:
412
cable (Cable): Associated cable
413
cable_end (str): Cable end (A or B)
414
termination (object): Termination object
415
"""
416
417
class PathEndpoint:
418
"""
419
Path endpoint management for complex topologies.
420
421
Attributes:
422
path (CablePath): Associated cable path
423
endpoint (object): Endpoint object
424
"""
425
```
426
427
### Virtualization Components
428
429
Virtual chassis and device contexts.
430
431
```python { .api }
432
class VirtualChassis:
433
"""
434
Virtual chassis stacking.
435
436
Attributes:
437
name (str): Virtual chassis name
438
domain (str): Chassis domain
439
master (Device): Master device
440
description (str): Chassis description
441
"""
442
443
class VirtualDeviceContext:
444
"""
445
Multi-context devices (virtual firewalls, routers, etc.).
446
447
Attributes:
448
name (str): Context name
449
device (Device): Parent device
450
identifier (int): Context identifier
451
primary_ip4 (IPAddress): Primary IPv4 address
452
primary_ip6 (IPAddress): Primary IPv6 address
453
tenant (Tenant): Tenant assignment
454
status (Status): Context status
455
description (str): Context description
456
comments (str): Comments
457
"""
458
```
459
460
### Software Management
461
462
Software version tracking and management.
463
464
```python { .api }
465
class SoftwareVersion:
466
"""
467
Software version tracking.
468
469
Attributes:
470
version (str): Software version string
471
platform (Platform): Associated platform
472
alias (str): Version alias
473
release_date (date): Release date
474
end_of_support_date (date): End of support date
475
documentation_url (str): Documentation URL
476
long_term_support (bool): LTS version flag
477
pre_release (bool): Pre-release version flag
478
tags (list): Associated tags
479
"""
480
481
class SoftwareImageFile:
482
"""
483
Software image files.
484
485
Attributes:
486
software_version (SoftwareVersion): Associated software version
487
image_file_name (str): Image file name
488
image_file_checksum (str): File checksum
489
hashing_algorithm (str): Checksum algorithm
490
image_file_size (int): File size in bytes
491
download_url (str): Download URL
492
default_image (bool): Default image flag
493
tags (list): Associated tags
494
"""
495
```
496
497
### Power Infrastructure
498
499
Power distribution and management.
500
501
```python { .api }
502
class PowerPanel:
503
"""
504
Electrical panels for power distribution.
505
506
Attributes:
507
name (str): Panel name
508
location (Location): Panel location
509
rack_group (RackGroup): Associated rack group
510
description (str): Panel description
511
"""
512
513
class PowerFeed:
514
"""
515
Power feed circuits from panels to racks.
516
517
Attributes:
518
power_panel (PowerPanel): Source power panel
519
rack (Rack): Destination rack
520
name (str): Feed name
521
status (Status): Feed status
522
type (str): Feed type (primary/redundant)
523
supply (str): Power supply type
524
phase (str): Electrical phase
525
voltage (int): Feed voltage
526
amperage (int): Feed amperage
527
max_utilization (int): Maximum utilization percentage
528
available_power (int): Available power in watts
529
comments (str): Comments
530
"""
531
```
532
533
### Device Templates
534
535
Template definitions for device components.
536
537
```python { .api }
538
class ConsolePortTemplate:
539
"""Console port templates for device types."""
540
541
class InterfaceTemplate:
542
"""Interface templates for device types."""
543
544
class PowerPortTemplate:
545
"""Power port templates for device types."""
546
547
class ConsoleServerPortTemplate:
548
"""Console server port templates for device types."""
549
550
class PowerOutletTemplate:
551
"""Power outlet templates for device types."""
552
553
class DeviceBayTemplate:
554
"""Device bay templates for device types."""
555
556
class ModuleBayTemplate:
557
"""Module bay templates for device types."""
558
559
class FrontPortTemplate:
560
"""Front port templates for device types."""
561
562
class RearPortTemplate:
563
"""Rear port templates for device types."""
564
```
565
566
## Usage Examples
567
568
### Device Management
569
570
```python
571
from nautobot.dcim.models import Device, Location, DeviceType, Manufacturer
572
from nautobot.extras.models import Status
573
574
# Get all active devices
575
active_status = Status.objects.get(name="Active")
576
devices = Device.objects.filter(status=active_status)
577
578
# Create a new device
579
location = Location.objects.get(name="DataCenter-1")
580
device_type = DeviceType.objects.get(model="ASR1001-X")
581
582
device = Device.objects.create(
583
name="router-01",
584
device_type=device_type,
585
location=location,
586
status=active_status
587
)
588
589
# Get devices by location
590
location_devices = Device.objects.filter(location=location)
591
```
592
593
### Interface Management
594
595
```python
596
from nautobot.dcim.models import Interface
597
598
# Get all interfaces for a device
599
interfaces = Interface.objects.filter(device=device)
600
601
# Create a new interface
602
interface = Interface.objects.create(
603
device=device,
604
name="GigabitEthernet0/0/0",
605
type="1000base-t",
606
enabled=True,
607
description="WAN Interface"
608
)
609
610
# Get interfaces by type
611
gigabit_interfaces = Interface.objects.filter(type="1000base-t")
612
```
613
614
### Cable Management
615
616
```python
617
from nautobot.dcim.models import Cable, Interface
618
619
# Create a cable connection
620
interface_a = Interface.objects.get(device__name="router-01", name="Gi0/0/0")
621
interface_b = Interface.objects.get(device__name="switch-01", name="Gi1/0/1")
622
623
cable = Cable.objects.create(
624
termination_a=interface_a,
625
termination_b=interface_b,
626
type="cat6",
627
status=active_status,
628
label="CAB-001",
629
length=5.0,
630
length_unit="m"
631
)
632
633
# Find connected devices
634
connected_interface = cable.termination_b
635
connected_device = connected_interface.device
636
```
637
638
### Location Hierarchy
639
640
```python
641
from nautobot.dcim.models import Location, LocationType
642
643
# Create location hierarchy
644
region_type = LocationType.objects.get(name="Region")
645
site_type = LocationType.objects.get(name="Site")
646
647
# Create parent location
648
region = Location.objects.create(
649
name="North America",
650
location_type=region_type
651
)
652
653
# Create child location
654
site = Location.objects.create(
655
name="New York DC",
656
location_type=site_type,
657
parent=region,
658
physical_address="123 Main St, New York, NY"
659
)
660
661
# Get all child locations
662
child_locations = Location.objects.filter(parent=region)
663
```