netbox package¶
Submodules¶
netbox.dcim module¶
-
class
netbox.dcim.
Dcim
(netbox_con)¶ Bases:
object
-
create_device
(name, device_role, site_name, device_type, **kwargs)¶ Create a new device
Parameters: - name – Name of the device
- device_role – Device role for the device
- site_name – Name of the site where the device is created
- device_type – Type for the new device
- kwargs – Optional arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_device_role
(name, color, slug, **kwargs)¶ Create device role
Parameters: - name – Role name
- color – HTML color code
- slug – Slug name
- kwargs – optional arguments
Returns: netbox object if successful otherwise CreateException
-
create_device_type
(model, slug, manufacturer, **kwargs)¶ Create device type
Parameters: - model – Model name
- slug – Slug name
- manufacturer – Name of the manufacurer
- kwargs – optional arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_interface
(name, interface_type, device_id, **kwargs)¶ Create a new interface
Parameters: - name – name of the interface
- interface_type – interface type. It is not possible to get the list of types from the api. Search in the netbox code for the correct type number.
- kwargs – optional arguments
- device_id – ID of the device to associate interface with
Returns: netbox object if successful otherwise raise CreateException
-
create_interface_template
(name, device_type, **kwargs)¶ Create a new interface template
Parameters: - name – rack_grounamep_id of the interface
- kwargs – optional arguments
- device_type – name of the device_type to associate template with
Returns: netbox object if successful otherwise raise CreateException
-
create_inventory_item
(name, device_name, **kwargs)¶ Create inventory item
Parameters: - name – Inventory item name
- device_name – Name of device
- kwargs – Extra inventory parameters
Returns: netbox object if successful otherwise raise CreateException
-
create_location
(name, slug, site_name, **kwargs)¶ Create a location
Parameters: - name – Location name
- slug – Slug for the location
- site_name – Name of the site to connect the location to
- kwargs – Extra location parameters
Returns: netbox object if successful otherwise raise CreateException
-
create_manufacturer
(name, slug, **kwargs)¶ Create new manufacturer
Parameters: - name – Name of manufacturer
- slug – Name of slug
- kwargs – Optional arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_platform
(name, slug, **kwargs)¶ Create new platform
Parameters: - name – Name of platform
- slug – Name of slug
- kwargs – Optional arguments
Returns:
-
create_rack
(name, site_name, **kwargs)¶ Create new rack
Parameters: - name – Organizational rack name
- site_name – The site at which the rack exists
- kwargs – Optional arguments
Returns: netbox object if successful otherwise create exception
-
create_rack_group
(name, slug, site_name, **kwargs)¶ Create new rack group
Parameters: - name – Rack group name
- slug – slug name
- site_name – The site at which the rack exists
- kwargs – Optional arguments
Returns: netbox object if successful otherwise create exception
-
create_region
(name, slug, **kwargs)¶ Create a new region
Parameters: - name – Region name
- slug – slug name
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
create_site
(name, slug, **kwargs)¶ Create a new site
Parameters: - name – Site name
- slug – slug name
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
delete_device
(device_name)¶ Delete device by device name
Parameters: device_name – Device to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_device_by_id
(device_id)¶ Delete device
Parameters: device_id – Device to delete Returns: bool True if successful otherwise raise Exception
-
delete_device_role
(device_role)¶ Delete device by device role
Parameters: device_role – name of the role Returns: bool True if successful otherwise raise DeleteException
-
delete_device_role_by_id
(device_role_id)¶ Delete device role
Parameters: device_role_id – device role to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_device_type
(model_name)¶ Delete device type
Parameters: model_name – Name of the model Returns: bool True if successful otherwise raise DeleteException
-
delete_device_type_by_id
(device_type_id)¶ Delete device type
Parameters: device_type_id – Id of the device-type to delete Returns: bool True if successful otherwise raise Exception
-
delete_interface
(interface_name, device)¶ Delete interface
Parameters: - interface_name – Name of interface to delete
- device – Device to which the interface belongs
Returns: bool True if successful otherwise raise DeleteException
-
delete_interface_by_id
(interface_id)¶ Delete interface
Parameters: interface_id – interface to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_interface_template
(interface_template_name)¶ Delete interface template
Parameters: interface_template_name – Name of interface template to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_interface_template_by_id
(interface_template_id)¶ Delete interface template
Parameters: interface_template_id – Name of interface template to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_inventory_item
(name, device_name)¶ Delete inventory item
Parameters: - name – Name of inventory item to delete
- device_name – Name of the device to remove inventory item from
Returns: bool True if successful otherwise raise DeleteException
-
delete_inventory_item_by_id
(inventory_item_id)¶ Delete inventory item
Parameters: inventory_item_id – Name of inventory item to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_location
(location_name)¶ Delete location
Parameters: location_name – Name of location to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_manufacturer
(manufacturer_name)¶ Delete manufacturer
Parameters: manufacturer_name – Name of manufacturer to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_manufacturer_id
(manufacturer_id)¶ Delete manufacturer
Parameters: manufacturer_id – manufacturer to delete Returns: bool True if successful otherwise raise Exception
-
delete_platform
(platform_name)¶ Delete platform
Parameters: platform_name – Name of platform to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_platform_by_id
(platform_id)¶ Delete platform
Parameters: platform_id – platform to delete Returns: bool True if successful otherwise raise Exception
-
delete_rack
(rack_name)¶ Delete rack
Parameters: rack_name – Name of the rack to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_rack_by_id
(rack_id)¶ Delete rack
Parameters: rack_id – Rack to delete Returns: bool True if successful otherwise raise Exception
-
delete_rack_group
(name)¶ Delete rack group
Parameters: name – Name of the rack group to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_rack_group_by_id
(rack_group_id)¶ Delete rack group
Parameters: rack_group_id – Rack group to delete Returns: bool True if successful otherwise raise Exception
-
delete_region
(region_name)¶ Delete region
Parameters: region_name – Region to delete Returns: bool True if succesful otherwise raise exception
-
delete_region_by_id
(region_id)¶ Delete region
Parameters: region_id – Region to delete Returns: bool True if succesful otherwise raise delete exception
-
delete_site
(site_name)¶ Delete site
Parameters: site_name – Site to delete Returns: bool True if succesful otherwise delete exception
-
delete_site_by_id
(site_id)¶ Delete site
Parameters: site_id – Site to delete Returns: bool True if succesful otherwise raise exception
-
get_choices
(choice_id=None)¶ Return choices for all fields if choice_id is not defined
Parameters: choice_id – Optional model:field tuple
-
get_device_roles
(**kwargs)¶ Return all the device roles
-
get_device_types
(**kwargs)¶ Get devices by device type
-
get_devices
(**kwargs)¶ Get all devices
-
get_devices_per_rack
(rack_name, **kwargs)¶ Get devices which belongs to the given rack
Parameters: rack_name – Name of the rack Returns: list of devices otherwise an empty list
-
get_interface_connections
(**kwargs)¶ Get interface connections
Parameters: kwargs – Filter arguments Returns: list of interface connections
-
get_interface_templates
(**kwargs)¶ Return interface templates
-
get_interfaces
(**kwargs)¶ Return interfaces
-
get_inventory_items
(**kwargs)¶ Return inventory items
-
get_locations
(**kwargs)¶ Return locations
-
get_manufacturers
(**kwargs)¶ Return all manufactures
-
get_platforms
(**kwargs)¶ Return all platforms
-
get_power_connections
(**kwargs)¶ Return power connections
-
get_power_outlets
(**kwargs)¶ Get power outlets matching optional kwarg filters
-
get_power_ports
(**kwargs)¶ Return power ports
-
get_rack_groups
(**kwargs)¶ Returns all available rack groups
-
get_racks
(**kwargs)¶ Returns all available racks
-
get_regions
(**kwargs)¶ Returns the available regions
-
get_sites
(**kwargs)¶ Returns all available sites
-
update_device
(device_name, **kwargs)¶ Update device by device name
Parameters: - device_name – device name to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_device_by_id
(device_id, **kwargs)¶ Update device by id
Parameters: - device_id – Device to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_device_role
(device_role, **kwargs)¶ Update device role
Parameters: - device_role – device-role to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_device_role_by_id
(device_role_id, **kwargs)¶ Update device role
Parameters: - device_role_id – device role to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_device_type
(device_type, **kwargs)¶ Update device type
Parameters: - device_type – device-type to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_device_type_by_id
(device_type_id, **kwargs)¶ Update device type
Parameters: - device_type_id – device-type to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_interface
(interface, device, **kwargs)¶ Update interface
Parameters: - interface – interface to update
- device – name of the device
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_interface_by_id
(interface_id, **kwargs)¶ Update interface
Parameters: - interface_id – interface to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_interface_template
(interface_template_name, **kwargs)¶ Update interface template
Parameters: - interface_template_name – interface template to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_interface_template_by_id
(interface_template_id, **kwargs)¶ Update interface template
Parameters: - interface_template_id – interface template to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_inventory_item
(name, device_name, **kwargs)¶ Update inventory item
Parameters: - name – Inventory item name
- device_name – Name of device
- kwargs – Extra inventory items to update
:return bool True if successful otherwise raise UpdateException
-
update_inventory_item_by_id
(inventory_item_id, **kwargs)¶ Update inventory item
Parameters: - inventory_item_id – Inventory item to delete
- kwargs – Extra inventory items to update
:return bool True if successful otherwise raise Exception
-
update_location
(location_id, **kwargs)¶ Update location
Parameters: - location – location item to update
- kwargs – Extra location items to update
:return bool True if successful otherwise raise Exception
-
update_manufacturer
(manufacturer_name, **kwargs)¶ Update manufacturer
Parameters: - manufacturer_name – manufacturer name to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_manufacturer_by_id
(manufacturer_id, **kwargs)¶ Update manufacturer
Parameters: - manufacturer_id – manufacturer to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_platform
(platform_name, **kwargs)¶ Update platform
Parameters: - platform_name – device name to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_platform_by_id
(platform_id, **kwargs)¶ Update platform
Parameters: - platform_id – platform to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_rack
(rack_name, **kwargs)¶ Parameters: - rack_name – Rack to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_rack_by_id
(rack_id, **kwargs)¶ Parameters: - rack_id – Rack group to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_rack_group
(name, **kwargs)¶ Parameters: - name – Rack group to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_rack_group_by_id
(rack_group_id, **kwargs)¶ Parameters: - rack_group_id – Rack group to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_region
(region_name, **kwargs)¶ Parameters: - region_name – Region to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_region_id
(region_id, **kwargs)¶ Update Region by id
Parameters: - region_id – Region to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
update_site
(site_name, **kwargs)¶ Parameters: - site_name – Site to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_site_by_id
(site_id, **kwargs)¶ Update a site by id
Parameters: - site_id – Site to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise Exception
-
netbox.exceptions module¶
-
exception
netbox.exceptions.
AuthException
¶ Bases:
BaseException
Raised when an API call method is not allowed
-
exception
netbox.exceptions.
AuthorizationException
(resp_data)¶ Bases:
netbox.exceptions.GeneralException
HTTP 403 status code
-
exception
netbox.exceptions.
ClientException
(resp_data)¶ Bases:
netbox.exceptions.GeneralException
HTTP 400 status code
-
exception
netbox.exceptions.
CreateException
(resp_data)¶ Bases:
netbox.exceptions.GeneralException
Raised when creation failed
-
exception
netbox.exceptions.
DeleteException
(resp_data)¶ Bases:
netbox.exceptions.GeneralException
Raised when delete failed
-
exception
netbox.exceptions.
GeneralException
(resp_data)¶ Bases:
BaseException
-
exception
netbox.exceptions.
GetException
(resp_data)¶
-
exception
netbox.exceptions.
NotFoundException
(resp_data)¶ Bases:
netbox.exceptions.GeneralException
Raised when item is not found
-
exception
netbox.exceptions.
ServerException
(resp_data)¶ Bases:
netbox.exceptions.GeneralException
HTTP 5xx status code
-
exception
netbox.exceptions.
UpdateException
(resp_data)¶ Bases:
BaseException
Raised when an object update fails
netbox.extras module¶
-
class
netbox.extras.
Extras
(netbox_con)¶ Bases:
object
-
create_config_context
(name, data, **kwargs)¶ Create a config-context
Parameters: - name – config-context name
- data – data in json format
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
create_tag
(name, slug, **kwargs)¶ Create a tag
Parameters: - name – tag name
- slug – tag slug
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
delete_config_context
(name)¶ Delete config-context
Parameters: name – Name of the config-context to delete Returns: bool True if succesful otherwise delete exception
-
delete_config_context_by_id
(config_context_id)¶ Delete config-context
Parameters: config_context_id – config-context to delete Returns: bool True if succesful otherwise delete exception
-
delete_tag
(name)¶ Delete tag
Parameters: name – Name of the tag to delete Returns: bool True if succesful otherwise delete exception
-
delete_tag_by_id
(tag_id)¶ Delete tag
Parameters: tag_id – tag to delete Returns: bool True if succesful otherwise delete exception
-
get_config_contexts
(**kwargs)¶ Returns all config-contexts
-
get_object_changes
(**kwargs)¶ Returns all object changes
-
get_reports
()¶ Returns all reports
Returns all tags
-
update_config_context
(name, **kwargs)¶ Update config-context
Parameters: - name – config-context to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_config_context_by_id
(config_context_id, **kwargs)¶ Update config-context
Parameters: - config_context_id – config-context to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_tag
(name, **kwargs)¶ Update tag
Parameters: - name – tag name
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_tag_by_id
(tag_id, **kwargs)¶ Update tag
Parameters: - tag_id – tag id
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
netbox.ipam module¶
-
class
netbox.ipam.
Ipam
(netbox_con)¶ Bases:
object
-
create_aggregate
(prefix, rir, **kwargs)¶ Creates a new aggregate
Parameters: - prefix – IP Prefix
- rir – Name of the RIR
- kwargs – Optional Arguments
Returns:
-
create_ip_address
(address, **kwargs)¶ Create a new ip address
Parameters: - address – IP address
- kwargs – Optional arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_ip_prefix
(prefix, **kwargs)¶ Create a new ip prefix
Parameters: - prefix – A valid ip prefix format. The syntax will be checked with the ipaddress module
- kwargs – Optional arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_rir
(name, slug)¶ Create new rir
Parameters: - name – Name of the rir
- slug – Name of the slug
Returns: netbox object if successful otherwise raise CreateException
-
create_role
(name, slug, **kwargs)¶ Create new prefix/vlan role
Parameters: - name – Name of the prefix/vlan role
- slug – Name of the slug
Returns: netbox object if successful otherwise raise CreateException
-
create_service
(name, port, protocol, **kwargs)¶ Create a new service definition
Parameters: - name – Name of the provided service
- port – Service listening port
- protocol – Service used protocol 6 is used to TCP and 17 for UDP
- kwargs – Optional arguments (need to attach service to a ‘virtual_machine: id’ or ‘device: id’ )
Returns: netbox object if successful otherwise raise CreateException
-
create_vlan
(vid, vlan_name, **kwargs)¶ Create new vlan
Parameters: - vid – ID of the new vlan
- vlan_name – Name of the vlan
- kwargs – Optional Arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_vlan_group
(name, slug, **kwargs)¶ Create new vlan-group
Parameters: - name – name of the vlan group
- slug – slug
- kwargs – Optional Arguments
Returns: netbox object if successful otherwise raise CreateException
-
create_vrf
(name, rd, **kwargs)¶ Create a new vrf
Parameters: - name – Name of the vrf
- rd – Route distinguisher in any format
- kwargs – Optional arguments
Returns: netbox object if successful otherwise raise CreateException
-
delete_ip_address
(ip_address)¶ Delete IP address
Parameters: ip_address – IP address to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_ip_by_id
(ip_id)¶ Delete IP address
Parameters: ip_id – ID of ip address to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_ip_prefix
(**kwargs)¶ Delete IP prefix
Parameters: kwargs – Delete prefix based on filter values Returns: bool True if successful otherwise raise DeleteException
-
delete_ip_prefix_by_id
(ip_prefix_id)¶ Delete IP prefix
Parameters: ip_prefix_id – Delete prefix based on id Returns: bool True if successful otherwise raise DeleteException
-
delete_rir
(rir_name)¶ Delete rir
Parameters: rir_name – rir name to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_rir_by_id
(rir_id)¶ Delete rir
Parameters: rir_id – rir to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_role
(role_name)¶ Delete prefix/vlan role
Parameters: role_name – prefix/vlan role to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_role_by_id
(role_id)¶ Delete prefix/vlan role
Parameters: role_id – prefix/vlan role to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_vlan
(vid)¶ Delete VLAN based on VLAN ID
Parameters: vid – vlan id to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_vlan_by_id
(vlan_id)¶ Delete VLAN based on VLAN ID
Parameters: vlan_id – vlan id to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_vlan_group
(name)¶ Delete VLAN group
Parameters: name – name of the vlan-group to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_vlan_group_by_id
(vlan_group_id)¶ Delete VLAN group
Parameters: vlan_group_id – vlan-group to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_vrf
(vrf_name)¶ Delete vrf
Parameters: vrf_name – Name of vrf to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_vrf_by_id
(vrf_id)¶ Delete vrf
Parameters: vrf_id – vrf to delete Returns: bool True if successful otherwise raise DeleteException
-
get_aggregates
(**kwargs)¶ Return all aggregates
-
get_choices
(choice_id=None)¶ Return choices for all fields if choice_id is not defined
Parameters: choice_id – Optional model:field tuple
-
get_ip_addresses
(**kwargs)¶ Return all ip addresses
-
get_ip_by_device
(device_name)¶ Get IPs which are associated to a device
Parameters: device_name – Name of the device Returns: ip address information
-
get_ip_by_virtual_machine
(vm_name)¶ Get IPs which are associated to a virtual-machine
Parameters: vm_name – Name of the virtual machine Returns: ip address information
-
get_ip_prefixes
(**kwargs)¶ Return all ip prefixes
-
get_next_available_ip
(**kwargs)¶ Return next available ip in prefix
Parameters: kwargs – Use the filter fields from the get_prefixes call Returns: next available ip
-
get_rirs
(**kwargs)¶ Return all rirs
-
get_roles
(**kwargs)¶ Return all roles
-
get_services
(**kwargs)¶ Return all services
-
get_vlan_groups
(**kwargs)¶ Return all vlan groups
-
get_vlans
(**kwargs)¶ Return all vlans
-
get_vrfs
(**kwargs)¶ Get all vrfs
-
update_aggregate
(prefix, **kwargs)¶ Update aggregate
Parameters: - prefix – Prefix of the aggregate
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_aggregate_by_id
(aggregate_id, **kwargs)¶ Update aggregate
Parameters: - aggregate_id – aggregate to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_ip
(ip_address, **kwargs)¶ Update ip address
Parameters: - ip_address – ip address with prefix. Format: 1.1.1.1/32
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_ip_by_id
(ip_id, **kwargs)¶ Update ip address
Parameters: - ip_id – ip id to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_ip_prefix
(ip_prefix, **kwargs)¶ Update ip address
Parameters: - ip_prefix – ip prefix to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_ip_prefix_by_id
(ip_prefix_id, **kwargs)¶ Update ip address
Parameters: - ip_prefix_id – ip prefix to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_rir
(rir_name, **kwargs)¶ Update rir
Parameters: - rir_name – Name of the rir
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_rir_by_id
(rir_id, **kwargs)¶ Update rir
Parameters: - rir_id – rir to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_role
(role_name, **kwargs)¶ Update prefix role
Parameters: - role_name – Name of the prefix/vlan role
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_role_by_id
(role_id, **kwargs)¶ Update prefix role
Parameters: - role_id – role to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_vlan
(vlan_name, **kwargs)¶ Update vlan
Parameters: - vlan_name – Name of the vlan
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_vlan_by_id
(vlan_id, **kwargs)¶ Update vlan
Parameters: - vlan_id – vlan to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_vlan_group
(name, **kwargs)¶ Update vlan-group
Parameters: - name – name of the vlan-group
- kwargs – arguments
Returns: bool True if successful otherwise raise UpdateException
-
update_vlan_group_by_id
(vlan_group_id, **kwargs)¶ Update vlan-group
Parameters: - vlan_group_id – vlan group to update
- kwargs – arguments
Returns: bool True if successful otherwise raise UpdateException
-
update_vrf
(vrf_name, **kwargs)¶ Update vrf
Parameters: - vrf_name – name of the vrf to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_vrf_by_id
(vrf_id, **kwargs)¶ Update vrf
Parameters: - vrf_id – vrf to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
netbox.tenancy module¶
-
class
netbox.tenancy.
Tenancy
(netbox_con)¶ Bases:
object
-
create_contact
(name: str, **kwargs)¶ Create a new contact
Parameters: - name – Contact name
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
create_contact_assignment_tenant
(contact_id: int, tenant_id: int, role_id: int, **kwargs)¶ Connect a contect to a tenant
Parameters: - contact_display_name – Contact display name
- tenant_id – The ID of the tenant
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
create_tenant
(name, slug, **kwargs)¶ Create a new tenant
Parameters: - name – Tenant name
- slug – slug name
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
create_tenant_group
(name, slug, **kwargs)¶ Create a new tenant-group
Parameters: - name – Tenant-group name
- slug – slug name
- kwargs – optional fields
Returns: netbox object if successful otherwise exception raised
-
delete_tenant
(tenant_name)¶ Delete tenant
Parameters: tenant_name – Tenant to delete Returns: bool True if succesful otherwise delete exception
-
delete_tenant_by_id
(tenant_id)¶ Delete tenant
Parameters: tenant_id – Tenant to delete Returns: bool True if succesful otherwise delete exception
-
delete_tenant_group
(tenant_group_name)¶ Delete tenant
Parameters: tenant_group_name – Tenant group to delete Returns: bool True if succesful otherwise delete exception
-
delete_tenant_group_id
(tenant_group_id)¶ Delete tenant
Parameters: tenant_group_id – Tenant group to delete Returns: bool True if succesful otherwise delete exception
-
get_choices
(choice_id=None)¶ Return choices for all fields if choice_id is not defined
Parameters: choice_id – Optional model:field tuple
-
get_contact_assignments
(**kwargs)¶ Returns the contacts
-
get_contact_roles
(**kwargs)¶ Returns the roles for contacts
-
get_contacts
(**kwargs)¶ Returns the contacts
-
get_tenant_groups
(**kwargs)¶ Returns the tenant groups
-
get_tenants
(**kwargs)¶ Returns the tenants
-
update_tenant
(tenant_name, **kwargs)¶ Update tenant
Parameters: - tenant_name – tenant to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_tenant_by_id
(tenant_id, **kwargs)¶ Update tenant
Parameters: - tenant_id – tenant to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_tenant_group
(tenant_group_name, **kwargs)¶ Update tenant group
Parameters: - tenant_group_name – tenant group to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
update_tenant_group_by_id
(tenant_group_id, **kwargs)¶ Update tenant group
Parameters: - tenant_group_id – tenant group to update
- kwargs – requests body dict
Returns: bool True if successful otherwise raise UpdateException
-
netbox.virtualization module¶
-
class
netbox.virtualization.
Virtualization
(netbox_con)¶ Bases:
object
-
create_cluster
(name, type, **kwargs)¶ Create a new cluster
Parameters: - name – name of the cluster
- type – cluster type
- kwargs – optional arguments
Returns: netbox object if successful otherwise exception raised
-
create_cluster_type
(name, slug)¶ Create a new cluster type
Parameters: - name – name of the cluster
- slug – slug name
Returns: netbox object if successful otherwise create exception
-
create_interface
(name, virtual_machine, **kwargs)¶ Create an interface for a virtual machine
Parameters: - name – name of the interface
- virtual_machine – name of virtual machine to attach interface
Returns: netbox object if successful otherwise raise CreateException
-
create_virtual_machine
(name, cluster_name, **kwargs)¶ Create a virtual machine
Parameters: - name – name of the virtual machine
- cluster_name – Name of existing cluster
Returns: netbox object if successful otherwise raise CreateException
-
delete_cluster
(name)¶ Delete a cluster
Parameters: name – name of the cluster to delete Returns: netbox object if succesful otherwise delete exception
-
delete_cluster_by_id
(cluster_id)¶ Delete a cluster
Parameters: cluster_id – cluster to delete Returns: netbox object if succesful otherwise delete exception
-
delete_cluster_type
(name)¶ Delete a cluster type
Parameters: name – name of the cluster type to delete Returns: bool True if succesful otherwise delete exception
-
delete_cluster_type_by_id
(cluster_type_id)¶ Delete a cluster type
Parameters: cluster_type_id – cluster type to delete Returns: bool True if succesful otherwise delete exception
-
delete_interface
(name, virtual_machine)¶ Delete interface from virtual_machine
Parameters: - name – interface name to delete
- virtual_machine – machine to delete interface from
Returns: bool True if successful otherwise raise DeleteException
-
delete_interface_by_id
(interface_id)¶ Delete interface from virtual_machine
Parameters: interface_id – interface to delete Returns: bool True if successful otherwise raise DeleteException
-
delete_virtual_machine
(virtual_machine_name)¶ Delete virtual machine
Parameters: virtual_machine_name – name of the virtual machine to delete Returns: bool True if successful otherwise raise exception
-
delete_virtual_machine_by_id
(virtual_machine_id)¶ Delete virtual machine
Parameters: virtual_machine_id – virtual machine to delete Returns: bool True if successful otherwise raise exception
-
get_choices
(choice_id=None)¶ Return choices for all fields if choice_id is not defined
Parameters: choice_id – Optional model:field tuple
-
get_cluster_types
(**kwargs)¶ Return all cluster types
-
get_clusters
(**kwargs)¶ Return all clusters
-
get_interface
(**kwargs)¶ Return interface by filter
-
get_interfaces
(**kwargs)¶ Return all interfaces
-
get_virtual_machine
(**kwargs)¶ Return virtual-machine based on filter
-
get_virtual_machines
(**kwargs)¶ Return all virtual-machines
-
update_cluster
(name, **kwargs)¶ Update cluster
Parameters: - kwargs – filter arguments
- name – cluster name to update
Returns: bool True if successful otherwise raise UpdateException
-
update_cluster_by_id
(cluster_id, **kwargs)¶ Update cluster
Parameters: - kwargs – filter arguments
- cluster_id – cluster to update
Returns: bool True if successful otherwise raise UpdateException
-
update_cluster_type
(name, **kwargs)¶ Update cluster type
Parameters: - name – name of the cluster type
- kwargs – fields to update
Returns: bool True if successful otherwise raise UpdateException
-
update_cluster_type_by_id
(cluster_type_id, **kwargs)¶ Update cluster type
Parameters: - cluster_type_id – ID of the cluster type
- kwargs – fields to update
Returns: bool True if successful otherwise raise UpdateException
-
update_interface
(name, virtual_machine, **kwargs)¶ Update virtual_machine interface
Parameters: - name – name of the interface to update
- virtual_machine – name of the virtual-machine to update
- kwargs – update data
Returns: bool True if successful otherwise raise UpdateException
-
update_interface_by_id
(interface_id, **kwargs)¶ Update virtual_machine interface
Parameters: - interface_id – id the interface to update
- kwargs – update data
Returns: bool True if successful otherwise raise UpdateException
-
update_virtual_machine
(virtual_machine_name, **kwargs)¶ Update virtual-machine
Parameters: - virtual_machine_name – name of the virtual-machine to update
- kwargs – update data
Returns: bool True if successful otherwise raise UpdateException
-
update_virtual_machine_by_id
(virtual_machine_id, **kwargs)¶ Update virtual-machine
Parameters: - virtual_machine_id – virtual-machine to update
- kwargs – update data
Returns: bool True if successful otherwise raise UpdateException
-