testlab 1.16.0 → 1.16.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/tl CHANGED
@@ -97,7 +97,7 @@ flag [:c, :config]
97
97
  desc 'Path to Log file'
98
98
  default_value STDOUT
99
99
  arg_name 'path/to/log_file'
100
- flag [:L, :log_file]
100
+ flag [:log]
101
101
 
102
102
  pre do |global,command,options,args|
103
103
  @testlab_start_time = Time.now.utc
@@ -105,7 +105,7 @@ pre do |global,command,options,args|
105
105
  (global[:verbose] == true) and (ENV['LOG_LEVEL'] = 'DEBUG')
106
106
 
107
107
  @ui = ZTK::UI.new(
108
- :logger => ZTK::Logger.new(global[:log_file]),
108
+ :logger => ZTK::Logger.new(global[:log]),
109
109
  :verbose => global[:verbose],
110
110
  :quiet => global[:quiet]
111
111
  )
@@ -199,6 +199,7 @@ end
199
199
  desc 'Display the lab status'
200
200
  command :status do |status|
201
201
  status.action do |global_options,options,args|
202
+ @testlab.ui.logger.level = ZTK::Logger::WARN
202
203
  @testlab.ui.stdout.puts("\nNODES:".green.bold)
203
204
  commands[:node].commands[:status].execute({}, {}, [])
204
205
 
@@ -43,8 +43,9 @@ class TestLab
43
43
  when :get, :put then
44
44
  elapsed = (Time.now - @start_time)
45
45
  current_size = (args[1] + args[2].length)
46
+ message = ((action == :get) ? 'downloading from' : 'uploading to')
46
47
 
