Class: Cisco::NameServer
Overview
NameServer - node utility class for DNS client name server config management
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from NodeUtil
client, #client, config_get, #config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, #node, node, platform, #platform, supports?, #supports?
Constructor Details
#initialize(name, instantiate = true) ⇒ NameServer
31
32
33
34
35
36
37
|
# File 'lib/cisco_node_utils/name_server.rb', line 31
def initialize(name, instantiate=true)
unless name.is_a? String
fail TypeError, "Expected a string, got a #{name.inspect}"
end
@name = name
create if instantiate
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
29
30
31
|
# File 'lib/cisco_node_utils/name_server.rb', line 29
def name
@name
end
|
Class Method Details
.nameservers ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/cisco_node_utils/name_server.rb', line 39
def self.nameservers
hosts = config_get('dnsclient', 'name_server')
return {} if hosts.nil?
hash = {}
hosts.join(' ').split(' ').each do |name|
hash[name] = NameServer.new(name, false)
end
hash
end
|
Instance Method Details
#==(other) ⇒ Object
52
53
54
|
# File 'lib/cisco_node_utils/name_server.rb', line 52
def ==(other)
name == other.name
end
|
#create ⇒ Object
56
57
58
|
# File 'lib/cisco_node_utils/name_server.rb', line 56
def create
config_set('dnsclient', 'name_server', state: '', ip: @name)
end
|
#destroy ⇒ Object
60
61
62
|
# File 'lib/cisco_node_utils/name_server.rb', line 60
def destroy
config_set('dnsclient', 'name_server', state: 'no', ip: @name)
end
|