Class: Rbeapi::Api::StpInstances
Overview
The StpInstances class provides a class instance for working with spanning-tree instances in EOS
Constant Summary collapse
- DEFAULT_STP_PRIORITY =
'32768'
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#delete(inst) ⇒ Boolean
Deletes a configured MST instance.
-
#get(inst) ⇒ nil, Hash<Symbol, Object] returns the stp instance config as a resource hash. If the instances is not configured this method will return a nil object
get returns the specified stp instance config parsed from the nodes current running configuration.
-
#getall ⇒ Hash<Symbol, Object>
getall returns all configured stp instances parsed from the nodes running configuration.
-
#set_priority(inst, opts = {}) ⇒ Boolean
Configures the spanning-tree MST priority.
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
#delete(inst) ⇒ Boolean
Deletes a configured MST instance
221 222 223 224 |
# File 'lib/rbeapi/api/stp.rb', line 221 def delete(inst) configure ['spanning-tree mst configuration', "no instance #{inst}", 'exit'] end |
#get(inst) ⇒ nil, Hash<Symbol, Object] returns the stp instance config as a resource hash. If the instances is not configured this method will return a nil object
get returns the specified stp instance config parsed from the nodes current running configuration.
156 157 158 159 160 161 |
# File 'lib/rbeapi/api/stp.rb', line 156 def get(inst) return nil unless parse_instances.include?(inst.to_s) response = {} response.merge!(parse_priority(inst)) response end |
#getall ⇒ Hash<Symbol, Object>
getall returns all configured stp instances parsed from the nodes running configuration. The return hash is keyed by the instance identifier value
177 178 179 180 181 182 |
# File 'lib/rbeapi/api/stp.rb', line 177 def getall parse_instances.each_with_object({}) do |inst, hsh| values = get(inst) hsh[inst] = values if values end end |
#set_priority(inst, opts = {}) ⇒ Boolean
Configures the spanning-tree MST priority
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/rbeapi/api/stp.rb', line 237 def set_priority(inst, opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) default = opts[:default] || false case default when true cmd = "default spanning-tree mst #{inst} priority" when false if enable cmd = "spanning-tree mst #{inst} priority #{value}" else cmd = "no spanning-tree mst #{inst} priority" end end configure cmd end |