sapoku 0.0.8 → 0.0.9
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/lib/sapoku.rb +10 -4
- metadata +1 -1
data/lib/sapoku.rb
CHANGED
@@ -2,7 +2,7 @@ require 'redis'
|
|
2
2
|
require 'erb'
|
3
3
|
|
4
4
|
class Tadpole
|
5
|
-
attr_accessor :container_ip, :local_port, :app_name, :userid, :ram
|
5
|
+
attr_accessor :container_ip, :local_port, :app_name, :userid, :ram, :stack
|
6
6
|
$redis = Redis.new
|
7
7
|
|
8
8
|
# return an instance based on a given name, if it exists
|
@@ -15,6 +15,7 @@ class Tadpole
|
|
15
15
|
tadpole.local_port = $redis.hget(name, "localport")
|
16
16
|
tadpole.userid = $redis.hget(name, "userid")
|
17
17
|
tadpole.ram = $redis.hget(name, "ram")
|
18
|
+
tadpole.stack = $redis.hget(name, "stack")
|
18
19
|
return tadpole
|
19
20
|
end
|
20
21
|
|
@@ -30,10 +31,11 @@ class Tadpole
|
|
30
31
|
end
|
31
32
|
|
32
33
|
# create a new container stub (then requires saving)
|
33
|
-
def initialize(name)
|
34
|
+
def initialize(name, stack = "ruby")
|
34
35
|
@container_ip = getfreeip
|
35
36
|
@local_port = getlocalport
|
36
37
|
@app_name = name
|
38
|
+
@stack = stack
|
37
39
|
@ram = 512
|
38
40
|
end
|
39
41
|
|
@@ -43,14 +45,18 @@ class Tadpole
|
|
43
45
|
$redis.hset(@app_name, "localport", @local_port)
|
44
46
|
$redis.hset(@app_name, "userid", @userid)
|
45
47
|
$redis.hset(@app_name, "ram", @ram)
|
48
|
+
$redis.hset(@app_name, "stack", @stack)
|
46
49
|
end
|
47
50
|
|
48
51
|
# actually creates and initializes the container
|
52
|
+
# returns the actual raw console output of the generated commands
|
49
53
|
def bootstrap
|
50
|
-
|
54
|
+
self.save
|
55
|
+
output = `sudo lxc-clone -o #{@stack} -n #{@app_name}`
|
51
56
|
create_config
|
52
|
-
|
57
|
+
output += `sudo lxc-start -n #{@app_name} -d`
|
53
58
|
create_iptables
|
59
|
+
return output
|
54
60
|
end
|
55
61
|
|
56
62
|
# returns a free IP to be used by the container being bootstrapped
|