linux_container 1.0 → 1.1

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/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ v1.1. scp into container support
1
2
  v1.0. state() should always return a string
2
3
  v0.9. default to aufs only for 0.8 for ephemeral
3
4
  v0.8. Support lxc 0.9
@@ -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.push("#{username}@#{ip}", cmd)
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)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "linux_container"
5
- s.version = "1.0"
5
+ s.version = "1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Andrew Snow"]
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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux_container
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: