testlab 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -81,9 +81,14 @@ You can also destroy it (only works for VM backed providers; this would be a NO-
81
81
 
82
82
  # Interacting with Containers
83
83
 
84
+ Most commands dealing will containers will take this argument:
85
+
86
+ COMMAND OPTIONS
87
+ -n, --name=container - Container ID or Name (default: none)
88
+
84
89
  You can interact with containers via SSH:
85
90
 
86
- tl container ssh -i <container ID>
91
+ tl container ssh -n <container ID>
87
92
 
88
93
  You can pass an optional alternate username and/or identity to use. By default TestLab will attempt to SSH as the user defined in the `Labfile` for that container, otherwise the default user for the containers distro is used.
89
94
 
@@ -96,18 +101,18 @@ You can pass an optional alternate username and/or identity to use. By default
96
101
 
97
102
  COMMAND OPTIONS
98
103
  -u, --user=username - Specify an SSH Username to use (default: none)
99
- -k, --key=key - Specify an SSH Identity Key to use (default: none)
104
+ -i, --identity=key - Specify an SSH Identity Key to use (default: none)
100
105
 
101
106
  You can individually online, offline, create or destroy containers:
102
107
 
103
- tl container down -i server-www-1
104
- tl container up -i server-www-1
105
- tl container setup -i server-www-1
106
- tl container teardown -i server-www-1
108
+ tl container down -n server-www-1
109
+ tl container up -n server-www-1
110
+ tl container setup -n server-www-1
111
+ tl container teardown -n server-www-1
107
112
 
108
113
  You can recycle a container, effectively destroying then creating it again, provisioning it back to a "pristine" condition.
109
114
 
110
- tl container recycle -i server-www-1
115
+ tl container recycle -n server-www-1
111
116
 
112
117
  # Ephemeral Container Cloning
113
118
 
@@ -115,22 +120,22 @@ As it stands attempting to iterate infrastructure while developing with Vagrant
115
120
 
116
121
  Here we are cloning the container for the first time. It takes a bit longer than normal because TestLab is actually shutting down the container so it can be retained as the "pristine" copy of it, and starting up a ephemeral container in its place. Subsequent calls to clone are very fast.
117
122
 
118
- $ tl container clone -i server-www-1
123
+ $ tl container clone -n server-www-1
119
124
  [TL] TestLab v0.6.1 Loaded
120
125
  [TL] container server-www-1 clone # Completed in 13.0116 seconds!
121
- $ tl container clone -i server-www-1
126
+ $ tl container clone -n server-www-1
122
127
  [TL] TestLab v0.6.1 Loaded
123
128
  [TL] container server-www-1 clone # Completed in 0.9169 seconds!
124
- $ tl container clone -i server-www-1
129
+ $ tl container clone -n server-www-1
125
130
  [TL] TestLab v0.6.1 Loaded
126
131
  [TL] container server-www-1 clone # Completed in 1.0794 seconds!
127
- $ tl container clone -i server-www-1
132
+ $ tl container clone -n server-www-1
128
133
  [TL] TestLab v0.6.1 Loaded
129
134
  [TL] container server-www-1 clone # Completed in 1.0281 seconds!
130
135
 
131
136
  We can also see the containers status reflects that it is a clone currently:
132
137
 
133
- $ tl container status -i server-www-1
138
+ $ tl container status -n server-www-1
134
139
  [TL] TestLab v0.6.1 Loaded
135
140
  +----------------------------------------------+
136
141
  | NODE_ID: vagrant |
@@ -146,17 +151,17 @@ We can also see the containers status reflects that it is a clone currently:
146
151
 
147
152
  We can easily revert it back to a full container if we want to make changes to it:
148
153
 
149
- $ tl container up -i server-www-1
154
+ $ tl container up -n server-www-1
150
155
 
151
156
  We can even recycle it while it is in a cloned state:
152
157
 
153
- $ tl container recycle -i server-www-1
158
+ $ tl container recycle -n server-www-1
154
159
 
155
160
  # Network Routes
156
161
 
157
162
  TestLab will add network routes for any networks defined in the `Labfile` with the route flag set to true. This will allow you to directly interact with containers. Here is an example of the routes added with the multi-network `Labfile`.
158
163
 
159
- $ tl network route show -i labnet
164
+ $ tl network route show -n labnet
160
165
  [TL] TestLab v0.6.1 Loaded
161
166
  TestLab routes:
162
167
  10.10.0.0 192.168.33.239 255.255.0.0 UG 0 0 0 vboxnet0
data/bin/tl CHANGED
@@ -110,16 +110,16 @@ command :node do |c|
110
110
 
111
111
  c.desc 'Node ID or Name'
112
112
  c.arg_name 'node'
113
- c.flag [:i, :id]
113
+ c.flag [:n, :name]
114
114
 
115
115
  # NODE SSH
116
116
  ###########
117
117
  c.desc 'Open an SSH console to a node'
118
118
  c.command :ssh do |ssh|
119
119
  ssh.action do |global_options,options,args|
120
- help_now!('id is required') if options[:id].nil?
120
+ help_now!('name is required') if options[:name].nil?
121
121
 
122
- node = @testlab.nodes.select{ |n| n.id.to_sym == options[:id].to_sym }.first
122
+ node = @testlab.nodes.select{ |n| n.id.to_sym == options[:name].to_sym }.first
123
123
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
124
124
 
125
125
  node.ssh.console
@@ -132,14 +132,14 @@ command :node do |c|
132
132
  c.long_desc 'Displays the status of all nodes or a single node if supplied via the ID parameter.'
133
133
  c.command :status do |status|
134
134
  status.action do |global_options, options, args|
135
- if options[:id].nil?
135
+ if options[:name].nil?
136
136
  # No ID supplied; show everything
137
137
  ZTK::Report.new(:ui => @testlab.ui).spreadsheet(@testlab.nodes, TestLab::Node::STATUS_KEYS) do |node|
138
138
  OpenStruct.new(node.status)
139
139
  end
140
140
  else
141
141
  # ID supplied; show just that item
142
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
142
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
143
143
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
144
144
 
145
145
  ZTK::Report.new(:ui => @testlab.ui).list(node, TestLab::Node::STATUS_KEYS) do |node|
@@ -157,10 +157,10 @@ Up a node. The node is started and brought online.
157
157
  EOF
158
158
  c.command :up do |up|
159
159
  up.action do |global_options, options, args|
160
- if options[:id].nil?
161
- help_now!('id is required') if options[:id].nil?
160
+ if options[:name].nil?
161
+ help_now!('name is required') if options[:name].nil?
162
162
  else
163
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
163
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
164
164
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
165
165
 
166
166
  node.up
@@ -176,10 +176,10 @@ Down a node. The node is stopped taking it offline.
176
176
  EOF
177
177
  c.command :down do |down|
178
178
  down.action do |global_options, options, args|
179
- if options[:id].nil?
180
- help_now!('id is required') if options[:id].nil?
179
+ if options[:name].nil?
180
+ help_now!('name is required') if options[:name].nil?
181
181
  else
182
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
182
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
183
183
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
184
184
 
185
185
  node.down
@@ -195,10 +195,10 @@ Create a node. The node is created.
195
195
  EOF
196
196
  c.command :create do |create|
197
197
  create.action do |global_options, options, args|
198
- if options[:id].nil?
199
- help_now!('id is required') if options[:id].nil?
198
+ if options[:name].nil?
199
+ help_now!('name is required') if options[:name].nil?
200
200
  else
201
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
201
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
202
202
  node.nil? and raise TestLab::TestLabError, "We could not find the node you screateplied!"
203
203
 
204
204
  node.create
@@ -214,10 +214,10 @@ Destroy a node. The node is stopped and destroyed.
214
214
  EOF
215
215
  c.command :destroy do |destroy|
216
216
  destroy.action do |global_options, options, args|
217
- if options[:id].nil?
218
- help_now!('id is required') if options[:id].nil?
217
+ if options[:name].nil?
218
+ help_now!('name is required') if options[:name].nil?
219
219
  else
220
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
220
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
221
221
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
222
222
 
223
223
  node.destroy
@@ -233,10 +233,10 @@ Setup a node. The node is created, started and provisioned.
233
233
  EOF
234
234
  c.command :setup do |setup|
235
235
  setup.action do |global_options, options, args|
236
- if options[:id].nil?
237
- help_now!('id is required') if options[:id].nil?
236
+ if options[:name].nil?
237
+ help_now!('name is required') if options[:name].nil?
238
238
  else
239
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
239
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
240
240
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
241
241
 
242
242
  node.setup
@@ -252,10 +252,10 @@ Teardown a node. The node is offlined and destroyed.
252
252
  EOF
253
253
  c.command :teardown do |teardown|
254
254
  teardown.action do |global_options, options, args|
255
- if options[:id].nil?
256
- help_now!('id is required') if options[:id].nil?
255
+ if options[:name].nil?
256
+ help_now!('name is required') if options[:name].nil?
257
257
  else
258
- node = @testlab.nodes.select{ |c| c.id.to_sym == options[:id].to_sym }.first
258
+ node = @testlab.nodes.select{ |c| c.id.to_sym == options[:name].to_sym }.first
259
259
  node.nil? and raise TestLab::TestLabError, "We could not find the node you supplied!"
260
260
 
261
261
  node.teardown
@@ -273,7 +273,7 @@ command :network do |c|
273
273
 
274
274
  c.desc 'Network ID or Name'
275
275
  c.arg_name 'network'
276
- c.flag [:i, :id]
276
+ c.flag [:n, :name]
277
277
 
278
278
 
279
279
  # ROUTES
@@ -286,9 +286,9 @@ command :network do |c|
286
286
  route.desc 'Add routes to lab networks'
287
287
  route.command :add do |add|
288
288
  add.action do |global_options,options,args|
289
- help_now!('id is required') if options[:id].nil?
289
+ help_now!('name is required') if options[:name].nil?
290
290
 
291
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
291
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
292
292
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
293
293
 
294
294
  network.manage_route(:add)
@@ -302,9 +302,9 @@ command :network do |c|
302
302
  route.desc 'Delete routes to lab networks'
303
303
  route.command :del do |del|
304
304
  del.action do |global_options,options,args|
305
- help_now!('id is required') if options[:id].nil?
305
+ help_now!('name is required') if options[:name].nil?
306
306
 
307
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
307
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
308
308
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
309
309
 
310
310
  network.manage_route(:del)
@@ -318,9 +318,9 @@ command :network do |c|
318
318
  route.desc 'Show routes to lab networks'
319
319
  route.command :show do |show|
320
320
  show.action do |global_options,options,args|
321
- help_now!('id is required') if options[:id].nil?
321
+ help_now!('name is required') if options[:name].nil?
322
322
 
323
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
323
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
324
324
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
325
325
 
326
326
  @testlab.ui.stdout.puts("TestLab routes:".green.bold)
@@ -340,7 +340,7 @@ command :network do |c|
340
340
  c.long_desc 'Displays the status of all networks or a single network if supplied via the ID parameter.'
341
341
  c.command :status do |status|
342
342
  status.action do |global_options, options, args|
343
- if options[:id].nil?
343
+ if options[:name].nil?
344
344
  # No ID supplied; show everything
345
345
  networks = @testlab.networks.delete_if{|n| n.node.dead? }
346
346
  if networks.count == 0
@@ -352,7 +352,7 @@ command :network do |c|
352
352
  end
353
353
  else
354
354
  # ID supplied; show just that item
355
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
355
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
356
356
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
357
357
 
358
358
  ZTK::Report.new(:ui => @testlab.ui).list(network, TestLab::Network::STATUS_KEYS) do |network|
@@ -370,10 +370,10 @@ Up a network. The network is started and brought online.
370
370
  EOF
371
371
  c.command :up do |up|
372
372
  up.action do |global_options, options, args|
373
- if options[:id].nil?
374
- help_now!('id is required') if options[:id].nil?
373
+ if options[:name].nil?
374
+ help_now!('name is required') if options[:name].nil?
375
375
  else
376
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
376
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
377
377
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
378
378
 
379
379
  network.up
@@ -389,10 +389,10 @@ Down a network. The network is stopped taking it offline.
389
389
  EOF
390
390
  c.command :down do |down|
391
391
  down.action do |global_options, options, args|
392
- if options[:id].nil?
393
- help_now!('id is required') if options[:id].nil?
392
+ if options[:name].nil?
393
+ help_now!('name is required') if options[:name].nil?
394
394
  else
395
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
395
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
396
396
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
397
397
 
398
398
  network.down
@@ -408,10 +408,10 @@ Setup a network. The network is created, started and provisioned.
408
408
  EOF
409
409
  c.command :setup do |setup|
410
410
  setup.action do |global_options, options, args|
411
- if options[:id].nil?
412
- help_now!('id is required') if options[:id].nil?
411
+ if options[:name].nil?
412
+ help_now!('name is required') if options[:name].nil?
413
413
  else
414
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
414
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
415
415
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
416
416
 
417
417
  network.setup
@@ -427,10 +427,10 @@ Teardown a network. The network is offlined and destroyed.
427
427
  EOF
428
428
  c.command :teardown do |teardown|
429
429
  teardown.action do |global_options, options, args|
430
- if options[:id].nil?
431
- help_now!('id is required') if options[:id].nil?
430
+ if options[:name].nil?
431
+ help_now!('name is required') if options[:name].nil?
432
432
  else
433
- network = @testlab.networks.select{ |c| c.id.to_sym == options[:id].to_sym }.first
433
+ network = @testlab.networks.select{ |c| c.id.to_sym == options[:name].to_sym }.first
434
434
  network.nil? and raise TestLab::TestLabError, "We could not find the network you supplied!"
435
435
 
436
436
  network.teardown
@@ -448,7 +448,7 @@ command :container do |c|
448
448
 
449
449
  c.desc 'Container ID or Name'
450
450
  c.arg_name 'container'
451
- c.flag [:i, :id]
451
+ c.flag [:n, :name]
452
452
 
453
453
  # CONTAINER SSH
454
454
  ################
@@ -461,17 +461,17 @@ command :container do |c|
461
461
 
462
462
  ssh.desc 'Specify an SSH Identity Key to use'
463
463
  ssh.arg_name 'key'
464
- ssh.flag [:k, :key]
464
+ ssh.flag [:i, :identity]
465
465
 
466
466
  ssh.action do |global_options, options, args|
467
- help_now!('id is required') if options[:id].nil?
467
+ help_now!('name is required') if options[:name].nil?
468
468
 
469
- container = @testlab.containers.select{ |n| n.id.to_sym == options[:id].to_sym }.first
469
+ container = @testlab.containers.select{ |n| n.id.to_sym == options[:name].to_sym }.first
470
470
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
471
471
 
472
472
  ssh_options = Hash.new
473
473
  ssh_options[:user] = options[:user]
474
- ssh_options[:keys] = options[:key]
474
+ ssh_options[:keys] = options[:identity]
475
475
 
476
476
  container.ssh(ssh_options).console
477
477
  end
@@ -485,7 +485,7 @@ Displays the status of all containers or a single container if supplied via the
485
485
  EOF
486
486
  c.command :status do |status|
487
487
  status.action do |global_options, options, args|
488
- if options[:id].nil?
488
+ if options[:name].nil?
489
489
  # No ID supplied; show everything
490
490
  containers = @testlab.containers.delete_if{ |c| c.node.dead? }
491
491
  if containers.count == 0
@@ -499,7 +499,7 @@ EOF
499
499
  end
500
500
  else
501
501
  # ID supplied; show just that item
502
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
502
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
503
503
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
504
504
 
505
505
  ZTK::Report.new(:ui => @testlab.ui).list(container, TestLab::Container::STATUS_KEYS) do |container|
@@ -521,10 +521,10 @@ Down -> Destroy -> Create -> Up
521
521
  EOF
522
522
  c.command :recycle do |recycle|
523
523
  recycle.action do |global_options, options, args|
524
- if options[:id].nil?
525
- help_now!('id is required') if options[:id].nil?
524
+ if options[:name].nil?
525
+ help_now!('name is required') if options[:name].nil?
526
526
  else
527
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
527
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
528
528
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
529
529
 
530
530
  container.teardown
@@ -541,10 +541,10 @@ Up a container. The container is started and brought online.
541
541
  EOF
542
542
  c.command :up do |up|
543
543
  up.action do |global_options, options, args|
544
- if options[:id].nil?
545
- help_now!('id is required') if options[:id].nil?
544
+ if options[:name].nil?
545
+ help_now!('name is required') if options[:name].nil?
546
546
  else
547
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
547
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
548
548
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
549
549
 
550
550
  container.up
@@ -560,10 +560,10 @@ Down a container. The container is stopped taking it offline.
560
560
  EOF
561
561
  c.command :down do |down|
562
562
  down.action do |global_options, options, args|
563
- if options[:id].nil?
564
- help_now!('id is required') if options[:id].nil?
563
+ if options[:name].nil?
564
+ help_now!('name is required') if options[:name].nil?
565
565
  else
566
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
566
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
567
567
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
568
568
 
569
569
  container.down
@@ -579,10 +579,10 @@ Create a container. The container is created.
579
579
  EOF
580
580
  c.command :create do |create|
581
581
  create.action do |global_options, options, args|
582
- if options[:id].nil?
583
- help_now!('id is required') if options[:id].nil?
582
+ if options[:name].nil?
583
+ help_now!('name is required') if options[:name].nil?
584
584
  else
585
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
585
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
586
586
  container.nil? and raise TestLab::TestLabError, "We could not find the container you screateplied!"
587
587
 
588
588
  container.create
@@ -598,10 +598,10 @@ Destroy a container. The container is stopped and destroyed.
598
598
  EOF
599
599
  c.command :destroy do |destroy|
600
600
  destroy.action do |global_options, options, args|
601
- if options[:id].nil?
602
- help_now!('id is required') if options[:id].nil?
601
+ if options[:name].nil?
602
+ help_now!('name is required') if options[:name].nil?
603
603
  else
604
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
604
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
605
605
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
606
606
 
607
607
  container.destroy
@@ -617,10 +617,10 @@ Setup a container. The container is created, started and provisioned.
617
617
  EOF
618
618
  c.command :setup do |setup|
619
619
  setup.action do |global_options, options, args|
620
- if options[:id].nil?
621
- help_now!('id is required') if options[:id].nil?
620
+ if options[:name].nil?
621
+ help_now!('name is required') if options[:name].nil?
622
622
  else
623
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
623
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
624
624
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
625
625
 
626
626
  container.setup
@@ -636,10 +636,10 @@ Teardown a container. The container is offlined and destroyed.
636
636
  EOF
637
637
  c.command :teardown do |teardown|
638
638
  teardown.action do |global_options, options, args|
639
- if options[:id].nil?
640
- help_now!('id is required') if options[:id].nil?
639
+ if options[:name].nil?
640
+ help_now!('name is required') if options[:name].nil?
641
641
  else
642
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
642
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
643
643
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
644
644
 
645
645
  container.teardown
@@ -655,10 +655,10 @@ Clone a container. The container is offlined and an ephemeral copy of it is sta
655
655
  EOF
656
656
  c.command :clone do |clone|
657
657
  clone.action do |global_options, options, args|
658
- if options[:id].nil?
659
- help_now!('id is required') if options[:id].nil?
658
+ if options[:name].nil?
659
+ help_now!('name is required') if options[:name].nil?
660
660
  else
661
- container = @testlab.containers.select{ |c| c.id.to_sym == options[:id].to_sym }.first
661
+ container = @testlab.containers.select{ |c| c.id.to_sym == options[:name].to_sym }.first
662
662
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
663
663
 
664
664
  container.clone
@@ -12,6 +12,8 @@ class TestLab
12
12
  def create
13
13
  @ui.logger.debug { "Container Create: #{self.id} " }
14
14
 
15
+ (self.lxc.state != :not_created) and return false
16
+
15
17
  please_wait(:ui => @ui, :message => format_object_action(self, 'Create', :green)) do
16
18
  self.domain ||= self.node.labfile.config[:domain]
17
19
  self.arch ||= detect_arch
@@ -48,7 +50,7 @@ class TestLab
48
50
  def up
49
51
  @ui.logger.debug { "Container Up: #{self.id} " }
50
52
 
51
- (self.lxc.state == :not_created) and return false #raise ContainerError, "We can not online a non-existant container!"
53
+ (self.lxc.state == :running) and return false
52
54
 
53
55
  please_wait(:ui => @ui, :message => format_object_action(self, 'Up', :green)) do
54
56
 
@@ -77,7 +79,7 @@ class TestLab
77
79
  def down
78
80
  @ui.logger.debug { "Container Down: #{self.id} " }
79
81
 
80
- (self.lxc.state == :not_created) and return false # raise ContainerError, "We can not offline a non-existant container!"
82
+ (self.lxc.state == :not_created) and return false
81
83
 
82
84
  please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do
83
85
  self.lxc.stop
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "0.6.4"
4
+ VERSION = "0.6.5"
5
5
  end
6
6
  end
@@ -148,6 +148,7 @@ describe TestLab::Container do
148
148
  subject.lxc.config.stub(:save) { true }
149
149
  subject.stub(:detect_arch) { "amd64" }
150
150
  subject.lxc.stub(:create) { true }
151
+ subject.lxc.stub(:state) { :not_created }
151
152
  subject.node.ssh.stub(:exec)
152
153
  subject.create
153
154
  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.4
4
+ version: 0.6.5
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: -2213038808322166943
296
+ hash: -1637961077093843979
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: -2213038808322166943
305
+ hash: -1637961077093843979
306
306
  requirements: []
307
307
  rubyforge_project:
308
308
  rubygems_version: 1.8.25