Class: Rbeapi::Api::EthernetInterface
- Inherits:
-
BaseInterface
- Object
- Entity
- BaseInterface
- Rbeapi::Api::EthernetInterface
- Defined in:
- lib/rbeapi/api/interfaces.rb
Constant Summary collapse
- DEFAULT_ETH_FLOWC_TX =
'off'
- DEFAULT_ETH_FLOWC_RX =
'off'
- DEFAULT_SPEED =
'auto'
- DEFAULT_FORCED =
false
Constants inherited from BaseInterface
BaseInterface::DEFAULT_INTF_DESCRIPTION
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 Etherent interface resource hash that respresents the interface’s current configuration in th e 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 th e 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_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_shutdown
Methods inherited from Entity
#configure, #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.
433 434 435 436 |
# File 'lib/rbeapi/api/interfaces.rb', line 433 def create(name) raise NotImplementedError, 'creating Ethernet interfaces is '\ 'not supported' end |
#delete(name) ⇒ Object
delete overrides the delete method fro the BaseInterface instance and raises an exception because Ethernet interface deletion is not supported.
447 448 449 450 |
# File 'lib/rbeapi/api/interfaces.rb', line 447 def delete(name) raise NotImplementedError, 'deleting Ethernet interfaces is '\ 'not supported' end |
#get(name) ⇒ nil, Hash<Symbol, Object>
get returns the specified Etherent interface resource hash that respresents the interface’s current configuration in th e node.
The resource hash returned contains the following information:
-
name (string): the interface name (eg Ethernet1)
-
type (string): will always be ‘ethernet’
-
description (string): the interface description value
-
speed (string): the current speed setting for the interface speed
-
forced (boolean): true if autonegotiation is disabled otherwise false
-
sflow (boolean): true if sflow is enabled on the interface otherwise false
-
flowcontrol_send (string): the inteface flowcontrol send value. Valid values are ‘on’ or ‘off’
-
flowconrol_receive (string): the interface flowcontrol receive value. Valid values are ‘on’ or ‘off’
346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/rbeapi/api/interfaces.rb', line 346 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 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 value is not provided 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 value keyword
575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/rbeapi/api/interfaces.rb', line 575 def set_flowcontrol(name, direction, opts = {}) value = opts[:value] default = opts.fetch(:default, false) commands = ["interface #{name}"] case default when true commands << "default flowcontrol #{direction}" when false commands << (value.nil? ? "no flowcontrol #{direction}" : "flowcontrol #{direction} #{value}") end configure(commands) end |
#set_flowcontrol_receive(name, opts = {}) ⇒ Boolean
set_flowcontrol_receive is a convenience function for configuring th e value of interface flowcontrol
646 647 648 |
# File 'lib/rbeapi/api/interfaces.rb', line 646 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.
616 617 618 |
# File 'lib/rbeapi/api/interfaces.rb', line 616 def set_flowcontrol_send(name, opts = {}) set_flowcontrol(name, 'send', opts) end |
#set_sflow(name, opts = {}) ⇒ Boolean
set_sflow configures the administrative state of sflow on the interface. Setting the value to true enables sflow on the interface and setting the value to false disables sflow on the interface. If the value is not provided, the sflow state is negated using the no keyword. 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 value keyword
530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/rbeapi/api/interfaces.rb', line 530 def set_sflow(name, opts = {}) value = opts[:value] default = opts.fetch(:default, false) cmds = ["interface #{name}"] case default when true cmds << 'default sflow' when false cmds << (value ? 'sflow enable' : 'no sflow enable') end configure(cmds) end |
#set_speed(name, opts = {}) ⇒ Boolean
set_speed configures the interface speed and negotiation values on the specified interface. If the value option is not provide, 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.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'lib/rbeapi/api/interfaces.rb', line 483 def set_speed(name, opts = {}) value = opts[:value] forced = opts.fetch(:forced, false) default = opts.fetch(:default, false) forced = 'forced' if forced forced = '' if value == 'auto' cmds = ["interface #{name}"] case default when true cmds << 'default speed' when false cmds << value ? "speed #{forced} #{value}" : 'no speed' end configure cmds end |