Use OVSDB client in order to retrive port list#41
Use OVSDB client in order to retrive port list#41shun159 wants to merge 8 commits intotrema:developfrom shun159:feature/ovsdb
Conversation
lib/phut/vsctl.rb
Outdated
| sudo("ovs-vsctl list-ports #{@bridge}").split | ||
| br_query = [select('Bridge', [[:name, :==, @bridge]], [:ports])] | ||
| br_ports = @client.transact(1, 'Open_vSwitch', br_query).first[:rows].first[:ports] | ||
| ports = if br_ports.include? "set" |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Gemfile
Outdated
|
|
||
| gemspec | ||
|
|
||
| gem 'active_flow', github: 'shun159/active_flow', branch: 'feature/ovsdb/core' |
There was a problem hiding this comment.
ここで shun159/active_flow に依存してしまうと、依存先が trema/active_flow と phut の active_flow とこの active_flow で 3 つになってしまうので 笑、まずは phut のほうにクラスをコピーしてもらうのが良いと思います (ライセンスなど問題がなければ)
| br_ports = @client.transact(1, 'Open_vSwitch', br_query) | ||
| if br_ports.first[:rows].first | ||
| br_ports = br_ports.first[:rows].first[:ports] | ||
| ports = if br_ports.include? "set" |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
|
まずテストについては、vswitch#ports.feature がそのまま使えると思います。この最後のシナリオでは、ポート 2 番に仮想リンクをつなげたときの Vswitch#ports の出力チェックをしています。 ここはたとえば |
|
テストを書きかきなおしてみました。 |
|
出力に変な改行が入ってしまい、本当は、 と書きたいのですが…。 Scenario: Vswitch#ports
Given I type "link = Link.create('a', 'b')"
And I type "vswitch.add_numbered_port 2, link.device('a')"
When I type "vswitch.ports"
And sleep 5
Then the output should contain:
"""
#<OpenStruct name="L0_a", ofport=2>
"" |
|
inspect の出力は、ActiveRecord 方式で あとは |
| @@ -0,0 +1,22 @@ | |||
| module Phut | |||
There was a problem hiding this comment.
Missing frozen string literal comment.
|
Portクラスになるように、直してみました。 |
features/shell/vswitch#ports.feature
Outdated
| ["L0_a"] | ||
| """ | ||
| """ | ||
| [#<Port device: "L0_a", number: 1>] |
There was a problem hiding this comment.
デバイス名とポート番号ではユーザが興味あるのはたいていポート番号のほうなので、
[#<Port number: 1, device: "L0_a">]
のほうが良いと思います。
| @@ -0,0 +1,92 @@ | |||
| module Phut | |||
There was a problem hiding this comment.
Missing frozen string literal comment.
|
修正しました。 |
https://3.basecamp.com/3088280/buckets/46054/messages/148393356
の通り、OVSDBを使った実装を試しに書いてみました。テストはまだありません。