Class: Rbeapi::Api::Routemaps
- Defined in:
- lib/rbeapi/api/routemaps.rb
Overview
The Routemaps class manages routemaps. A route map is a list of rules that control the redistribution of IP routes into a protocol domain on the basis of such criteria as route metrics, access control lists, next hop addresses, and route tags.
rubocop:disable Metrics/ClassLength
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#create(name, action, seqno, opts = {}) ⇒ Boolean
create will create a new routemap with the specified name.
-
#default(name, action, seqno) ⇒ Boolean
This method will attempt to default the routemap from the nodes operational config.
-
#delete(name, action, seqno) ⇒ Boolean
delete will delete an existing routemap name from the nodes current running configuration.
-
#get(name) ⇒ nil, Hash<Symbol, Object>
get returns a hash of routemap configurations for the given name.
-
#getall ⇒ nil, Hash<Symbol, Object>
getall returns a collection of routemap resource hashes from the nodes running configuration.
-
#set_continue(name, action, seqno, value) ⇒ Boolean
set_continue will set the continue value for a specified routemap.
-
#set_description(name, action, seqno, value) ⇒ Boolean
set_description will set the description for a specified routemap.
-
#set_match_statements(name, action, seqno, value) ⇒ Boolean
set_match_statements will set the match values for a specified routemap.
-
#set_set_statements(name, action, seqno, value) ⇒ Boolean
set_set_statements will set the set values for a specified routemap.
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
#create(name, action, seqno, opts = {}) ⇒ Boolean
create will create a new routemap with the specified name.
rubocop:disable Metrics/MethodLength
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/rbeapi/api/routemaps.rb', line 277 def create(name, action, seqno, opts = {}) if opts.empty? cmds = name_commands(name, action, seqno) else cmds = name_commands(name, action, seqno, opts) if opts[:description] cmds << 'no description' cmds << "description #{opts[:description]}" end if opts[:continue] cmds << 'no continue' cmds << "continue #{opts[:continue]}" end if opts[:match] remove_match_statements(name, action, seqno, cmds) opts[:match].each do || cmds << "match #{options}" end end if opts[:set] remove_set_statements(name, action, seqno, cmds) opts[:set].each do || cmds << "set #{options}" end end end configure(cmds) end |
#default(name, action, seqno) ⇒ Boolean
This method will attempt to default the routemap from the nodes operational config. Since routemaps do not exist by default, the default action is essentially a negation and the result will be the removal of the routemap clause. If the routemap does not exist then this method will not perform any changes but still return True
375 376 377 |
# File 'lib/rbeapi/api/routemaps.rb', line 375 def default(name, action, seqno) configure(["default route-map #{name} #{action} #{seqno}"]) end |
#delete(name, action, seqno) ⇒ Boolean
delete will delete an existing routemap name from the nodes current running configuration. If the delete method is called and the routemap name does not exist, this method will succeed.
353 354 355 |
# File 'lib/rbeapi/api/routemaps.rb', line 353 def delete(name, action, seqno) configure(["no route-map #{name} #{action} #{seqno}"]) end |
#get(name) ⇒ nil, Hash<Symbol, Object>
get returns a hash of routemap configurations for the given name
90 91 92 |
# File 'lib/rbeapi/api/routemaps.rb', line 90 def get(name) parse_entries(name) end |
#getall ⇒ nil, Hash<Symbol, Object>
getall returns a collection of routemap resource hashes from the nodes running configuration. The routemap resource collection hash is keyed by the unique routemap name.
166 167 168 169 170 171 172 |
# File 'lib/rbeapi/api/routemaps.rb', line 166 def getall routemaps = config.scan(/(?<=^route-map\s)[^\s]+/) return nil if routemaps.empty? routemaps.each_with_object({}) do |name, response| response[name] = parse_entries(name) end end |
#set_continue(name, action, seqno, value) ⇒ Boolean
set_continue will set the continue value for a specified routemap. If the specified routemap does not exist, it will be created.
445 446 447 448 449 450 |
# File 'lib/rbeapi/api/routemaps.rb', line 445 def set_continue(name, action, seqno, value) cmds = ["route-map #{name} #{action} #{seqno}"] cmds << 'no continue' cmds << "continue #{value}" configure(cmds) end |
#set_description(name, action, seqno, value) ⇒ Boolean
set_description will set the description for a specified routemap. If the specified routemap does not exist, it will be created.
468 469 470 471 472 473 |
# File 'lib/rbeapi/api/routemaps.rb', line 468 def set_description(name, action, seqno, value) cmds = ["route-map #{name} #{action} #{seqno}"] cmds << 'no description' cmds << "description #{value}" configure(cmds) end |
#set_match_statements(name, action, seqno, value) ⇒ Boolean
set_match_statements will set the match values for a specified routemap. If the specified routemap does not exist, it will be created.
395 396 397 398 399 400 401 402 |
# File 'lib/rbeapi/api/routemaps.rb', line 395 def set_match_statements(name, action, seqno, value) cmds = ["route-map #{name} #{action} #{seqno}"] remove_match_statements(name, action, seqno, cmds) Array(value).each do || cmds << "match #{options}" end configure(cmds) end |
#set_set_statements(name, action, seqno, value) ⇒ Boolean
set_set_statements will set the set values for a specified routemap. If the specified routemap does not exist, it will be created.
420 421 422 423 424 425 426 427 |
# File 'lib/rbeapi/api/routemaps.rb', line 420 def set_set_statements(name, action, seqno, value) cmds = ["route-map #{name} #{action} #{seqno}"] remove_set_statements(name, action, seqno, cmds) Array(value).each do || cmds << "set #{options}" end configure(cmds) end |