Class: Rbeapi::Api::Dns
Overview
The Dns class manages DNS settings on an EOS node.
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#add_domain_list(name) ⇒ Boolean
add_domain_list adds an ip domain-list.
-
#add_name_server(server) ⇒ Boolean
add_name_server adds an ip name-server.
-
#get ⇒ Hash
get returns the DNS resource.
-
#remove_domain_list(name) ⇒ Boolean
remove_domain_list removes a specified ip domain-list.
-
#remove_name_server(server) ⇒ Boolean
remove_name_server removes the specified ip name-server.
-
#set_domain_list(opts = {}) ⇒ Boolean
set_domain_list configures the set of domain names to search when making dns queries for the FQDN.
-
#set_domain_name(opts = {}) ⇒ Boolean
Configure the domain-name value in the running-config.
-
#set_name_servers(opts = {}) ⇒ Boolean
set_name_servers configures the set of name servers that eos will use to resolve dns queries.
Methods inherited from Entity
#command_builder, #configure, #configure_interface, #get_block, #initialize, instance
Constructor Details
This class inherits a constructor from Rbeapi::Api::Entity
Instance Method Details
#add_domain_list(name) ⇒ Boolean
add_domain_list adds an ip domain-list.
247 248 249 |
# File 'lib/rbeapi/api/dns.rb', line 247 def add_domain_list(name) configure "ip domain-list #{name}" end |
#add_name_server(server) ⇒ Boolean
add_name_server adds an ip name-server.
172 173 174 |
# File 'lib/rbeapi/api/dns.rb', line 172 def add_name_server(server) configure "ip name-server #{server}" end |
#get ⇒ Hash
get returns the DNS resource.
55 56 57 58 59 60 61 |
# File 'lib/rbeapi/api/dns.rb', line 55 def get response = {} response.merge!(parse_domain_name) response.merge!(parse_name_servers) response.merge!(parse_domain_list) response end |
#remove_domain_list(name) ⇒ Boolean
remove_domain_list removes a specified ip domain-list.
257 258 259 |
# File 'lib/rbeapi/api/dns.rb', line 257 def remove_domain_list(name) configure "no ip domain-list #{name}" end |
#remove_name_server(server) ⇒ Boolean
remove_name_server removes the specified ip name-server.
182 183 184 |
# File 'lib/rbeapi/api/dns.rb', line 182 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 enable option is set to false, then 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.
Commands
ip domain-list <value>
no ip domain-list
default ip domain-list
rubocop:disable Metrics/MethodLength
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/rbeapi/api/dns.rb', line 210 def set_domain_list(opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) default = opts[:default] || false if value unless value.is_a?(Array) raise ArgumentError, 'value must be an Array' end end cmds = [] case default when true parse_domain_list[:domain_list].each do |name| cmds << "default ip domain-list #{name}" end when false parse_domain_list[:domain_list].each do |name| cmds << "no ip domain-list #{name}" end if enable value.each do |name| cmds << "ip domain-list #{name}" end end end configure cmds end |
#set_domain_name(opts = {}) ⇒ Boolean
Configure the domain-name value in the running-config.
114 115 116 117 |
# File 'lib/rbeapi/api/dns.rb', line 114 def set_domain_name(opts = {}) cmds = command_builder('ip domain-name', opts) 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 enable option is false, then 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.
Commands
ip name-server <value>
no ip name-server
default ip name-server
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/rbeapi/api/dns.rb', line 147 def set_name_servers(opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) default = opts[:default] || false case default when true cmds = 'default ip name-server' when false cmds = ['no ip name-server'] if enable value.each do |srv| cmds << "ip name-server #{srv}" end end end configure cmds end |