veritas.sot.onboarding

Module Contents

Classes

Onboarding

Class to onboard devices including interfaces, vlans, tags an d further more

class veritas.sot.onboarding.Onboarding(sot: Onboarding.__init__.sot)

Class to onboard devices including interfaces, vlans, tags an d further more

onboarding is used to add devices to nautobot. All necessary properties including interfaces, vlans, primary interfaces or IP addresses can be added in one single call to onboarding.

Parameter

sotsot

sot object

Examples

>>> sot.onboarding.interfaces(list_of_interfaces_properties)
...               .vlans(list_of_vlans_properties)
...               .primary_interface(name_of_primary_interface)
...               .add_prefix(False)
...               .add_device(device_properties)
interfaces(*unnamed, **named) Onboarding

add interface to nautobot

Parameters:
  • *unnamed – unnamed arguments that are passed to create interfaces

  • **named – named arguments that are passed to create interfaces

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

  • The arguments are saved as list for later use.

interfaces look like:

interfaces = [{'name': 'GigabitEthernet 0/0',
                       'ip_addresses': [{'address': '192.168.0.1/24',
                                         'status': {'name': 'Active'}
                                        }],
                       'description': 'Primary Interface',
                       'type': '1000base-t',
                       'status': {'name': 'Active'}
             }]
vlans(*unnamed, **named) Onboarding

add vlans to nautobot

Parameters:
  • *unnamed – unnamed arguments that are passed to create vlans

  • **named – named arguments that are passed to create vlans

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

  • The arguments are saved as list for later use.

vlans look like:

vlans = [{'name': 'my_vlan',
          'vid': 100,
          'status': {'name': 'Active'},
          'location': 'location_name
        }]
primary_interface(primary_interface: str) Onboarding

segt primary interface

Parameters:

primary_interface – name of the primary interface

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

  • The argument is saved as str for later use.

use_device_if_exists(use_device: bool) Onboarding

if device already exist return device instead of error

Parameters:

use_device (bool) – True if device should be returned otherwise False

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

use_interface_if_exists(use_interface: bool) Onboarding

return interface if interface exists instead of error

Parameters:

use_interface (bool) – True if interface should be returned otherwise False

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

use_ip_if_exists(use_ip: bool) Onboarding

return IP if IP exists instead of error

Parameters:

use_ip (bool) – True if IP should be returned otherwise False

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

add_prefix(add_prefix: bool) Onboarding

add prefix to nautobot

Parameters:

add_prefix (bool) – if True add prefix to nautobot

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

Examples

assign_ip(assign_ip: bool) Onboarding

assign IP to device

Parameters:

assign_ip (bool) – if True assign IP to device

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

bulk(bulk: bool) Onboarding

use bulk to add data to nautobot

Parameters:

bulk (bool) – if True use bulk method to insert data

Returns:

the onboarding object

Return type:

Onboarding

Notes

  • we use this method to implement the fluent syntax

add_device(*unnamed, **named)

add device to nautobot

The device including vlans and interfaces are added to nautobot. The IP assignment as well as adding the prefixes to nautobot and setting the pimary IP is done as well.

Parameters:
  • *unnamed – unnamed arguments that are passed to add device

  • **named – named arguments that are passed to add device

Returns:

device – the device added to nautobot

Return type:

nautobot.dcim.devices

Notes

You an use named AND unnamed parameter. This functions converts ALL parameter to one property and passes it to the underlaying methods.

Examples

>>> sot.onboarding.interfaces(list_of_interfaces_properties)
...               .vlans(list_of_vlans_properties)
...               .primary_interface(name_of_primary_interface)
...               .add_prefix(False)
...               .add_device(device_properties)
add_interfaces(device, interfaces: list) bool

add interfaces to nautobot

Add interfaces to nautobot. This method is normally called by add_device. Physical interfaces like GigabitEthernetx/y and logical interfaces like port-channels are added to nautobot. The IP address(es) of the interfaces are also added to nautobot when calling this method.

Parameters:
  • device (nautobot.dcim.devices) – the device of the interfaces

  • interfaces (list) – list of interfaces to add

Returns:

success – True if interfaces were added

Return type:

bool

See also

add_device

Examples

>>> sot.onboarding.add_prefix(False)
...               .assign_ip(True)
...               .add_interfaces(device=device_obj, interfaces=list_of_interfaces)
update_interfaces(device, interfaces: list) bool

update interface of a device

Update interface of a device.

Parameters:
  • device (nautobot.dcim.devices) – the device of the interfaces

  • interfaces (list) – list of interfaces to add

Returns:

success – True if successful

Return type:

bool

Examples

>>> sot.add_prefix(False)
...    .assign_ip(True)
...    .update_interfaces(device=device_obj, interfaces=list_of_interfaces)
set_primary_address(address, device) bool

set primary interface of a device

Update interface of a device.

Parameters:
  • address – IP address of the device

  • device (nautobot.dcim.devices) – the device

Returns:

success – True if successful

Return type:

bool

Notes

address can either be a str or nautobot.ipam.ip_address

_add_device_to_nautobot(device_properties: dict)

private method to add device to nautobot

Parameters:

device_properties (dict) – device_properties

Returns:

device – nautobot.dcim.devices or None if not successfull

Return type:

nautobot.dcim.devices

_add_vlans_to_nautobot()

private method to add vlans to nautobot

Returns:

nautobot.dcim.devices if success otherwise None

Return type:

success

_add_interfaces_to_nautobot(device, interfaces: list, debug_msg='')

private method to add interfaces to nautobot

Parameters:
  • device (nautobot.dcim.devices) – the device of the interfaces

  • interfaces (list) – list of interfaces

Returns:

success – True if successful

Return type:

bool

_add_prefix_to_nautobot(ip_addresses: list) list

private method to add prefixes to nautobot

Parameters:

ip_addresses (list) – list of IP addresses

Returns:

added_prefixe – list of prefixes added

Return type:

list

_add_ipaddress_to_nautbot(device, addresses: list) list

private method to add IP addresses to nautobot

Parameters:
  • device (nautobot.dcim.devices) – the device of the interfaces

  • addresses (list) – list of IP adresses

Returns:

added_addresses – list of IP addresses added

Return type:

list

_assign_ip_and_set_primary(device, interface, ip_address) bool

private method to assign IPv4 address to interface set primary IPv4

Parameters:
  • device (nautobot.dcim.devices) – the device of the interfaces

  • interface (nautobot.dcim.interfaces) – interface to assign IP to

  • ip_address (nautobot.ipam.ip_addresses) – IP address to assign

Returns:

assigned – True if successfull

Return type:

bool

_remove_all_assignments(device, interface)

remove all assigments

Parameters:
  • device (nautobot.dcim.devices) – the device of the interfaces

  • interface (nautobot.dcim.interfaces) – interface to assign IP to

Returns:

response – True if successfull

Return type:

bool