vswitch ( "vswitch1" ) {
datapath_id 0x01
}
1.upto(3) do | each |
netns ( "vhost#{ each }" ) {
ip "192.168.0.#{ each }"
netmask "255.255.255.0"
}
link "vswitch1", "vhost#{ each }"
end
class SimpleBridge4 < Controller
MIN_PACKET_DATA_LEN = 60
def start
@port_list = [ 1, 2, 3 ] # all port numbers
end
def switch_ready( datapath_id )
info "Switch[0x%016x] is up." % datapath_id
send_flow_mod_add( datapath_id, :priority => 100 )
@port_list.each do | port |
send_flow_mod_add( datapath_id,
:match => Match.new( :in_port => port ),
:actions => SendOutPort.new( OFPP_CONTROLLER ) )
end
end
def switch_disconnected( datapath_id )
info "Switch[0x%016x] is disconnected." % datapath_id
end
def packet_in( datapath_id, message )
return unless message.reason == Trema::PacketIn::OFPR_ACTION
# padding. length of sending data must be >= 60
data_len = message.data.length
if ( data_len < MIN_PACKET_DATA_LEN )
data = message.data + "\x00" * ( MIN_PACKET_DATA_LEN - data_len )
else
data = message.data
end
actions = [ ]
@port_list.each do | port |
if ( message.in_port != port )
actions.push( SendOutPort.new( port ) )
end
end
send_packet_out( datapath_id,
:in_port => message.in_port,
:data => data, :actions => actions )
end
end
■再現環境
(1)再現環境の作り方 以下のコマンドを実行します。当然、すでに Open vSwitch がインストール済であることが前提です。
sudo ovs-vsctl add-br ofs1
sudo ovs-vsctl set-fail-mode ofs1 secure
sudo ip netns add vhost1
sudo ip link add name vlink1-0 type veth peer name vlink1-1
sudo ip link set vlink1-1 netns vhost1
sudo ip netns exec vhost1 ifconfig vlink1-1 up 192.168.0.1
sudo ip link set vlink1-0 up
sudo ovs-vsctl add-port ofs1 vlink1-0
sudo ip netns add vhost2
sudo ip link add name vlink2-0 type veth peer name vlink2-1
sudo ip link set vlink2-1 netns vhost2
sudo ip netns exec vhost2 ifconfig vlink2-1 up 192.168.0.2
sudo ip link set vlink2-0 up
sudo ovs-vsctl add-port ofs1 vlink2-0
sudo ovs-vsctl set-controller ofs1 tcp:127.0.0.1:6653
sudo ovs-vsctl set controller ofs1 connection-mode=out-of-band
sudo ovs-vsctl set controller ofs1 inactivity-probe=180
MAC[02:00:00:00:00:01] is found at Port 3. MAC[02:00:00:00:00:02] is found at Port 1. MAC[02:00:00:00:00:03] is found at Port 2. MAC[02:00:00:00:00:04] is found at Port 4.
packet_in (PacketIn) — default: nil — The PacketIn object received by packet_in
handler. If this option is not nil, :buffer_id, :data, and :in_port option is set automatically according to the value of :packet_in.
:buffer_id (Number) — default: 0xffffffff — The buffer ID assigned by the datapath. If 0xffffffff, the frame is not buffered, and the entire frame must be passed in :data.
@port_list.each do | port | send_flow_mod_add( datapath_id, :match => Match.new( :in_port => port ), :actions => SendOutPort.new( OFPP_CONTROLLER ) ) end end
def switch_disconnected( datapath_id ) info "Switch[0x%016x] is disconnected." % datapath_id end
3. 「Install Trema at the command prompt:」に従い以下のコマンドを実行します:
$ sudo gem install trema
コマンド実行時の画面は以下の通り:
$ sudo gem install trema
Fetching: bundler-1.6.2.gem (100%)
Fetching: gli-2.10.0.gem (100%)
Fetching: Platform-0.4.0.gem (100%)
Fetching: open4-1.3.4.gem (100%)
Fetching: POpen4-0.1.4.gem (100%)
Fetching: rake-10.3.2.gem (100%)
Fetching: paper_house-0.6.2.gem (100%)
Fetching: bindata-2.1.0.gem (100%)
Fetching: pio-0.7.0.gem (100%)
Fetching: json-1.8.1.gem (100%)
Building native extensions. This could take a while...
Fetching: rdoc-4.1.1.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Fetching: trema-0.4.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed bundler-1.6.2
Successfully installed gli-2.10.0
Successfully installed Platform-0.4.0
Successfully installed open4-1.3.4
Successfully installed POpen4-0.1.4
Successfully installed rake-10.3.2
Successfully installed paper_house-0.6.2
Successfully installed bindata-2.1.0
Successfully installed pio-0.7.0
Successfully installed json-1.8.1
Successfully installed rdoc-4.1.1
Successfully installed trema-0.4.7
12 gems installed
Installing ri documentation for bundler-1.6.2...
Installing ri documentation for gli-2.10.0...
Installing ri documentation for Platform-0.4.0...
Installing ri documentation for open4-1.3.4...
Installing ri documentation for POpen4-0.1.4...
Installing ri documentation for rake-10.3.2...
Installing ri documentation for paper_house-0.6.2...
Installing ri documentation for bindata-2.1.0...
Installing ri documentation for pio-0.7.0...
Installing ri documentation for json-1.8.1...
Installing ri documentation for rdoc-4.1.1...
Installing ri documentation for trema-0.4.7...
Installing RDoc documentation for bundler-1.6.2...
Installing RDoc documentation for gli-2.10.0...
Installing RDoc documentation for Platform-0.4.0...
Installing RDoc documentation for open4-1.3.4...
Installing RDoc documentation for POpen4-0.1.4...
Installing RDoc documentation for rake-10.3.2...
Installing RDoc documentation for paper_house-0.6.2...
Installing RDoc documentation for bindata-2.1.0...
Installing RDoc documentation for pio-0.7.0...
Installing RDoc documentation for json-1.8.1...
Installing RDoc documentation for rdoc-4.1.1...
Installing RDoc documentation for trema-0.4.7...
4.Trema のバージョン確認
では、Trema のバージョン確認をしてみます:
$ trema version trema version 0.4.7
無事 Trema がインストールできました。
■ RubyGems 2.3.0 を使うとどうなるのか?
上書きをするか求められて N を選択するとインストールが中断されます:
$ sudo gem install trema
Fetching: json-1.8.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed json-1.8.1
Fetching: rdoc-4.1.1.gem (100%)
rdoc's executable "rdoc" conflicts with /usr/bin/rdoc
Overwrite the executable? [yN] N
ERROR: Error installing trema:
"rdoc" from rdoc conflicts with /usr/bin/rdoc
再度、実行して上書きを y で許可すると今度は大量のメッセージが・・・:
$ sudo gem install trema
rdoc's executable "rdoc" conflicts with /usr/bin/rdoc
Overwrite the executable? [yN] y
rdoc's executable "ri" conflicts with /usr/bin/ri
Overwrite the executable? [yN] y
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed rdoc-4.1.1
Fetching: rake-10.3.2.gem (100%)
Successfully installed rake-10.3.2
Fetching: bindata-2.1.0.gem (100%)
Successfully installed bindata-2.1.0
Fetching: pio-0.7.0.gem (100%)
Successfully installed pio-0.7.0
Fetching: Platform-0.4.0.gem (100%)
Successfully installed Platform-0.4.0
Fetching: open4-1.3.4.gem (100%)
Successfully installed open4-1.3.4
Fetching: POpen4-0.1.4.gem (100%)
Successfully installed POpen4-0.1.4
Fetching: paper_house-0.6.2.gem (100%)
Successfully installed paper_house-0.6.2
Fetching: gli-2.10.0.gem (100%)
Successfully installed gli-2.10.0
Fetching: bundler-1.6.2.gem (100%)
Successfully installed bundler-1.6.2
Fetching: trema-0.4.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed trema-0.4.7
Installing ri documentation for rdoc-4.1.1
Installing ri documentation for rake-10.3.2
unable to convert "\xC5" from ASCII-8BIT to UTF-8 for examples/NBT.txt, skipping
Installing ri documentation for bindata-2.1.0
Installing ri documentation for pio-0.7.0
Installing ri documentation for Platform-0.4.0
Installing ri documentation for open4-1.3.4
Installing ri documentation for POpen4-0.1.4
unable to convert "\xCF" from ASCII-8BIT to UTF-8 for examples/fail/hello, skipping
Installing ri documentation for paper_house-0.6.2
Installing ri documentation for gli-2.10.0
Installing ri documentation for bundler-1.6.2
unable to convert "\xD0" from ASCII-8BIT to UTF-8 for objects/tremashark/syslog_relay, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for objects/tremashark/stdin_relay, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for objects/tremashark/tremashark, skipping
unable to convert "\xC0" from ASCII-8BIT to UTF-8 for objects/tremashark/packet_capture, skipping
unable to convert "\xE4" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-vsctl, skipping
unable to convert "\x98" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovsdb-client, skipping
unable to convert "\x94" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-appctl, skipping
unable to convert "\xE0" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-controller, skipping
unable to convert "\xEC" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-openflowd, skipping
unable to convert "\xE4" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-dpctl, skipping
unable to convert "\xAC" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovsdb-tool, skipping
unable to convert "\xB8" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-ofctl, skipping
unable to convert "\xB0" from ASCII-8BIT to UTF-8 for objects/openvswitch/bin/ovs-benchmark, skipping
unable to convert "\x8C" from ASCII-8BIT to UTF-8 for objects/openvswitch/sbin/ovsdb-server, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for objects/openvswitch/sbin/ovs-brcompatd, skipping
unable to convert "\xD8" from ASCII-8BIT to UTF-8 for objects/openvswitch/sbin/ovs-vlan-bug-workaround, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for objects/openvswitch/sbin/ovs-vswitchd, skipping
unable to convert "\xD0" from ASCII-8BIT to UTF-8 for objects/packetin_filter/packetin_filter, skipping
unable to convert "\xF0" from ASCII-8BIT to UTF-8 for objects/examples/openflow_switch/echo_switch, skipping
unable to convert "\xF0" from ASCII-8BIT to UTF-8 for objects/examples/openflow_switch/hello_switch, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/dumper/dumper, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/switch_monitor/switch_monitor, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/packet_in/packet_in, skipping
unable to convert "\xC0" from ASCII-8BIT to UTF-8 for objects/examples/traffic_monitor/traffic_monitor, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/switch_info/switch_info, skipping
unable to convert "\xA7" from ASCII-8BIT to UTF-8 for objects/examples/multi_learning_switch/multi_learning_switch, skipping
unable to convert "\xA8" from ASCII-8BIT to UTF-8 for objects/examples/switch_event_config/delete_forward_entry, skipping
unable to convert "\xA8" from ASCII-8BIT to UTF-8 for objects/examples/switch_event_config/dump_forward_entries, skipping
unable to convert "\xA8" from ASCII-8BIT to UTF-8 for objects/examples/switch_event_config/add_forward_entry, skipping
unable to convert "\xA8" from ASCII-8BIT to UTF-8 for objects/examples/switch_event_config/set_forward_entries, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/cbench_switch/cbench_switch, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/repeater_hub/repeater_hub, skipping
unable to convert "\x90" from ASCII-8BIT to UTF-8 for objects/examples/packetin_filter_config/dump_filter, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for objects/examples/packetin_filter_config/add_filter, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for objects/examples/packetin_filter_config/delete_filter_strict, skipping
unable to convert "\x90" from ASCII-8BIT to UTF-8 for objects/examples/packetin_filter_config/dump_filter_strict, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for objects/examples/packetin_filter_config/delete_filter, skipping
unable to convert "\xB0" from ASCII-8BIT to UTF-8 for objects/examples/learning_switch/learning_switch, skipping
unable to convert "\xB0" from ASCII-8BIT to UTF-8 for objects/examples/list_switches/list_switches, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/openflow_message/features_request, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/openflow_message/hello, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/openflow_message/vendor_action, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/openflow_message/echo, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/examples/openflow_message/set_config, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/management/set_logging_level, skipping
unable to convert "\xD0" from ASCII-8BIT to UTF-8 for objects/management/application, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/management/echo, skipping
unable to convert "\xA6" from ASCII-8BIT to UTF-8 for objects/management/show_stats, skipping
unable to convert "\x9D" from ASCII-8BIT to UTF-8 for objects/oflops/bin/oflops, skipping
unable to convert "\x94" from ASCII-8BIT to UTF-8 for objects/oflops/bin/cbench, skipping
unable to convert "\x95" from ASCII-8BIT to UTF-8 for objects/phost/phost, skipping
unable to convert "\xEC" from ASCII-8BIT to UTF-8 for objects/phost/cli, skipping
unable to convert "\xAA" from ASCII-8BIT to UTF-8 for objects/switch_manager/switch, skipping
unable to convert "\xC0" from ASCII-8BIT to UTF-8 for objects/switch_manager/switch_manager, skipping
unable to convert "\x9D" from ASCII-8BIT to UTF-8 for vendor/oflops-0.03.trema1/oflops, skipping
unable to convert "\x94" from ASCII-8BIT to UTF-8 for vendor/oflops-0.03.trema1/cbench/cbench, skipping
unable to convert "\xE4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-vsctl, skipping
unable to convert "\xE3" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/nlmon, skipping
unable to convert "\x94" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-appctl, skipping
unable to convert "\xE0" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-controller, skipping
unable to convert "\xE4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-dpctl, skipping
unable to convert "\xD8" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-vlan-bug-workaround, skipping
unable to convert "\xB8" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-ofctl, skipping
unable to convert "\xB0" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/utilities/ovs-benchmark, skipping
unable to convert "\xE0" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-lockfile, skipping
unable to convert "\xD5" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-random, skipping
unable to convert "\xF0" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-sha1, skipping
unable to convert "\xFE" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-classifier, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-aes128, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-byte-order, skipping
unable to convert "\x88" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-list, skipping
unable to convert "\xD7" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-uuid, skipping
unable to convert "\xD8" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-reconnect, skipping
unable to convert "\x88" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-hmap, skipping
unable to convert "\xDC" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-bundle, skipping
unable to convert "\x86" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-strtok_r, skipping
unable to convert "\xD3" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-file_name, skipping
unable to convert "\xCC" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-ovsdb, skipping
unable to convert "\xDC" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-json, skipping
unable to convert "\xF0" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/testsuite, skipping
unable to convert "\xE3" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-packets, skipping
unable to convert "\xC8" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-jsonrpc, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-unix-socket, skipping
unable to convert "\xE2" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-timeval, skipping
unable to convert "\xD3" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-util, skipping
unable to convert "\xB7" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-flows, skipping
unable to convert "\xB8" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-multipath, skipping
unable to convert "\xF8" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-hash, skipping
unable to convert "\xA0" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-csum, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-vconn, skipping
unable to convert "\xEC" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-openflowd, skipping
unable to convert "\x91" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/tests/test-type-props, skipping
unable to convert "\x8C" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/ovsdb/ovsdb-server, skipping
unable to convert "\x98" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/ovsdb/ovsdb-client, skipping
unable to convert "\xAC" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/ovsdb/ovsdb-tool, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/vswitchd/ovs-brcompatd, skipping
unable to convert "\xD4" from ASCII-8BIT to UTF-8 for vendor/openvswitch-1.2.2.trema1/vswitchd/ovs-vswitchd, skipping
unable to convert "\x95" from ASCII-8BIT to UTF-8 for vendor/phost/src/phost, skipping
unable to convert "\xEC" from ASCII-8BIT to UTF-8 for vendor/phost/src/cli, skipping
Installing ri documentation for trema-0.4.7
11 gems installed
ここから RubyGems 1.8.25 にダウングレードしてインストールさせてみます:
$ sudo gem uninstall rubygems-update $ sudo gem install rubygems-update -v 1.8.25
Fetching: rubygems-update-1.8.25.gem (100%)
Successfully installed rubygems-update-1.8.25
Parsing documentation for rubygems-update-1.8.25
Installing ri documentation for rubygems-update-1.8.25
Done installing documentation for rubygems-update after 0 seconds
1 gem installed $ sudo update_rubygems
RubyGems 1.8.25 installed
== 1.8.25/ 2013-01-24
* 6 bug fixes:
* Added 11627 to setup bin_file location to protect against errors. Fixes #328 by ConradIrwin
* Specification#ruby_code didn't handle Requirement with multiple
* Fix error on creating a Version object with a frozen string.
* Fix incremental index updates
* Fix missing load_yaml in YAML-related requirement.rb code.
* Manually backport encoding-aware YAML gemspec
------------------------------------------------------------------------------
RubyGems installed the following executables:
/usr/bin/gem1.9.1
$ sudo gem uninstall trema
Remove executables:
trema, trema-config
in addition to the gem? [Yn] Y
Removing trema
Removing trema-config
Successfully uninstalled trema-0.4.7
$ sudo gem install trema
Fetching: trema-0.4.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed trema-0.4.7
1 gem installed
Installing ri documentation for trema-0.4.7...
Installing RDoc documentation for trema-0.4.7...
$ trema version
trema version 0.4.7
$ sudo gem install trema Fetching: bundler-1.6.2.gem (100%) Fetching: gli-2.10.0.gem (100%) Fetching: Platform-0.4.0.gem (100%) Fetching: open4-1.3.4.gem (100%) Fetching: POpen4-0.1.4.gem (100%) Fetching: rake-10.3.2.gem (100%) Fetching: paper_house-0.6.2.gem (100%) Fetching: bindata-2.1.0.gem (100%) Fetching: pio-0.7.0.gem (100%) Fetching: json-1.8.1.gem (100%) Building native extensions. This could take a while... Fetching: rdoc-4.1.1.gem (100%) Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported = 1.8.7 : gem install rdoc-data; rdoc-data --install = 1.9.1 : gem install rdoc-data; rdoc-data --install >= 1.9.2 : nothing to do! Yay! Fetching: trema-0.4.7.gem (100%) Building native extensions. This could take a while... ERROR: Error installing trema: ERROR: Failed to build gem native extension.
"/usr/bin/ruby1.9.1" -rubygems /var/lib/gems/1.9.1/gems/rake-10.3.2/bin/rake RUBYARCHDIR=/var/lib/gems/1.9.1/gems/trema-0.4.7/ruby RUBYLIBDIR=/var/lib/gems/1.9.1/gems/trema-0.4.7/ruby rake aborted! Bundler::GemspecError: There was a RuntimeError while loading trema.gemspec: can't modify frozen String from /var/lib/gems/1.9.1/gems/trema-0.4.7/trema.gemspec:7:in `block in <main>' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:393:in `rescue in eval_gemspec' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:382:in `eval_gemspec' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:353:in `block in load_gemspec_uncached' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/shared_helpers.rb:52:in `chdir' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/shared_helpers.rb:52:in `chdir' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:348:in `load_gemspec_uncached' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:338:in `load_gemspec' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/gem_helper.rb:31:in `initialize' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/gem_helper.rb:13:in `new' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/gem_helper.rb:13:in `install_tasks' /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/gem_tasks.rb:2:in `<top (required)>' /var/lib/gems/1.9.1/gems/trema-0.4.7/Rakefile:760:in `<top (required)>' (See full trace by running task with --trace)
Gem files will remain installed in /var/lib/gems/1.9.1/gems/trema-0.4.7 for inspection. Results logged to /var/lib/gems/1.9.1/gems/trema-0.4.7/./gem_make.out
この Trema::VERSION はというと、ruby/trema/version.rb で定義されていました。0.4.7 で VERSION の記述のしかたがfreeze 指定に変更されていることが影響していそうです: Trema 0.4.7 の場合の VERSION の記述: VERSION = '0.4.7'.freeze Trema 0.4.6 の場合の VERSION の記述: VERSION = "0.4.6"
$ sudo gem install trema --version 0.4.6 Fetching: gli-2.8.1.gem (100%) Fetching: rake-10.1.1.gem (100%) Fetching: paper_house-0.5.0.gem (100%) Fetching: bindata-1.6.0.gem (100%) Fetching: pio-0.3.0.gem (100%) Fetching: rdoc-4.0.1.gem (100%) Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported = 1.8.7 : gem install rdoc-data; rdoc-data --install = 1.9.1 : gem install rdoc-data; rdoc-data --install >= 1.9.2 : nothing to do! Yay! Fetching: trema-0.4.6.gem (100%) Building native extensions. This could take a while... Successfully installed gli-2.8.1 Successfully installed rake-10.1.1 Successfully installed paper_house-0.5.0 Successfully installed bindata-1.6.0 Successfully installed pio-0.3.0 Successfully installed rdoc-4.0.1 Successfully installed trema-0.4.6 7 gems installed Installing ri documentation for gli-2.8.1... Installing ri documentation for rake-10.1.1... Installing ri documentation for paper_house-0.5.0... Installing ri documentation for bindata-1.6.0... Installing ri documentation for pio-0.3.0... Installing ri documentation for rdoc-4.0.1... Installing ri documentation for trema-0.4.6... Installing RDoc documentation for gli-2.8.1... Installing RDoc documentation for rake-10.1.1... Installing RDoc documentation for paper_house-0.5.0... Installing RDoc documentation for bindata-1.6.0... Installing RDoc documentation for pio-0.3.0... Installing RDoc documentation for rdoc-4.0.1... Installing RDoc documentation for trema-0.4.6...
class SimpleBridge2 < Controller
def start
@port_list = [ 1, 2, 3 ] # all port numbers
end
def switch_ready( datapath_id )
info "Switch[0x%016x] is up." % datapath_id
send_flow_mod_add( datapath_id, :priority => 100 )
@port_list.each do | port |
send_flow_mod_add( datapath_id,
:match => Match.new( :in_port => port ),
:actions => SendOutPort.new( OFPP_CONTROLLER ) )
end
end
def switch_disconnected( datapath_id )
info "Switch[0x%016x] is disconnected." % datapath_id
end
def packet_in( datapath_id, message )
return unless message.reason == Trema::PacketIn::OFPR_ACTION
actions = [ ]
@port_list.each do | port |
if ( message.in_port != port )
actions.push( SendOutPort.new( port ) )
end
end
send_packet_out( datapath_id,
:packet_in => message,
:actions => actions )
end
end
最近のコメント