Class: PuppetX::Eos::System

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/eos/modules/system.rb

Overview

The System class provides management of system level functions

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ PuppetX::Eos::System

Initializes a new instance of System.

Parameters:



49
50
51
# File 'lib/puppet_x/eos/modules/system.rb', line 49

def initialize(api)
  @api = api
end

Instance Method Details

#get_domain_listArray

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

Returns:

  • (Array)

    the list of configured domain names



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_nameString

Returns the configured domain-name from the running-config

Returns:

  • (String)

    the configured domain-name



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_hostnameString

Returns the configured system hostname from the running-config

Returns:

  • (String)

    the configured system hostname



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_serversArray

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

Returns:

  • (Array)

    the list of configured name servers



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

Returns:

  • (Boolean)

    True if the commands succeed otherwise False



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

Parameters:

  • name (String)

    The name to configure the domain-name to

Returns:

  • (Boolean)

    True if the commands succeed otherwise False



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

Parameters:

  • name (String)

    The name to configure the hostname to

Returns:

  • (Boolean)

    True if the commands succeed otherwise False



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

Parameters:

  • list (Array)

    of name-server values

Returns:

  • (Boolean)

    True if the commands succeed otherwise False



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