class Rbeapi::Api::System
The System
class configures the node system services such as hostname and domain name.
Public Class Methods
Rbeapi::Api::Entity::new
# 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
Public Instance Methods
Returns the system settings for hostname, iprouting, and banners.
@example
{ hostname: <string>, iprouting: <boolean>, banner_motd: <string>, banner_login: <string> }
@return [Hash] A Ruby hash object that provides the system settings as
key/value pairs.
# 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!(parse_banners(config)) response end
Configures the system hostname value in the running-config.
@param opts [Hash] The configuration parameters.
@option opts value [string] The value to set the hostname to.
@option opts enable [Boolean] If false then the command is
negated. Default is true.
@option opts default [Boolean] If true configure the command using
the default keyword. Default is false.
@return [Boolean] Returns true if the command completed successfully.
# File lib/rbeapi/api/system.rb, line 155 def set_hostname(opts = {}) cmd = command_builder('hostname', opts) configure(cmd) end
Configures the state of global ip routing.
@param opts [Hash] The configuration parameters.
@option opts enable [Boolean] True if ip routing should be enabled
or False if ip routing should be disabled. Default is true.
@option opts default [Boolean] If true configure the command using
the default keyword. Default is false.
@return [Boolean] Returns true if the command completed successfully.
# File lib/rbeapi/api/system.rb, line 172 def set_iprouting(opts = {}) cmd = command_builder('ip routing', opts) configure(cmd) end
Configures the value of clock timezone in the running-config.
@param opts [Hash] The configuration parameters.
@option opts value [string] The value to set the clock timezone to.
@option opts enable [Boolean] If false then the command is
negated. Default is true.
@option opts default [Boolean] If true configure the command using
the default keyword. Default is false.
@return [Boolean] Returns true if the command completed successfully.
# File lib/rbeapi/api/system.rb, line 191 def set_timezone(opts = {}) cmd = command_builder('clock timezone', opts) configure(cmd) end
Private Instance Methods
parse_hostname
parses hostname values from the provided config.
@api private
@param config [String] The configuration block returned
from the node's running configuration.
@return [Hash<Symbol, Object>] The resource hash attribute.
# File lib/rbeapi/api/system.rb, line 80 def parse_hostname(config) mdata = /(?<=^hostname\s)(.+)$/.match(config) { hostname: mdata.nil? ? '' : mdata[1] } end
parse_iprouting
parses ip routing from the provided config.
@api private
@param config [String] The configuration block returned
from the node's running configuration.
@return [Hash<Symbol, Object>] The resource hash attribute.
# File lib/rbeapi/api/system.rb, line 95 def parse_iprouting(config) mdata = /no\sip\srouting$/.match(config) { iprouting: mdata.nil? ? true : false } end
parse_timezone
parses the value of clock timezone.
@api private
@param config [String] The configuration block returned
from the node's running configuration.
@return [Hash<Symbol, Object>] The resource hash attribute.
# File lib/rbeapi/api/system.rb, line 110 def parse_timezone(config) mdata = /(?<=^clock timezone\s)(.+)$/.match(config) { timezone: mdata.nil? ? '' : mdata[1] } end