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
Commands
route-map <name> action <value> seqno <value> description <value>
match <value> set <value> continue <value>
| 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | # File 'lib/rbeapi/api/routemaps.rb', line 303 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 #{}" end end if opts[:set] remove_set_statements(name, action, seqno, cmds) opts[:set].each do || cmds << "set #{}" 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.
Commands
no route-map <name>
| 421 422 423 | # File 'lib/rbeapi/api/routemaps.rb', line 421 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.
Commands
no route-map <name> <action> <seqno>
| 399 400 401 | # File 'lib/rbeapi/api/routemaps.rb', line 399 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.
Commands
route-map <name> action <value> seqno <value> continue <value>
| 491 492 493 494 495 496 | # File 'lib/rbeapi/api/routemaps.rb', line 491 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.
Commands
route-map <name> action <value> seqno <value> description <value>
| 514 515 516 517 518 519 | # File 'lib/rbeapi/api/routemaps.rb', line 514 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.
Commands
route-map <name> action <value> seqno <value> match <value>
| 441 442 443 444 445 446 447 448 | # File 'lib/rbeapi/api/routemaps.rb', line 441 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 #{}" 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.
Commands
route-map <name> action <value> seqno <value> set <value>
| 466 467 468 469 470 471 472 473 | # File 'lib/rbeapi/api/routemaps.rb', line 466 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 #{}" end configure(cmds) end |