linux_container 0.7 → 0.8
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 +10 -2
- data/linux_container.gemspec +2 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/linux_container.rb
CHANGED
@@ -11,6 +11,12 @@ class LinuxContainer
|
|
11
11
|
`#{sudo_if_needed} lxc-ls -1`.lines.map(&:strip).uniq.map {|cname| new(name: cname) }
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.version
|
15
|
+
@version ||= if `lxc-version` =~ /version: (\d+\.\d+)\./i
|
16
|
+
$1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
def initialize(params={})
|
15
21
|
params.each {|k,v| instance_variable_set "@#{k}", v }
|
16
22
|
@username ||= 'ubuntu'
|
@@ -40,11 +46,12 @@ class LinuxContainer
|
|
40
46
|
|
41
47
|
def start_ephemeral
|
42
48
|
args = ['lxc-start-ephemeral','-U','overlayfs','-u',username,'-o',name]
|
49
|
+
args << '-d' if self.class.version == '0.9'
|
43
50
|
logfile_path = bg_execute(*args)
|
44
51
|
newname = nil
|
45
52
|
while newname.nil?
|
46
53
|
sleep 1
|
47
|
-
newname = $1 if File.read(logfile_path) =~ /^(.*) is running
|
54
|
+
newname = $1 || $2 if File.read(logfile_path) =~ /^(.*) is running|lxc-console -n (.*)$/
|
48
55
|
end
|
49
56
|
self.class.new(name: newname, ssh_key_path: ssh_key_path, username: username)
|
50
57
|
end
|
@@ -107,7 +114,8 @@ class LinuxContainer
|
|
107
114
|
end
|
108
115
|
|
109
116
|
def self.get_ip_for(name)
|
110
|
-
|
117
|
+
fn = ['/var/lib/misc/dnsmasq.lxcbr0.leases', '/var/lib/misc/dnsmasq.leases'].detect {|f| File.readable?(f) }
|
118
|
+
File.read(fn).each_line do |line|
|
111
119
|
(timestamp,macaddr,ip,hostname,misc) = line.split(' ')
|
112
120
|
return ip if hostname == name
|
113
121
|
end
|
data/linux_container.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "linux_container"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.8"
|
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"]
|
9
|
-
s.date = "2013-03-
|
9
|
+
s.date = "2013-03-17"
|
10
10
|
s.description = "Ruby gem for ephemeral LXC linux containers"
|
11
11
|
s.email = "andrew@modulus.org"
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "README.md", "lib/linux_container.rb"]
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: linux_container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: '0.
|
5
|
+
version: '0.8'
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andrew Snow
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby gem for ephemeral LXC linux containers
|
15
15
|
email: andrew@modulus.org
|