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 =
''
DEFAULT_LOCAL_INTF =
''
DEFAULT_PEER_ADDR =
''
''

Instance Attribute Summary

Attributes inherited from Entity

#config, #error, #node

Instance Method Summary collapse

Methods inherited from Entity

#configure, #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 descriping the current state.

The resource hash returned contains the following:

* domain_id: (String) The MLAG domain-id value
* local_interface: (String) The MLAG local-interface value
* peer_address: (String) The IP address of the MLAG peer
* peer_link: (String) The MLAG transit peer-link value
* shutdown: (Boolean) The administrative staet of the mlag
  configuration
* interfaces: (Hash) The list of configured MLAG interfaces.  (See
  parse_interfaces for the Hash details)

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

67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rbeapi/api/mlag.rb', line 67

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 value keyword is not provided, 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 value keywork if both options are specified

Parameters:

  • :opts (Hash)

    Optional keyword arguments

Returns:

  • (Boolean)

    returns true if the command completed successfully


219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/rbeapi/api/mlag.rb', line 219

def set_domain_id(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['mlag configuration']
  case default
  when true
    cmds << 'default domain-id'
  when false
    cmds << (value ? "domain-id #{value}" : 'no domain-id')
  end
  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 value keyword is not provided, 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 value keywork if both options are specified

Parameters:

  • :opts (Hash)

    Optional keyword arguments

Returns:

  • (Boolean)

    returns true if the command completed successfully


259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/rbeapi/api/mlag.rb', line 259

def set_local_interface(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['mlag configuration']
  case default
  when true
    cmds << 'default local-interface'
  when false
    cmds << (value ? "local-interface #{value}" : 'no local-interface')
  end
  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 value is not specified, 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 value keyword if both options are specified

Parameters:

  • :name (String)

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

  • :opts (Hash)

    Optional keyword arguments

Returns:

  • (Boolean)

    returns true if the command completed successfully


422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/rbeapi/api/mlag.rb', line 422

def set_mlag_id(name, opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ["interface #{name}"]
  case default
  when true
    cmds << 'default mlag'
  when false
    cmds << (value ? "mlag #{value}"  : 'no mlag')
  end
  configure(cmds)
end

#set_peer_address(opts = {}) ⇒ Boolean

set_peer_address configures the mlag peer-address value in the current nodes running configuration. If the value keyword is not provided, 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 value keywork if both options are specified

Parameters:

  • :opts (Hash)

    Optional keyword arguments

Returns:

  • (Boolean)

    returns true if the command completed successfully


339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/rbeapi/api/mlag.rb', line 339

def set_peer_address(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['mlag configuration']
  case default
  when true
    cmds << 'default peer-address'
  when false
    cmds << (value ? "peer-address #{value}" : 'no peer-address')
  end
  configure(cmds)
end

set_peer_link configures the mlag peer-link value in the current nodes running configuration. If the value keyword is not provided, 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 value keywork if both options are specified

Parameters:

  • :opts (Hash)

    Optional keyword arguments

Returns:

  • (Boolean)

    returns true if the command completed successfully


299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/rbeapi/api/mlag.rb', line 299

def set_peer_link(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['mlag configuration']
  case default
  when true
    cmds << 'default peer-link'
  when false
    cmds << (value ? "peer-link #{value}" : 'no peer-link')
  end
  configure(cmds)
end

#set_shutdown(opts = {}) ⇒ Boolean

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

Parameters:

  • :opts (Hash)

    Optional keyword arguments

Returns:

  • (Boolean)

    returns true if the command completed successfully


379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/rbeapi/api/mlag.rb', line 379

def set_shutdown(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['mlag configuration']
  case default
  when true
    cmds << 'default shutdown'
  when false
    cmds << (value ? 'shutdown' : 'no shutdown')
  end
  configure(cmds)
end