linux_container 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/lib/linux_container.rb +15 -3
- data/linux_container.gemspec +1 -1
- data/test/test_all.rb +3 -0
- metadata +1 -1
data/CHANGELOG
CHANGED
data/lib/linux_container.rb
CHANGED
@@ -66,13 +66,25 @@ class LinuxContainer
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def ssh(cmd)
|
69
|
+
execute('ssh', *ssh_args, "#{username}@#{ip}", cmd)
|
70
|
+
end
|
71
|
+
|
72
|
+
def scp_to(srcpath, dstpath, *args)
|
73
|
+
execute('scp', *args, *ssh_args, srcpath, "#{username}@#{ip}:#{dstpath}")
|
74
|
+
end
|
75
|
+
|
76
|
+
def scp_from(srcpath, dstpath, *args)
|
77
|
+
execute('scp', *args, *ssh_args, "#{username}@#{ip}:#{srcpath}", dstpath)
|
78
|
+
end
|
79
|
+
|
80
|
+
def ssh_args
|
69
81
|
raise "cannot ssh without ip" unless ip
|
70
82
|
args = ['-o','StrictHostKeyChecking=no','-o','UserKnownHostsFile=/dev/null']
|
71
83
|
args.push('-i', ssh_key_path) if ssh_key_path
|
72
|
-
args
|
73
|
-
execute('ssh', *args)
|
84
|
+
args
|
74
85
|
end
|
75
86
|
|
87
|
+
|
76
88
|
def sshable?
|
77
89
|
ssh('true') rescue false
|
78
90
|
end
|
@@ -100,7 +112,7 @@ class LinuxContainer
|
|
100
112
|
end
|
101
113
|
end
|
102
114
|
end
|
103
|
-
|
115
|
+
|
104
116
|
#############################################################################
|
105
117
|
|
106
118
|
def lxc_execute(cmd, *args)
|
data/linux_container.gemspec
CHANGED
data/test/test_all.rb
CHANGED
@@ -49,6 +49,9 @@ class TestLinuxContainer < MiniTest::Unit::TestCase
|
|
49
49
|
assert($ec.wait_for { ip }, 'wait_for ip')
|
50
50
|
assert($ec.wait_for { sshable? }, 'wait_for sshable?')
|
51
51
|
assert_equal "hi\n", $ec.execute('echo hi')
|
52
|
+
File.unlink('/tmp/lsb-release') rescue nil
|
53
|
+
$ec.scp_from('/etc/lsb-release', '/tmp/lsb-release')
|
54
|
+
assert File.exists?('/tmp/lsb-release')
|
52
55
|
$ec.stop
|
53
56
|
assert($ec.wait_for { !running? }, 'wait_for !running?')
|
54
57
|
assert($ec.wait_for { !File.exists?($ec.dir) }, 'wait_for directory deletion')
|