sapoku 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sapoku.rb +10 -4
  2. metadata +1 -1
@@ -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
- system("sudo lxc-clone -o frox -n #{@app_name}")
54
+ self.save
55
+ output = `sudo lxc-clone -o #{@stack} -n #{@app_name}`
51
56
  create_config
52
- system("sudo lxc-start -n #{@app_name} -d")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapoku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: