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.
233 234 235 |
# File 'lib/rbeapi/api/dns.rb', line 233 def add_domain_list(name) configure "ip domain-list #{name}" end |
#add_name_server(server) ⇒ Boolean
add_name_server adds an ip name-server.
166 167 168 |
# File 'lib/rbeapi/api/dns.rb', line 166 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.
243 244 245 |
# File 'lib/rbeapi/api/dns.rb', line 243 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.
176 177 178 |
# File 'lib/rbeapi/api/dns.rb', line 176 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.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/rbeapi/api/dns.rb', line 203 def set_domain_list(opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) default = opts[:default] || false 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
111 112 113 114 |
# File 'lib/rbeapi/api/dns.rb', line 111 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
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/rbeapi/api/dns.rb', line 141 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 |