Class: Trema::OpenVswitch

Inherits:
HardwareSwitch show all
Includes:
Daemon
Defined in:
ruby/trema/open-vswitch.rb

Overview

Open vSwitch support (openvswitch.org)

Constant Summary collapse

DEFAULT_PORT =
6633

Instance Attribute Summary

Attributes inherited from HardwareSwitch

#name

Instance Method Summary collapse

Methods included from Daemon

#pid_file, #restart!, #run, #run!, #running?, #shutdown, #shutdown!

Methods inherited from HardwareSwitch

#dpid_long, #dpid_short

Constructor Details

#initialize(stanza, port = DEFAULT_PORT) ⇒ OpenVswitch

Creates a new Open vSwitch from DSL::Vswitch

Examples:

vswitch = Trema::OpenVswitch.new( stanza )


49
50
51
52
53
# File 'ruby/trema/open-vswitch.rb', line 49

def initialize stanza, port = DEFAULT_PORT
  super stanza
  @port = port
  @interfaces = []
end

Instance Method Details

#<<(interface) ⇒ Array

Add a network interface used for a virtual port

Examples:

vswitch << "trema3-0"

Returns:

  • (Array)


64
65
66
67
68
# File 'ruby/trema/open-vswitch.rb', line 64

def << interface
  @interfaces << interface
  restart!
  @interfaces
end

#bring_port_down(port_number) ⇒ Object



103
104
105
# File 'ruby/trema/open-vswitch.rb', line 103

def bring_port_down port_number
  Ofctl.new.bring_port_down self, port_number
end

#bring_port_up(port_number) ⇒ Object



98
99
100
# File 'ruby/trema/open-vswitch.rb', line 98

def bring_port_up port_number
  Ofctl.new.bring_port_up self, port_number
end

#flowsArray

Returns flow entries

Examples:

vswitch.flows  #=> [ flow0, flow1, ... ]

Returns:

  • (Array)


93
94
95
# File 'ruby/trema/open-vswitch.rb', line 93

def flows
  Ofctl.new.users_flows( self )
end

#network_deviceString

Returns the network device name associated with the datapath’s local port

Examples:

vswitch.network_device  #=> "vsw_0xabc"

Returns:



80
81
82
# File 'ruby/trema/open-vswitch.rb', line 80

def network_device
  "vsw_#{ @stanza.fetch :dpid_short }"
end