bosh_vsphere_cpi 1.3012.0 → 1.3016.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloud/vsphere/client.rb +2 -0
- data/lib/cloud/vsphere/cloud.rb +36 -36
- data/lib/cloud/vsphere/cloud_searcher.rb +11 -16
- data/lib/cloud/vsphere/resources/folder.rb +5 -1
- data/lib/cloud/vsphere/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c61a2fd7f8813ae36703f920a3e4f80379b35aa
|
4
|
+
data.tar.gz: e2d98c14a4ddbdc145cf17fea60de324fe2cc8e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e4bd7d512cd05bce61c73cb39c1155e7efc189d6b0d3bd2cf4ccf8f456b0c6cabd0775a1284431a60f922a578ff5e20049d856c541ecda91ce970f20fc230a
|
7
|
+
data.tar.gz: 8075f67026ba56ae50fe8f9d74407fd1c20da9f8e1f57b849765732cbcaa4dc8ded95bb2ea03a874752ef0863b2cd7faff50410740e2bfe03c60a3bf2f8c837f
|
data/lib/cloud/vsphere/client.rb
CHANGED
@@ -4,6 +4,7 @@ module VSphereCloud
|
|
4
4
|
|
5
5
|
class TaskException < StandardError; end
|
6
6
|
class FileNotFoundException < TaskException; end
|
7
|
+
class DuplicateName < TaskException; end
|
7
8
|
class AlreadyLoggedInException < StandardError; end
|
8
9
|
class NotLoggedInException < StandardError; end
|
9
10
|
|
@@ -270,6 +271,7 @@ module VSphereCloud
|
|
270
271
|
def task_exception_for_vim_fault(fault)
|
271
272
|
exceptions_by_fault = {
|
272
273
|
VimSdk::Vim::Fault::FileNotFound => FileNotFoundException,
|
274
|
+
VimSdk::Vim::Fault::DuplicateName => DuplicateName,
|
273
275
|
}
|
274
276
|
exceptions_by_fault.fetch(fault.class, TaskException).new(fault.msg)
|
275
277
|
end
|
data/lib/cloud/vsphere/cloud.rb
CHANGED
@@ -35,13 +35,6 @@ module VSphereCloud
|
|
35
35
|
@file_provider = FileProvider.new(config.rest_client, config.vcenter_host)
|
36
36
|
@agent_env = AgentEnv.new(client, @file_provider, @cloud_searcher)
|
37
37
|
|
38
|
-
# Global lock
|
39
|
-
@lock = Mutex.new
|
40
|
-
|
41
|
-
# Resource locks
|
42
|
-
@locks = {}
|
43
|
-
@locks_mutex = Mutex.new
|
44
|
-
|
45
38
|
# We get disconnected if the connection is inactive for a long period.
|
46
39
|
Thread.new do
|
47
40
|
while true do
|
@@ -407,33 +400,7 @@ module VSphereCloud
|
|
407
400
|
|
408
401
|
if replicated_stemcell_vm.nil?
|
409
402
|
@logger.info("Cluster doesn't have stemcell #{stemcell}, replicating")
|
410
|
-
|
411
|
-
@locks_mutex.synchronize do
|
412
|
-
lock = @locks[local_stemcell_name]
|
413
|
-
if lock.nil?
|
414
|
-
lock = @locks[local_stemcell_name] = Mutex.new
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
lock.synchronize do
|
419
|
-
replicated_stemcell_vm = client.find_by_inventory_path(local_stemcell_path)
|
420
|
-
if replicated_stemcell_vm.nil?
|
421
|
-
@logger.info("Replicating #{stemcell} (#{stemcell_vm}) to #{local_stemcell_name}")
|
422
|
-
task = clone_vm(stemcell_vm,
|
423
|
-
local_stemcell_name,
|
424
|
-
cluster.datacenter.template_folder.mob,
|
425
|
-
cluster.resource_pool.mob,
|
426
|
-
datastore: datastore.mob)
|
427
|
-
replicated_stemcell_vm = client.wait_for_task(task)
|
428
|
-
@logger.info("Replicated #{stemcell} (#{stemcell_vm}) to #{local_stemcell_name} (#{replicated_stemcell_vm})")
|
429
|
-
@logger.info("Creating initial snapshot for linked clones on #{replicated_stemcell_vm}")
|
430
|
-
# Despite the naming, this has nothing to do with the Cloud notion of a disk snapshot
|
431
|
-
# (which comes from AWS). This is a vm snapshot.
|
432
|
-
task = replicated_stemcell_vm.create_snapshot('initial', nil, false, false)
|
433
|
-
client.wait_for_task(task)
|
434
|
-
@logger.info("Created initial snapshot for linked clones on #{replicated_stemcell_vm}")
|
435
|
-
end
|
436
|
-
end
|
403
|
+
replicated_stemcell_vm = replicate_stemcell_helper(stemcell, stemcell_vm, local_stemcell_name, cluster, datastore, replicated_stemcell_vm, local_stemcell_path)
|
437
404
|
else
|
438
405
|
@logger.info("Found local stemcell replica: #{replicated_stemcell_vm}")
|
439
406
|
end
|
@@ -442,7 +409,6 @@ module VSphereCloud
|
|
442
409
|
@logger.info("Stemcell was already local: #{stemcell_vm}")
|
443
410
|
result = stemcell_vm
|
444
411
|
end
|
445
|
-
|
446
412
|
@logger.info("Using stemcell VM: #{result}")
|
447
413
|
|
448
414
|
result
|
@@ -725,6 +691,40 @@ module VSphereCloud
|
|
725
691
|
placer.nil? ? @resources : placer
|
726
692
|
end
|
727
693
|
|
728
|
-
|
694
|
+
def replicate_stemcell_helper(stemcell, stemcell_vm, local_stemcell_name, cluster, datastore, replicated_stemcell_vm, local_stemcell_path)
|
695
|
+
@logger.info("Replicating #{stemcell} (#{stemcell_vm}) to #{local_stemcell_name}")
|
696
|
+
task = clone_vm(stemcell_vm,
|
697
|
+
local_stemcell_name,
|
698
|
+
cluster.datacenter.template_folder.mob,
|
699
|
+
cluster.resource_pool.mob,
|
700
|
+
datastore: datastore.mob)
|
701
|
+
begin
|
702
|
+
replicated_stemcell_vm = client.wait_for_task(task)
|
703
|
+
@logger.info("Replicated #{stemcell} (#{stemcell_vm}) to #{local_stemcell_name} (#{replicated_stemcell_vm})")
|
704
|
+
rescue VSphereCloud::Client::DuplicateName => ex
|
705
|
+
@logger.info("Stemcell is being replicated by another thread, waiting for #{local_stemcell_name} to be ready")
|
706
|
+
replicated_stemcell_vm = client.find_by_inventory_path(local_stemcell_path)
|
707
|
+
# get_properties will ensure the existence of the snapshot by retrying.
|
708
|
+
# This forces us to wait for a valid snapshot before returning with the
|
709
|
+
# replicated stemcell vm, if a snapshot is not found then an exception is thrown.
|
710
|
+
client.cloud_searcher.get_properties(replicated_stemcell_vm,
|
711
|
+
VimSdk::Vim::VirtualMachine,
|
712
|
+
['snapshot'], ensure_all: true)
|
713
|
+
@logger.info("Stemcell #{local_stemcell_name} has been replicated.")
|
714
|
+
|
715
|
+
return replicated_stemcell_vm
|
716
|
+
end
|
717
|
+
# Despite the naming, this has nothing to do with the Cloud notion of a disk snapshot
|
718
|
+
# (which comes from AWS). This is a vm snapshot.
|
719
|
+
@logger.info("Creating initial snapshot for linked clones on #{replicated_stemcell_vm}")
|
720
|
+
task = replicated_stemcell_vm.create_snapshot('initial', nil, false, false)
|
721
|
+
client.wait_for_task(task)
|
722
|
+
@logger.info("Created initial snapshot for linked clones on #{replicated_stemcell_vm}")
|
723
|
+
|
724
|
+
replicated_stemcell_vm
|
725
|
+
end
|
726
|
+
|
727
|
+
attr_reader :config
|
728
|
+
|
729
729
|
end
|
730
730
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
require 'common/common'
|
2
|
+
|
1
3
|
module VSphereCloud
|
2
4
|
class CloudSearcher
|
3
5
|
include VimSdk
|
4
6
|
|
7
|
+
class MissingPropertiesException < StandardError; end
|
8
|
+
|
5
9
|
PC = Vmodl::Query::PropertyCollector
|
6
10
|
|
7
11
|
def initialize(service_content, logger)
|
@@ -24,9 +28,11 @@ module VSphereCloud
|
|
24
28
|
end
|
25
29
|
|
26
30
|
filter_spec = PC::FilterSpec.new(:prop_set => property_specs, :object_set => object_spec)
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
|
32
|
+
# Bosh::Common.retryable default has an exponential sleeper,
|
33
|
+
# with 30 tries the timeout will be ~265s
|
34
|
+
errors = [MissingPropertiesException]
|
35
|
+
Bosh::Common.retryable(tries: 30, on: errors) do |tries, error|
|
30
36
|
properties_response = get_all_properties(filter_spec)
|
31
37
|
result = {}
|
32
38
|
|
@@ -44,26 +50,15 @@ module VSphereCloud
|
|
44
50
|
end
|
45
51
|
end
|
46
52
|
unless remaining_properties.empty?
|
47
|
-
raise "The object[s] #{obj
|
53
|
+
raise MissingPropertiesException.new("The object[s] #{obj} " +
|
48
54
|
"should have the following properties: #{properties.pretty_inspect}, " +
|
49
|
-
"but they were missing these: #{remaining_properties.pretty_inspect}."
|
55
|
+
"but they were missing these: #{remaining_properties.pretty_inspect}.")
|
50
56
|
end
|
51
57
|
result[object_content.obj] = object_properties
|
52
58
|
end
|
53
59
|
|
54
60
|
result = result.values.first if obj.is_a?(Vmodl::ManagedObject)
|
55
61
|
result
|
56
|
-
rescue => e
|
57
|
-
attempts += 1
|
58
|
-
if attempts < 8
|
59
|
-
sleep_interval = 2 ** attempts
|
60
|
-
@logger.warn("Error retrieving properties, retrying in #{sleep_interval} seconds: " +
|
61
|
-
"#{e} - #{e.backtrace.join("\n")}")
|
62
|
-
sleep(sleep_interval)
|
63
|
-
retry
|
64
|
-
else
|
65
|
-
raise e
|
66
|
-
end
|
67
62
|
end
|
68
63
|
end
|
69
64
|
|
@@ -16,7 +16,11 @@ module VSphereCloud
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def find_or_create_folder(path_components)
|
19
|
-
|
19
|
+
if path_components.empty?
|
20
|
+
folder = root_vm_folder
|
21
|
+
raise "Root VM Folder not found: #{@datacenter_name}/vm" if folder.nil?
|
22
|
+
return folder
|
23
|
+
end
|
20
24
|
|
21
25
|
folder = find_folder(path_components)
|
22
26
|
if folder.nil?
|
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.
|
4
|
+
version: 1.3016.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-07-
|
11
|
+
date: 2015-07-14 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.
|
19
|
+
version: 1.3016.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.
|
26
|
+
version: 1.3016.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.
|
33
|
+
version: 1.3016.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.
|
40
|
+
version: 1.3016.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
|
-
|
211
|
+
10557b
|
212
212
|
email: support@cloudfoundry.com
|
213
213
|
executables:
|
214
214
|
- vsphere_cpi
|