testlab 0.6.3 → 0.6.4

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.
data/bin/tl CHANGED
@@ -187,6 +187,44 @@ EOF
187
187
  end
188
188
  end
189
189
 
190
+ # NODE CREATE
191
+ ##############
192
+ c.desc 'Create a node'
193
+ c.long_desc <<-EOF
194
+ Create a node. The node is created.
195
+ EOF
196
+ c.command :create do |create|
197
+ create.action do |global_options, options, args|
198
+ if options[:id].nil?
199
+ help_now!('id is required') if options[:id].nil?
200
+ else
201
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
202
+ node.nil? and raise TestLab::TestLabError, "We could not find the node you screateplied!"
203
+
204
+ node.create
205
+ end
206
+ end
207
+ end
208
+
209
+ # NODE DESTROY
210
+ ############
211
+ c.desc 'Destroy a node'
212
+ c.long_desc <<-EOF
213
+ Destroy a node. The node is stopped and destroyed.
214
+ EOF
215
+ c.command :destroy do |destroy|
216
+ destroy.action do |global_options, options, args|
217
+ if options[:id].nil?
218
+ help_now!('id is required') if options[:id].nil?
219
+ else
220
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
221
+ node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
222
+
223
+ node.destroy
224
+ end
225
+ end
226
+ end
227
+
190
228
  # NODE SETUP
191
229
  #############
192
230
  c.desc 'Setup a node'
@@ -533,6 +571,44 @@ EOF
533
571
  end
534
572
  end
535
573
 
574
+ # CONTAINER CREATE
575
+ ###################
576
+ c.desc 'Create a container'
577
+ c.long_desc <<-EOF
578
+ Create a container. The container is created.
579
+ EOF
580
+ c.command :create do |create|
581
+ create.action do |global_options, options, args|
582
+ if options[:id].nil?
583
+ help_now!('id is required') if options[:id].nil?
584
+ else
585
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
586
+ container.nil? and raise TestLab::TestLabError, "We could not find the container you screateplied!"
587
+
588
+ container.create
589
+ end
590
+ end
591
+ end
592
+
593
+ # CONTAINER DESTROY
594
+ ####################
595
+ c.desc 'Destroy a container'
596
+ c.long_desc <<-EOF
597
+ Destroy a container. The container is stopped and destroyed.
598
+ EOF
599
+ c.command :destroy do |destroy|
600
+ destroy.action do |global_options, options, args|
601
+ if options[:id].nil?
602
+ help_now!('id is required') if options[:id].nil?
603
+ else
604
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
605
+ container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
606
+
607
+ container.destroy
608
+ end
609
+ end
610
+ end
611
+
536
612
  # CONTAINER SETUP
537
613
  ####################
538
614
  c.desc 'Setup a container'
@@ -60,6 +60,10 @@ class TestLab
60
60
 
61
61
  (self.lxc.state != :running) and raise ContainerError, "The container failed to online!"
62
62
 
63
+ self.users.each do |user|
64
+ user.setup
65
+ end
66
+
63
67
  end
64
68
 
65
69
  true
@@ -18,10 +18,6 @@ class TestLab
18
18
 
19
19
  please_wait(:ui => @ui, :message => format_object_action(self, 'Setup', :green)) do
20
20
 
21
- self.users.each do |user|
22
- user.setup
23
- end
24
-
25
21
  self.provisioners.each do |provisioner|
26
22
  @ui.logger.info { ">>>>> SETUP CONTAINER PROVISIONER: #{provisioner} <<<<<" }
27
23
  p = provisioner.new(self.config, @ui)
@@ -36,13 +36,14 @@ class TestLab
36
36
  user_authkeys2 = File.join(user_home_dir, ".ssh", "authorized_keys2")
37
37
 
38
38
  authkeys = {
39
- node_authkeys => user_authkeys,
40
- node_authkeys => user_authkeys2
39
+ user_authkeys => node_authkeys,
40
+ user_authkeys2 => node_authkeys
41
41
  }
42
42
 
43
- authkeys.each do |source, destination|
43
+ authkeys.each do |destination, source|
44
+ @ui.logger.info { "SOURCE: #{source} >>> #{destination}" }
44
45
  self.container.node.ssh.exec(%(sudo mkdir -pv #{File.dirname(destination)}))
45
- self.container.node.ssh.exec(%(sudo cp -v #{source} #{destination}))
46
+ self.container.node.ssh.exec(%(sudo grep "$(cat #{source})" #{destination} || sudo cat #{source} | sudo tee -a #{destination}))
46
47
  self.container.node.ssh.exec(%(sudo chmod -v 644 #{destination}))
47
48
  end
48
49
 
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "0.6.3"
4
+ VERSION = "0.6.4"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -293,7 +293,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
293
  version: '0'
294
294
  segments:
295
295
  - 0
296
- hash: -429496536353905042
296
+ hash: -2213038808322166943
297
297
  required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  none: false
299
299
  requirements:
@@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
302
  version: '0'
303
303
  segments:
304
304
  - 0
305
- hash: -429496536353905042
305
+ hash: -2213038808322166943
306
306
  requirements: []
307
307
  rubyforge_project:
308
308
  rubygems_version: 1.8.25