Class: Rbeapi::Api::Staticroute
- Defined in:
- lib/rbeapi/api/staticroutes.rb
Overview
The Staticroute class provides a configuration instance for working with static routes in EOS.
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
- #create(route, nexthop, opts = {}) ⇒ Object
- #delete(route) ⇒ Object
-
#getall ⇒ Object
Returns the static routes configured on the node.
Methods inherited from Entity
#configure, #get_block, #initialize, instance
Constructor Details
This class inherits a constructor from Rbeapi::Api::Entity
Instance Method Details
#create(route, nexthop, opts = {}) ⇒ Object
77 78 79 80 81 |
# File 'lib/rbeapi/api/staticroutes.rb', line 77 def create(route, nexthop, opts = {}) cmd = "ip route #{route} #{nexthop}" opts.each { |param, value| cmds << "#{param} #{value}" } configure cmd end |
#delete(route) ⇒ Object
83 84 85 |
# File 'lib/rbeapi/api/staticroutes.rb', line 83 def delete(route) configure "no ip route #{route}" end |
#getall ⇒ Object
Returns the static routes configured on the node
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rbeapi/api/staticroutes.rb', line 59 def getall regex = %r{ (?<=^ip\sroute\s) ([^\s]+)\s # captures network ([^\s$]+) # captures next hop (?:\s\d+) # non-capture metric (?:\stag\s\d+) # non-catpure route tag [\s|$]{1}(?:name\s(.+))? # capture route name }x routes = config.scan(regex) routes.each_with_object({}) do |route, hsh| hsh[route[0]] = { 'next_hop' => route[1], 'name' => route[2] } end end |