phut 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +14 -1
- data/.travis.yml +2 -6
- data/Gemfile +30 -2
- data/Gemfile.lock +156 -0
- data/README.md +7 -2
- data/Rakefile +4 -3
- data/bin/phut +35 -83
- data/bin/vhost +28 -26
- data/features/{dsl.feature → dsl/error.feature} +8 -6
- data/features/{dsl_link.feature → dsl/link.feature} +11 -14
- data/features/dsl/netns.feature +115 -0
- data/features/dsl/vhost.feature +37 -0
- data/features/{dsl_vswitch.feature → dsl/vswitch.feature} +12 -12
- data/features/phut_run.feature +15 -0
- data/features/shell/vswitch#destroy.feature +10 -0
- data/features/shell/vswitch#ports.feature +36 -0
- data/features/shell/vswitch.all.feature +26 -0
- data/features/shell/vswitch.create.feature +30 -0
- data/features/shell/vswitch.destroy.feature +19 -0
- data/features/shell/vswitch.destroy_all.feature +18 -0
- data/features/step_definitions/link_steps.rb +5 -0
- data/features/step_definitions/netns_steps.rb +31 -0
- data/features/step_definitions/phut_steps.rb +5 -34
- data/features/step_definitions/vhost_steps.rb +5 -0
- data/features/step_definitions/vswitch_steps.rb +17 -0
- data/features/support/env.rb +3 -3
- data/features/support/hooks.rb +23 -15
- data/lib/phut.rb +3 -0
- data/lib/phut/finder.rb +19 -0
- data/lib/phut/link.rb +84 -0
- data/lib/phut/netns.rb +111 -22
- data/lib/phut/open_vswitch.rb +98 -96
- data/lib/phut/parser.rb +39 -8
- data/lib/phut/raw_socket.rb +4 -0
- data/lib/phut/route.rb +34 -0
- data/lib/phut/setting.rb +21 -4
- data/lib/phut/shell_runner.rb +13 -2
- data/lib/phut/syntax.rb +31 -14
- data/lib/phut/syntax/directive.rb +9 -1
- data/lib/phut/syntax/netns_directive.rb +13 -2
- data/lib/phut/syntax/vhost_directive.rb +2 -0
- data/lib/phut/syntax/vswitch_directive.rb +3 -1
- data/lib/phut/version.rb +3 -1
- data/lib/phut/veth.rb +68 -0
- data/lib/phut/vhost.rb +99 -58
- data/lib/phut/vhost_daemon.rb +53 -11
- data/lib/phut/vsctl.rb +125 -0
- data/lib/phut/vswitch.rb +10 -0
- data/phut.gemspec +9 -31
- data/tasks/cucumber.rake +5 -1
- data/tasks/flay.rake +2 -0
- data/tasks/flog.rake +3 -1
- data/tasks/gem.rake +2 -0
- data/tasks/minitest.rake +7 -0
- data/tasks/reek.rake +2 -0
- data/tasks/rubocop.rake +2 -0
- data/tasks/yard.rake +2 -0
- data/test/phut/link_test.rb +85 -0
- data/test/phut/netns_test.rb +58 -0
- data/test/phut/open_vswitch_test.rb +125 -0
- data/test/phut/veth_test.rb +48 -0
- data/test/phut/vhost_test.rb +56 -0
- metadata +41 -287
- data/.rspec +0 -3
- data/Guardfile +0 -29
- data/features/dsl_vhost.feature +0 -37
- data/features/phut_kill.feature +0 -27
- data/features/shell.feature +0 -39
- data/lib/phut/configuration.rb +0 -92
- data/lib/phut/null_logger.rb +0 -14
- data/lib/phut/virtual_link.rb +0 -109
- data/spec/phut/parser_spec.rb +0 -66
- data/spec/phut_spec.rb +0 -45
- data/spec/spec_helper.rb +0 -14
- data/tasks/LICENSE +0 -675
- data/tasks/relish.rake +0 -8
- data/tasks/rspec.rake +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf439f6885b93bd1cb5f5fef8b80a35edefa5ed8
|
4
|
+
data.tar.gz: ed8c7ddd217343b3e572d1373845e869ee68ce16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25fb8ec4082f787dd572bc0b58b6f216b3ef9e54b7398365f5111b5145e898e79118a6b2b3312747153c0f9f1264dab65498b87cbeb695b9242f774a9c2477a7
|
7
|
+
data.tar.gz: 2eb3d617feef2cc265495b53c1a55abd7a5393f19f033e75f2553553ae1bbd9e60cdc0dbf1065af9927b1e5f46ce5d9f8e48d75c7eebec19073fcb1d4fb4785d
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
2
3
|
Include:
|
3
4
|
- Gemfile
|
4
5
|
- Guardfile
|
@@ -7,9 +8,21 @@ AllCops:
|
|
7
8
|
- features/**/*.rb
|
8
9
|
- lib/**/*.rb
|
9
10
|
- phut.gemspec
|
10
|
-
- spec/**/*.rb
|
11
11
|
- tasks/*.rake
|
12
12
|
|
13
|
+
Metrics/LineLength:
|
14
|
+
Exclude:
|
15
|
+
- features/step_definitions/*_steps.rb
|
16
|
+
- test/**/*_test.rb
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Exclude:
|
20
|
+
- test/**/*_test.rb
|
21
|
+
|
22
|
+
Metrics/AbcSize:
|
23
|
+
Exclude:
|
24
|
+
- test/**/*_test.rb
|
25
|
+
|
13
26
|
Style/StringLiterals:
|
14
27
|
EnforcedStyle: single_quotes
|
15
28
|
|
data/.travis.yml
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
sudo: false
|
2
|
-
|
3
1
|
language: ruby
|
4
2
|
|
5
3
|
bundler_args: --without development
|
@@ -8,9 +6,8 @@ cache: bundler
|
|
8
6
|
script: bundle exec rake travis
|
9
7
|
|
10
8
|
rvm:
|
11
|
-
- 2.
|
12
|
-
- 2.1
|
13
|
-
- 2.2
|
9
|
+
- 2.3.4
|
10
|
+
- 2.4.1
|
14
11
|
- ruby-head
|
15
12
|
|
16
13
|
before_install:
|
@@ -32,4 +29,3 @@ notifications:
|
|
32
29
|
env:
|
33
30
|
global:
|
34
31
|
- secure: ZQeasm+7jSVYKsEKp34hxA65cObvmSFWvRuOkRVmmbHRkPyopWOc2U1NIvhYfeAZiUzKscKL4ABXL5uiLtUR2+tmLWSGK8NgKzY/xQcGksN7jQKFanbGYbizg6dVnVlTZ9A3INbp8VIr3HmBmYdjs/vTdX5mfDzZgia9ToNxZlw=
|
35
|
-
- secure: iBrnaPXgLJrebRBgs3hrWvMjcB80OUt0XT38DpvgEP/YliELJBQ9qVW/2mcUkSwwsApS6zzgCpfFeWrIxDffwKqLk+BToDWA2FRNQ78gfIunvhEUMJYkxKBm6dBQ0w8kQOuT4dFr/8zQjjfuyQbMJrB3CI+6VNhNnJjIzxTthoQ=
|
data/Gemfile
CHANGED
@@ -1,4 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
git_source(:github) do |repo_name|
|
8
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
9
|
+
"https://github.com/#{repo_name}.git"
|
10
|
+
end
|
11
|
+
|
12
|
+
gem 'pio', github: 'trema/pio', branch: 'develop'
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'aruba', require: false
|
16
|
+
gem 'cucumber', require: false
|
17
|
+
gem 'faker', require: false
|
18
|
+
gem 'minitest', require: false
|
19
|
+
gem 'rake', require: false
|
20
|
+
end
|
21
|
+
|
22
|
+
group :metrics do
|
23
|
+
gem 'codeclimate-test-reporter', require: false
|
24
|
+
gem 'flay', require: false
|
25
|
+
gem 'flog', require: false
|
26
|
+
gem 'reek', require: false
|
27
|
+
gem 'rubocop', require: false
|
28
|
+
end
|
29
|
+
|
30
|
+
group :doc do
|
31
|
+
gem 'yard', require: false
|
32
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/trema/pio.git
|
3
|
+
revision: 620a7a9b0a4e18bbc38e1c6d641360990ab02607
|
4
|
+
branch: develop
|
5
|
+
specs:
|
6
|
+
pio (0.30.2)
|
7
|
+
activesupport (~> 5.1.0)
|
8
|
+
bindata (~> 2.1.0)
|
9
|
+
|
10
|
+
PATH
|
11
|
+
remote: .
|
12
|
+
specs:
|
13
|
+
phut (0.7.8)
|
14
|
+
activesupport (~> 5.1.0)
|
15
|
+
gli (~> 2.16.0)
|
16
|
+
pio (~> 0.30.2)
|
17
|
+
pry (~> 0.10.3)
|
18
|
+
|
19
|
+
GEM
|
20
|
+
remote: https://rubygems.org/
|
21
|
+
specs:
|
22
|
+
activesupport (5.1.0)
|
23
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
+
i18n (~> 0.7)
|
25
|
+
minitest (~> 5.1)
|
26
|
+
tzinfo (~> 1.1)
|
27
|
+
aruba (0.14.2)
|
28
|
+
childprocess (~> 0.5.6)
|
29
|
+
contracts (~> 0.9)
|
30
|
+
cucumber (>= 1.3.19)
|
31
|
+
ffi (~> 1.9.10)
|
32
|
+
rspec-expectations (>= 2.99)
|
33
|
+
thor (~> 0.19)
|
34
|
+
ast (2.3.0)
|
35
|
+
axiom-types (0.1.1)
|
36
|
+
descendants_tracker (~> 0.0.4)
|
37
|
+
ice_nine (~> 0.11.0)
|
38
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
39
|
+
bindata (2.1.0)
|
40
|
+
builder (3.2.2)
|
41
|
+
childprocess (0.5.9)
|
42
|
+
ffi (~> 1.0, >= 1.0.11)
|
43
|
+
codeclimate-engine-rb (0.4.0)
|
44
|
+
virtus (~> 1.0)
|
45
|
+
codeclimate-test-reporter (1.0.8)
|
46
|
+
simplecov (<= 0.13)
|
47
|
+
coderay (1.1.1)
|
48
|
+
coercible (1.0.0)
|
49
|
+
descendants_tracker (~> 0.0.1)
|
50
|
+
concurrent-ruby (1.0.5)
|
51
|
+
contracts (0.14.0)
|
52
|
+
cucumber (2.4.0)
|
53
|
+
builder (>= 2.1.2)
|
54
|
+
cucumber-core (~> 1.5.0)
|
55
|
+
cucumber-wire (~> 0.0.1)
|
56
|
+
diff-lcs (>= 1.1.3)
|
57
|
+
gherkin (~> 4.0)
|
58
|
+
multi_json (>= 1.7.5, < 2.0)
|
59
|
+
multi_test (>= 0.1.2)
|
60
|
+
cucumber-core (1.5.0)
|
61
|
+
gherkin (~> 4.0)
|
62
|
+
cucumber-wire (0.0.1)
|
63
|
+
descendants_tracker (0.0.4)
|
64
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
65
|
+
diff-lcs (1.2.5)
|
66
|
+
docile (1.1.5)
|
67
|
+
equalizer (0.0.11)
|
68
|
+
erubis (2.7.0)
|
69
|
+
faker (1.7.3)
|
70
|
+
i18n (~> 0.5)
|
71
|
+
ffi (1.9.18)
|
72
|
+
flay (2.9.0)
|
73
|
+
erubis (~> 2.7.0)
|
74
|
+
path_expander (~> 1.0)
|
75
|
+
ruby_parser (~> 3.0)
|
76
|
+
sexp_processor (~> 4.0)
|
77
|
+
flog (4.6.1)
|
78
|
+
path_expander (~> 1.0)
|
79
|
+
ruby_parser (~> 3.1, > 3.1.0)
|
80
|
+
sexp_processor (~> 4.8)
|
81
|
+
gherkin (4.0.0)
|
82
|
+
gli (2.16.0)
|
83
|
+
i18n (0.8.1)
|
84
|
+
ice_nine (0.11.2)
|
85
|
+
json (2.1.0)
|
86
|
+
method_source (0.8.2)
|
87
|
+
minitest (5.10.1)
|
88
|
+
multi_json (1.12.1)
|
89
|
+
multi_test (0.1.2)
|
90
|
+
parser (2.4.0.0)
|
91
|
+
ast (~> 2.2)
|
92
|
+
path_expander (1.0.1)
|
93
|
+
powerpack (0.1.1)
|
94
|
+
pry (0.10.4)
|
95
|
+
coderay (~> 1.1.0)
|
96
|
+
method_source (~> 0.8.1)
|
97
|
+
slop (~> 3.4)
|
98
|
+
rainbow (2.2.2)
|
99
|
+
rake
|
100
|
+
rake (12.0.0)
|
101
|
+
reek (4.6.2)
|
102
|
+
codeclimate-engine-rb (~> 0.4.0)
|
103
|
+
parser (>= 2.4.0.0, < 2.5)
|
104
|
+
rainbow (~> 2.0)
|
105
|
+
rspec-expectations (3.5.0)
|
106
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
107
|
+
rspec-support (~> 3.5.0)
|
108
|
+
rspec-support (3.5.0)
|
109
|
+
rubocop (0.48.1)
|
110
|
+
parser (>= 2.3.3.1, < 3.0)
|
111
|
+
powerpack (~> 0.1)
|
112
|
+
rainbow (>= 1.99.1, < 3.0)
|
113
|
+
ruby-progressbar (~> 1.7)
|
114
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
115
|
+
ruby-progressbar (1.8.1)
|
116
|
+
ruby_parser (3.9.0)
|
117
|
+
sexp_processor (~> 4.1)
|
118
|
+
sexp_processor (4.9.0)
|
119
|
+
simplecov (0.13.0)
|
120
|
+
docile (~> 1.1.0)
|
121
|
+
json (>= 1.8, < 3)
|
122
|
+
simplecov-html (~> 0.10.0)
|
123
|
+
simplecov-html (0.10.0)
|
124
|
+
slop (3.6.0)
|
125
|
+
thor (0.19.4)
|
126
|
+
thread_safe (0.3.6)
|
127
|
+
tzinfo (1.2.3)
|
128
|
+
thread_safe (~> 0.1)
|
129
|
+
unicode-display_width (1.2.1)
|
130
|
+
virtus (1.0.5)
|
131
|
+
axiom-types (~> 0.1)
|
132
|
+
coercible (~> 1.0)
|
133
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
134
|
+
equalizer (~> 0.0, >= 0.0.9)
|
135
|
+
yard (0.9.9)
|
136
|
+
|
137
|
+
PLATFORMS
|
138
|
+
ruby
|
139
|
+
|
140
|
+
DEPENDENCIES
|
141
|
+
aruba
|
142
|
+
codeclimate-test-reporter
|
143
|
+
cucumber
|
144
|
+
faker
|
145
|
+
flay
|
146
|
+
flog
|
147
|
+
minitest
|
148
|
+
phut!
|
149
|
+
pio!
|
150
|
+
rake
|
151
|
+
reek
|
152
|
+
rubocop
|
153
|
+
yard
|
154
|
+
|
155
|
+
BUNDLED WITH
|
156
|
+
1.14.6
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@ phut
|
|
3
3
|
|
4
4
|
[![Build Status](http://img.shields.io/travis/trema/phut/develop.svg?style=flat)][travis]
|
5
5
|
[![Code Climate](http://img.shields.io/codeclimate/github/trema/phut.svg?style=flat)][codeclimate]
|
6
|
-
[![Coverage Status](http://img.shields.io/codeclimate/coverage/github/trema/phut.svg?style=flat)][coveralls]
|
7
6
|
[![Dependency Status](http://img.shields.io/gemnasium/trema/phut.svg?style=flat)][gemnasium]
|
8
7
|
[![Gitter chat](http://img.shields.io/badge/GITTER-phut-blue.svg?style=flat)][gitter]
|
9
8
|
|
@@ -11,7 +10,6 @@ Virtual network in seconds
|
|
11
10
|
|
12
11
|
[travis]: http://travis-ci.org/trema/phut
|
13
12
|
[codeclimate]: https://codeclimate.com/github/trema/phut
|
14
|
-
[coveralls]: https://coveralls.io/r/trema/phut
|
15
13
|
[gemnasium]: https://gemnasium.com/trema/phut
|
16
14
|
[gitter]: https://gitter.im/trema/phut
|
17
15
|
|
@@ -47,3 +45,10 @@ Then you can pass the network configuration to `phut run`.
|
|
47
45
|
```
|
48
46
|
$ bundle exec phut run phut.conf
|
49
47
|
```
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
Phut is released under the GNU General Public License version 2.0 or MIT License:
|
52
|
+
|
53
|
+
* http://www.gnu.org/licenses/gpl-2.0.html
|
54
|
+
* http://www.opensource.org/licenses/MIT
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
4
|
|
3
5
|
require 'rake/clean'
|
@@ -5,8 +7,7 @@ require 'rake/clean'
|
|
5
7
|
RELISH_PROJECT = 'trema/phut'
|
6
8
|
|
7
9
|
task default: :test
|
8
|
-
task
|
9
|
-
task
|
10
|
-
task quality: [:rubocop, :reek, :flog, :flay]
|
10
|
+
task travis: ['cucumber:travis', :quality]
|
11
|
+
task quality: %i[rubocop reek flog flay]
|
11
12
|
|
12
13
|
Dir.glob('tasks/*.rake').each { |each| import each }
|
data/bin/phut
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'rubygems'
|
4
5
|
require 'bundler'
|
5
6
|
Bundler.setup :default
|
6
7
|
|
7
8
|
require 'gli'
|
8
|
-
require 'logger'
|
9
9
|
require 'phut'
|
10
10
|
require 'pry'
|
11
11
|
|
12
|
-
$stdout.sync = true
|
13
|
-
|
14
12
|
module Phut
|
15
13
|
# /bin/phut command
|
16
|
-
# rubocop:disable ModuleLength
|
17
14
|
module App
|
18
15
|
extend GLI::App
|
19
16
|
|
@@ -22,37 +19,25 @@ module Phut
|
|
22
19
|
version Phut::VERSION
|
23
20
|
|
24
21
|
desc 'Be verbose'
|
25
|
-
switch [
|
22
|
+
switch %i[v verbose], negatable: false
|
26
23
|
|
27
24
|
command :shell do |c|
|
28
|
-
c.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Pry
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if Phut::OpenVswitch.find_by(name: dpid)
|
45
|
-
fail(Phut::OpenVswitch::AlreadyRunning,
|
46
|
-
"Open vSwitch (dpid = #{dpid}) is already running!")
|
47
|
-
end
|
48
|
-
Phut::OpenVswitch.create(dpid).run
|
49
|
-
end
|
50
|
-
Pry::Commands.block_command 'dump_flows' do |dpid|
|
51
|
-
puts Phut::OpenVswitch.dump_flows(dpid)
|
52
|
-
end
|
53
|
-
Pry::Commands.block_command 'kill' do |dpid|
|
54
|
-
Phut::OpenVswitch.shutdown(dpid)
|
55
|
-
end
|
25
|
+
c.desc 'Location to put pid files'
|
26
|
+
c.flag %i[P pid_dir], default_value: Phut.pid_dir
|
27
|
+
c.desc 'Location to put log files'
|
28
|
+
c.flag %i[L log_dir], default_value: Phut.log_dir
|
29
|
+
c.desc 'Location to put socket files'
|
30
|
+
c.flag %i[S socket_dir], default_value: Phut.socket_dir
|
31
|
+
|
32
|
+
c.action do |_global_options, options, _args|
|
33
|
+
Phut.pid_dir = options.fetch(:pid_dir)
|
34
|
+
Phut.log_dir = options.fetch(:log_dir)
|
35
|
+
Phut.socket_dir = options.fetch(:socket_dir)
|
36
|
+
|
37
|
+
Pry.prompt = [proc { 'phut> ' },
|
38
|
+
proc { 'phut* ' }]
|
39
|
+
|
40
|
+
include Phut
|
56
41
|
pry
|
57
42
|
end
|
58
43
|
end
|
@@ -61,67 +46,33 @@ module Phut
|
|
61
46
|
arg_name 'FILE'
|
62
47
|
command :run do |c|
|
63
48
|
c.desc 'Location to put pid files'
|
64
|
-
c.flag [
|
49
|
+
c.flag %i[P pid_dir], default_value: Phut.pid_dir
|
65
50
|
c.desc 'Location to put log files'
|
66
|
-
c.flag [
|
51
|
+
c.flag %i[L log_dir], default_value: Phut.log_dir
|
67
52
|
c.desc 'Location to put socket files'
|
68
|
-
c.flag [
|
53
|
+
c.flag %i[S socket_dir], default_value: Phut.socket_dir
|
69
54
|
|
70
|
-
c.action do |
|
71
|
-
stdout_logger = Logger.new($stderr).tap do |logger|
|
72
|
-
logger.formatter = proc { |_sev, _dtm, _name, msg| msg + "\n" }
|
73
|
-
logger.level = global_options[:verbose] ? Logger::DEBUG : Logger::INFO
|
74
|
-
end
|
55
|
+
c.action do |_global_options, options, args|
|
75
56
|
Phut.pid_dir = options.fetch(:pid_dir)
|
76
57
|
Phut.log_dir = options.fetch(:log_dir)
|
77
58
|
Phut.socket_dir = options.fetch(:socket_dir)
|
78
|
-
Phut::Parser.new(stdout_logger).parse(args[0]).run
|
79
|
-
end
|
80
|
-
end
|
81
59
|
|
82
|
-
|
83
|
-
arg_name 'SWITCH'
|
84
|
-
command :show do |c|
|
85
|
-
c.action do |_global_options, _options, args|
|
86
|
-
system "sudo ovs-ofctl show br#{args[0]}"
|
60
|
+
Phut::Parser.new(args[0]).parse
|
87
61
|
end
|
88
62
|
end
|
89
63
|
|
90
64
|
desc 'Stops a virtual network'
|
91
|
-
arg_name 'FILE'
|
92
65
|
command :stop do |c|
|
93
|
-
c.desc 'Location to put pid files'
|
94
|
-
c.flag [:P, :pid_dir], default_value: Phut.pid_dir
|
95
|
-
c.desc 'Location to put log files'
|
96
|
-
c.flag [:L, :log_dir], default_value: Phut.log_dir
|
97
66
|
c.desc 'Location to put socket files'
|
98
|
-
c.flag [
|
67
|
+
c.flag %i[S socket_dir], default_value: Phut.socket_dir
|
99
68
|
|
100
|
-
c.action do |
|
101
|
-
stdout_logger = Logger.new($stderr).tap do |logger|
|
102
|
-
logger.formatter = proc { |_sev, _dtm, _name, msg| msg + "\n" }
|
103
|
-
logger.level = global_options[:verbose] ? Logger::DEBUG : Logger::INFO
|
104
|
-
end
|
105
|
-
Phut.pid_dir = options.fetch(:pid_dir)
|
106
|
-
Phut.log_dir = options.fetch(:log_dir)
|
69
|
+
c.action do |_global_options, options, _args|
|
107
70
|
Phut.socket_dir = options.fetch(:socket_dir)
|
108
|
-
Phut::Parser.new(stdout_logger).parse(args[0]).stop
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
desc 'Kills a vswitch or a vhost'
|
113
|
-
arg_name 'NAME'
|
114
|
-
command :kill do |c|
|
115
|
-
c.desc 'Location to find socket files'
|
116
|
-
c.flag [:S, :socket_dir], default_value: Phut.socket_dir
|
117
71
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
rescue
|
123
|
-
Phut::OpenVswitch.shutdown(args[0])
|
124
|
-
end
|
72
|
+
Phut::Vswitch.destroy_all
|
73
|
+
Phut::Vhost.destroy_all
|
74
|
+
Phut::Netns.destroy_all
|
75
|
+
Phut::Link.destroy_all
|
125
76
|
end
|
126
77
|
end
|
127
78
|
|
@@ -130,16 +81,17 @@ module Phut
|
|
130
81
|
puts "#{exe_name} version #{version_string}"
|
131
82
|
exit_now! nil, 0
|
132
83
|
end
|
84
|
+
|
85
|
+
if global[:verbose]
|
86
|
+
ENV['GLI_DEBUG'] = 'true'
|
87
|
+
Phut.logger.level = Logger::DEBUG
|
88
|
+
end
|
89
|
+
|
133
90
|
true
|
134
91
|
end
|
135
92
|
|
136
93
|
default_command :shell
|
137
94
|
|
138
|
-
on_error do |e|
|
139
|
-
fail e
|
140
|
-
end
|
141
|
-
|
142
95
|
exit run(ARGV)
|
143
96
|
end
|
144
|
-
# rubocop:enable ModuleLength
|
145
97
|
end
|