Attributes:
name
(str) - device namedevice_type
(str, DeviceType) - device type name or DeviceType entityplatform
(str, Platform) - platform name or Platform entitymanufacturer
(str, Manufacturer) - manufacturer name or Manufacturer entitysite
(str, Site) - site name or Site entityrole
(str, Role) - role name or Role entityserial
(str) - serial numberasset_tag
(str) - asset tagstatus
(str) - status (e.g.active
,planned
,staged
,failed
,inventory
,decommissioning
,offine
)comments
(str) - commentstags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Device,
DeviceType,
Entity,
Manufacturer,
Platform,
Role,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Device entity with only a name provided will attempt to create or update a device with
the given name and placeholders (i.e. "undefined") for other nested objects types
(e.g. DeviceType, Platform, Site, Role) required by NetBox.
"""
device = Device(name="Device A")
entities.append(Entity(device=device))
"""
Device entity using flat data structure.
"""
device_flat = Device(
name="Device A",
device_type="Device Type A",
platform="Platform A",
manufacturer="Manufacturer A",
site="Site ABC",
role="Role ABC",
serial="123456",
asset_tag="123456",
status="active",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(device=device_flat))
"""
Device entity using explicit data structure.
"""
device_explicit = Device(
name="Device A",
device_type=DeviceType(
model="Device Type A", manufacturer=Manufacturer(name="Manufacturer A")
),
platform=Platform(
name="Platform A", manufacturer=Manufacturer(name="Manufacturer A")
),
site=Site(name="Site ABC"),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
serial="123456",
asset_tag="123456",
status="active",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(device=device_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - interface namedevice
(str, Device) - device name or Device entitydevice_type
(str, DeviceType) - device type name or DeviceType entityrole
(str, Role) - role name or Role entityplatform
(str, Platform) - platform name or Platform entitymanufacturer
(str, Manufacturer) - manufacturer name or Manufacturer entitysite
(str, Site) - site name or Site entitytype
(str) - interface type (e.g.virtual
,other
, etc.)enabled
(bool) - is the interface enabledmtu
(int) - maximum transmission unitmac_address
(str) - MAC addressspeed
(int) - speedwwn
(str) - world wide namemgmt_only
(bool) - is the interface for management onlydescription
(str) - descriptionmark_connected
(bool) - mark connectedmode
(str) - mode (access
,tagged
,tagged-all
)tags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Device,
DeviceType,
Entity,
Interface,
Manufacturer,
Platform,
Role,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Interface entity with only a name provided will attempt to create or update an interface with
the given name and placeholders (i.e. "undefined") for other nested objects types
(e.g. Device, DeviceType, Platform, Site, Role) required by NetBox.
"""
interface = Interface(name="Interface A")
entities.append(Entity(interface=interface))
"""
Interface entity using flat data structure.
"""
interface_flat = Interface(
name="Interface A",
device="Device A",
device_type="Device Type A",
role="Role ABC",
platform="Platform A",
site="Site ABC",
type="virtual",
enabled=True,
mtu=1500,
mac_address="00:00:00:00:00:00",
description="Interface A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(interface=interface_flat))
"""
Interface entity using explicit data structure.
"""
interface_explicit = Interface(
name="Interface A",
device=Device(
name="Device A",
device_type=DeviceType(
model="Device Type A",
manufacturer=Manufacturer(name="Manufacturer A"),
),
platform=Platform(
name="Platform A", manufacturer=Manufacturer(name="Manufacturer A")
),
site=Site(name="Site ABC"),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
),
type="virtual",
enabled=True,
mtu=1500,
mac_address="00:00:00:00:00:00",
description="Interface A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(interface=interface_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
model
(str) - device type modelslug
(str) - slugmanufacturer
(str, Manufacturer) - manufacturer name or Manufacturer entitydescription
(str) - descriptioncomments
(str) - commentspart_number
(str) - part numbertags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
DeviceType,
Entity,
Manufacturer,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
DeviceType entity with only a name provided will attempt to create or update a device type with
the given name and placeholder (i.e. "undefined") for nested Manufacturer object type
required by NetBox.
"""
device_type = DeviceType(model="Device Type A")
entities.append(Entity(device_type=device_type))
"""
DeviceType entity using flat data structure.
"""
device_type_flat = DeviceType(
model="Device Type A",
manufacturer="Manufacturer A",
part_number="123456",
description="Device Type A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(device_type=device_type_flat))
"""
DeviceType entity using explicit data structure.
"""
device_type_explicit = DeviceType(
model="Device Type A",
manufacturer=Manufacturer(
name="Manufacturer A",
description="Manufacturer A description",
tags=["tag 1", "tag 2"],
),
part_number="123456",
description="Device Type A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(device_type=device_type_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - platform nameslug
(str) - slugmanufacturer
(str, Manufacturer) - manufacturer name or Manufacturer entitydescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
Manufacturer,
Platform,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Platform entity with only a name provided will attempt to create or update a platform with
the given name and placeholders (i.e. "undefined") for other nested objects types (e.g. Manufacturer)
required by NetBox.
"""
platform = Platform(
name="Platform A",
)
entities.append(Entity(platform=platform))
"""
Platform entity using flat data structure.
"""
platform_flat = Platform(
name="Platform A",
manufacturer="Manufacturer A",
description="Platform A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(platform=platform_flat))
"""
Platform entity using explicit data structure.
"""
platform_explicit = Platform(
name="Platform A",
manufacturer=Manufacturer(name="Manufacturer A", tags=["tag 1", "tag 3"]),
description="Platform A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(platform=platform_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - manufacturer nameslug
(str) - slugdescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
Manufacturer,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Manufacturer entity.
"""
manufacturer = Manufacturer(
name="Manufacturer A",
description="Manufacturer A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(manufacturer=manufacturer))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - site nameslug
(str) - slugstatus
(str) - status (active
,planned
,retired
,staging
,decommissioning
)facility
(str) - facilitytime_zone
(str) - time zonedescription
(str) - descriptioncomments
(str) - commentstags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Site entity.
"""
site = Site(
name="Site A",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(site=site))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - role nameslug
(str) - slugcolor
(str) - colordescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
Role,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Role entity.
"""
role = Role(
name="Role A",
slug="role-a",
color="ffffff",
description="Role A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(device_role=role))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
address
(str) - IP addressinterface
(str, Interface) - interface name or Interface entitydevice
(str, Device) - device name or Device entitydevice_type
(str, DeviceType) - device type name or DeviceType entitydevice_role
(str, Role) - device role name or Role entityplatform
(str, Platform) - platform name or Platform entitymanufacturer
(str, Manufacturer) - manufacturer name or Manufacturer entitysite
(str, Site) - site name or Site entitystatus
(str) - status (active
,reserved
,deprecated
,dhcp
,slaac
)role
(str) - role (loopback
,secondary
,anycast
,vip
,vrrp
,hsrp
,glbp
,carp
)dns_name
(str) - DNS namedescription
(str) - descriptioncomments
(str) - commentstags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Device,
DeviceType,
Entity,
Interface,
IPAddress,
Manufacturer,
Platform,
Role,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
IPAddress entity with only an address provided will attempt to create or update an IP address with
the given address and placeholders (i.e. "undefined") for other nested objects types
(e.g. Interface, Device, DeviceType, Platform, Site, Role) required by NetBox.
"""
ip_address = IPAddress(
address="192.168.0.1/24",
)
entities.append(Entity(ip_address=ip_address))
"""
IPAddress entity using flat data structure.
"""
ip_address_flat = IPAddress(
address="192.168.0.1/24",
interface="Interface ABC",
device="Device ABC",
device_type="Device Type ABC",
device_role="Role ABC",
platform="Platform ABC",
manufacturer="Cisco",
site="Site ABC",
status="active",
role="Role ABC",
description="IP Address A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag1", "tag2"],
)
entities.append(Entity(ip_address=ip_address_flat))
"""
IPAddress entity using explicit data structure.
"""
ip_address_explicit = IPAddress(
address="192.168.0.1/24",
interface=Interface(
name="Interface ABC",
device=Device(
name="Device ABC",
device_type=DeviceType(
model="Device Type ABC", manufacturer=Manufacturer(name="Cisco")
),
platform=Platform(
name="Platform ABC", manufacturer=Manufacturer(name="Cisco")
),
site=Site(name="Site ABC"),
role=Role(name="Role ABC", tags=["tag1", "tag3"]),
),
),
status="active",
role="Role ABC",
description="IP Address A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag1", "tag2"],
)
entities.append(Entity(ip_address=ip_address_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
prefix
(str) - prefixsite
(str, Site) - site name or Site entitystatus
(str) - status (active
,reserved
,deprecated
,container
)is_pool
(bool) - is poolmark_utilized
(bool) - mark utilizeddescription
(str) - descriptioncomments
(str) - commentstags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
Prefix,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Prefix entity with only a prefix provided will attempt to create or update a prefix with
the given prefix and placeholders (i.e. "undefined") for other nested objects types (e.g. Site)
required by NetBox.
"""
prefix = Prefix(
prefix="192.168.0.0/32",
)
entities.append(Entity(prefix=prefix))
"""
Prefix entity using flat data structure.
"""
prefix_flat = Prefix(
prefix="192.168.0.0/32",
site="Site ABC",
status="active",
is_pool=True,
mark_utilized=True,
description="Prefix A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(prefix=prefix_flat))
"""
Prefix entity using explicit data structure.
"""
prefix_explicit = Prefix(
prefix="192.168.0.0/32",
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
is_pool=True,
mark_utilized=True,
description="Prefix A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(prefix=prefix_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - cluster type nameslug
(str) - slugdescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
ClusterType,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
ClusterType entity.
"""
cluster_type = ClusterType(
name="Cluster Type A",
description="Cluster Type A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(cluster_type=cluster_type))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - cluster group nameslug
(str) - slugdescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
ClusterGroup,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
ClusterGroup entity.
"""
cluster_group = ClusterGroup(
name="Cluster Group A",
description="Cluster Group A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(cluster_group=cluster_group))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - cluster nametype
(str, ClusterType) - cluster type name or ClusterType entitygroup
(str, ClusterGroup) - cluster group name or ClusterGroup entitysite
(str, Site) - site name or Site entitystatus
(str) - status (offline
,active
,planned
,staged
,failed
,decommissioning
)description
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
Cluster,
ClusterGroup,
ClusterType,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
Cluster entity with only a name provided will attempt to create or update a cluster with
the given name and placeholders (i.e. "undefined") for other nested objects types
(e.g. ClusterGroup, ClusterType, Site) required by NetBox.
"""
cluster = Cluster(name="Cluster A")
entities.append(Entity(cluster=cluster))
"""
Cluster entity using flat data structure.
"""
cluster_flat = Cluster(
name="Cluster A",
type="Cluster Type",
group="Cluster Group",
site="Site ABC",
status="active",
description="Cluster A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(cluster=cluster_flat))
"""
Cluster entity using explicit data structure.
"""
cluster_explicit = Cluster(
name="Cluster A",
type = ClusterType(
name="Cluster Type A",
description="Cluster Type description",
tags=["tag 1", "tag 2"],
),
group = ClusterGroup(
name="Cluster Group A",
description="Cluster Group description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
description="Cluster A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(cluster=cluster_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - virtual machine namestatus
(str) - status (offline
,active
,planned
,staged
,failed
,decommissioning
)site
(str, Site) - site name or Site entitycluster
(str, Cluster) - cluster name or Cluster entityrole
(str, Role) - role name or Role entitydevice
(str, Device) - device name or Device entityplatform
(str, Platform) - platform name or Platform entityvcpus
(int) - virtual machine CPU numbermemory
(int) - virtual machine memorydisk
(int) - virtual machine disk sizedescription
(str) - descriptioncomments
(str) - commentstags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
VirtualMachine,
Cluster,
ClusterGroup,
ClusterType,
Device,
DeviceType,
Manufacturer,
Platform,
Role,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
VirtualMachine entity with only a name provided will attempt to create or update a name with
the given name and placeholders (i.e. "undefined") for other nested objects types (e.g. Site,
Role, Cluster, Platform, Device) required by NetBox.
"""
virtual_machine = VirtualMachine(name="VM A")
entities.append(Entity(virtual_machine=virtual_machine))
"""
VirtualMachine entity using flat data structure.
"""
virtual_machine_flat = VirtualMachine(
name="VM A",
status="active",
cluster="Cluster Type A",
site="Site ABC",
role="Role ABC",
device="Device A",
platform="Platform A",
vcpus=8,
memory=12128,
disk=16786,
description="Virtual Machine A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(virtual_machine=virtual_machine_flat))
"""
VirtualMachine entity using explicit data structure.
"""
virtual_machine_explicit = VirtualMachine(
name="VM A",
status="active",
cluster=Cluster(
name="Cluster A",
type=ClusterType(
name="Cluster Type A",
description="Cluster Type description",
tags=["tag 1", "tag 2"],
),
group=ClusterGroup(
name="Cluster Group",
description="Cluster Group description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
description="Cluster A description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
device=Device(
name="Device A",
device_type=DeviceType(
model="Device Type A",
manufacturer=Manufacturer(name="Manufacturer A"),
),
platform=Platform(
name="Platform A", manufacturer=Manufacturer(name="Manufacturer A")
),
site=Site(name="Site ABC"),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
serial="123456",
asset_tag="123456",
status="active",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
platform=Platform(
name="Platform A", manufacturer=Manufacturer(name="Manufacturer A")
),
vcpus=8,
memory=12128,
disk=16786,
description="Virtual Machine A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(virtual_machine=virtual_machine_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - virtual disk namevirtual_machine
(str, VirtualMachine) - virtual machine name or VirtualMachine entitysize
(int) - disk sizedescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
VirtualDisk,
VirtualMachine,
Cluster,
ClusterGroup,
ClusterType,
Device,
DeviceType,
Manufacturer,
Platform,
Role,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
VirtualDisk entity with only a name provided will attempt to create or update a name
with the given name and placeholders (i.e. "undefined") for other nested objects types (e.g.
VirtualMachine) required by NetBox.
"""
virtual_disk = VirtualDisk(name="Disk A", size=16480)
entities.append(Entity(virtual_disk=virtual_disk))
"""
VirtualDisk entity using flat data structure.
"""
virtual_disk_flat = VirtualDisk(
name="Disk A",
virtual_machine="VM A",
size=16480,
description="Disk A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(virtual_disk=virtual_disk_flat))
"""
VirtualDisk entity using explicit data structure.
"""
virtual_disk_explicit = VirtualDisk(
name="Disk A",
virtual_machine=VirtualMachine(
name="VM A",
status="active",
cluster=Cluster(
name="Cluster A",
type=ClusterType(
name="Cluster Type A",
description="Cluster Type description",
tags=["tag 1", "tag 2"],
),
group=ClusterGroup(
name="Cluster Group",
description="Cluster Group description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
description="Cluster A description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
device=Device(
name="Device A",
device_type=DeviceType(
model="Device Type A",
manufacturer=Manufacturer(name="Manufacturer A"),
),
platform=Platform(
name="Platform A",
manufacturer=Manufacturer(name="Manufacturer A"),
),
site=Site(name="Site ABC"),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
serial="123456",
asset_tag="123456",
status="active",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
platform=Platform(
name="Platform A", manufacturer=Manufacturer(name="Manufacturer A")
),
vcpus=8,
memory=12128,
disk=16480,
description="Virtual Machine A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
size=16480,
description="Disk A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(virtual_disk=virtual_disk_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()
Attributes:
name
(str) - virtual interface namevirtual_machine
(str, VirtualMachine) - virtual machine name or VirtualMachine entityenabled
(bool) - is the interface enabledmtu
(int) - maximum transmission unitmac_address
(str) - MAC addressdescription
(str) - descriptiontags
(list) - tags
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
Entity,
VMInterface,
VirtualMachine,
Cluster,
ClusterGroup,
ClusterType,
Device,
DeviceType,
Manufacturer,
Platform,
Role,
Site,
)
def main():
with DiodeClient(
target="grpc://localhost:8080/diode",
app_name="my-test-app",
app_version="0.0.1",
) as client:
entities = []
"""
VMInterface entity with only a name provided will attempt to create or update a name
with the given name and placeholders (i.e. "undefined") for other nested objects types (e.g.
VirtualMachine) required by NetBox.
"""
vminterface = VMInterface(name="Interface A")
entities.append(Entity(vminterface=vminterface))
"""
VMInterface entity using flat data structure.
"""
vminterface_flat = VMInterface(
name="Interface A",
virtual_machine="VM A",
enabled=True,
mtu=1500,
mac_address="00:00:00:00:00:00",
description="Interface A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(vminterface=vminterface_flat))
"""
VMInterface entity using explicit data structure.
"""
vminterface_explicit = VMInterface(
name="Interface A",
virtual_machine=VirtualMachine(
name="VM A",
status="active",
cluster=Cluster(
name="Cluster A",
type=ClusterType(
name="Cluster Type A",
description="Cluster Type description",
tags=["tag 1", "tag 2"],
),
group=ClusterGroup(
name="Cluster Group",
description="Cluster Group description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
description="Cluster A description",
tags=["tag 1", "tag 2"],
),
site=Site(
name="Site ABC",
status="active",
facility="Data Center 1",
time_zone="UTC",
description="Site A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
device=Device(
name="Device A",
device_type=DeviceType(
model="Device Type A",
manufacturer=Manufacturer(name="Manufacturer A"),
),
platform=Platform(
name="Platform A",
manufacturer=Manufacturer(name="Manufacturer A"),
),
site=Site(name="Site ABC"),
role=Role(name="Role ABC", tags=["tag 1", "tag 3"]),
serial="123456",
asset_tag="123456",
status="active",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
platform=Platform(
name="Platform A", manufacturer=Manufacturer(name="Manufacturer A")
),
vcpus=8,
memory=12128,
disk=16480,
description="Virtual Machine A description",
comments="Lorem ipsum dolor sit amet",
tags=["tag 1", "tag 2"],
),
enabled=True,
mtu=1500,
mac_address="00:00:00:00:00:00",
description="Interface A description",
tags=["tag 1", "tag 2"],
)
entities.append(Entity(vminterface=vminterface_explicit))
response = client.ingest(entities=entities)
if response.errors:
print(f"Errors: {response.errors}")
if __name__ == "__main__":
main()