Class: Rbeapi::Api::Prefixlists
- Defined in:
- lib/rbeapi/api/prefixlists.rb
Overview
The Prefixlists class provides a configuration instance for working with static routes in EOS.
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
- 
  
    
      #add_rule(name, action, prefix, seq = nil)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    add_rule will create an ip prefix-list with the designated name, seqno, action and prefix. 
- 
  
    
      #create(name)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    create will create a new ip prefix-list with designated name. 
- 
  
    
      #delete(name, seq = nil)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    delete will remove the designated prefix-list. 
- 
  
    
      #get(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns the static routes configured on the node. 
- 
  
    
      #getall  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns the static routes configured on the node. 
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_rule(name, action, prefix, seq = nil) ⇒ Boolean
add_rule will create an ip prefix-list with the designated name,
seqno, action and prefix.
| 119 120 121 122 123 124 | # File 'lib/rbeapi/api/prefixlists.rb', line 119 def add_rule(name, action, prefix, seq = nil) cmd = "ip prefix-list #{name}" cmd << " seq #{seq}" if seq cmd << " #{action} #{prefix}" configure cmd end | 
#create(name) ⇒ Boolean
create will create a new ip prefix-list with designated name.
| 102 103 104 | # File 'lib/rbeapi/api/prefixlists.rb', line 102 def create(name) configure "ip prefix-list #{name}" end | 
#delete(name, seq = nil) ⇒ Boolean
delete will remove the designated prefix-list
| 134 135 136 137 138 | # File 'lib/rbeapi/api/prefixlists.rb', line 134 def delete(name, seq = nil) cmd = "no ip prefix-list #{name}" cmd << " seq #{seq}" if seq configure cmd end | 
#get(name) ⇒ Object
Returns the static routes configured on the node
| 62 63 64 65 66 67 68 69 70 71 | # File 'lib/rbeapi/api/prefixlists.rb', line 62 def get(name) config = get_block("ip prefix-list #{name}") return nil unless config entries = config.scan(/^\s{3}(?:seq\s)(\d+)\s(permit|deny)\s(.+)$/) entries.each_with_object([]) do |entry, arry| arry << { 'seq' => entry[0], 'action' => entry[1], 'prefex' => entry[2] } end end | 
#getall ⇒ Object
Returns the static routes configured on the node
| 88 89 90 91 92 93 94 | # File 'lib/rbeapi/api/prefixlists.rb', line 88 def getall lists = config.scan(/(?<=^ip\sprefix-list\s).+/) lists.each_with_object({}) do |name, hsh| values = get name hsh[name] = values if values end end |