Class: Rbeapi::Api::Varp

Inherits:
Entity
  • Object
show all
Defined in:
lib/rbeapi/api/varp.rb

Overview

The Varp class provides an instance for working with the global VARP configuration of the node.

Instance Attribute Summary

Attributes inherited from Entity

#config, #error, #node

Instance Method Summary collapse

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

#getHash

Returns the global VARP configuration from the node.

Examples:

{
  mac_address: <string>,
  interfaces: {
    <name>: {
      addresses: <array>
    },
    <name>: {
      addresses: <array>
    },
    ...
  }
}

Returns:

  • (Hash)

    A Ruby hash object that provides the Varp settings as key / value pairs.



63
64
65
66
67
68
# File 'lib/rbeapi/api/varp.rb', line 63

def get
  response = {}
  response.merge!(parse_mac_address(config))
  response[:interfaces] = interfaces.getall
  response
end

#interfacesObject



88
89
90
91
92
# File 'lib/rbeapi/api/varp.rb', line 88

def interfaces
  return @interfaces if @interfaces
  @interfaces = VarpInterfaces.new(node)
  @interfaces
end

#set_mac_address(opts = {}) ⇒ Boolean

Configure the VARP virtual-router mac-address value.

Parameters:

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

    The configuration parameters.

Options Hash (opts):

  • value (string)

    The value to set the mac-address to.

  • enable (Boolean)

    If false then the command is negated. Default is true.

  • default (Boolean)

    The value should be set to default.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.



107
108
109
110
# File 'lib/rbeapi/api/varp.rb', line 107

def set_mac_address(opts = {})
  cmd = command_builder('ip virtual-router mac-address', opts)
  configure(cmd)
end