Class: Rbeapi::Api::Managementdefaults

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

Overview

The Managementdefaults class provides a configuration instance for configuring management defaults of the node.

Constant Summary collapse

DEFAULT_SECRET_HASH =
'md5'.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 management defaults are 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:

{
  secret_hash: <string>
}

Returns:

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

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



58
59
60
61
62
63
# File 'lib/rbeapi/api/managementdefaults.rb', line 58

def get
  config = get_block('management defaults')

  settings = {}
  settings.merge!(parse_secret_hash(config))
end

#set_secret_hash(opts = {}) ⇒ Boolean

set_secret_hash configures the management defaults secret hash value in the current nodes running configuration. If the default keyword is provided, the configuration is defaulted using the default keyword.

===Commands management defaults secret hash no secret hash default secret hash

Parameters:

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

    Optional keyword arguments

Options Hash (opts):

  • value (String)

    The value to configure the secret hash to.

  • enable (Boolean)

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

  • default (Boolean)

    Configure the secret hash value using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



109
110
111
112
113
114
115
116
# File 'lib/rbeapi/api/managementdefaults.rb', line 109

def set_secret_hash(opts = {})
  unless ['md5', 'sha512', nil].include?(opts[:value])
    raise ArgumentError, 'secret hash must be md5 or sha512'
  end
  cmd = command_builder("secret hash #{opts[:value]}")
  cmds = ['management defaults', cmd]
  configure(cmds)
end