Vlans

Module for working with EOS VLAN resources

The Vlans resource provides configuration of VLAN resources for an EOS node.

param name

The name parameter maps to the VLAN name in EOS. Valid values include any consecutive sequence of numbers, letters and underscore up to the maximum number of characters. This parameter is defaultable.

type name

string

param state

The state parameter sets the operational state of the VLAN on the node. It has two valid values: active or suspend. The state parameter is defaultable.

type state

string

param trunk_groups

The trunk_groups parameter provides a list of trunk groups configured for this VLAN. This parameter is defaultable.

type trunk_groups

array

class pyeapi.api.vlans.Vlans(node)[source]

Bases: pyeapi.api.abstract.EntityCollection

The Vlans class provides a configuration resource for VLANs

The Vlans class is derived from ResourceBase a standard set of methods for working with VLAN configurations on an EOS node.

add_trunk_group(vid, name)[source]

Adds a new trunk group to the Vlan in the running-config

EosVersion:

4.13.7M

Parameters
  • vid (str) – The VLAN ID to configure

  • name (str) – The trunk group to add to the list

Returns

True if the operation was successful otherwise False

configure_vlan(vid, commands)[source]

Configures the specified Vlan using commands

Parameters
  • vid (str) – The VLAN ID to configure

  • commands – The list of commands to configure

Returns

True if the commands completed successfully

create(vid)[source]

Creates a new VLAN resource

Parameters

vid (str) – The VLAN ID to create

Returns

True if create was successful otherwise False

default(vid)[source]

Defaults the VLAN configuration

default vlan <vlanid>
Parameters

vid (str) – The VLAN ID to default

Returns

True if the operation was successful otherwise False

delete(vid)[source]

Deletes a VLAN from the running configuration

Parameters

vid (str) – The VLAN ID to delete

Returns

True if the operation was successful otherwise False

get(value)[source]

Returns the VLAN configuration as a resource dict.

Parameters

vid (string) – The vlan identifier to retrieve from the running configuration. Valid values are in the range of 1 to 4095

Returns

A Python dict object containing the VLAN attributes as

key/value pairs.

getall()[source]

Returns a dict object of all Vlans in the running-config

Returns

A dict object of Vlan attributes

remove_trunk_group(vid, name)[source]

Removes a trunk group from the list of configured trunk groups for the specified VLAN ID

EosVersion:

4.13.7M

Parameters
  • vid (str) – The VLAN ID to configure

  • name (str) – The trunk group to add to the list

Returns

True if the operation was successful otherwise False

set_name(vid, name=None, default=False, disable=False)[source]

Configures the VLAN name

EosVersion:

4.13.7M

Parameters
  • vid (str) – The VLAN ID to Configures

  • name (str) – The value to configure the vlan name

  • default (bool) – Defaults the VLAN ID name

  • disable (bool) – Negates the VLAN ID name

Returns

True if the operation was successful otherwise False

set_state(vid, value=None, default=False, disable=False)[source]

Configures the VLAN state

EosVersion:

4.13.7M

Parameters
  • vid (str) – The VLAN ID to configure

  • value (str) – The value to set the vlan state to

  • default (bool) – Configures the vlan state to its default value

  • disable (bool) – Negates the vlan state

Returns

True if the operation was successful otherwise False

set_trunk_groups(vid, value=None, default=False, disable=False)[source]

Configures the list of trunk groups support on a vlan

This method handles configuring the vlan trunk group value to default if the default flag is set to True. If the default flag is set to False, then this method will calculate the set of trunk group names to be added and to be removed.

EosVersion:

4.13.7M

Parameters
  • vid (str) – The VLAN ID to configure

  • value (str) – The list of trunk groups that should be configured for this vlan id.

  • default (bool) – Configures the trunk group value to default if this value is true

  • disable (bool) – Negates the trunk group value if set to true

Returns

True if the operation was successful otherwise False

pyeapi.api.vlans.instance(node)[source]

Returns an instance of Vlans

This method will create and return an instance of the Vlans object passing the value of API to the object. The instance method is required for the resource to be autoloaded by the Node object

Parameters

node (Node) – The node argument passes an instance of Node to the resource

pyeapi.api.vlans.isvlan(value)[source]

Checks if the argument is a valid VLAN

A valid VLAN is an integer value in the range of 1 to 4094. This function will test if the argument falls into the specified range and is considered a valid VLAN

Parameters

value – The value to check if is a valid VLAN

Returns

True if the supplied value is a valid VLAN otherwise False