bosh_docker_cpi 0.0.1.pre.2 → 0.0.1.pre.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,8 +4,10 @@ module Bosh::Registry
4
4
 
5
5
  class Docker < InstanceManager
6
6
 
7
+ require 'bosh_docker_cpi'
8
+
7
9
  def initialize(cloud_config)
8
- @docker = Docker::API.new(base_url: 'http://localhost:4243')
10
+ @docker = ::Docker::API.new(base_url: 'http://localhost:4243')
9
11
  end
10
12
 
11
13
  # Get the list of IPs belonging to this instance
@@ -4,16 +4,16 @@ module Bosh
4
4
 
5
5
  def initialize(options)
6
6
  @agent_properties ||= options.fetch('agent', {})
7
- registry_properties = options.fetch('registry')
8
- registry_endpoint = registry_properties.fetch('endpoint')
9
- registry_user = registry_properties.fetch('user')
10
- registry_password = registry_properties.fetch('password')
7
+ #registry_properties = options.fetch('registry')
8
+ #registry_endpoint = registry_properties.fetch('endpoint')
9
+ #registry_user = registry_properties.fetch('user')
10
+ #registry_password = registry_properties.fetch('password')
11
+ #
12
+ #@registry = Bosh::Registry::Client.new(registry_endpoint,
13
+ # registry_user,
14
+ # registry_password)
11
15
 
12
- @registry = Bosh::Registry::Client.new(registry_endpoint,
13
- registry_user,
14
- registry_password)
15
-
16
- @docker = Docker::API.new(base_url: 'http://localhost:4243')
16
+ @docker = ::Docker::API.new(base_url: 'http://localhost:4243')
17
17
  end
18
18
 
19
19
  def current_vm_id
@@ -23,31 +23,43 @@ module Bosh
23
23
  def create_stemcell(image_path, cloud_properties)
24
24
  Dir.mktmpdir do |dir|
25
25
  Dir.chdir(dir) do
26
+ system 'mkdir mnt'
26
27
  system "tar -xzf #{image_path} root.img"
27
-
28
+ system 'sudo kpartx -a root.img'
29
+ system 'sudo mount /dev/mapper/loop0p1 mnt'
30
+ Dir.chdir('mnt') do
31
+ system 'sudo tar zcf ../stemcell_img.tgz .'
32
+ end
33
+ system 'sudo umount mnt'
34
+ system 'sudo kpartx -d root.img'
35
+ system 'sudo chmod 777 stemcell_img.tgz'
36
+ system 'cat stemcell_img.tgz | docker image - bosh latest' #returns stemcell_id
28
37
  end
29
38
  end
30
39
  end
31
40
 
32
41
  def delete_stemcell(stemcell_id)
33
- not_implemented(:delete_stemcell)
42
+ system "docker rmi #{stemcell_id}"
34
43
  end
35
44
 
36
45
  def create_vm(agent_id, stemcell_id, resource_pool,
37
46
  network_spec, disk_locality = nil, environment = nil)
38
47
 
39
-
40
- result = containers.create(['/bin/sh', '-c', 'while true; do echo hello world; sleep 1; done'], stemcell_id)
48
+ nats_uri = 'nats://172.16.42.1:21084'
49
+ blobstore_uri = 'http://172.16.42.1:21081'
50
+ agent_base_dir = '/var/vcap/bosh'
51
+ root_dir = '/var/vcap/bosh'
52
+ result = containers.create(['/bin/sh', '-c', "/var/vcap/bosh/bin/bosh_agent -a #{agent_id} -s #{blobstore_uri} -p simple -b #{agent_base_dir} -n #{nats_uri} -r #{root_dir}"], stemcell_id)
41
53
  vm_id = result["Id"]
42
54
 
43
55
 
44
- registry_settings = initial_agent_settings(
45
- agent_id,
46
- network_spec,
47
- environment,
48
- ''
49
- )
50
- registry.update_settings(vm_id, registry_settings)
56
+ #registry_settings = initial_agent_settings(
57
+ # agent_id,
58
+ # network_spec,
59
+ # environment,
60
+ # ''
61
+ #)
62
+ #registry.update_settings(vm_id, registry_settings)
51
63
 
52
64
  containers.start(vm_id)
53
65
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_docker_cpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.2
4
+ version: 0.0.1.pre.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-08 00:00:00.000000000 Z
12
+ date: 2013-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: docker-client