Class: Rbeapi::Api::EthernetInterface
- Inherits:
-
BaseInterface
- Object
- Entity
- BaseInterface
- Rbeapi::Api::EthernetInterface
- Defined in:
- lib/rbeapi/api/interfaces.rb
Overview
The EthernetInterface class manages all Ethernet interfaces on an EOS node.
Constant Summary collapse
- DEFAULT_ETH_FLOWC_TX =
'off'.freeze
- DEFAULT_ETH_FLOWC_RX =
'off'.freeze
- DEFAULT_SPEED =
'default'.freeze
- DEFAULT_LACP_PRIORITY =
32_768
Constants inherited from BaseInterface
BaseInterface::DEFAULT_INTF_DESCRIPTION, BaseInterface::DEFAULT_INTF_ENCAPSULATION, BaseInterface::DEFAULT_LOAD_INTERVAL
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#create(name) ⇒ Object
create overrides the create method from the BaseInterface and raises an exception because Ethernet interface creation is not supported.
-
#delete(name) ⇒ Object
delete overrides the delete method fro the BaseInterface instance and raises an exception because Ethernet interface deletion is not supported.
-
#get(name) ⇒ nil, Hash<Symbol, Object>
get returns the specified Ethernet interface resource hash that represents the interface’s current configuration in the node.
-
#set_flowcontrol(name, direction, opts = {}) ⇒ Boolean
set_flowcontrol configures the flowcontrol value either on or off for the for the specified interface in the specified direction (either send or receive).
-
#set_flowcontrol_receive(name, opts = {}) ⇒ Boolean
set_flowcontrol_receive is a convenience function for configuring the value of interface flowcontrol.
-
#set_flowcontrol_send(name, opts = {}) ⇒ Boolean
set_flowcontrol_send is a convenience function for configuring the value of interface flowcontrol.
-
#set_lacp_priority(name, opts = {}) ⇒ Boolean
set_lacp_priority configures the lacp port-priority on the interface.
-
#set_sflow(name, opts = {}) ⇒ Boolean
set_sflow configures the administrative state of sflow on the interface.
-
#set_speed(name, opts = {}) ⇒ Boolean
set_speed configures the interface speed and negotiation values on the specified interface.
Methods inherited from BaseInterface
#default, #set_description, #set_encapsulation, #set_load_interval, #set_shutdown
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) ⇒ Object
create overrides the create method from the BaseInterface and raises an exception because Ethernet interface creation is not supported. This doesn’t happen for Ethernet subinterfaces
587 588 589 590 591 592 593 594 |
# File 'lib/rbeapi/api/interfaces.rb', line 587 def create(name) if name !~ /\./ raise NotImplementedError, 'creating Ethernet interfaces is '\ 'not supported' else configure("interface #{name}") end end |
#delete(name) ⇒ Object
delete overrides the delete method fro the BaseInterface instance and raises an exception because Ethernet interface deletion is not supported.
605 606 607 608 609 610 611 612 |
# File 'lib/rbeapi/api/interfaces.rb', line 605 def delete(name) if name !~ /\./ raise NotImplementedError, 'deleting Ethernet interfaces is '\ 'not supported' else configure("no interface #{name}") end end |
#get(name) ⇒ nil, Hash<Symbol, Object>
get returns the specified Ethernet interface resource hash that represents the interface’s current configuration in the node.
475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/rbeapi/api/interfaces.rb', line 475 def get(name) config = get_block("^interface #{name}") return nil unless config response = super(name) response[:type] = 'ethernet' response.merge!(parse_speed(config)) response.merge!(parse_sflow(config)) response.merge!(parse_flowcontrol_send(config)) response.merge!(parse_flowcontrol_receive(config)) response.merge!(parse_lacp_priority(config)) response end |
#set_flowcontrol(name, direction, opts = {}) ⇒ Boolean
set_flowcontrol configures the flowcontrol value either on or off for the for the specified interface in the specified direction (either send or receive). If the enable keyword is false then the configuration is negated using the no keyword. If the default keyword is set to true, then the state value is defaulted using the default keyword. The default keyword takes precedence over the enable keyword
708 709 710 711 |
# File 'lib/rbeapi/api/interfaces.rb', line 708 def set_flowcontrol(name, direction, opts = {}) commands = command_builder("flowcontrol #{direction}", opts) configure_interface(name, commands) end |
#set_flowcontrol_receive(name, opts = {}) ⇒ Boolean
set_flowcontrol_receive is a convenience function for configuring the value of interface flowcontrol.
763 764 765 |
# File 'lib/rbeapi/api/interfaces.rb', line 763 def set_flowcontrol_receive(name, opts = {}) set_flowcontrol(name, 'receive', opts) end |
#set_flowcontrol_send(name, opts = {}) ⇒ Boolean
set_flowcontrol_send is a convenience function for configuring the value of interface flowcontrol.
736 737 738 |
# File 'lib/rbeapi/api/interfaces.rb', line 736 def set_flowcontrol_send(name, opts = {}) set_flowcontrol(name, 'send', opts) end |
#set_lacp_priority(name, opts = {}) ⇒ Boolean
set_lacp_priority configures the lacp port-priority on the interface. Setting the enable keyword to true enables the lacp port-priority on the interface and setting enable to false disables the lacp port-priority on the interface. If the default keyword is set to true, then the lacp port-priority value is defaulted using the default keyword. The default keyword takes precedence over the enable keyword
791 792 793 794 |
# File 'lib/rbeapi/api/interfaces.rb', line 791 def set_lacp_priority(name, opts = {}) commands = command_builder('lacp port-priority', opts) configure_interface(name, commands) end |
#set_sflow(name, opts = {}) ⇒ Boolean
set_sflow configures the administrative state of sflow on the interface. Setting the enable keyword to true enables sflow on the interface and setting enable to false disables sflow on the interface. If the default keyword is set to true, then the sflow value is defaulted using the default keyword. The default keyword takes precedence over the enable keyword
675 676 677 678 |
# File 'lib/rbeapi/api/interfaces.rb', line 675 def set_sflow(name, opts = {}) commands = command_builder('sflow enable', opts) configure_interface(name, commands) end |
#set_speed(name, opts = {}) ⇒ Boolean
set_speed configures the interface speed and negotiation values on the specified interface. If the enable option is false the speed setting is configured using the no keyword. If the default options is set to true, then the speed setting is configured using the default keyword. If both options are specified, the default keyword takes precedence.
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/rbeapi/api/interfaces.rb', line 636 def set_speed(name, opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) default = (value == :default) cmds = ["interface #{name}"] case default when true cmds << 'default speed' when false cmd = enable ? "speed #{value}" : 'no speed' cmds << cmd end configure cmds end |