Class: Trema::HardwareSwitch

Inherits:
Object
  • Object
show all
Defined in:
ruby/trema/hardware-switch.rb

Overview

Hardware switch that supports OpenFlow protocol.

Direct Known Subclasses

CustomSwitch, OpenVswitch, RubySwitch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stanza) ⇒ HardwareSwitch

Creates a new HardwareSwitch from DSL::Switch

Examples:

switch = Trema::HardwareSwitch.new( stanza )


46
47
48
49
50
51
# File 'ruby/trema/hardware-switch.rb', line 46

def initialize stanza
  stanza.validate
  @name = stanza.name
  @stanza = stanza
  OpenflowSwitch.add self
end

Instance Attribute Details

#nameString (readonly)

The name of this switch

Examples:

switch.name #=> "My expensive OpenFlow switch"

Returns:



35
36
37
# File 'ruby/trema/hardware-switch.rb', line 35

def name
  @name
end

Instance Method Details

#dpid_longString

Returns datapath id in long format

Examples:

switch.dpid_long #=> "0000000000000abc"

Returns:



62
63
64
# File 'ruby/trema/hardware-switch.rb', line 62

def dpid_long
  @stanza.fetch :dpid_long
end

#dpid_shortString

Returns datapath id prefixed with “0x”

Examples:

switch.dpid_short #=> "0xabc"

Returns:



75
76
77
# File 'ruby/trema/hardware-switch.rb', line 75

def dpid_short
  @stanza.fetch :dpid_short
end