Class: Rbeapi::Api::System
Overview
The System class configures the node system services such as hostname and domain name
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#get ⇒ Hash
Returns the system settings.
- #parse_hostname(config) ⇒ Object
-
#set_hostname(opts = {}) ⇒ Boolean
Configures the system hostname value in the running-config.
Methods inherited from Entity
#configure, #get_block, #initialize, instance
Constructor Details
This class inherits a constructor from Rbeapi::Api::Entity
Instance Method Details
#get ⇒ Hash
Returns the system settings
53 54 55 56 57 |
# File 'lib/rbeapi/api/system.rb', line 53 def get() response = {} response.merge!(parse_hostname(config)) response end |
#parse_hostname(config) ⇒ Object
59 60 61 62 |
# File 'lib/rbeapi/api/system.rb', line 59 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
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rbeapi/api/system.rb', line 72 def set_hostname(opts = {}) value = opts[:value] default = opts[:default] || false case default when true cmds = ['default hostname'] when false cmds = (value.nil? ? 'no hostname' : \ "hostname #{value}") end configure(cmds) end |