bosh_vsphere_cpi 1.2818.0 → 1.2820.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -185,7 +185,7 @@ module VSphereCloud
185
185
 
186
186
  def stemcell_vm(name)
187
187
  dc = @resources.datacenters.values.first
188
- client.find_by_inventory_path([dc.name, 'vm', dc.template_folder.path, name])
188
+ client.find_by_inventory_path([dc.name, 'vm', dc.template_folder.path_components, name])
189
189
  end
190
190
 
191
191
  def create_vm(agent_id, stemcell, cloud_properties, networks, disk_locality = nil, environment = nil)
@@ -524,7 +524,7 @@ module VSphereCloud
524
524
 
525
525
  def get_vm_by_cid(vm_cid)
526
526
  @resources.datacenters.each_value do |datacenter|
527
- vm = client.find_by_inventory_path([datacenter.name, 'vm', datacenter.vm_folder.path, vm_cid])
527
+ vm = client.find_by_inventory_path([datacenter.name, 'vm', datacenter.vm_folder.path_components, vm_cid])
528
528
  return vm unless vm.nil?
529
529
  end
530
530
  raise Bosh::Clouds::VMNotFound, "VM `#{vm_cid}' not found"
@@ -532,7 +532,7 @@ module VSphereCloud
532
532
 
533
533
  def replicate_stemcell(cluster, datastore, stemcell)
534
534
  stemcell_vm = client.find_by_inventory_path([cluster.datacenter.name, 'vm',
535
- cluster.datacenter.template_folder.path, stemcell])
535
+ cluster.datacenter.template_folder.path_components, stemcell])
536
536
  raise "Could not find stemcell: #{stemcell}" if stemcell_vm.nil?
537
537
  stemcell_datastore = @cloud_searcher.get_property(stemcell_vm, Vim::VirtualMachine, 'datastore', ensure_all: true)
538
538
 
@@ -540,7 +540,7 @@ module VSphereCloud
540
540
  @logger.info("Stemcell lives on a different datastore, looking for a local copy of: #{stemcell}.")
541
541
  local_stemcell_name = "#{stemcell} %2f #{datastore.mob.__mo_id__}"
542
542
  local_stemcell_path =
543
- [cluster.datacenter.name, 'vm', cluster.datacenter.template_folder.path, local_stemcell_name]
543
+ [cluster.datacenter.name, 'vm', cluster.datacenter.template_folder.path_components, local_stemcell_name]
544
544
  replicated_stemcell_vm = client.find_by_inventory_path(local_stemcell_path)
545
545
 
546
546
  if replicated_stemcell_vm.nil?
@@ -848,9 +848,9 @@ module VSphereCloud
848
848
  subfolders = []
849
849
  with_thread_name("get_vms") do
850
850
  @resources.datacenters.each_value do |datacenter|
851
- @logger.info("Looking for VMs in: #{datacenter.name} - #{datacenter.master_vm_folder.name}")
851
+ @logger.info("Looking for VMs in: #{datacenter.name} - #{datacenter.master_vm_folder.path}")
852
852
  subfolders += datacenter.master_vm_folder.mob.child_entity
853
- @logger.info("Looking for Stemcells in: #{datacenter.name} - #{datacenter.master_template_folder.name}")
853
+ @logger.info("Looking for Stemcells in: #{datacenter.name} - #{datacenter.master_template_folder.path}")
854
854
  subfolders += datacenter.master_template_folder.mob.child_entity
855
855
  end
856
856
  end
@@ -17,26 +17,28 @@ module VSphereCloud
17
17
 
18
18
  def vm_folder
19
19
  if @config.datacenter_use_sub_folder
20
- Folder.new([@config.datacenter_vm_folder, Bosh::Clouds::Config.uuid], @config)
20
+ folder_path = [@config.datacenter_vm_folder, Bosh::Clouds::Config.uuid].join('/')
21
+ Folder.new(folder_path, @config)
21
22
  else
22
23
  master_vm_folder
23
24
  end
24
25
  end
25
26
 
26
27
  def master_vm_folder
