Central data models of NAV’s management subsystems¶
Netbox¶
- class nav.models.manage.Netbox(*args, **kwargs)¶
From NAV Wiki: The netbox table is the heart of the heart so to speak, the most central table of them all. The netbox tables contains information on all IP devices that NAV manages with adhering information and relations.
- Parameters
id (AutoField) – Id
ip (GenericIPAddressField) – Ip
room (ForeignKey to
Room
) – Roomtype (ForeignKey to
NetboxType
) – Typesysname (VarcharField) – Sysname
category (ForeignKey to
Category
) – Categoryorganization (ForeignKey to
Organization
) – Organizationup (CharField) – Up
up_since (DateTimeField) – Up since
up_to_date (BooleanField) – Up to date
discovered (DateTimeField) – Discovered
deleted_at (DateTimeField) – Deleted at
master (ForeignKey to
Netbox
) – Masterdata (HStoreField) – Data
groups (ManyToManyField) – Groups
profiles (ManyToManyField) – Profiles
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- UP_CHOICES = (('y', 'up'), ('n', 'down'), ('s', 'shadow'))¶
- UP_DOWN = 'n'¶
- UP_SHADOW = 's'¶
- UP_UP = 'y'¶
- adjacencycandidate_set¶
Model field: netbox, accesses the M2M
AdjacencyCandidate
model.
- alerthistory_set¶
Model field: netbox, accesses the M2M
AlertHistory
model.
- alertqueue_set¶
Model field: netbox, accesses the M2M
AlertQueue
model.
- arp_set¶
Model field: netbox, accesses the M2M
Arp
model.
- cam_set¶
Model field: netbox, accesses the M2M
Cam
model.
- category_id¶
Model field: category
- clean()¶
Custom validation
- data¶
Model field: data
- deleted_at¶
Model field: deleted at
- property device¶
Property to access the former device-field
Returns the first chassis device if any
- discovered¶
Model field: discovered
- entity_set¶
Model field: netbox, accesses the M2M
NetboxEntity
model.
- eventqueue_set¶
Model field: netbox, accesses the M2M
EventQueue
model.
- gatewaypeersession_set¶
Model field: netbox, accesses the M2M
GatewayPeerSession
model.
- get_absolute_url()¶
- get_availability()¶
Calculates and returns an availability data structure.
- get_chassis()¶
Returns a QuerySet of chassis devices seen on this netbox
- get_environment_sensors()¶
Returns the sensors to be displayed on the Environment Sensor tab
- get_fans()¶
- get_filtered_prefix()¶
Returns the netbox’ prefix address only when the prefix is not a scope, private or reserved prefix.
- get_function()¶
Returns the function description of this netbox.
- get_gwport_count()¶
Returns the number of all interfaces that have IP addresses.
- get_gwports()¶
Returns all interfaces that have IP addresses.
- get_gwports_sorted()¶
Returns gwports naturally sorted by interface name
- get_last_jobs()¶
Returns the last log entry for all jobs
- get_next_by_discovered(*, field=<django.db.models.fields.DateTimeField: discovered>, is_next=True, **kwargs)¶
Autogenerated: Finds next instance based on
discovered
.
- get_next_by_up_since(*, field=<django.db.models.fields.DateTimeField: up_since>, is_next=True, **kwargs)¶
Autogenerated: Finds next instance based on
up_since
.
- get_physical_ports()¶
Return all ports that are present.
- get_physical_ports_sorted()¶
Return all ports that are present sorted by interface name.
- get_powersupplies()¶
- get_prefix()¶
Returns the prefix address for this netbox’ IP address.
- get_previous_by_discovered(*, field=<django.db.models.fields.DateTimeField: discovered>, is_next=False, **kwargs)¶
Autogenerated: Finds previous instance based on
discovered
.
- get_previous_by_up_since(*, field=<django.db.models.fields.DateTimeField: up_since>, is_next=False, **kwargs)¶
Autogenerated: Finds previous instance based on
up_since
.
- get_sensors()¶
Returns sensors associated with this netbox
- get_short_sysname()¶
Returns sysname without the domain suffix if specified in the DOMAIN_SUFFIX setting in nav.conf
- get_swport_count()¶
Returns the number of all interfaces that are switch ports.
- get_swports()¶
Returns all interfaces that are switch ports.
- get_swports_sorted()¶
Returns swports naturally sorted by interface name
- get_system_metrics()¶
Gets a list of available Graphite metrics related to this Netbox, except for ports and sensors, which are seen as separate.
- Returns
A list of dicts describing the metrics, e.g.: {id:”nav.devices.some-gw.cpu.cpu1.loadavg1min”,
group=”cpu”, suffix=”cpu1.loadavg1min”}
- get_unresolved_alerts(kind=None)¶
Returns a queryset of unresolved alert states
- get_up_display(*, field=<django.db.models.fields.CharField: up>)¶
Autogenerated: Shows the label of the
up
- get_uplinks()¶
Returns a list of uplinks on this netbox. Requires valid vlan.
- get_uplinks_regarding_of_vlan()¶
- get_week_availability()¶
Gets the availability for this netbox for the last week
- has_unignored_unrecognized_neighbors()¶
Returns true if this netbox has unignored unrecognized neighbors
- id¶
Model field: id
- info_set¶
Model field: netbox, accesses the M2M
NetboxInfo
model.
- ip¶
Model field: ip
- is_on_maintenance()¶
Returns True if this netbox is currently on maintenance
- is_snmp_down()¶
Returns True if this netbox has any unresolved snmp agent state alerts
- is_up()¶
Returns True if the Netbox isn’t known to be down or in shadow
- job_log¶
Model field: netbox, accesses the M2M
IpdevpollJobLog
model.
- last_downtime_ended()¶
Returns the end_time of the last known boxState alert.
- Returns
A datetime object if a serviceState alert was found, otherwise None
- last_updated(job='inventory')¶
Returns the last updated timestamp of a particular job as a datetime object.
- master_id¶
Model field: master
- memory_set¶
Model field: netbox, accesses the M2M
Memory
model.
- module_set¶
Model field: netbox, accesses the M2M
Module
model.
- netboxcategory_set¶
Model field: netbox, accesses the M2M
NetboxCategory
model.
- netboxprefix¶
Model field: netbox, accesses the
NetboxPrefix
model.
- netboxprofile_set¶
Model field: netbox, accesses the M2M
NetboxProfile
model.
- netboxvtpvlan_set¶
Model field: netbox, accesses the M2M
NetboxVtpVlan
model.
- node_position_set¶
Model field: netbox, accesses the M2M
NetmapViewNodePosition
model.
- objects = <django.db.models.manager.ManagerFromNetboxQuerySet object>¶
- organization¶
Model field: organization, accesses the
Organization
model.
- organization_id¶
Model field: organization
- poegroup_set¶
Model field: netbox, accesses the M2M
POEGroup
model.
- poeport_set¶
Model field: netbox, accesses the M2M
POEPort
model.
- powersupplyorfan_set¶
Model field: netbox, accesses the M2M
PowerSupplyOrFan
model.
- property read_only¶
Returns the read-only SNMP community
- property read_write¶
Returns the read-write SNMP community
- room_id¶
Model field: room
- service_set¶
Model field: netbox, accesses the M2M
Service
model.
- property snmp_version¶
Returns the configured SNMP version as an integer
- sysname¶
Model field: sysname
- to_adjacencycandidate_set¶
Model field: to netbox, accesses the M2M
AdjacencyCandidate
model.
- type¶
Model field: type, accesses the
NetboxType
model.
- type_id¶
Model field: type
- unrecognizedneighbor_set¶
Model field: netbox, accesses the M2M
UnrecognizedNeighbor
model.
- up¶
Model field: up
- up_since¶
Model field: up since
- up_to_date¶
Model field: up to date
- ups_objects = <nav.models.manage.UpsManager object>¶
- vlan_set¶
Model field: netbox, accesses the M2M
Vlan
model.
NetboxType¶
- class nav.models.manage.NetboxType(*args, **kwargs)¶
From NAV Wiki: The type table defines the type of a netbox, the sysobjectid being the unique identifier.
- Parameters
id (AutoField) – Id
vendor (ForeignKey to
Vendor
) – Vendorname (VarcharField) – Type name
sysobjectid (VarcharField) – Sysobjectid
description (VarcharField) – Description
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- description¶
Model field: description
- get_enterprise_id()¶
Returns the type’s enterprise ID as an integer.
The type’s sysobjectid should always start with SNMPv2-SMI::enterprises (1.3.6.1.4.1). The next OID element will be an enterprise ID, while the remaining elements will describe the type specific to the vendor.
- id¶
Model field: id
- name¶
Model field: type name
- objects = <django.db.models.manager.Manager object>¶
- sysobjectid¶
Model field: sysobjectid
- vendor¶
Model field: vendor, accesses the
Vendor
model.
- vendor_id¶
Model field: vendor
Category¶
- class nav.models.manage.Category(*args, **kwargs)¶
From NAV Wiki: The cat table defines the categories of a netbox (GW,GSW,SW,EDGE,WLAN,SRV,OTHER).
- Parameters
id (CharField) – Id
description (VarcharField) – Description
req_mgmt (BooleanField) – Req mgmt
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- description¶
Model field: description
- id¶
Model field: id
- is_edge()¶
Is this an edge switch?
- is_gsw()¶
Is this a routing switch?
- is_gw()¶
Is this a router?
- is_other()¶
Is this an uncategorized device?
- is_srv()¶
Is this a server?
- is_sw()¶
Is this a core switch?
- netmap_views¶
Model field: categories, accesses the M2M
NetmapView
model.
- netmapview_set¶
Model field: category, accesses the M2M
NetmapViewCategories
model.
- objects = <django.db.models.manager.Manager object>¶
- req_mgmt¶
Model field: req mgmt
Interface¶
- class nav.models.manage.Interface(*args, **kwargs)¶
The network interfaces, both physical and virtual, of a Netbox.
- Parameters
id (AutoField) – Id
netbox (ForeignKey to
Netbox
) – Netboxmodule (ForeignKey to
Module
) – Moduleifindex (IntegerField) – Ifindex
ifname (VarcharField) – Ifname
ifdescr (VarcharField) – Ifdescr
iftype (IntegerField) – Iftype
speed (FloatField) – Speed
ifphysaddress (CharField) – Ifphysaddress
ifadminstatus (IntegerField) – Ifadminstatus
ifoperstatus (IntegerField) – Ifoperstatus
iflastchange (IntegerField) – Iflastchange
ifconnectorpresent (BooleanField) – Ifconnectorpresent
ifpromiscuousmode (BooleanField) – Ifpromiscuousmode
ifalias (VarcharField) – Ifalias
baseport (IntegerField) – Baseport
media (VarcharField) – Media
vlan (IntegerField) – Vlan
trunk (BooleanField) – Trunk
duplex (CharField) – Duplex
to_netbox (ForeignKey to
Netbox
) – To netboxto_interface (ForeignKey to
Interface
) – To interfacegone_since (DateTimeField) – Gone since
- ADM_DOWN = 2¶
- ADM_STATUS_CHOICES = ((1, 'up'), (2, 'down'), (3, 'testing'))¶
- ADM_TESTING = 3¶
- ADM_UP = 1¶
- DUPLEX_CHOICES = (('f', 'full duplex'), ('h', 'half duplex'))¶
- DUPLEX_FULL = 'f'¶
- DUPLEX_HALF = 'h'¶
- exception DoesNotExist¶
- ETHERNET_INTERFACE_TYPES = (6, 62, 69, 117)¶
- exception MultipleObjectsReturned¶
- OPER_DORMANT = 5¶
- OPER_DOWN = 2¶
- OPER_LOWERLAYERDOWN = 7¶
- OPER_NOTPRESENT = 6¶
- OPER_STATUS_CHOICES = ((1, 'up'), (2, 'down'), (3, 'testing'), (4, 'unknown'), (5, 'dormant'), (6, 'not present'), (7, 'lower layer down'))¶
- OPER_TESTING = 3¶
- OPER_UNKNOWN = 4¶
- OPER_UP = 1¶
- __init__(*args, **kwargs)¶
- above_me()¶
Returns interfaces stacked with this one on a layer above
- adjacencycandidate_set¶
Model field: interface, accesses the M2M
AdjacencyCandidate
model.
- aggregators¶
Model field: aggregator, accesses the M2M
InterfaceAggregate
model.
- property audit_logname¶
- baseport¶
Model field: baseport
- below_me()¶
Returns interfaces stacked with this one on a layer below
- bundled¶
Model field: interface, accesses the M2M
InterfaceAggregate
model.
- duplex¶
Model field: duplex
- get_absolute_url()¶
- get_active_time(interval=600)¶
Time since last CAM activity on port, looking at CAM entries for the last ``interval’’ days.
Returns None if no activity is found, else number of days since last activity as a datetime.timedelta object.
- get_aggregator()¶
Returns the interface that is selected as an aggregator for me.
Naively selects the aggregator with the lowest ifIndex in cases where there are multiple aggregators (may happen on e.g. Juniper devices, due to stacking of logical units)
- get_allowed_vlan_ranges()¶
Returns the set of allowed vlans as a list of ranges
- Return type
nav.util.NumberRange
- get_bundled_interfaces()¶
Returns the interfaces that are bundled on this interface
- get_duplex_display(*, field=<django.db.models.fields.CharField: duplex>)¶
Autogenerated: Shows the label of the
duplex
- get_ifadminstatus_display(*, field=<django.db.models.fields.IntegerField: ifadminstatus>)¶
Autogenerated: Shows the label of the
ifadminstatus
- get_ifoperstatus_display(*, field=<django.db.models.fields.IntegerField: ifoperstatus>)¶
Autogenerated: Shows the label of the
ifoperstatus
- get_last_cam_record()¶
Returns the newest cam record gotten from this switch port.
- get_link_display()¶
Returns a display value for this interface’s link status.
- get_next_by_gone_since(*, field=<django.db.models.fields.DateTimeField: gone_since>, is_next=True, **kwargs)¶
Autogenerated: Finds next instance based on
gone_since
.
- get_port_metrics()¶
Gets a list of available Graphite metrics related to this Interface.
- Returns
A list of dicts describing the metrics, e.g.: {id:”nav.devices.some-gw.ports.gi1_1.ifInOctets”,
suffix:”ifInOctets”}
- get_previous_by_gone_since(*, field=<django.db.models.fields.DateTimeField: gone_since>, is_next=False, **kwargs)¶
Autogenerated: Finds previous instance based on
gone_since
.
- get_sorted_vlans()¶
Returns a queryset of sorted swportvlans
- get_trunkvlans_as_range()¶
Converts the list of allowed vlans on trunk to a string of ranges. Ex: [1, 2, 3, 4, 7, 8, 10] -> “1-4,7-8,10”
- get_vlan_numbers()¶
List of VLAN numbers related to the port
- gone_since¶
Model field: gone since
- gwportprefix_set¶
Model field: interface, accesses the M2M
GwPortPrefix
model.
- has_unignored_unrecognized_neighbors()¶
Returns True if this interface has unrecognized neighbors that are not ignored
- higher_layer¶
Model field: higher, accesses the M2M
InterfaceStack
model.
- id¶
Model field: id
- identity_set¶
Model field: interface, accesses the M2M
Identity
model.
- ifadminstatus¶
Model field: ifadminstatus
- ifalias¶
Model field: ifalias
- ifconnectorpresent¶
Model field: ifconnectorpresent
- ifdescr¶
Model field: ifdescr
- ifindex¶
Model field: ifindex
- iflastchange¶
Model field: iflastchange
- ifname¶
Model field: ifname
- ifoperstatus¶
Model field: ifoperstatus
- ifphysaddress¶
Model field: ifphysaddress
- ifpromiscuousmode¶
Model field: ifpromiscuousmode
- iftype¶
Model field: iftype
- is_admin_up()¶
Returns True if interface is administratively up
- is_degraded()¶
Returns True if this aggregator has been degraded, False if it has not, None if this interface is not a known aggregator.
- is_gwport()¶
Returns True if the interface has an IP address.
NOTE: This doesn’t necessarily mean the port forwards packets for other hosts.
- is_on_maintenace()¶
Returns True if the owning Netbox is on maintenance
- is_oper_up()¶
Returns True if interface is operationally up
- is_physical_port()¶
Returns true if this interface has a physical connector present
- is_swport()¶
Returns True if the interface is configured as a switch-port
- lower_layer¶
Model field: lower, accesses the M2M
InterfaceStack
model.
- media¶
Model field: media
- module¶
Model field: module, accesses the
Module
model.
- module_id¶
Model field: module
- netbox_id¶
Model field: netbox
- objects = <django.db.models.manager.Manager object>¶
- patches¶
Model field: interface, accesses the M2M
Patch
model.
- poeport_set¶
Model field: interface, accesses the M2M
POEPort
model.
- routingprotocolattribute_set¶
Model field: interface, accesses the M2M
RoutingProtocolAttribute
model.
- classmethod sort_ports_by_ifname(ports)¶
- speed¶
Model field: speed
- swportallowedvlan¶
Model field: interface, accesses the
SwPortAllowedVlan
model.
- swportblocked_set¶
Model field: interface, accesses the M2M
SwPortBlocked
model.
- swportvlan_set¶
Model field: interface, accesses the M2M
SwPortVlan
model.
- to_adjacencycandidate_set¶
Model field: to interface, accesses the M2M
AdjacencyCandidate
model.
- to_interface_id¶
Model field: to interface
- to_netbox_id¶
Model field: to netbox
- trunk¶
Model field: trunk
- unrecognizedneighbor_set¶
Model field: interface, accesses the M2M
UnrecognizedNeighbor
model.
- vlan¶
Model field: vlan
Room¶
- class nav.models.manage.Room(*args, **kwargs)¶
From NAV Wiki: The room table defines a wiring closes / network room / server room.
- Parameters
id (CharField) – Id
location (ForeignKey to
Location
) – Locationdescription (VarcharField) – Description
position (PointField) – Position
data (HStoreField) – Data
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- cabling_set¶
Model field: room, accesses the M2M
Cabling
model.
- data¶
Model field: data
- description¶
Model field: description
- get_absolute_url()¶
- id¶
Model field: id
- image_set¶
Model field: room, accesses the M2M
Image
model.
- property latitude¶
- location_id¶
Model field: location
- property longitude¶
- objects = <django.db.models.manager.Manager object>¶
- position¶
Model field: position
Location¶
- class nav.models.manage.Location(*args, **kwargs)¶
The location table defines a group of rooms; i.e. a campus.
- Parameters
id (CharField) – Id
parent (ForeignKey to
Location
) – Parentdescription (VarcharField) – Description
data (HStoreField) – Data
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- data¶
Model field: data
- description¶
Model field: description
- get_all_rooms()¶
Return a queryset returning all rooms in this location and sublocations
- id¶
Model field: id
- image_set¶
Model field: location, accesses the M2M
Image
model.
- objects = <django.db.models.manager.Manager object>¶
- parent_id¶
Model field: parent
Organization¶
- class nav.models.manage.Organization(*args, **kwargs)¶
From NAV Wiki: The org table defines an organization which is in charge of a given netbox and is the user of a given prefix.
- Parameters
id (CharField) – Id
parent (ForeignKey to
Organization
) – Parentdescription (VarcharField) – Description
contact (VarcharField) – Contact
data (HStoreField) – Data
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- account_set¶
Model field: organizations, accesses the M2M
Account
model.
- contact¶
Model field: contact
- data¶
Model field: data
- description¶
Model field: description
- extract_emails()¶
Naively extract email addresses from the contact string
- id¶
Model field: id
- identity_set¶
Model field: organization, accesses the M2M
Identity
model.
- objects = <django.db.models.manager.Manager object>¶
- organization_set¶
Model field: parent, accesses the M2M
Organization
model.
- parent¶
Model field: parent, accesses the
Organization
model.
- parent_id¶
Model field: parent
- vlan_set¶
Model field: organization, accesses the M2M
Vlan
model.