testlab 0.4.2 → 0.4.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.
data/bin/tl CHANGED
@@ -244,13 +244,21 @@ command :container do |c|
244
244
  ################
245
245
  c.desc 'Open an SSH console to a container'
246
246
  c.command :ssh do |ssh|
247
+
248
+ ssh.desc 'Username'
249
+ ssh.arg_name 'username'
250
+ ssh.flag [:u, :user]
251
+
247
252
  ssh.action do |global_options, options, args|
248
253
  help_now!('id is required') if options[:id].nil?
249
254
 
250
255
  container = @testlab.containers.select{ |n| n.id.to_sym == options[:id].to_sym }.first
251
256
  container.nil? and raise TestLab::TestLabError, "We could not find the container you supplied!"
252
257
 
253
- container.ssh.console
258
+ ssh_options = Hash.new
259
+ ssh_options[:user] = options[:user]
260
+
261
+ container.ssh(ssh_options).console
254
262
  end
255
263
  end
256
264
 
@@ -20,7 +20,7 @@ class TestLab
20
20
  self.arch ||= detect_arch
21
21
 
22
22
  self.lxc.config.clear
23
- self.lxc.config['lxc.utsname'] = self.id
23
+ self.lxc.config['lxc.utsname'] = self.fqdn
24
24
  self.lxc.config['lxc.arch'] = self.arch
25
25
  self.lxc.config.networks = build_lxc_network_conf(self.interfaces)
26
26
  self.lxc.config.save
@@ -31,13 +31,22 @@ class TestLab
31
31
  home_dir = ((self.node.user == "root") ? %(/root) : %(/home/#{self.node.user}))
32
32
  container_home_dir = File.join(self.lxc.fs_root, "/home/ubuntu")
33
33
 
34
- home_authkeys = File.join(home_dir, %(.ssh), %(authorized_keys))
35
- container_authkeys = File.join(container_home_dir, %(.ssh), %(authorized_keys))
34
+ home_authkeys = File.join(home_dir, ".ssh", "authorized_keys")
35
+ container_authkeys = File.join(container_home_dir, ".ssh", "authorized_keys")
36
+ container_authkeys2 = File.join(container_home_dir, ".ssh", "authorized_keys2")
37
+
38
+ authkeys = {
39
+ home_authkeys => container_authkeys,
40
+ home_authkeys => container_authkeys2
41
+ }
36
42
 
37
43
  self.node.ssh.exec(%(mkdir -pv #{File.join(container_home_dir, %(.ssh))}))
38
- self.node.ssh.exec(%(sudo cp -v #{home_authkeys} #{container_authkeys}))
39
- self.node.ssh.exec(%(sudo chown -v 1000:1000 #{container_authkeys}))
40
- self.node.ssh.exec(%(sudo chmod -v 644 #{container_authkeys}))
44
+ authkeys.each do |source, destination|
45
+ self.node.ssh.exec(%(sudo cp -v #{source} #{destination}))
46
+ self.node.ssh.exec(%(sudo chown -v 1000:1000 #{destination}))
47
+ self.node.ssh.exec(%(sudo chmod -v 644 #{destination}))
48
+ end
49
+
41
50
  end
42
51
 
43
52
  true
@@ -75,7 +84,7 @@ class TestLab
75
84
  (self.lxc.state != :running) and raise ContainerError, "The container failed to online!"
76
85
 
77
86
  # TODO: This needs to really go somewhere else:
78
- self.lxc.attach(%(/bin/bash -c 'grep "sudo\tALL=\(ALL:ALL\) ALL" /etc/sudoers && sed -i "s/sudo\tALL=\(ALL:ALL\) ALL/sudo\tALL=\(ALL:ALL\) NOPASSWD: ALL/" /etc/sudoers'))
87
+ self.lxc.attach(%(-- /bin/bash -c 'grep "sudo\tALL=\(ALL:ALL\) ALL" /etc/sudoers && sed -i "s/sudo\tALL=\(ALL:ALL\) ALL/sudo\tALL=\(ALL:ALL\) NOPASSWD: ALL/" /etc/sudoers'))
79
88
  end
80
89
 
81
90
  true
@@ -20,7 +20,7 @@ class TestLab
20
20
  self.node.ssh.file(:target => File.join(self.lxc.fs_root, remote_tempfile), :chmod => '0777', :chown => 'root:root') do |file|
21
21
  file.puts(content)
22
22
  end
23
- output = self.lxc.attach(%(/bin/bash), remote_tempfile)
23
+ output = self.lxc.attach(%(--), %(/bin/bash), remote_tempfile)
24
24
  if output =~ /No such file or directory/
25
25
  raise ContainerError, "We could not find the bootstrap file!"
26
26
  end
@@ -30,11 +30,11 @@ class TestLab
30
30
  c.proxy_keys = @provider.identity
31
31
 
32
32
  c.host_name = container.ip
33
- c.user = container.user
33
+ c.user = (options[:user] || container.user)
34
34
  if container.keys.nil?
35
- c.password = container.passwd
35
+ c.password = (options[:passwd] || container.passwd)
36
36
  else
37
- c.keys = container.keys
37
+ c.keys = (options[:keys] || container.keys)
38
38
  end
39
39
  end
40
40
  end
@@ -1,6 +1,6 @@
1
1
  class TestLab
2
2
  unless const_defined?(:VERSION)
3
3
  # TestLab Gem Version
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
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.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -281,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  segments:
283
283
  - 0
284
- hash: 3482118721192015302
284
+ hash: -4535491562100824154
285
285
  required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  none: false
287
287
  requirements:
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  segments:
292
292
  - 0
293
- hash: 3482118721192015302
293
+ hash: -4535491562100824154
294
294
  requirements: []
295
295
  rubyforge_project:
296
296
  rubygems_version: 1.8.25