dewiring 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/wire/cli/cli_commands.rb +4 -4
- data/lib/wire/commands/base_command.rb +1 -1
- data/lib/wire/commands/spec_command.rb +0 -78
- data/lib/wire/commands/spec_templates.rb +1 -1
- data/lib/wire/commands/spec_writer.rb +86 -0
- data/lib/wire/commands.rb +1 -0
- data/lib/wire/resource/network_injection.rb +18 -7
- data/lib/wire/version.rb +1 -1
- data/{bin → lib}/wire-network-container.sh +52 -36
- metadata +4 -5
- data/lib/test_fig.rb +0 -46
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzZlOTQxOTc2YzIyMmExOWQ1OGJmZmRmYzQ4MDRlMWJiMTZkMmI0Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGRjNWIyNWNlYjFkMGFkOTM1OTRkYWI4YWY0NTRlY2I4YWFiYTgwMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjNmNzNhNDUzYTU2YzBkNmFmYWEyMWQ5Y2I2Mzk3ZDJjZjA3MmUxNGE5ODFm
|
10
|
+
OGEwYjk3N2I1NDQ4MDgyYzNmZDJkODVhZWNlYjA5MDE3M2JhMDBiMzQyMGQ3
|
11
|
+
MWRiODg2NGQ1MzRlNTFjNzQ3MWQ2YWM0MDI4Y2NjODJhNzVmOTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjNiNjllYTJiZjU2YWJmNGZiOGJmMDEyMTBiYjNmNzUxOTJlZTQwMmJkZDkx
|
14
|
+
ZDUzYmI5ZjJlMTM1OTBjM2RhYTdhYjdjZGVlMDhlZTY2ODhlMDA0YTI0ZGMz
|
15
|
+
NDhjN2IxODMxOWUwMmI5ZTIzZTExM2UyMjU0MjgwMTBjYmEwNjU=
|
@@ -50,10 +50,10 @@ module Wire
|
|
50
50
|
if cmd_ver_obj.findings.size == 0
|
51
51
|
puts 'OK, system is conforming to model'.color(:green)
|
52
52
|
else
|
53
|
-
puts 'ERROR, detected inconsistencies/errors
|
54
|
-
cmd_ver_obj.findings.each do |val_error|
|
55
|
-
|
56
|
-
end
|
53
|
+
puts 'ERROR, detected inconsistencies/errors.'.color(:red)
|
54
|
+
# cmd_ver_obj.findings.each do |val_error|
|
55
|
+
# puts val_error.to_s
|
56
|
+
# end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -159,82 +159,4 @@ module Wire
|
|
159
159
|
$log.debug("Done for appgroup #{appgroup_name}")
|
160
160
|
end
|
161
161
|
end
|
162
|
-
|
163
|
-
# SpecWriter is able to create a directory
|
164
|
-
# structure according to basic serverspec
|
165
|
-
# needs and fill in the templates
|
166
|
-
class SpecWriter
|
167
|
-
# create SpecWriter in +target_dir+ directory
|
168
|
-
# with given +spec_contents+
|
169
|
-
def initialize(target_dir, spec_contents)
|
170
|
-
@target_dir = target_dir
|
171
|
-
@spec_contents = spec_contents
|
172
|
-
end
|
173
|
-
|
174
|
-
# writes spec to disk
|
175
|
-
def write
|
176
|
-
ensure_directory_structure
|
177
|
-
ensure_files
|
178
|
-
end
|
179
|
-
|
180
|
-
# make sure that we have a rspec-conformant dir structure
|
181
|
-
def ensure_directory_structure
|
182
|
-
ensure_directory @target_dir
|
183
|
-
ensure_directory File.join(@target_dir, 'spec')
|
184
|
-
ensure_directory File.join(@target_dir, 'spec', 'localhost')
|
185
|
-
end
|
186
|
-
|
187
|
-
# writes erb +template+ to open +file+ object
|
188
|
-
def write_template(template, file)
|
189
|
-
erb = ERB.new(template, nil, '%')
|
190
|
-
file.puts(erb.result(binding))
|
191
|
-
end
|
192
|
-
|
193
|
-
# ensures that all serverspec skeleton files such as
|
194
|
-
# Rakefile, spec_helper etc. exist
|
195
|
-
# Then writes the models specification files into the
|
196
|
-
# skeleton
|
197
|
-
def ensure_files
|
198
|
-
rakefile_name = File.join(@target_dir, 'Rakefile')
|
199
|
-
file?(rakefile_name) || File.open(rakefile_name, 'w') do |file|
|
200
|
-
write_template(SpecTemplates.template_rakefile, file)
|
201
|
-
end
|
202
|
-
|
203
|
-
spechelper_name = File.join(@target_dir, 'spec', 'spec_helper.rb')
|
204
|
-
file?(spechelper_name) || File.open(spechelper_name, 'w') do |file|
|
205
|
-
write_template(SpecTemplates.template_spec_helper, file)
|
206
|
-
end
|
207
|
-
|
208
|
-
specfile_name = File.join(@target_dir, 'spec', 'localhost', 'wire_spec.rb')
|
209
|
-
File.open(specfile_name, 'w') do |file|
|
210
|
-
template = <<ERB
|
211
|
-
require 'spec_helper.rb'
|
212
|
-
|
213
|
-
# begin of generated specs
|
214
|
-
|
215
|
-
<%= @spec_contents.join('\n') %>
|
216
|
-
|
217
|
-
# end of spec file
|
218
|
-
ERB
|
219
|
-
write_template(template, file)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
private
|
224
|
-
|
225
|
-
# make sure that +target_dir+ exists
|
226
|
-
def ensure_directory(target_dir)
|
227
|
-
return if File.exist?(target_dir)
|
228
|
-
begin
|
229
|
-
FileUtils.mkdir_p(target_dir)
|
230
|
-
rescue => excpt
|
231
|
-
$log.error "ERROR: Unable to create #{target_dir}: #{excpt}"
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
# checks if +target_file+ exists
|
236
|
-
def file?(target_file)
|
237
|
-
File.exist?(target_file) && File.file?(target_file)
|
238
|
-
end
|
239
|
-
end
|
240
162
|
end
|
@@ -42,7 +42,7 @@ ERB
|
|
42
42
|
'on ovs bridge named <%= bridge_name %>, serving addresses from ' \
|
43
43
|
'<%= ip_start %> to <%= ip_end %>' do
|
44
44
|
|
45
|
-
describe file '/etc/dnsmasq.d/wire__<%= zone_name %>.conf' do
|
45
|
+
describe file '/etc/dnsmasq.d/wire__<%= zone_name %>__<%= bridge_name %>.conf' do
|
46
46
|
it { should be_file }
|
47
47
|
its(:content) { should match /<%= ip_start %>/ }
|
48
48
|
its(:content) { should match /<%= ip_end %>/ }
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# The MIT License (MIT)
|
4
|
+
# Copyright (c) 2014 Andreas Schmidt, andreas@de-wiring.net
|
5
|
+
#
|
6
|
+
|
7
|
+
# Wire module
|
8
|
+
module Wire
|
9
|
+
# SpecWriter is able to create a directory
|
10
|
+
# structure according to basic serverspec
|
11
|
+
# needs and fill in the templates
|
12
|
+
class SpecWriter
|
13
|
+
# create SpecWriter in +target_dir+ directory
|
14
|
+
# with given +spec_contents+
|
15
|
+
def initialize(target_dir, spec_contents)
|
16
|
+
@target_dir = target_dir
|
17
|
+
@spec_contents = spec_contents
|
18
|
+
end
|
19
|
+
|
20
|
+
# writes spec to disk
|
21
|
+
def write
|
22
|
+
ensure_directory_structure
|
23
|
+
ensure_files
|
24
|
+
end
|
25
|
+
|
26
|
+
# make sure that we have a rspec-conformant dir structure
|
27
|
+
def ensure_directory_structure
|
28
|
+
ensure_directory @target_dir
|
29
|
+
ensure_directory File.join(@target_dir, 'spec')
|
30
|
+
ensure_directory File.join(@target_dir, 'spec', 'localhost')
|
31
|
+
end
|
32
|
+
|
33
|
+
# writes erb +template+ to open +file+ object
|
34
|
+
def write_template(template, file)
|
35
|
+
erb = ERB.new(template, nil, '%')
|
36
|
+
file.puts(erb.result(binding))
|
37
|
+
end
|
38
|
+
|
39
|
+
# ensures that all serverspec skeleton files such as
|
40
|
+
# Rakefile, spec_helper etc. exist
|
41
|
+
# Then writes the models specification files into the
|
42
|
+
# skeleton
|
43
|
+
def ensure_files
|
44
|
+
rakefile_name = File.join(@target_dir, 'Rakefile')
|
45
|
+
file?(rakefile_name) || File.open(rakefile_name, 'w') do |file|
|
46
|
+
write_template(SpecTemplates.template_rakefile, file)
|
47
|
+
end
|
48
|
+
|
49
|
+
spechelper_name = File.join(@target_dir, 'spec', 'spec_helper.rb')
|
50
|
+
file?(spechelper_name) || File.open(spechelper_name, 'w') do |file|
|
51
|
+
write_template(SpecTemplates.template_spec_helper, file)
|
52
|
+
end
|
53
|
+
|
54
|
+
specfile_name = File.join(@target_dir, 'spec', 'localhost', 'wire_spec.rb')
|
55
|
+
File.open(specfile_name, 'w') do |file|
|
56
|
+
template = <<ERB
|
57
|
+
require 'spec_helper.rb'
|
58
|
+
|
59
|
+
# begin of generated specs
|
60
|
+
|
61
|
+
<%= @spec_contents.join('\n') %>
|
62
|
+
|
63
|
+
# end of spec file
|
64
|
+
ERB
|
65
|
+
write_template(template, file)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# make sure that +target_dir+ exists
|
72
|
+
def ensure_directory(target_dir)
|
73
|
+
return if File.exist?(target_dir)
|
74
|
+
begin
|
75
|
+
FileUtils.mkdir_p(target_dir)
|
76
|
+
rescue => excpt
|
77
|
+
$log.error "ERROR: Unable to create #{target_dir}: #{excpt}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# checks if +target_file+ exists
|
82
|
+
def file?(target_file)
|
83
|
+
File.exist?(target_file) && File.file?(target_file)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/wire/commands.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative 'commands/validate_command.rb'
|
|
11
11
|
require_relative 'commands/verify_command.rb'
|
12
12
|
require_relative 'commands/verify_command_handler.rb'
|
13
13
|
require_relative 'commands/spec_command.rb'
|
14
|
+
require_relative 'commands/spec_writer.rb'
|
14
15
|
require_relative 'commands/spec_templates.rb'
|
15
16
|
require_relative 'commands/updown_command_base.rb'
|
16
17
|
require_relative 'commands/up_command.rb'
|
@@ -35,18 +35,29 @@ module Wire
|
|
35
35
|
self.containers = containers
|
36
36
|
self.networks = networks
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
begin
|
39
|
+
# try to locate the gem base path and find shell script
|
40
|
+
gem 'dewiring'
|
41
|
+
gem_base_dir = Gem.datadir('dewiring').split('/')[0..-3].join('/')
|
42
|
+
@executables = {
|
43
|
+
:network => File.join(gem_base_dir, 'lib/wire-network-container.sh')
|
44
|
+
}
|
45
|
+
rescue LoadError
|
46
|
+
# use fallback
|
47
|
+
@executables = {
|
48
|
+
:network => '/usr/local/bin/wire-network-container.sh'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
$log.debug "Using network injection script #{@executables[:network]}"
|
42
52
|
end
|
43
53
|
|
44
54
|
# calls helper executable with correct +action+
|
45
55
|
# and given +command_arr+ array
|
46
|
-
def with_helper(action, params)
|
56
|
+
def with_helper(action, params, options = '')
|
47
57
|
# puts "#{@executables[:network]} #{action} --debug -- #{params.join(' ')}"
|
58
|
+
dbg_param = ($log.level == Logger::DEBUG ? '--debug' : '')
|
48
59
|
LocalExecution.with(@executables[:network],
|
49
|
-
[action,
|
60
|
+
[action, dbg_param, options, '--', params].flatten,
|
50
61
|
{ :b_sudo => false, :b_shell => false }) do |exec_obj|
|
51
62
|
yield exec_obj
|
52
63
|
end
|
@@ -75,7 +86,7 @@ module Wire
|
|
75
86
|
# same as exist?
|
76
87
|
def up?
|
77
88
|
with_helper('verify', [construct_helper_params,
|
78
|
-
containers.join(' ')]) do |exec_obj|
|
89
|
+
containers.join(' ')], '--quiet') do |exec_obj|
|
79
90
|
exec_obj.run
|
80
91
|
|
81
92
|
return (exec_obj.exitstatus == 0 && count_errors(exec_obj) == 0)
|
data/lib/wire/version.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# wire-network-container.sh
|
4
4
|
# MIT License
|
5
5
|
#
|
6
6
|
# attaches multiple containers to multiple ovs bridges
|
7
|
-
#
|
7
|
+
# exit codes:
|
8
|
+
# 0 action completed successfully
|
9
|
+
# 1 unknown option/action or no action given
|
10
|
+
# 2 No device/bridge part specified.
|
11
|
+
# 3 No container ids specified.
|
12
|
+
# 10 No running containers found.
|
13
|
+
# 100 action failed
|
8
14
|
|
9
15
|
# Display usage and help
|
10
16
|
function usage() {
|
@@ -13,13 +19,15 @@ function usage() {
|
|
13
19
|
echo ' verify verify given container/device/bridge options'
|
14
20
|
echo ' attach attach devices to bridges and containers'
|
15
21
|
echo ' detach detach devices from bridges and containers'
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
echo ' where OPTIONS are'
|
23
|
+
echo ' -n/--noop only print commands, do not change'
|
24
|
+
echo ' -d/--debug show debug output'
|
25
|
+
echo ' -q/--quiet be quiet'
|
26
|
+
# echo ' -s/--state <FILE> write state to <FILE>' # TODO
|
27
|
+
echo ' Examples:'
|
28
|
+
echo ' attach-containers.sh attach --debug -- eth1:br1 eth2:br2 02978729 12673482'
|
29
|
+
echo ' attach-containers.sh verify -- eth1:br1 eth2:br2 02978729 12673482'
|
30
|
+
echo ' attach-containers.sh detach -q -- eth1:br1 eth2:br2 02978729 12673482'
|
23
31
|
}
|
24
32
|
|
25
33
|
|
@@ -45,7 +53,7 @@ function debug() {
|
|
45
53
|
[[ "$QUIET" != "1" ]] && echo DEBUG $*
|
46
54
|
}
|
47
55
|
function log_error() {
|
48
|
-
echo ERROR $* >&2
|
56
|
+
[[ "$QUIET" != "1" ]] && echo ERROR $* >&2
|
49
57
|
}
|
50
58
|
function log_ok() {
|
51
59
|
[[ "$QUIET" != "1" ]] && echo OK $*
|
@@ -55,6 +63,7 @@ NOOP=
|
|
55
63
|
MODE=
|
56
64
|
ACTION=
|
57
65
|
DEBUG=nodebug
|
66
|
+
QUIET=
|
58
67
|
|
59
68
|
while :
|
60
69
|
do
|
@@ -69,15 +78,19 @@ do
|
|
69
78
|
;;
|
70
79
|
-n | --noop)
|
71
80
|
NOOP=1
|
72
|
-
|
81
|
+
shift
|
73
82
|
;;
|
74
83
|
-d | --debug)
|
75
84
|
DEBUG=debug
|
76
|
-
|
85
|
+
shift
|
86
|
+
;;
|
87
|
+
-q | --quiet)
|
88
|
+
QUIET=1
|
89
|
+
shift
|
77
90
|
;;
|
78
91
|
--) # End of all options
|
79
92
|
shift
|
80
|
-
|
93
|
+
break
|
81
94
|
;;
|
82
95
|
-*)
|
83
96
|
echo "Error: Unknown option: $1" >&2
|
@@ -102,6 +115,8 @@ if [[ -z "$DEVICE_ARR" ]]; then
|
|
102
115
|
log_error No device/bridge part specified.
|
103
116
|
usage
|
104
117
|
exit 2
|
118
|
+
else
|
119
|
+
$DEBUG Attaching devices/bridges "$DEVICE_ARR"
|
105
120
|
fi
|
106
121
|
if [[ -z "$ID_ARR" ]]; then
|
107
122
|
log_error No container ids specified.
|
@@ -119,6 +134,7 @@ PS4='+|${BASH_SOURCE##*/} ${LINENO}${FUNCNAME[0]:+ ${FUNCNAME[0]}}| '
|
|
119
134
|
IP=$(which ip)
|
120
135
|
OVS_VSCTL=$(which ovs-vsctl)
|
121
136
|
DOCKER=$(which docker)
|
137
|
+
DHCLIENT=$(which dhclient)
|
122
138
|
|
123
139
|
# -- FUNCTION ----------------------------------------------------------------
|
124
140
|
# Name: container_process
|
@@ -304,7 +320,7 @@ function has_interfaces() {
|
|
304
320
|
function dhcp_container() {
|
305
321
|
local NS=$1
|
306
322
|
local DEVICE=$2
|
307
|
-
$MODE sudo $IP netns exec $NS
|
323
|
+
$MODE sudo "$IP" netns exec "$NS" "$DHCLIENT" -v -1 "$DEVICE"
|
308
324
|
return $?
|
309
325
|
}
|
310
326
|
|
@@ -323,20 +339,20 @@ function handle_verify() {
|
|
323
339
|
local RES=0
|
324
340
|
|
325
341
|
# ensure there are containers running before continuing
|
326
|
-
CURRENT_IDS=$(sudo $DOCKER ps -q --no-trunc)
|
342
|
+
CURRENT_IDS=$(sudo "$DOCKER" ps -q --no-trunc)
|
327
343
|
if [[ -z "$CURRENT_IDS" ]]; then
|
328
344
|
log_error No running containers found.
|
329
345
|
exit 10
|
330
346
|
fi
|
331
347
|
|
332
348
|
for DEVICE_PAIR in $DEVICE_ARR; do
|
333
|
-
BRIDGE=$(echo $DEVICE_PAIR | awk -F':' '{ print $2 }' )
|
334
|
-
$DEBUG Checking $BRIDGE
|
335
|
-
sudo $OVS_VSCTL br-exists $BRIDGE
|
349
|
+
BRIDGE=$(echo "$DEVICE_PAIR" | awk -F':' '{ print $2 }' )
|
350
|
+
$DEBUG Checking "$BRIDGE"
|
351
|
+
sudo "$OVS_VSCTL" br-exists "$BRIDGE"
|
336
352
|
if [[ $? -eq 0 ]]; then
|
337
|
-
log_ok $BRIDGE
|
353
|
+
log_ok "$BRIDGE"
|
338
354
|
else
|
339
|
-
log_error Unable to find ovs bridge $BRIDGE
|
355
|
+
log_error Unable to find ovs bridge "$BRIDGE"
|
340
356
|
RES=1
|
341
357
|
fi
|
342
358
|
done
|
@@ -400,9 +416,9 @@ function handle_attach() {
|
|
400
416
|
$DEBUG Attaching $TARGET
|
401
417
|
|
402
418
|
TARGET_PID=$(container_process $TARGET)
|
403
|
-
|
419
|
+
$DEBUG PID of $TARGET is $TARGET_PID
|
404
420
|
|
405
|
-
|
421
|
+
link_netns "${TARGET_PID}"
|
406
422
|
|
407
423
|
# iterate given devices
|
408
424
|
for DEVICE_PAIR in $DEVICE_ARR; do
|
@@ -417,12 +433,12 @@ function handle_attach() {
|
|
417
433
|
break
|
418
434
|
fi
|
419
435
|
|
420
|
-
|
421
|
-
|
422
|
-
|
436
|
+
HOST_IFNAME=v${INTF}h${TARGET_PID}
|
437
|
+
CONTAINER_IFNAME=v${INTF}c${TARGET_PID}
|
438
|
+
$DEBUG - interface pair names are ${HOST_IFNAME}/${CONTAINER_IFNAME}
|
423
439
|
|
424
440
|
$DEBUG - creating peer interfaces
|
425
|
-
|
441
|
+
add_peer_interfaces "$HOST_IFNAME" "$CONTAINER_IFNAME" "$BRIDGEDEV_MTU"
|
426
442
|
if [[ $? -ne 0 ]]; then
|
427
443
|
log_error creating peer interfaces. aborting
|
428
444
|
RES=1
|
@@ -430,7 +446,7 @@ function handle_attach() {
|
|
430
446
|
fi
|
431
447
|
|
432
448
|
$DEBUG - adding $HOST_IFNAME to $BRIDGE
|
433
|
-
|
449
|
+
add_device_to_switch "$HOST_IFNAME" "$BRIDGE"
|
434
450
|
if [[ $? -ne 0 ]]; then
|
435
451
|
log_error adding device to bridge. aborting
|
436
452
|
RES=1
|
@@ -438,7 +454,7 @@ function handle_attach() {
|
|
438
454
|
fi
|
439
455
|
|
440
456
|
$DEBUG - configuring interfaces
|
441
|
-
|
457
|
+
configure_interfaces "$HOST_IFNAME" "$CONTAINER_IFNAME" "$TARGET_PID" "$INTF"
|
442
458
|
if [[ $? -ne 0 ]]; then
|
443
459
|
log_error configuring interfaces. aborting
|
444
460
|
RES=1
|
@@ -446,7 +462,7 @@ function handle_attach() {
|
|
446
462
|
fi
|
447
463
|
|
448
464
|
$DEBUG - dhcp requesting address
|
449
|
-
|
465
|
+
dhcp_container "$TARGET_PID" "$INTF"
|
450
466
|
if [[ $? -ne 0 ]]; then
|
451
467
|
log_error running dhcp. aborting
|
452
468
|
RES=1
|
@@ -454,7 +470,7 @@ function handle_attach() {
|
|
454
470
|
fi
|
455
471
|
done
|
456
472
|
|
457
|
-
unlink_netns $TARGET_PID
|
473
|
+
unlink_netns "$TARGET_PID"
|
458
474
|
done
|
459
475
|
|
460
476
|
return $RES
|
@@ -483,12 +499,12 @@ function handle_detach() {
|
|
483
499
|
INTF=$(echo $DEVICE_PAIR | awk -F':' '{ print $1 }' )
|
484
500
|
BRIDGE=$(echo $DEVICE_PAIR | awk -F':' '{ print $2 }' )
|
485
501
|
|
486
|
-
|
487
|
-
|
488
|
-
|
502
|
+
HOST_IFNAME=v${INTF}h${TARGET_PID}
|
503
|
+
CONTAINER_IFNAME=v${INTF}c${TARGET_PID}
|
504
|
+
$DEBUG - interface pair names are ${HOST_IFNAME}/${CONTAINER_IFNAME}
|
489
505
|
|
490
506
|
$DEBUG - removing $HOST_IFNAME from $BRIDGE
|
491
|
-
|
507
|
+
remove_device_from_switch "$HOST_IFNAME" "$BRIDGE"
|
492
508
|
if [[ $? -ne 0 ]]; then
|
493
509
|
log_error removing device from bridge. aborting
|
494
510
|
RES=1
|
@@ -496,7 +512,7 @@ function handle_detach() {
|
|
496
512
|
fi
|
497
513
|
|
498
514
|
$DEBUG - delete interfaces
|
499
|
-
|
515
|
+
delete_interfaces "$HOST_IFNAME" "$CONTAINER_IFNAME" "$TARGET_PID" "$INTF"
|
500
516
|
if [[ $? -ne 0 ]]; then
|
501
517
|
log_error deleting interfaces
|
502
518
|
RES=1
|
@@ -504,7 +520,7 @@ function handle_detach() {
|
|
504
520
|
fi
|
505
521
|
done
|
506
522
|
|
507
|
-
unlink_netns $TARGET_PID
|
523
|
+
unlink_netns "$TARGET_PID"
|
508
524
|
done
|
509
525
|
|
510
526
|
return $RES
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dewiring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Schmidt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -43,13 +43,11 @@ description: System and Network architecture generator
|
|
43
43
|
email: gem@de-wiring.net
|
44
44
|
executables:
|
45
45
|
- wire
|
46
|
-
- wire-network-container.sh
|
47
46
|
extensions: []
|
48
47
|
extra_rdoc_files: []
|
49
48
|
files:
|
50
49
|
- bin/wire
|
51
|
-
-
|
52
|
-
- lib/test_fig.rb
|
50
|
+
- lib/wire-network-container.sh
|
53
51
|
- lib/wire.rb
|
54
52
|
- lib/wire/cli.rb
|
55
53
|
- lib/wire/cli/cli_commands.rb
|
@@ -62,6 +60,7 @@ files:
|
|
62
60
|
- lib/wire/commands/init_interactive.rb
|
63
61
|
- lib/wire/commands/spec_command.rb
|
64
62
|
- lib/wire/commands/spec_templates.rb
|
63
|
+
- lib/wire/commands/spec_writer.rb
|
65
64
|
- lib/wire/commands/up_command.rb
|
66
65
|
- lib/wire/commands/up_command_handler.rb
|
67
66
|
- lib/wire/commands/updown_command_base.rb
|
data/lib/test_fig.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# The MIT License (MIT)
|
4
|
-
# Copyright (c) 2014 Andreas Schmidt, andreas@de-wiring.net
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
|
9
|
-
#
|
10
|
-
# modules
|
11
|
-
#
|
12
|
-
require_relative 'wire/common.rb'
|
13
|
-
require_relative 'wire/cli.rb'
|
14
|
-
require_relative 'wire/commands.rb'
|
15
|
-
require_relative 'wire/model.rb'
|
16
|
-
require_relative 'wire/execution.rb'
|
17
|
-
require_relative 'wire/resource.rb'
|
18
|
-
|
19
|
-
include Wire
|
20
|
-
|
21
|
-
$log.level = Logger::DEBUG
|
22
|
-
|
23
|
-
fa = Wire::Resource::FigAdapter.new('wiredmz', 'test/d1/fig/fig_dmz.yaml')
|
24
|
-
pp fa
|
25
|
-
|
26
|
-
$log.info 'Checking if containers are up'
|
27
|
-
r = fa.up?
|
28
|
-
$log.info "Result=#{r}"
|
29
|
-
|
30
|
-
$log.info 'Bringing it up...'
|
31
|
-
r = fa.up
|
32
|
-
$log.info "Result=#{r}"
|
33
|
-
|
34
|
-
$log.info 'Checking if containers are up'
|
35
|
-
r = fa.up?
|
36
|
-
$log.info "Result=#{r}"
|
37
|
-
|
38
|
-
$log.info "IDs=#{fa.up_ids}"
|
39
|
-
|
40
|
-
$log.info 'Taking it down...'
|
41
|
-
r = fa.down
|
42
|
-
$log.info "Result=#{r}"
|
43
|
-
|
44
|
-
$log.info 'Checking if containers are up'
|
45
|
-
r = fa.up?
|
46
|
-
$log.info "Result=#{r}"
|