0
# Virtualization and Cloud
1
2
Virtual infrastructure management including virtual machines, cloud services, and wireless networks. Extends the DCIM model to virtual and cloud environments.
3
4
## Capabilities
5
6
### Virtual Machines
7
8
Virtual machine management similar to physical devices.
9
10
```python { .api }
11
class VirtualMachine:
12
"""
13
Virtual machines with similar functionality to physical devices.
14
15
Attributes:
16
name (str): VM name
17
status (Status): VM status
18
cluster (Cluster): Host cluster
19
tenant (Tenant): Tenant assignment
20
platform (Platform): VM platform/OS
21
primary_ip4 (IPAddress): Primary IPv4 address
22
primary_ip6 (IPAddress): Primary IPv6 address
23
vcpus (int): Virtual CPU count
24
memory (int): Memory in MB
25
disk (int): Disk space in GB
26
role (Role): VM role
27
comments (str): Comments
28
local_context_data (dict): Local configuration context
29
tags (list): Associated tags
30
"""
31
32
class VMInterface:
33
"""
34
Virtual machine network interfaces.
35
36
Attributes:
37
virtual_machine (VirtualMachine): Parent VM
38
name (str): Interface name
39
enabled (bool): Whether interface is enabled
40
parent (VMInterface): Parent interface
41
bridge (VMInterface): Bridge interface
42
mtu (int): Maximum transmission unit
43
mac_address (str): MAC address
44
description (str): Interface description
45
mode (str): Interface mode (access/tagged/trunk)
46
untagged_vlan (VLAN): Untagged VLAN
47
tagged_vlans (list): Tagged VLANs
48
vrf (VRF): VRF assignment
49
ip_addresses (list): Assigned IP addresses
50
tags (list): Associated tags
51
"""
52
```
53
54
### Cloud Infrastructure
55
56
Cloud service management (implementation varies by cloud provider).
57
58
```python { .api }
59
# Cloud models are provider-specific and may include:
60
# - Cloud accounts and regions
61
# - Cloud instances and services
62
# - Cloud networks and subnets
63
# - Cloud storage and databases
64
# - Cloud load balancers and firewalls
65
```
66
67
### Wireless Infrastructure
68
69
Wireless network infrastructure management.
70
71
```python { .api }
72
# Wireless models may include:
73
# - Wireless controllers
74
# - Access points
75
# - Wireless networks/SSIDs
76
# - Wireless clients
77
# - RF coverage and planning
78
```
79
80
## Usage Examples
81
82
### Virtual Machine Management
83
84
```python
85
from nautobot.virtualization.models import VirtualMachine, VMInterface
86
from nautobot.extras.models import Status
87
88
# Create virtual machine
89
active_status = Status.objects.get(name="Active")
90
vm = VirtualMachine.objects.create(
91
name="web-server-01",
92
status=active_status,
93
vcpus=4,
94
memory=8192, # 8GB
95
disk=100, # 100GB
96
comments="Web server VM"
97
)
98
99
# Create VM interface
100
vm_interface = VMInterface.objects.create(
101
virtual_machine=vm,
102
name="eth0",
103
enabled=True,
104
description="Primary network interface"
105
)
106
107
# Assign IP address
108
from nautobot.ipam.models import IPAddress, Namespace
109
namespace = Namespace.objects.get(name="Global")
110
ip = IPAddress.objects.create(
111
address="192.168.100.10/24",
112
namespace=namespace,
113
status=active_status,
114
assigned_object=vm_interface
115
)
116
117
vm.primary_ip4 = ip
118
vm.save()
119
```
120
121
### Virtual Machine Queries
122
123
```python
124
# Get all VMs
125
all_vms = VirtualMachine.objects.all()
126
127
# Get VMs by status
128
active_vms = VirtualMachine.objects.filter(status__name="Active")
129
130
# Get VMs by resource requirements
131
high_memory_vms = VirtualMachine.objects.filter(memory__gte=16384)
132
133
# Get VM interfaces
134
vm_interfaces = VMInterface.objects.filter(virtual_machine=vm)
135
136
# Get VMs with IP addresses
137
vms_with_ips = VirtualMachine.objects.exclude(primary_ip4__isnull=True)
138
```