Class: Rbeapi::Api::System

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

Overview

The System class configures the node system services such as hostname and domain name

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 system settings

Examples:

{
  hostname: <string>
}

Returns:

  • (Hash)

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



54
55
56
57
58
# File 'lib/rbeapi/api/system.rb', line 54

def get
  response = {}
  response.merge!(parse_hostname(config))
  response
end

#parse_hostname(config) ⇒ Object



60
61
62
63
# File 'lib/rbeapi/api/system.rb', line 60

def parse_hostname(config)
  mdata = /(?<=^hostname\s)(.+)$/.match(config)
  { hostname: mdata.nil? ? '' : mdata[1] }
end

#set_hostname(opts = {}) ⇒ Boolean

Configures the system hostname value in the running-config

Parameters:

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

    The configuration parameters

  • :opts (Hash)

    a customizable set of options

Options Hash (opts):

  • :value (string)

    The value to set the hostname to

  • :default (Boolean)

    The value should be set to default

Returns:

  • (Boolean)

    returns true if the command completed successfully



75
76
77
78
# File 'lib/rbeapi/api/system.rb', line 75

def set_hostname(opts = {})
  cmd = command_builder('hostname', opts)
  configure(cmd)
end