Class: Rbeapi::Api::BaseInterface
- Defined in:
- lib/rbeapi/api/interfaces.rb
Overview
The BaseInterface class extends Entity and provides an implementation that is common to all interfaces configured in EOS.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_INTF_DESCRIPTION =
''- DEFAULT_LOAD_INTERVAL =
''
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#create(value) ⇒ Boolean
create will create a new interface resource in the node’s current configuration with the specified interface name.
-
#default(value) ⇒ Boolean
default will configure the interface using the default keyword.
-
#delete(value) ⇒ Boolean
delete will delete an existing interface resource in the node’s current configuration with the specified interface name.
-
#get(name) ⇒ nil, Hash<String, Object>
get returns the specified interface resource hash that represents the node’s current interface configuration.
-
#set_description(name, opts = {}) ⇒ Boolean
set_description configures the description value for the specified interface name in the nodes running configuration.
-
#set_load_interval(name, opts = {}) ⇒ Boolean
set_load_interval is a convenience function for configuring the value of interface load-interval.
-
#set_shutdown(name, opts = {}) ⇒ Boolean
set_shutdown configures the administrative state of the specified interface in 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
#create(value) ⇒ Boolean
create will create a new interface resource in the node’s current configuration with the specified interface name. If the create method is called and the interface already exists, this method will return successful.
250 251 252 |
# File 'lib/rbeapi/api/interfaces.rb', line 250 def create(value) configure("interface #{value}") end |
#default(value) ⇒ Boolean
default will configure the interface using the default keyword. For virtual interfaces this is equivalent to deleting the interface. For physical interfaces, the entire interface configuration will be set to defaults.
284 285 286 |
# File 'lib/rbeapi/api/interfaces.rb', line 284 def default(value) configure("default interface #{value}") end |
#delete(value) ⇒ Boolean
delete will delete an existing interface resource in the node’s current configuration with the specified interface name. If the delete method is called and interface does not exist, this method will return successful.
267 268 269 |
# File 'lib/rbeapi/api/interfaces.rb', line 267 def delete(value) configure("no interface #{value}") end |
#get(name) ⇒ nil, Hash<String, Object>
get returns the specified interface resource hash that represents the node’s current interface configuration. The BaseInterface class provides all the set of attributes that are common to all interfaces in EOS. This method will return an interface type of generic.
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/rbeapi/api/interfaces.rb', line 170 def get(name) config = get_block("^interface #{name}") return nil unless config response = { name: name, type: 'generic' } response.merge!(parse_description(config)) response.merge!(parse_shutdown(config)) response.merge!(parse_load_interval(config)) response end |
#set_description(name, opts = {}) ⇒ Boolean
set_description configures the description value for the specified interface name in the nodes running configuration. If the enable keyword is false then the description value is negated using the no keyword. If the default keyword is set to true, then the description value is defaulted using the default keyword. The default keyword takes precedence over the enable keyword if both are provided.
313 314 315 316 |
# File 'lib/rbeapi/api/interfaces.rb', line 313 def set_description(name, opts = {}) commands = command_builder('description', opts) configure_interface(name, commands) end |
#set_load_interval(name, opts = {}) ⇒ Boolean
set_load_interval is a convenience function for configuring the value of interface load-interval
values to. The name must be the full interface identifier.
load-interval setting for. Valid values are between 5 and 600.
the interface using the default keyword.
367 368 369 370 |
# File 'lib/rbeapi/api/interfaces.rb', line 367 def set_load_interval(name, opts = {}) commands = command_builder('load-interval', opts) configure_interface(name, commands) end |
#set_shutdown(name, opts = {}) ⇒ Boolean
set_shutdown configures the administrative state of the specified interface in the node. If the enable keyword is false, then the interface is administratively disabled. If the enable keyword is true, then the interface is administratively enabled. If the default keyword is set to true, then the interface shutdown value is configured using the default keyword. The default keyword takes precedence over the enable keyword if both are provided.
342 343 344 345 346 347 348 349 |
# File 'lib/rbeapi/api/interfaces.rb', line 342 def set_shutdown(name, opts = {}) fail 'set_shutdown has the value option set' if opts[:value] # Shutdown semantics are opposite of enable semantics so invert enable. value = !opts[:enable] opts.merge!(enable: value) commands = command_builder('shutdown', opts) configure_interface(name, commands) end |