27
- Folder.new([@config.datacenter_vm_folder], @config)
28
+ Folder.new(@config.datacenter_vm_folder, @config)
28
29
  end
29
30
 
30
31
  def template_folder
31
32
  if @config.datacenter_use_sub_folder
32
- Folder.new([@config.datacenter_template_folder, Bosh::Clouds::Config.uuid], @config)
33
+ folder_path = [@config.datacenter_template_folder, Bosh::Clouds::Config.uuid].join('/')
34
+ Folder.new(folder_path, @config)
33
35
  else
34
36
  master_template_folder
35
37
  end
36
38
  end
37
39
 
38
40
  def master_template_folder
39
- Folder.new([@config.datacenter_template_folder], @config)
41
+ Folder.new(@config.datacenter_template_folder, @config)
40
42
  end
41
43
 
42
44
  def name
@@ -1,48 +1,47 @@
1
1
  module VSphereCloud
2
2
  class Resources
3
3
  class Folder
4
- attr_reader :mob, :path, :name
4
+ attr_reader :mob, :path, :path_components
5
5
 
6
- # path - an array of names starting from parent down to child folders
7
6
  def initialize(path, config)
8
7
  @path = path
9
8
  @config = config
10
9
 
11
- @name = path.join('/')
10
+ @path_components = path.split('/')
12
11
 
13
- @mob = find_or_create_folder
12
+ @mob = find_or_create_folder(@path_components)
14
13
  end
15
14
 
16
15
  private
17
16
 
18
- def find_or_create_folder
19
- folder = find_folder
17
+ def find_or_create_folder(path_components)
18
+ return root_vm_folder if path_components.empty?
20
19
 
20
+ folder = find_folder(path_components)
21
21
  if folder.nil?
22
+ last_component = path_components.last
23
+ parent_folder = find_or_create_folder(path_components[0..-2])
24
+
22
25
  begin
23
- @config.logger.debug("Creating folder #{@name}")
24
- folder = parent_folder.create_folder(@path.last)
26
+ @config.logger.debug("Creating folder #{last_component}")
27
+ folder = parent_folder.create_folder(last_component)
25
28
  rescue VimSdk::SoapError => e
26
29
  raise e unless VimSdk::Vim::Fault::DuplicateName === e.fault
27
30
 
28
- @config.logger.debug("Folder already exists #{@name}")
29
- folder = find_folder
31
+ @config.logger.debug("Folder already exists #{last_component}")
32
+ folder = find_folder(path_components)
30
33
  end
31
34
  end
32
35
 
33
36
  folder
34
37
  end
35
38
 
36
- def find_folder
37
- @config.client.find_by_inventory_path([@config.datacenter_name, 'vm', @path].flatten)
39
+ def find_folder(path_components)
40
+ @config.client.find_by_inventory_path([@config.datacenter_name, 'vm', path_components].flatten)
38
41
  end
39
42
 
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
43
+ def root_vm_folder
44
+ @config.client.find_by_inventory_path([@config.datacenter_name, 'vm'])
46
45
  end
47
46
  end
48
47
  end
@@ -1,7 +1,7 @@
1
1
  module Bosh
2
2
  module Clouds
3
3
  class VSphere
4
- VERSION = '1.2818.0'
4
+ VERSION = '1.2820.0'
5
5
  end
6
6
  end
7
7
  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.2818.0
4
+ version: 1.2820.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: 2015-01-16 00:00:00.000000000 Z
12
+ date: 2015-01-20 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.2818.0
21
+ version: 1.2820.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.2818.0
29
+ version: 1.2820.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.2818.0
37
+ version: 1.2820.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.2818.0
45
+ version: 1.2820.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
- 59d102'
176
+ ebc2f0'
177
177
  email: support@cloudfoundry.com
178
178
  executables:
179
179
  - vsphere_cpi
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  version: '0'
264
264
  segments:
265
265
  - 0
266
- hash: 4401758864189890306
266
+ hash: -159309430642534818
267
267
  requirements: []
268
268
  rubyforge_project:
269
269
  rubygems_version: 1.8.23