Class: Rbeapi::Api::Mlag

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

Overview

The Mlag class provides a configuration instance for working with the global MLAG configuration of the node.

Constant Summary collapse

DEFAULT_DOMAIN_ID =
''.freeze
DEFAULT_LOCAL_INTF =
''.freeze
DEFAULT_PEER_ADDR =
''.freeze
''.freeze

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

#getnil, Hash<Symbol, Object] returns the nodes current running configuration as a Hash. If mlag is not configured on the node this method will return nil.

get scans the current nodes configuration and returns the values as a Hash describing the current state.

Examples:

{
  global: {
    domain_id: <string>,
    local_interface: <string>,
    peer_address: <string>,
    peer_link: <string>,
    shutdown: <boolean>
  },
  interfaces: {
    <name>: {
      mlag_id: <fixnum>
    },
    <name>: {
      mlag_id: <fixnum>
    },
    ...
  }
}

Returns:

  • (nil, Hash<Symbol, Object] returns the nodes current running configuration as a Hash. If mlag is not configured on the node this method will return nil.)

    nil, Hash<Symbol, Object] returns the nodes current running configuration as a Hash. If mlag is not configured on the node this method will return nil.

See Also:

  • #parse_interfaces


78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/rbeapi/api/mlag.rb', line 78

def get
  config = get_block('mlag configuration')

  global = {}
  global.merge!(parse_domain_id(config))
  global.merge!(parse_local_interface(config))
  global.merge!(parse_peer_address(config))
  global.merge!(parse_peer_link(config))
  global.merge!(parse_shutdown(config))

  { global: global, interfaces: parse_interfaces }
end

#set_domain_id(opts = {}) ⇒ Boolean

set_domain_id configures the mlag domain-id value in the current nodes running configuration. If the enable keyword is false, the the domain-id is configured with the no keyword. If the default keyword is provided, the configuration is defaulted using the default keyword. The default keyword takes precedence over the enable keyword if both options are specified.

Commands

mlag configuration
  domain-id <value>
  no domain-id
  default domain-id

Parameters:

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

    Optional keyword arguments

Options Hash (opts):

  • value (String)

    The value to configure the mlag domain-id to.

  • enable (Boolean)

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

  • default (Boolean)

    Configure the domain-id value using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



232
233
234
235
236
# File 'lib/rbeapi/api/mlag.rb', line 232

def set_domain_id(opts = {})
  cmd = command_builder('domain-id', opts)
  cmds = ['mlag configuration', cmd]
  configure(cmds)
end

#set_local_interface(opts = {}) ⇒ Boolean

set_local_interface configures the mlag local-interface value in the current nodes running configuration. If the enable keyword is false, the local-interface is configured with the no keyword. If the default keyword is provided, the configuration is defaulted using the default keyword. The default keyword takes precedence over the enable keyword if both options are specified

Commands

mlag configuration
  local-interface <value>
  no local-interface
  default local-interface

Parameters:

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

    Optional keyword arguments

Options Hash (opts):

  • value (String)

    The value to configure the mlag local-interface to. The local-interface accepts full interface identifiers and expects a Vlan interface

  • enable (Boolean)

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

  • default (Boolean)

    Configure the local-interface value using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



267
268
269
270
271
# File 'lib/rbeapi/api/mlag.rb', line 267

def set_local_interface(opts = {})
  cmd = command_builder('local-interface', opts)
  cmds = ['mlag configuration', cmd]
  configure(cmds)
end

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

set_mlag_id configures the mlag id on the interface in the nodes current running configuration. If the enable keyword is false, then the interface mlag id is configured using the no keyword. If the default keyword is provided and set to true, the interface mlag id is configured using the default keyword. The default keyword takes precedence over the enable keyword if both options are specified

Commands

interface <name>
  mlag <value>
  no mlag
  default mlag

Parameters:

  • name (String)

    The full interface identifier of the interface to configure th mlag id for.

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

    Optional keyword arguments.

Options Hash (opts):

  • value (String, Integer)

    The value to configure the interface mlag to. The mlag id should be in the valid range of 1 to 2000.

  • enable (Boolean)

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

  • default (Boolean)

    Configure the mlag value using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



411
412
413
414
# File 'lib/rbeapi/api/mlag.rb', line 411

def set_mlag_id(name, opts = {})
  cmd = command_builder('mlag', opts)
  configure_interface(name, cmd)
end

#set_peer_address(opts = {}) ⇒ Boolean

set_peer_address configures the mlag peer-address value in the current nodes running configuration. If the enable keyword is false, then the peer-address is configured with the no keyword. If the default keyword is provided, the configuration is defaulted using the default keyword. The default keyword takes precedence over the enable keyword if both options are specified

Commands

mlag configuration
  peer-address <value>
  no peer-address
  default peer-address

Parameters:

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

    Optional keyword arguments.

Options Hash (opts):

  • value (String)

    The value to configure the mlag peer-address to. The peer-address accepts an IP address in the form of A.B.C.D/E.

  • enable (Boolean)

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

  • default (Boolean)

    Configure the peer-address using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



337
338
339
340
341
# File 'lib/rbeapi/api/mlag.rb', line 337

def set_peer_address(opts = {})
  cmd = command_builder('peer-address', opts)
  cmds = ['mlag configuration', cmd]
  configure(cmds)
end

set_peer_link configures the mlag peer-link value in the current nodes running configuration. If enable keyword is false, then the peer-link is configured with the no keyword. If the default keyword is provided, the configuration is defaulted using the default keyword. The default keyword takes precedence over the enable keyword if both options are specified.

Commands

mlag configuration
  peer-link <value>
  no peer-link
  default peer-link

Parameters:

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

    Optional keyword arguments.

Options Hash (opts):

  • value (String)

    The value to configure the mlag peer-link to. The peer-link accepts full interface identifiers and expects an Ethernet or Port-Channel interface.

  • enable (Boolean)

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

  • default (Boolean)

    Configure the peer-link using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



302
303
304
305
306
# File 'lib/rbeapi/api/mlag.rb', line 302

def set_peer_link(opts = {})
  cmd = command_builder('peer-link', opts)
  cmds = ['mlag configuration', cmd]
  configure(cmds)
end

#set_shutdown(opts = {}) ⇒ Boolean

set_shutdown configures the administrative state of the mlag process on the current node. If the enable keyword is true, then mlag is enabled and if the enable keyword is false, then mlag is disabled. If the default keyword is provided, the configuration is defaulted using the default keyword. The default keyword takes precedence over the enable keyword if both options are specified

Commands

mlag configuration
  shutdown
  no shutdown
  default shutdown

Parameters:

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

    Optional keyword arguments.

Options Hash (opts):

  • enable (Boolean)

    True if the interface should be administratively enabled or false if the interface should be administratively disabled.

  • default (Boolean)

    Configure the shutdown value using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



369
370
371
372
373
374
375
376
377
# File 'lib/rbeapi/api/mlag.rb', line 369

def set_shutdown(opts = {})
  raise 'set_shutdown has the value option set' if opts[:value]
  # Shutdown semantics are opposite of enable semantics so invert enable
  value = !opts[:enable]
  opts[:enable] = value
  cmd = command_builder('shutdown', opts)
  cmds = ['mlag configuration', cmd]
  configure(cmds)
end