bosh_vsphere_cpi 1.2962.0 → 1.2968.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3ca370cda454ae8a8b61c5ea8ae2e39c22c6202
4
- data.tar.gz: 3b5079885117a157273b91ac77d4ae222fc2ffd4
3
+ metadata.gz: b21d5e6a2fd3f2d76712418bcdf2bdd91e9374fc
4
+ data.tar.gz: ee8bf9eac292090e597a343409d75c8d1f51b382
5
5
  SHA512:
6
- metadata.gz: b3f571670b4c301433dbe971c8d36a32d6a4a1c277ca0b94444a7ddecaec8b310bef3f942f1c27c822825946a13e0b9cf5e7447f5b6463d7d62bfb1b6bd46329
7
- data.tar.gz: 3e1edffbab7088f30b85d72a9c8737d22238c373e41dfb245819fcde44ac1d1d29aa7048a1534c1b622a17220cc6e19c3cfac15330d4e7621051da81d2f010fa
6
+ metadata.gz: 2b9fe21f6393b697ca844c0a6f101ce7382f85de43bd449cdaba6d80e8df2fede323b04b1ec7600872fcc3c669848ef2d3c6b3d817d2dd6965f2a0729eb169f4
7
+ data.tar.gz: 08e59c03f9f3a7bbde3cd7c8b4a697da1fddb5e0fd9c6f7cde29e3ddefe10c468932ca7578903174dc2a1c3d23ff05f0f0d6600fe5ae2331b40853b137324bc0
data/lib/cloud/vsphere.rb CHANGED
@@ -17,6 +17,7 @@ require 'cloud/vsphere/fixed_cluster_placer'
17
17
  require 'cloud/vsphere/lease_obtainer'
18
18
  require 'cloud/vsphere/lease_updater'
19
19
  require 'cloud/vsphere/path_finder'
20
+ require 'cloud/vsphere/resources/cluster_provider'
20
21
  require 'cloud/vsphere/resources/cluster'
21
22
  require 'cloud/vsphere/resources/datacenter'
22
23
  require 'cloud/vsphere/resources/datastore'
@@ -100,11 +100,11 @@ module VSphereCloud
100
100
  create_parent_folder(dest_datacenter, dest_path)
101
101
  tasks = []
102
102
  base_source_path = source_path.chomp(File.extname(source_path))
103
- base_dest_path = source_path.chomp(File.extname(dest_path))
103
+ base_dest_path = dest_path.chomp(File.extname(dest_path))
104
104
  [".vmdk", "-flat.vmdk"].each do |extension|
105
105
  tasks << @service_content.file_manager.move_file(
106
- "#{base_source_path}#{extension}", source_datacenter,
107
- "#{base_dest_path}#{extension}", dest_datacenter, false
106
+ "#{base_source_path}#{extension}", source_datacenter.mob,
107
+ "#{base_dest_path}#{extension}", dest_datacenter.mob, false
108
108
  )
109
109
  end
110
110
 
@@ -299,9 +299,9 @@ module VSphereCloud
299
299
  @logger.info("Attaching disk: #{disk_cid} on vm: #{vm_cid}")
300
300
 
301
301
  vm = vm_provider.find(vm_cid)
302
-
303
302
  cluster = @datacenter.clusters[vm.cluster]
304
- disk = disk_provider.find_and_move(disk_cid, cluster, @datacenter.name, vm.accessible_datastores)
303
+
304
+ disk = disk_provider.find_and_move(disk_cid, cluster, @datacenter, vm.accessible_datastores)
305
305
  disk_config_spec = disk.attach_spec(vm.system_disk.controller_key)
306
306
 
307
307
  vm_config = Vim::Vm::ConfigSpec.new
@@ -366,10 +366,17 @@ module VSphereCloud
366
366
  end
367
367
  end
368
368
 
369
- def create_disk(size_in_mb, cloud_properties, _ = nil)
369
+ def create_disk(size_in_mb, cloud_properties, vm_cid = nil)
370
370
  with_thread_name("create_disk(#{size_in_mb}, _)") do
371
371
  @logger.info("Creating disk with size: #{size_in_mb}")
372
- disk = disk_provider.create(size_in_mb)
372
+
373
+ cluster = nil
374
+ if vm_cid
375
+ vm = vm_provider.find(vm_cid)
376
+ cluster = @datacenter.clusters[vm.cluster]
377
+ end
378
+
379
+ disk = disk_provider.create(size_in_mb, cluster)
373
380
  @logger.info("Created disk: #{disk.inspect}")
374
381
  disk.cid
375
382
  end
@@ -708,19 +715,16 @@ module VSphereCloud
708
715
 
709
716
  unless cluster_spec.nil?
710
717
  cluster_name = cluster_spec.keys.first
