bosh_vsphere_cpi 1.2792.0 → 1.2797.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/cloud/vsphere/cloud.rb
CHANGED
@@ -14,7 +14,6 @@ require 'cloud/vsphere/resources/cluster'
|
|
14
14
|
require 'cloud/vsphere/resources/datacenter'
|
15
15
|
require 'cloud/vsphere/resources/datastore'
|
16
16
|
require 'cloud/vsphere/resources/folder'
|
17
|
-
require 'cloud/vsphere/resources/multi_tenant_folder'
|
18
17
|
require 'cloud/vsphere/resources/resource_pool'
|
19
18
|
require 'cloud/vsphere/resources/scorer'
|
20
19
|
require 'cloud/vsphere/resources/util'
|
@@ -185,7 +184,7 @@ module VSphereCloud
|
|
185
184
|
|
186
185
|
def stemcell_vm(name)
|
187
186
|
dc = @resources.datacenters.values.first
|
188
|
-
client.find_by_inventory_path([dc.name, 'vm', dc.template_folder.
|
187
|
+
client.find_by_inventory_path([dc.name, 'vm', dc.template_folder.path, name])
|
189
188
|
end
|
190
189
|
|
191
190
|
def create_vm(agent_id, stemcell, cloud_properties, networks, disk_locality = nil, environment = nil)
|
@@ -599,7 +598,7 @@ module VSphereCloud
|
|
599
598
|
|
600
599
|
def get_vm_by_cid(vm_cid)
|
601
600
|
@resources.datacenters.each_value do |datacenter|
|
602
|
-
vm = client.find_by_inventory_path([datacenter.name, 'vm', datacenter.vm_folder.
|
601
|
+
vm = client.find_by_inventory_path([datacenter.name, 'vm', datacenter.vm_folder.path, vm_cid])
|
603
602
|
return vm unless vm.nil?
|
604
603
|
end
|
605
604
|
raise Bosh::Clouds::VMNotFound, "VM `#{vm_cid}' not found"
|
@@ -607,7 +606,7 @@ module VSphereCloud
|
|
607
606
|
|
608
607
|
def replicate_stemcell(cluster, datastore, stemcell)
|
609
608
|
stemcell_vm = client.find_by_inventory_path([cluster.datacenter.name, 'vm',
|
610
|
-
cluster.datacenter.template_folder.
|
609
|
+
cluster.datacenter.template_folder.path, stemcell])
|
611
610
|
raise "Could not find stemcell: #{stemcell}" if stemcell_vm.nil?
|
612
611
|
stemcell_datastore = @cloud_searcher.get_property(stemcell_vm, Vim::VirtualMachine, 'datastore', ensure_all: true)
|
613
612
|
|
@@ -615,7 +614,7 @@ module VSphereCloud
|
|
615
614
|
@logger.info("Stemcell lives on a different datastore, looking for a local copy of: #{stemcell}.")
|
616
615
|
local_stemcell_name = "#{stemcell} %2f #{datastore.mob.__mo_id__}"
|
617
616
|
local_stemcell_path =
|
618
|
-
[cluster.datacenter.name, 'vm', cluster.datacenter.template_folder.
|
617
|
+
[cluster.datacenter.name, 'vm', cluster.datacenter.template_folder.path, local_stemcell_name]
|
619
618
|
replicated_stemcell_vm = client.find_by_inventory_path(local_stemcell_path)
|
620
619
|
|
621
620
|
if replicated_stemcell_vm.nil?
|
@@ -17,26 +17,26 @@ module VSphereCloud
|
|
17
17
|
|
18
18
|
def vm_folder
|
19
19
|
if @config.datacenter_use_sub_folder
|
20
|
-
|
20
|
+
Folder.new([@config.datacenter_vm_folder, Bosh::Clouds::Config.uuid], @config)
|
21
21
|
else
|
22
22
|
master_vm_folder
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def master_vm_folder
|
27
|
-
Folder.new(@config.datacenter_vm_folder, @config)
|
27
|
+
Folder.new([@config.datacenter_vm_folder], @config)
|
28
28
|
end
|
29
29
|
|
30
30
|
def template_folder
|
31
31
|
if @config.datacenter_use_sub_folder
|
32
|
-
|
32
|
+
Folder.new([@config.datacenter_template_folder, Bosh::Clouds::Config.uuid], @config)
|
33
33
|
else
|
34
34
|
master_template_folder
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def master_template_folder
|
39
|
-
Folder.new(@config.datacenter_template_folder, @config)
|
39
|
+
Folder.new([@config.datacenter_template_folder], @config)
|
40
40
|
end
|
41
41
|
|
42
42
|
def name
|
@@ -1,21 +1,48 @@
|
|
1
1
|
module VSphereCloud
|
2
2
|
class Resources
|
3
3
|
class Folder
|
4
|
-
attr_reader :mob, :name
|
4
|
+
attr_reader :mob, :path, :name
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
# path - an array of names starting from parent down to child folders
|
7
|
+
def initialize(path, config)
|
8
|
+
@path = path
|
8
9
|
@config = config
|
9
10
|
|
10
|
-
|
11
|
+
@name = path.join('/')
|
12
|
+
|
13
|
+
@mob = find_or_create_folder
|
11
14
|
end
|
12
15
|
|
13
16
|
private
|
14
17
|
|
18
|
+
def find_or_create_folder
|
19
|
+
folder = find_folder
|
20
|
+
|
21
|
+
if folder.nil?
|
22
|
+
begin
|
23
|
+
@config.logger.debug("Creating folder #{@name}")
|
24
|
+
folder = parent_folder.create_folder(@path.last)
|
25
|
+
rescue VimSdk::SoapError => e
|
26
|
+
raise e unless VimSdk::Vim::Fault::DuplicateName === e.fault
|
27
|
+
|
28
|
+
@config.logger.debug("Folder already exists #{@name}")
|
29
|
+
folder = find_folder
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
folder
|
34
|
+
end
|
35
|
+
|
15
36
|
def find_folder
|
16
|
-
|
17
|
-
|
18
|
-
|
37
|
+
@config.client.find_by_inventory_path([@config.datacenter_name, 'vm', @path].flatten)
|
38
|
+
end
|
39
|
+
|
40
|
+
def parent_folder
|
41
|
+
if @path.size > 1
|
42
|
+
Folder.new(@path[0..-2], @config).mob
|
43
|
+
else
|
44
|
+
@config.client.find_by_inventory_path([@config.datacenter_name, 'vm'])
|
45
|
+
end
|
19
46
|
end
|
20
47
|
end
|
21
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_vsphere_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2797.0
|
5
5
|
prerelease:
|
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: 2014-12-
|
12
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bosh_common
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.2797.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.2797.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bosh_cpi
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.2797.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
45
|
+
version: 1.2797.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: membrane
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,7 +173,7 @@ dependencies:
|
|
173
173
|
version: 0.7.1
|
174
174
|
description: ! 'BOSH VSphere CPI
|
175
175
|
|
176
|
-
|
176
|
+
3fe6aa'
|
177
177
|
email: support@cloudfoundry.com
|
178
178
|
executables:
|
179
179
|
- vsphere_cpi
|
@@ -204,7 +204,6 @@ files:
|
|
204
204
|
- lib/cloud/vsphere/resources/datacenter.rb
|
205
205
|
- lib/cloud/vsphere/resources/datastore.rb
|
206
206
|
- lib/cloud/vsphere/resources/folder.rb
|
207
|
-
- lib/cloud/vsphere/resources/multi_tenant_folder.rb
|
208
207
|
- lib/cloud/vsphere/resources/resource_pool.rb
|
209
208
|
- lib/cloud/vsphere/resources/scorer.rb
|
210
209
|
- lib/cloud/vsphere/resources/util.rb
|
@@ -261,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
260
|
version: '0'
|
262
261
|
segments:
|
263
262
|
- 0
|
264
|
-
hash:
|
263
|
+
hash: 1302345183759456352
|
265
264
|
requirements: []
|
266
265
|
rubyforge_project:
|
267
266
|
rubygems_version: 1.8.23
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module VSphereCloud
|
2
|
-
class Resources
|
3
|
-
class MultiTenantFolder
|
4
|
-
attr_reader :mob, :name
|
5
|
-
|
6
|
-
def initialize(parent_folder_name, sub_folder_name, config)
|
7
|
-
@parent_folder_name = parent_folder_name
|
8
|
-
@sub_folder_name = sub_folder_name
|
9
|
-
@name = [parent_folder_name, sub_folder_name]
|
10
|
-
@config = config
|
11
|
-
|
12
|
-
find_or_create_sub_folder
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def find_or_create_sub_folder
|
18
|
-
parent_folder = find_parent_folder
|
19
|
-
name_join = @name.join("/")
|
20
|
-
|
21
|
-
@config.logger.debug("Attempting to create folder #{name_join}")
|
22
|
-
|
23
|
-
begin
|
24
|
-
sub_folder = parent_folder.create_folder(@sub_folder_name)
|
25
|
-
@config.logger.debug("Created folder #{name_join}")
|
26
|
-
rescue VimSdk::SoapError => e
|
27
|
-
raise e unless VimSdk::Vim::Fault::DuplicateName === e.fault
|
28
|
-
sub_folder = @config.client.find_by_inventory_path([@config.datacenter_name, 'vm', @name])
|
29
|
-
@config.logger.debug("Folder #{name_join} already exists")
|
30
|
-
end
|
31
|
-
|
32
|
-
@mob = sub_folder
|
33
|
-
end
|
34
|
-
|
35
|
-
def find_parent_folder
|
36
|
-
folder = @config.client.find_by_inventory_path([@config.datacenter_name, 'vm', @parent_folder_name])
|
37
|
-
raise "Missing folder: #{@parent_folder_name}" if folder.nil?
|
38
|
-
folder
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|