-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use OVSDB client in order to retrive port list #41
base: develop
Are you sure you want to change the base?
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -3,6 +3,8 @@ source 'https://rubygems.org' | |||
|
|||
gemspec | |||
|
|||
gem 'active_flow', github: 'shun159/active_flow', branch: 'feature/ovsdb/core' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここで shun159/active_flow に依存してしまうと、依存先が trema/active_flow と phut の active_flow とこの active_flow で 3 つになってしまうので 笑、まずは phut のほうにクラスをコピーしてもらうのが良いと思います (ライセンスなど問題がなければ)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
しょうちしました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コピーしてきました。
7ee0730
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing frozen string literal comment.
Portクラスになるように、直してみました。 |
["L0_a"] | ||
""" | ||
""" | ||
[#<Port device: "L0_a", number: 1>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
デバイス名とポート番号ではユーザが興味あるのはたいていポート番号のほうなので、
[#<Port number: 1, device: "L0_a">]
のほうが良いと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
しょうちしました。
@@ -0,0 +1,92 @@ | |||
module Phut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing frozen string literal comment.
修正しました。 |
https://3.basecamp.com/3088280/buckets/46054/messages/148393356
の通り、OVSDBを使った実装を試しに書いてみました。テストはまだありません。