class PuppetX::Eos::System

The System class provides management of system level functions

Public Class Methods

new(api) click to toggle source

Initializes a new instance of System.

@param [PuppetX::Eos::Eapi] api An instance of Eapi

@return [PuppetX::Eos::System] instance

# File lib/puppet_x/eos/modules/system.rb, line 49
def initialize(api)
  @api = api
end

Public Instance Methods

get_domain_list() click to toggle source

Returns the configure domain-list from the running-config. If no domain-list has been created, then an empty array is returned

@return [Array] the list of configured domain names

# 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() click to toggle source

Returns the configured domain-name from the running-config

@return [String] the configured domain-name

# 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() click to toggle source

Returns the configured system hostname from the running-config

@return [String] the configured system hostname

# 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() click to toggle source

Returns the list of configured name-servers from the running-config

@return [Array] the list of configured name servers

# 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) click to toggle source

Configures the list of domain suffixes to search

@param list of domain-name values

@return [Boolean] True if the commands succeed otherwise False

# 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) click to toggle source

Configures the system domain-name

@param [String] name The name to configure the domain-name to

@return [Boolean] True if the commands succeed otherwise False

# 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) click to toggle source

Configures the system hostname

@param [String] name The name to configure the hostname to

@return [Boolean] True if the commands succeed otherwise False

# File lib/puppet_x/eos/modules/system.rb, line 97
def set_hostname(name)
  @api.config("hostname #{name}") == [{}]
end
set_name_servers(servers) click to toggle source

Configures the system name servers

@param [Array] list of name-server values

@return [Boolean] True if the commands succeed otherwise False

# 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