711
- cluster = find_cluster(cluster_name)
712
- cluster_config = cluster_spec.values.first
713
- drs_rules = cluster_config.fetch('drs_rules', [])
718
+ spec = cluster_spec.values.first
719
+ cluster_config = ClusterConfig.new(cluster_name, spec)
720
+ cluster = Resources::ClusterProvider.new(@datacenter, @client, @logger).find(cluster_name, cluster_config)
721
+ drs_rules = spec.fetch('drs_rules', [])
714
722
  placer = FixedClusterPlacer.new(cluster, drs_rules)
715
723
  end
716
724
 
717
725
  placer.nil? ? @resources : placer
718
726
  end
719
727
 
720
- def find_cluster(cluster_name)
721
- @datacenter.clusters[cluster_name]
722
- end
723
-
724
728
  attr_reader :config
725
729
  end
726
730
  end
@@ -12,19 +12,23 @@ module VSphereCloud
12
12
  @logger = logger
13
13
  end
14
14
 
15
- def create(disk_size_in_mb)
16
- datastore = @datacenter.pick_persistent_datastore(disk_size_in_mb)
15
+ def create(disk_size_in_mb, cluster)
16
+ if cluster
17
+ datastore = @resources.pick_persistent_datastore_in_cluster(cluster.name, disk_size_in_mb)
18
+ else
19
+ datastore = @datacenter.pick_persistent_datastore(disk_size_in_mb)
20
+ end
17
21
  disk_cid = "disk-#{SecureRandom.uuid}"
18
22
  @logger.debug("Creating disk '#{disk_cid}' in datastore '#{datastore.name}'")
19
23
 
20
24
  @client.create_disk(@datacenter, datastore, disk_cid, @disk_path, disk_size_in_mb)
21
25
  end
22
26
 
23
- def find_and_move(disk_cid, cluster, datacenter_name, accessible_datastores)
27
+ def find_and_move(disk_cid, cluster, datacenter, accessible_datastores)
24
28
  disk = find(disk_cid)
25
29
  return disk if accessible_datastores.include?(disk.datastore.name)
26
30
 
27
- destination_datastore = @resources.pick_persistent_datastore_in_cluster(cluster, disk.size_in_mb)
31
+ destination_datastore = @resources.pick_persistent_datastore_in_cluster(cluster.name, disk.size_in_mb)
28
32
 
29
33
  unless accessible_datastores.include?(destination_datastore.name)
30
34
  raise "Datastore '#{destination_datastore.name}' is not accessible to cluster '#{cluster.name}'"
@@ -32,13 +36,15 @@ module VSphereCloud
32
36
 
33
37
  destination_path = path(destination_datastore, disk_cid)
34
38
  @logger.info("Moving #{disk.path} to #{destination_path}")
35
- @client.move_disk(datacenter_name, disk.path, datacenter_name, destination_path) #TODO: return the new disk
39
+ @client.move_disk(datacenter, disk.path, datacenter, destination_path)
36
40
  @logger.info('Moved disk successfully')
37
41
  Resources::Disk.new(disk_cid, disk.size_in_mb, destination_datastore, destination_path)
38
42
  end
39
43
 
40
44
  def find(disk_cid)
41
- @datacenter.persistent_datastores.each do |_, datastore|
45
+ persistent_datastores = @datacenter.persistent_datastores
46
+ @logger.debug("Looking for disk #{disk_cid} in datastores: #{persistent_datastores}")
47
+ persistent_datastores.each do |_, datastore|
42
48
  disk = @client.find_disk(disk_cid, datastore, @disk_path)
43
49
  return disk unless disk.nil?
44
50
  end
@@ -0,0 +1,46 @@
1
+ module VSphereCloud
2
+ class Resources
3
+ class ClusterProvider
4
+ def initialize(datacenter, client, logger)
5
+ @datacenter = datacenter
6
+ @client = client
7
+ @logger = logger
8
+ end
9
+
10
+ def find(name, config)
11
+ cluster_mob = cluster_mobs[name]
12
+ raise "Can't find cluster: #{name}" if cluster_mob.nil?
13
+
14
+ cluster_properties = @client.cloud_searcher.get_properties(
15
+ cluster_mob, VimSdk::Vim::ClusterComputeResource,
16
+ Cluster::PROPERTIES, :ensure_all => true
17
+ )
18
+ raise "Can't find properties for cluster: #{name}" if cluster_properties.nil?
19
+
20
+ Cluster.new(
21
+ @datacenter,
22
+ @datacenter.ephemeral_pattern,
23
+ @datacenter.persistent_pattern,
24
+ @datacenter.mem_overcommit,
25
+ config,
26
+ cluster_properties,
27
+ @logger,
28
+ @client
29
+ )
30
+ end
31
+
32
+ private
33
+
34
+ def cluster_mobs
35
+ @cluster_mobs ||= begin
36
+ cluster_tuples = @client.cloud_searcher.get_managed_objects(
37
+ VimSdk::Vim::ClusterComputeResource,
38
+ root: @datacenter.mob,
39
+ include_name: true
40
+ )
41
+ Hash[*(cluster_tuples.flatten)]
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -19,9 +19,11 @@ module VSphereCloud
19
19
  @clusters = attrs.fetch(:clusters)
