Class: Rbeapi::Api::VlanInterface

Inherits:
BaseInterface show all
Defined in:
lib/rbeapi/api/interfaces.rb

Overview

The VlanInterface class manages all Vlan interfaces on an EOS node.

Constant Summary

Constants inherited from BaseInterface

BaseInterface::DEFAULT_INTF_DESCRIPTION, BaseInterface::DEFAULT_INTF_ENCAPSULATION, BaseInterface::DEFAULT_LOAD_INTERVAL

Instance Attribute Summary

Attributes inherited from Entity

#config, #error, #node

Instance Method Summary collapse

Methods inherited from BaseInterface

#create, #default, #delete, #set_description, #set_encapsulation, #set_load_interval, #set_shutdown

Methods inherited from Entity

#command_builder, #configure, #configure_interface, #get_block, #initialize, instance

Constructor Details

This class inherits a constructor from Rbeapi::Api::Entity

Instance Method Details

#get(name) ⇒ nil, Hash<String, String>

Returns the Vlan interface configuration as a Ruby hash of key/value pairs from the nodes running configuration. This method extends the BaseInterface get method and adds the Vlan specific attributes to the hash.

Examples:

{
  name: <string>,
  type: <string>,
  description: <string>,
  shutdown: <boolean>,
  autostate: <boolean>
}

Parameters:

  • name (String)

    The interface name to return from the nodes configuration.

Returns:

  • (nil, Hash<String, String>)

    Returns the interface configuration as a Ruby hash object. If the provided interface name is not found then this method will return nil.



1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'lib/rbeapi/api/interfaces.rb', line 1483

def get(name)
  config = get_block("interface #{name}")
  return nil unless config

  response = super(name)
  response[:type] = 'vlan'
  response.merge!(parse_autostate(config))
  response
end

#set_autostate(name, opts = {}) ⇒ Boolean

set_autostate configures the autostate on a vlan interface. Default value is true, if set to false ‘no autostate’ is configured on the interface.

Parameters:

  • name (String)

    The interface name to apply the configuration values to. The name must be the full interface identifier.

  • opts (Hash) (defaults to: {})

    Optional keyword arguments.

Options Hash (opts):

  • value (Boolean)

    Enables or disables autotate for vlan interfaces. Default is true.

  • default (Boolean)

    Configures the autostate value on the interface using the default value (true).

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



1530
1531
1532
1533
1534
1535
1536
1537
# File 'lib/rbeapi/api/interfaces.rb', line 1530

def set_autostate(name, opts = {})
  commands = if opts[:value] == :false
               command_builder('no autostate')
             else
               command_builder('autostate')
             end
  configure_interface(name, commands)
end