« 2013年11月 | トップページ | 2014年7月 »

2014年6月

2014年6月29日 (日)

◆ 単純なブリッジの実装その3~より完璧な土管化~【OpenFlow1.0をTremaの土管として使う】

[2014/07/27 追記。イーサネットの最少パケットサイズを確保する修正をした記事を書きました。「◆ 単純なブリッジの実装その4~Open vSwitch対策~【OpenFlow1.0をTremaの土管として使う】」]

[注意: 本記事は、OpenFlow の適切な使い方ではありません。単にパケットの出し入れの道具として利用しています。]

以前書いた記事「◆ 単純なブリッジの実装その2~複数ポート対応~【OpenFlow1.0をTremaの土管として使う】」のコードを、パケットのデータを加工して流すことにも対応できるように修正してみます。

先の記事のコードでは、パケットを送付する際、Trema の send_packet_out に引数 :packet_in を使って受信メッセージをそのまま送信データとして渡しています。仕様を確認してみましょう。
http://rubydoc.info/github/trema/trema/master/Trema/Controller:send_packet_out

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.

:packet_in を使うと自動で :buffer_id, :in_port, :data を設定します。

OpenFlow では、コントローラからはパケットのデータそのものを渡すのではなくスイッチ側で管理している識別子 buffer_id を渡すという仕掛けがあります。コントローラでデータを加工して送付したい場合にはこの機能は不要です。
openflow 1.0.0 仕様書の "25.3.6 Send Packet Message" には以下の説明があります:
http://archive.openflow.org/documents/openflow-spec-v1.0.0.pdf

/* uint8_t data[0]; */ /* Packet data. The length is inferred
                          from the length field in the header.
                          (Only meaningful if buffer_id == -1.) */

このカッコ書きのところがポイントです。データに変更を加えたパケットを送付するには buffer_id を指定してはいけないということです。

Trema の send_packet_out の引数 :buffer_id を確認してみると:

: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.

:buffer_id はデフォルトのままで引数 :data に指定したデータを送付します。

以上から、:packet_in を使うのではなく、:data, :in_port を指定すれば良いということがわかります。

■対策後のコード
赤字のところが変更箇所です。

class SimpleBridge3 < 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,
      :in_port => message.in_port,
      :data => message.data,

      :actions => actions )
  end

end

2014年6月11日 (水)

◆【改訂】OpenFlow フレームワーク Trema 0.4 のインストール手順【0.4.7対応】

[2014-0727 追記: apt-get install で Not Found になる場合について追加しました。]
[2014-0727 追記2: 新規に Lubuntu 13.04 をインストールする場合の注意事項を追加。]

Trema 0.4.7 では、前提となる RubyGems のバージョンがあがっているため、https://github.com/trema/trema に記載のコマンドを実行しただけではインストールに失敗することが分かりました。失敗しないようにするためのインストール手順を整理しておきます。

RubyGems をバージョンアップしないとどうなるかは、前回の記事「◆ Trema 0.4.7インストール失敗とバージョン指定インストール」に記載しています。

■確認環境
・OS: Lubuntu 13.04 Desktop (i386)
    (2014年06月08日にソフトウェアアップデート済)
  未確認ですが Ubuntu 13.04 Desktop (i386)でも同じだと思います。
  ※[2014-0727 追記:新規に Lubuntu13.04 をインストールされる場合は、記事「◆サポート期限切れの Lubuntu 13.04 を新規インストール 」を参照ください。]
・Trema: 0.4.7

■インストール手順

https://github.com/trema/trema の「Getting Started」に従ってインストールしていきます。

1. 「1.Install the prerequisites at the command prompt:」に従い以下のコマンドを実行:

$ sudo apt-get install gcc make git ruby rubygems ruby-dev libpcap-dev libsqlite3-dev libglib2.0-dev

[2014-0727 追記: ここで、「Not Found」が出て失敗する現象が起きる場合は、記事「◆ Lubuntu 13.04 の apt-get install で「Not Found」となる現象への対処」を参照して対処ください。
]

2.前提の確認 (ここがミソ)

「Getting Started」には書いていない手順です。前提を満たしているか確認します。
「Supported Platforms」を見ると以下の記載があります(2014年06月11時点):
•Ruby 1.9.3 or higher
•RubyGems 1.8.25 or higher

実際にインストールされているバージョンを確認します。

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
$ gem -v
1.8.23

RubyGems のバージョンが 1.8.23 で満たせていません。そこで、RubyGems のバージョンをあげるため以下のコマンドを実行します:

$ sudo gem install rubygems-update -v 1.8.25
$ sudo update_rubygems

update_rubygems コマンドを実行するとバージョンアップ分の変更内容が大量に出力されます。ちょっとびっくりしますが問題ありません。

ここでは rubygem-update のインストールで -v 1.8.25 と指定することで Trema が必要とする最低のバージョンにしています。
バージョン指定なしだと最新版(現時点で 2.3.0)が入るのですが trema のインストール時に妙なメッセージが出るので避けた方が良さそうです。
(ちなみに 1.8 の最新 1.8.29 でも大丈夫でしたが、Trema さえ入れば良いと割り切って 1.8 の最新にする手順にはしていません。)

では、バージョンを再度確認します:

$ gem -v
1.8.25

今度は 1.8.25 なので前提を満たせていることが確認できました。

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

2014年6月 8日 (日)

◆ Trema 0.4.7インストール失敗とバージョン指定インストール

[2014/6/8 16:30追記:
インストール失敗はすでに https://github.com/trema/trema/issues/366 にて報告されている現象でした。
ここに記載があるように事前に RubyGems を更新する作業をしたところ Trema 0.4.7 のインストールに成功しました。以下の手順になります:
  sudo gem install update-rubygems
  sudo update_rubygems
  sudo gem install trema
2014/6/9 00:15追記:

  上記の方法で成功はしたものの Warning がやたら出たりしてまだ少し変。RubyGems のバージョンが 2.2.2 になっていたので、以下のようにして 1.8.x のままにした方が良さそう。

 
sudo gem install update-rubygems -v 1.8.25
あとでもう少し確認します。

]
[2014/06/11 追記:
インストール方法を整理して 「
◆【改訂】OpenFlow フレームワーク Trema 0.4 のインストール手順【0.4.7対応】」を書きました。
]

パソコンの入れ替えがあって OpenFlow フレームワーク Trema のテスト環境を新規に作ろうとしたら Trema のインストールに失敗してはまったのでここに記録を残しておきます。
最新の 0.4.7 でだめなら一つ前の 0.4.6 を入れられないかと調べてみたら gem コマンドには --version オプションがあってバージョン指定ができるんですね。
0.4.6 にしたら無事インストール成功しました。

■現象発生環境
  OS: Lubuntu 13.04 Desktop (i386, 32bit)
  Trema: 0.4.7 … インストール失敗
            0.4.6 … インストール成功

■現象発生時のインストール画面とエラー箇所

以下の通り:

$ 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.gemspec の7行目で問題起きています。ソースコードから7行目を見てみると以下の通り:
  gem.version = Trema::VERSION

この 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"

■暫定的な回避策
Trema 0.4.6 をインストールします。--version でバージョンを指定します。

  sudo gem install trema --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...

« 2013年11月 | トップページ | 2014年7月 »

最近のトラックバック

無料ブログはココログ