47
- transfer_message(%(uploading to node:), args[0].local, current_size, @total_size, elapsed)
48
+ transfer_message(%(#{message} node:), args[0].local, current_size, @total_size, elapsed)
48
49
 
49
50
  when :finish
50
51
  @ui.stdout.puts
@@ -73,7 +74,8 @@ class TestLab
73
74
  # Ensure the container is stopped before we attempt to export it.
74
75
  self.down
75
76
 
76
- self.lxc.attach(%(-- /bin/bash -c 'apt-get clean'))
77
+ self.lxc.execute(%(/bin/bash -c 'apt-get -y autoremove'))
78
+ self.lxc.execute(%(/bin/bash -c 'apt-get -y clean'))
77
79
 
78
80
  export_tempfile = Tempfile.new('export')
79
81
  remote_filename = File.basename(export_tempfile.path.dup)
@@ -85,13 +87,13 @@ class TestLab
85
87
  root_fs_path = self.lxc.fs_root.split(File::SEPARATOR).last
86
88
 
87
89
  please_wait(:ui => @ui, :message => format_object_action(self, 'Compress', :cyan)) do
88
- self.node.bootstrap(<<-EOF)
89
- du -sh #{self.lxc.container_root}
90
- cd #{self.lxc.container_root}
91
- find #{root_fs_path} -depth -print0 | cpio -o0 | pbzip2 -#{compression} -vfczm#{PBZIP2_MEMORY} > #{remote_file}
92
- chown ${SUDO_USER}:${SUDO_USER} #{remote_file}
93
- ls -lah #{remote_file}
94
- EOF
90
+ self.node.bootstrap(<<-EOSCRIPT)
91
+ du -sh #{self.lxc.container_root}
92
+ cd #{self.lxc.container_root}
93
+ find #{root_fs_path} -depth -print0 | cpio -o0 | pbzip2 -#{compression} -vfczm#{PBZIP2_MEMORY} > #{remote_file}
94
+ chown ${SUDO_USER}:${SUDO_USER} #{remote_file}
95
+ ls -lah #{remote_file}
96
+ EOSCRIPT
95
97
  end
96
98
 
97
99
  File.exists?(local_file) and FileUtils.rm_f(local_file)
@@ -100,9 +102,9 @@ EOF
100
102
 
101
103
  self.node.download(remote_file, local_file, :on_progress => method(:progress_callback), :read_size => READ_SIZE, :use_scp => true)
102
104
 
103
- self.node.bootstrap(<<-EOF)
104
- rm -fv #{remote_file}
105
- EOF
105
+ self.node.bootstrap(<<-EOSCRIPT)
106
+ rm -fv #{remote_file}
107
+ EOSCRIPT
106
108
 
107
109
  @ui.stdout.puts(format_message("Your shipping container is now exported and available at '#{local_file}'!".green.bold))
108
110
 
@@ -49,7 +49,10 @@ class TestLab
49
49
 
50
50
  # Destroy Vagrant-controlled VM
51
51
  def destroy
52
+ @state = nil
52
53
  self.alive? and self.down
54
+
55
+ @state = nil
53
56
  self.exists? and self.vagrant_cli("destroy", "--force", self.instance_id)
54
57
 
55
58
  true
@@ -59,6 +62,7 @@ class TestLab
59
62
 
60
63
  # Online Vagrant-controlled VM
61
64
  def up
65
+ @state = nil
62
66
  self.vagrant_cli("up", self.instance_id)
63
67
 
64
68
  ZTK::TCPSocketCheck.new(:host => self.ip, :port => self.port, :wait => 120, :ui => @ui).wait
@@ -68,8 +72,8 @@ class TestLab
68
72
 
69
73
  # Halt Vagrant-controlled VM
70
74
  def down(*args)
75
+ @state = nil
71
76
  arguments = (%W(halt #{self.instance_id}) + args).flatten.compact
72
-
73
77
  self.vagrant_cli(*arguments)
74
78
 
75
79
  true
@@ -151,15 +155,18 @@ class TestLab
151
155
 
152
156
  # Inquire the state of the Vagrant-controlled VM
153
157
  def state
154
- output = self.vagrant_cli("status").output.split("\n").select{ |line| (line =~ /#{self.instance_id}/) }.first
155
- result = UNKNOWN_STATE
156
- ALL_STATES.map{ |s| s.to_s.gsub('_', ' ') }.each do |state|
157
- if output =~ /#{state}/
158
- result = state.to_s.gsub(' ', '_')
159
- break
158
+ if @state.nil?
159
+ output = self.vagrant_cli("status").output.split("\n").select{ |line| (line =~ /#{self.instance_id}/) }.first
160
+ result = UNKNOWN_STATE
161
+ ALL_STATES.map{ |s| s.to_s.gsub('_', ' ') }.each do |state|
162
+ if output =~ /#{state}/
163
+ result = state.to_s.gsub(' ', '_')
164
+ break
165
+ end
160
166
  end
167
+ @state = result.to_sym
161
168
  end
162
- result.to_sym
169
+ @state
163
170
  end
164
171
 
165
172
  ################################################################################
@@ -32,7 +32,6 @@ class TestLab
32
32
 
33
33
  true
34
34
  end
35
- alias :on_node_up :on_node_provision
36
35
 
37
36
  # Bind: Container Provision
38
37
  #
@@ -41,7 +41,6 @@ class TestLab
41
41
 
42
42
  true
43
43
  end
44
- alias :on_node_up :on_node_provision
45
44
 
46
45
  # Resolv: Container Provision
47
46
  #
@@ -1,6 +1,3 @@
1
- set -x
2
- set -e
3
-
4
1
  export DEBIAN_FRONTEND="noninteractive"
5
2
 
6
3
  <% if !@apt[:multiarch].nil? && (@apt[:multiarch] == false) -%>
@@ -1,6 +1,3 @@
1
- set -x
2
- set -e
3
-
4
1
  export DEBIAN_FRONTEND="noninteractive"
5
2
 
6
3
  if ! dpkg --status apt-cacher-ng &> /dev/null; then
@@ -1,6 +1,3 @@
1
- set -x
2
- set -e
3
-
4
1
  export DEBIAN_FRONTEND="noninteractive"
5
2
 
6
3
  # Update APT and ensure our required packages are installed
@@ -1,6 +1,3 @@
1
- set -x
2
- set -e
3
-
4
1
  dpkg --status bind9 &> /dev/null || <%= (@resolv[:object] == :container).inspect %>
5
2
 
6
3
  cat <<EOF | tee /etc/resolv.conf
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "1.16.0"
4
+ VERSION = "1.16.1"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.16.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Zachary Patten
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-01-11 00:00:00.000000000 Z
12
+ date: 2014-01-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: gli
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: lxc
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: ztk
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: activesupport
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: bundler
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ! '>='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ! '>='
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: pry
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ! '>='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ! '>='
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rake
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: redcarpet
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ! '>='
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ! '>='
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: aruba
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ! '>='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ! '>='
137
156
  - !ruby/object:Gem::Version
@@ -139,6 +158,7 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: rspec
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - ! '>='
144
164
  - !ruby/object:Gem::Version
@@ -146,6 +166,7 @@ dependencies:
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
171
  - - ! '>='
151
172
  - !ruby/object:Gem::Version
@@ -153,6 +174,7 @@ dependencies:
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: yard
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - ! '>='
158
180
  - !ruby/object:Gem::Version
@@ -160,6 +182,7 @@ dependencies:
160
182
  type: :development
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - ! '>='
165
188
  - !ruby/object:Gem::Version
@@ -167,6 +190,7 @@ dependencies:
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: coveralls
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
195
  - - ! '>='
172
196
  - !ruby/object:Gem::Version
@@ -174,6 +198,7 @@ dependencies:
174
198
  type: :development
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
177
202
  requirements:
178
203
  - - ! '>='
179
204
  - !ruby/object:Gem::Version
@@ -314,26 +339,27 @@ files:
314
339
  homepage: http://hackers.lookout.com/testlab/
315
340
  licenses:
316
341
  - Apache 2.0
317
- metadata: {}
318
342
  post_install_message:
319
343
  rdoc_options: []
320
344
  require_paths:
321
345
  - lib
322
346
  required_ruby_version: !ruby/object:Gem::Requirement
347
+ none: false
323
348
  requirements:
324
349
  - - ! '>='
325
350
  - !ruby/object:Gem::Version
326
351
  version: '0'
327
352
  required_rubygems_version: !ruby/object:Gem::Requirement
353
+ none: false
328
354
  requirements:
329
355
  - - ! '>='
330
356
  - !ruby/object:Gem::Version
331
357
  version: '0'
332
358
  requirements: []
333
359
  rubyforge_project:
334
- rubygems_version: 2.1.11
360
+ rubygems_version: 1.8.25
335
361
  signing_key:
336
- specification_version: 4
362
+ specification_version: 3
337
363
  summary: A toolkit for building virtual computer labs
338
364
  test_files:
339
365
  - features/step_definitions/container_steps.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NmQ5ZmI1ZmRjYTJhNjJjOGNkOWRiYjE1ODQ3ZDM4OGVjODAxNjRlNw==
5
- data.tar.gz: !binary |-
6
- NzU1NDg1NDc0MjM4MWZjZmQwZThhYjQyNWY2NjQ4YjNjMzRjODEwMw==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- YjRmYTkzZWM3ZTEwOWI5MjMwY2U1NjY1MjI4YTdmYWVmYWY4OWYyOTNmNzUx
10
- ZTY4NDkxODdiZWMwNzI2MjY1Mzc1MjQwZmI0ZjUyYmIzY2FhY2U2ZjhjYzM3
11
- M2Y1MGIwMjcxOTk2YTU2NDkzZGIzYThlOThiNWQxNjQ4YmQ5YjQ=
12
- data.tar.gz: !binary |-
13
- NDkzMTBjZTI2ODUzZDI3OGQyZjc0OWI3YzMxMWVjMDNhZTRjYTA4MzE4Zjg0
14
- MDQxZmRjMWVkZjFmYTk3MmZhOTA4MzdkOTMxMTgyOGFiYmQ5NjRmOWFjOTk2
15
- MGJlZTFmMjQ3OTQxMjNlNDk1ZWNhMTNhZWMzMDk4M2MyMzc5ZGM=