Class: Rbeapi::Api::Dns
Instance Attribute Summary
Attributes inherited from Entity
#config, #error, #node
Instance Method Summary
collapse
Methods inherited from Entity
#configure, #get_block, #initialize, instance
Instance Method Details
#add_domain_list(name) ⇒ Object
189
190
191
|
# File 'lib/rbeapi/api/dns.rb', line 189
def add_domain_list(name)
configure "ip domain-list #{name}"
end
|
#add_name_server(server) ⇒ Object
139
140
141
|
# File 'lib/rbeapi/api/dns.rb', line 139
def add_name_server(server)
configure "ip name-server #{server}"
end
|
#get ⇒ Hash
52
53
54
55
56
57
58
|
# File 'lib/rbeapi/api/dns.rb', line 52
def get
response = {}
response.merge!(parse_domain_name)
response.merge!(parse_name_servers)
response.merge!(parse_domain_list)
response
end
|
#parse_domain_list ⇒ Object
71
72
73
74
|
# File 'lib/rbeapi/api/dns.rb', line 71
def parse_domain_list
search = config.scan(/(?<=^ip\sdomain-list\s).+$/)
{ domain_list: search }
end
|
#parse_domain_name ⇒ Object
60
61
62
63
|
# File 'lib/rbeapi/api/dns.rb', line 60
def parse_domain_name
mdata = /ip domain-name ([\w.]+)/.match(config)
{ domain_name: mdata.nil? ? '' : mdata[1] }
end
|
#parse_name_servers ⇒ Object
65
66
67
68
69
|
# File 'lib/rbeapi/api/dns.rb', line 65
def parse_name_servers
servers = config.scan(/(?:ip name-server vrf )(?:\w+)\s(.+)/)
values = servers.each_with_object([]) { |srv, arry| arry << srv.first }
{ name_servers: values }
end
|
#remove_domain_list(name) ⇒ Object
193
194
195
|
# File 'lib/rbeapi/api/dns.rb', line 193
def remove_domain_list(name)
configure "no ip domain-list #{name}"
end
|
#remove_name_server(server) ⇒ Object
143
144
145
|
# File 'lib/rbeapi/api/dns.rb', line 143
def remove_name_server(server)
configure "no ip name-server #{server}"
end
|
#set_domain_list(opts = {}) ⇒ Boolean
set_domain_list configures the set of domain names to search when making dns queries for the FQDN. If the value option is not provided, the domain-list will be configured using the no keyword. If the default option is specified, then the domain list will be configured using the default keyword. If both options are provided the default keyword option will take precedence.
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/rbeapi/api/dns.rb', line 170
def set_domain_list(opts = {})
value = opts[:value] || []
default = opts[:default] || false
case default
when true
cmds = 'default ip domain-list'
when false
cmds = []
parse_domain_list[:domain_list].each do |name|
cmds << "no ip domain-list #{name}"
end
value.each do |name|
cmds << "ip domain-list #{name}"
end
end
configure cmds
end
|
#set_domain_name(opts = {}) ⇒ Boolean
Configure the domain-name value in the running-config
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/rbeapi/api/dns.rb', line 84
def set_domain_name(opts = {})
value = opts[:value]
default = opts[:default] || false
case default
when true
cmds = 'default ip domain-name'
when false
cmds = (value ? "ip domain-name #{value}" : 'no ip domain-name')
end
configure(cmds)
end
|
#set_name_servers(opts = {}) ⇒ Boolean
set_name_servers configures the set of name servers that eos will use to resolve dns queries. If the value option is not provided, the name-server list will be configured using the no keyword. If the default option is specified, then the name server list will be configured using the default keyword. If both options are provided the keyword option will take precedence
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/rbeapi/api/dns.rb', line 120
def set_name_servers(opts = {})
value = opts[:value] || []
default = opts[:default] || false
case default
when true
cmds = 'default ip name-server'
when false
cmds = []
parse_name_servers[:name_servers].each do |srv|
cmds << "no ip name-server #{srv}"
end
value.each do |srv|
cmds << "ip name-server #{srv}"
end
end
configure cmds
end
|