Class: PuppetX::Eos::System
- Inherits:
-
Object
- Object
- PuppetX::Eos::System
- Defined in:
- lib/puppet_x/eos/modules/system.rb
Overview
The System class provides management of system level functions
Instance Method Summary collapse
-
#get_domain_list ⇒ Array
Returns the configure domain-list from the running-config.
-
#get_domain_name ⇒ String
Returns the configured domain-name from the running-config.
-
#get_hostname ⇒ String
Returns the configured system hostname from the running-config.
-
#get_name_servers ⇒ Array
Returns the list of configured name-servers from the running-config.
-
#initialize(api) ⇒ PuppetX::Eos::System
constructor
Initializes a new instance of System.
-
#set_domain_list(domains) ⇒ Boolean
Configures the list of domain suffixes to search.
-
#set_domain_name(name) ⇒ Boolean
Configures the system domain-name.
-
#set_hostname(name) ⇒ Boolean
Configures the system hostname.
-
#set_name_servers(servers) ⇒ Boolean
Configures the system name servers.
Constructor Details
#initialize(api) ⇒ PuppetX::Eos::System
Initializes a new instance of System.
49 50 51 |
# File 'lib/puppet_x/eos/modules/system.rb', line 49 def initialize(api) @api = api end |
Instance Method Details
#get_domain_list ⇒ Array
Returns the configure domain-list from the running-config. If no domain-list has been created, then an empty array is returned
76 77 78 79 80 |
# File 'lib/puppet_x/eos/modules/system.rb', line 76 def get_domain_list result = @api.enable('show running-config section ip\sdomain-list', 'text') result.first['output'].scan(/(?<=list\s).*$/) end |
#get_domain_name ⇒ String
Returns the configured domain-name from the running-config
66 67 68 69 |
# File 'lib/puppet_x/eos/modules/system.rb', line 66 def get_domain_name result = @api.enable('show ip domain-name', 'text') result.first['output'].gsub("\n", '') end |
#get_hostname ⇒ String
Returns the configured system hostname from the running-config
57 58 59 60 |
# File 'lib/puppet_x/eos/modules/system.rb', line 57 def get_hostname result = @api.enable('show hostname') result.first['hostname'].gsub("\n", '') end |
#get_name_servers ⇒ Array
Returns the list of configured name-servers from the running-config
86 87 88 89 |
# File 'lib/puppet_x/eos/modules/system.rb', line 86 def get_name_servers result = @api.enable('show ip name-server', 'text') result.first['output'].split("\n") end |
#set_domain_list(domains) ⇒ Boolean
Configures the list of domain suffixes to search
@param list of domain-name values
130 131 132 133 134 135 |
# File 'lib/puppet_x/eos/modules/system.rb', line 130 def set_domain_list(domains) domains.each do |name| resp = @api.config("ip domain-list #{name}") return false unless resp == [{}] end end |
#set_domain_name(name) ⇒ Boolean
Configures the system domain-name
107 108 109 |
# File 'lib/puppet_x/eos/modules/system.rb', line 107 def set_domain_name(name) @api.config("ip domain-name #{name}") end |
#set_hostname(name) ⇒ Boolean
Configures the system hostname
97 98 99 |
# File 'lib/puppet_x/eos/modules/system.rb', line 97 def set_hostname(name) @api.config("hostname #{name}") == [{}] end |
#set_name_servers(servers) ⇒ Boolean
Configures the system name servers
117 118 119 120 121 122 |
# File 'lib/puppet_x/eos/modules/system.rb', line 117 def set_name_servers(servers) servers.each do |srv| resp = @api.config("ip name-server #{srv}") return false unless resp == [{}] end end |