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 for hostname, iprouting, and banners.
-
#initialize(node) ⇒ System
constructor
A new instance of System.
-
#set_banner(banner_type, opts = {}) ⇒ Boolean
Configures system banners.
-
#set_hostname(opts = {}) ⇒ Boolean
Configures the system hostname value in the running-config.
-
#set_iprouting(opts = {}) ⇒ Boolean
Configures the state of global ip routing.
-
#set_timezone(opts = {}) ⇒ Boolean
Configures the value of clock timezone in the running-config.
Methods inherited from Entity
#command_builder, #configure, #configure_interface, #get_block, instance
Constructor Details
#initialize(node) ⇒ System
Returns a new instance of System.
44 45 46 47 |
# File 'lib/rbeapi/api/system.rb', line 44 def initialize(node) super(node) @banners_re = Regexp.new(/^banner\s+(login|motd)\s?$\n(.*?)$\nEOF$\n/m) end |
Instance Method Details
#get ⇒ Hash
Returns the system settings for hostname, iprouting, and banners.
62 63 64 65 66 67 68 69 |
# File 'lib/rbeapi/api/system.rb', line 62 def get response = {} response.merge!(parse_hostname(config)) response.merge!(parse_iprouting(config)) response.merge!(parse_timezone(config)) response.merge!((config)) response end |
#set_banner(banner_type, opts = {}) ⇒ Boolean
Configures system banners.
213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/rbeapi/api/system.rb', line 213 def (, opts = {}) value = opts[:value] cmd_string = "banner #{}" if value value += "\n" if value[-1, 1] != "\n" cmd = [{ cmd: cmd_string, input: value }] else cmd = command_builder(cmd_string, opts) end configure(cmd) end |
#set_hostname(opts = {}) ⇒ Boolean
Configures the system hostname value in the running-config.
155 156 157 158 |
# File 'lib/rbeapi/api/system.rb', line 155 def set_hostname(opts = {}) cmd = command_builder('hostname', opts) configure(cmd) end |
#set_iprouting(opts = {}) ⇒ Boolean
Configures the state of global ip routing.
172 173 174 175 |
# File 'lib/rbeapi/api/system.rb', line 172 def set_iprouting(opts = {}) cmd = command_builder('ip routing', opts) configure(cmd) end |
#set_timezone(opts = {}) ⇒ Boolean
Configures the value of clock timezone in the running-config.
191 192 193 194 |
# File 'lib/rbeapi/api/system.rb', line 191 def set_timezone(opts = {}) cmd = command_builder('clock timezone', opts) configure(cmd) end |