20
20
  @logger = attrs.fetch(:logger)
21
21
  @mem_overcommit = attrs.fetch(:mem_overcommit)
22
+
23
+ @cluster_provider = ClusterProvider.new(self, @client, @logger)
22
24
  end
23
25
 
24
- attr_reader :name, :disk_path, :ephemeral_pattern, :persistent_pattern
26
+ attr_reader :name, :disk_path, :ephemeral_pattern, :persistent_pattern, :mem_overcommit
25
27
 
26
28
  def mob
27
29
  mob = @client.find_by_inventory_path(name)
@@ -64,23 +66,9 @@ module VSphereCloud
64
66
  end
65
67
 
66
68
  def clusters
67
- cluster_mobs = get_cluster_mobs
68
-
69
- clusters_properties = @client.cloud_searcher.get_properties(
70
- cluster_mobs.values, Vim::ClusterComputeResource,
71
- Cluster::PROPERTIES, :ensure_all => true
72
- )
73
-
74
69
  clusters = {}
75
70
  @clusters.each do |cluster_name, cluster_config|
76
- cluster_mob = cluster_mobs[cluster_name]
77
- raise "Can't find cluster: #{cluster_name}" if cluster_mob.nil?
78
-
79
- cluster_properties = clusters_properties[cluster_mob]
80
- raise "Can't find properties for cluster: #{cluster_name}" if cluster_properties.nil?
81
-
82
- cluster = Cluster.new(self, @ephemeral_pattern, @persistent_pattern, @mem_overcommit, cluster_config, cluster_properties, @logger, @client)
83
- clusters[cluster.name] = cluster
71
+ clusters[cluster_name] = @cluster_provider.find(cluster_name, cluster_config)
84
72
  end
85
73
  clusters
86
74
  end
@@ -118,16 +106,6 @@ module VSphereCloud
118
106
  end
119
107
  selected_datastore
120
108
  end
121
-
122
- private
123
-
124
- def get_cluster_mobs
125
- cluster_tuples = @client.cloud_searcher.get_managed_objects(
126
- Vim::ClusterComputeResource, root: mob, include_name: true
127
- )
128
- non_clusters = cluster_tuples.reject { |name, _| !@clusters.has_key?(name) }
129
- Hash[*(non_clusters.flatten)]
130
- end
131
109
  end
132
110
  end
133
111
  end
@@ -22,6 +22,10 @@ module VSphereCloud
22
22
  cluster['name']
23
23
  end
24
24
 
25
+ def resource_pool
26
+ properties['resourcePool'].name
27
+ end
28
+
25
29
  def accessible_datastores
26
30
  host_properties['datastore'].map do |store|
27
31
  ds = cloud_searcher.get_properties(store, Vim::Datastore, 'info', ensure_all: true)
@@ -163,7 +167,7 @@ module VSphereCloud
163
167
  @properties ||= cloud_searcher.get_properties(
164
168
  @mob,
165
169
  Vim::VirtualMachine,
166
- ['runtime.powerState', 'runtime.question', 'config.hardware.device', 'name', 'runtime'],
170
+ ['runtime.powerState', 'runtime.question', 'config.hardware.device', 'name', 'runtime', 'resourcePool'],
167
171
  ensure: ['config.hardware.device', 'runtime']
168
172
  )
169
173
  end
@@ -1,7 +1,7 @@
1
1
  module Bosh
2
2
  module Clouds
3
3
  class VSphere
4
- VERSION = '1.2962.0'
4
+ VERSION = '1.2968.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_vsphere_cpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2962.0
4
+ version: 1.2968.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-01 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2962.0
19
+ version: 1.2968.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2962.0
26
+ version: 1.2968.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh_cpi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2962.0
33
+ version: 1.2968.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2962.0
40
+ version: 1.2968.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: membrane
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ dependencies:
208
208
  version: '0'
209
209
  description: |-
210
210
  BOSH VSphere CPI
211
- 74c57f
211
+ 237575
212
212
  email: support@cloudfoundry.com
213
213
  executables:
214
214
  - vsphere_cpi
@@ -236,6 +236,7 @@ files:
236
236
  - lib/cloud/vsphere/path_finder.rb
237
237
  - lib/cloud/vsphere/resources.rb
238
238
  - lib/cloud/vsphere/resources/cluster.rb
239
+ - lib/cloud/vsphere/resources/cluster_provider.rb
239
240
  - lib/cloud/vsphere/resources/datacenter.rb
240
241
  - lib/cloud/vsphere/resources/datastore.rb
241
242
  - lib/cloud/vsphere/resources/disk.rb