bosh_vsphere_cpi 1.2922.0 → 1.2941.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/disk_provider.rb +2 -13
- data/lib/cloud/vsphere/fixed_cluster_placer.rb +0 -6
- data/lib/cloud/vsphere/resources/cluster.rb +13 -51
- data/lib/cloud/vsphere/resources/datacenter.rb +24 -9
- data/lib/cloud/vsphere/resources/datastore.rb +4 -0
- data/lib/cloud/vsphere/resources.rb +1 -6
- 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: c170ec260d3cfe333240d18e22e6e29d9556dece
|
4
|
+
data.tar.gz: 1657d5501ba4ccaf32cac849af21498060cb544e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe8cc464b57fefe3be2c60b6d47b9165129f635a3f0d6b5d71eb2e52474cea84fc05a522af8a0ddcfff3e0c1589371be602645433ea99878d331d15eb885a550
|
7
|
+
data.tar.gz: ed36e5442ed70f0bda060c85c791ba44e3ee2f30445c3a0be05c60cf8825c1400f83f4058889669759a11290ffb582d05ff616f7644f33c8d022e74e5de5cbe0
|
@@ -13,7 +13,7 @@ module VSphereCloud
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def create(disk_size_in_mb)
|
16
|
-
datastore =
|
16
|
+
datastore = @datacenter.pick_persistent_datastore(disk_size_in_mb)
|
17
17
|
disk_cid = "disk-#{SecureRandom.uuid}"
|
18
18
|
@logger.debug("Creating disk '#{disk_cid}' in datastore '#{datastore.name}'")
|
19
19
|
|
@@ -24,7 +24,7 @@ module VSphereCloud
|
|
24
24
|
disk = find(disk_cid)
|
25
25
|
return disk if accessible_datastores.include?(disk.datastore.name)
|
26
26
|
|
27
|
-
destination_datastore =
|
27
|
+
destination_datastore = @resources.pick_persistent_datastore_in_cluster(cluster, disk.size_in_mb)
|
28
28
|
|
29
29
|
unless accessible_datastores.include?(destination_datastore.name)
|
30
30
|
raise "Datastore '#{destination_datastore.name}' is not accessible to cluster '#{cluster.name}'"
|
@@ -51,16 +51,5 @@ module VSphereCloud
|
|
51
51
|
def path(datastore, disk_cid)
|
52
52
|
"[#{datastore.name}] #{@disk_path}/#{disk_cid}.vmdk"
|
53
53
|
end
|
54
|
-
|
55
|
-
def find_datastore(disk_size_in_mb)
|
56
|
-
datastore = @datacenter.pick_persistent_datastore(disk_size_in_mb)
|
57
|
-
|
58
|
-
if datastore.nil?
|
59
|
-
raise Bosh::Clouds::NoDiskSpace.new(true),
|
60
|
-
"Not enough persistent space #{disk_size_in_mb}"
|
61
|
-
end
|
62
|
-
|
63
|
-
datastore
|
64
|
-
end
|
65
54
|
end
|
66
55
|
end
|
@@ -14,12 +14,6 @@ module VSphereCloud
|
|
14
14
|
|
15
15
|
def pick_ephemeral_datastore(cluster, disk_size_in_mb)
|
16
16
|
datastore = cluster.pick_ephemeral(disk_size_in_mb)
|
17
|
-
|
18
|
-
if datastore.nil?
|
19
|
-
raise Bosh::Clouds::NoDiskSpace.new(
|
20
|
-
"Not enough ephemeral disk space (#{disk_size_in_mb}MB) in cluster #{cluster.name}")
|
21
|
-
end
|
22
|
-
|
23
17
|
datastore.allocate(disk_size_in_mb)
|
24
18
|
datastore
|
25
19
|
end
|
@@ -81,8 +81,8 @@ module VSphereCloud
|
|
81
81
|
# Picks the best datastore for the specified persistent disk.
|
82
82
|
#
|
83
83
|
# @param [Integer] size persistent disk size.
|
84
|
-
# @return [Datastore
|
85
|
-
#
|
84
|
+
# @return [Datastore] the best datastore for the requested size.
|
85
|
+
# @raise [Bosh::Clouds::NoDiskSpace] if no datastore available for the requested size
|
86
86
|
def pick_persistent(size)
|
87
87
|
pick_store(:persistent, size)
|
88
88
|
end
|
@@ -90,8 +90,8 @@ module VSphereCloud
|
|
90
90
|
# Picks the best datastore for the specified ephemeral disk.
|
91
91
|
#
|
92
92
|
# @param [Integer] size ephemeral disk size.
|
93
|
-
# @return [Datastore
|
94
|
-
#
|
93
|
+
# @return [Datastore] the best datastore for the requested size.
|
94
|
+
# @raise [Bosh::Clouds::NoDiskSpace] if no datastore available for the requested size
|
95
95
|
def pick_ephemeral(size)
|
96
96
|
pick_store(:ephemeral, size)
|
97
97
|
end
|
@@ -124,58 +124,20 @@ module VSphereCloud
|
|
124
124
|
matching_datastores.inject({}) { |h, datastore| h[datastore.name] = datastore; h }
|
125
125
|
end
|
126
126
|
|
127
|
-
# Picks the best datastore for the specified disk size and type.
|
128
|
-
#
|
129
|
-
# First the exclusive datastore pool is used. If it's empty or doesn't
|
130
|
-
# have enough capacity then the shared pool will be used.
|
131
|
-
#
|
132
|
-
# @param [Integer] size disk size.
|
133
|
-
# @param [Symbol] type disk type.
|
134
|
-
# @return [Datastore, nil] best datastore if available for the requested
|
135
|
-
# size.
|
136
|
-
|
137
127
|
def pick_store(type, size)
|
138
|
-
datastores = type == :ephemeral ? ephemeral_datastores : persistent_datastores
|
139
|
-
|
140
|
-
[datastore, datastore.free_space]
|
141
|
-
end
|
142
|
-
|
143
|
-
datastores_and_free_space_with_enough_space = datastores_and_free_space.reject do |datastore, free_space|
|
144
|
-
free_space - size < DISK_HEADROOM
|
145
|
-
end
|
146
|
-
|
147
|
-
log_datastore_selection(type, datastores_and_free_space, datastores_and_free_space_with_enough_space, size)
|
128
|
+
datastores = (type == :ephemeral ? ephemeral_datastores : persistent_datastores).values
|
129
|
+
available_datastores = datastores.reject { |datastore| datastore.free_space - size < DISK_HEADROOM }
|
148
130
|
|
149
|
-
|
150
|
-
|
151
|
-
|
131
|
+
@logger.debug("Looking for a #{type} datastore in #{self.name} with #{size}MB free space.")
|
132
|
+
@logger.debug("All datastores: #{datastores.map(&:debug_info)}")
|
133
|
+
@logger.debug("Datastores with enough space: #{available_datastores.map(&:debug_info)}")
|
152
134
|
|
153
|
-
Util.weighted_random(
|
154
|
-
end
|
135
|
+
selected_datastore = Util.weighted_random(available_datastores.map { |datastore| [datastore, datastore.free_space] })
|
155
136
|
|
156
|
-
|
157
|
-
|
158
|
-
"#{datastore.name} (#{free_space}MB free of #{datastore.total_space}MB capacity)"
|
137
|
+
if selected_datastore.nil?
|
138
|
+
raise Bosh::Clouds::NoDiskSpace.new(true), "Couldn't find a #{type} datastore with #{size}MB of free space accessible from cluster '#{self.name}'. Found:\n #{datastores.map(&:debug_info).join("\n ")}\n"
|
159
139
|
end
|
160
|
-
|
161
|
-
Couldn't find a #{type} datastore with #{size}MB of free space in #{name}. Found:
|
162
|
-
#{datastore_debug_info.join("\n ")}
|
163
|
-
MESSAGE
|
164
|
-
end
|
165
|
-
|
166
|
-
def log_datastore_selection(type, datastores_and_free_space, datastores_and_free_space_with_enough_space, size)
|
167
|
-
@logger.debug("Looking for a #{type} datastore in #{name} with #{size}MB free space in:")
|
168
|
-
datastores_and_free_space.each do |datastore, _|
|
169
|
-
@logger.debug(" #{debug_info_for_datastore(datastore)}")
|
170
|
-
end
|
171
|
-
acceptable_datastores_message = datastores_and_free_space_with_enough_space.map do |datastore, _|
|
172
|
-
datastore.name
|
173
|
-
end.join(", ")
|
174
|
-
@logger.debug("Picking a random datastore (weighted by free space) from: #{acceptable_datastores_message}")
|
175
|
-
end
|
176
|
-
|
177
|
-
def debug_info_for_datastore(datastore)
|
178
|
-
"#{datastore.name} (#{datastore.free_space}MB free of #{datastore.total_space}MB capacity)"
|
140
|
+
selected_datastore
|
179
141
|
end
|
180
142
|
|
181
143
|
def synced_free_memory
|
@@ -64,11 +64,12 @@ module VSphereCloud
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def clusters
|
67
|
-
cluster_mobs =
|
67
|
+
cluster_mobs = get_cluster_mobs
|
68
68
|
|
69
69
|
clusters_properties = @client.cloud_searcher.get_properties(
|
70
70
|
cluster_mobs.values, Vim::ClusterComputeResource,
|
71
|
-
Cluster::PROPERTIES, :ensure_all => true
|
71
|
+
Cluster::PROPERTIES, :ensure_all => true
|
72
|
+
)
|
72
73
|
|
73
74
|
clusters = {}
|
74
75
|
@clusters.each do |cluster_name, cluster_config|
|
@@ -94,24 +95,38 @@ module VSphereCloud
|
|
94
95
|
datastores
|
95
96
|
end
|
96
97
|
|
97
|
-
def pick_persistent_datastore(
|
98
|
+
def pick_persistent_datastore(size)
|
98
99
|
weighted_datastores = []
|
99
100
|
persistent_datastores.each_value do |datastore|
|
100
|
-
if datastore.free_space -
|
101
|
+
if datastore.free_space - size >= DISK_HEADROOM
|
101
102
|
weighted_datastores << [datastore, datastore.free_space]
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
105
|
-
|
106
|
+
type = :persistent
|
107
|
+
datastores = persistent_datastores.values
|
108
|
+
available_datastores = datastores.reject { |datastore| datastore.free_space - size < DISK_HEADROOM }
|
109
|
+
|
110
|
+
@logger.debug("Looking for a #{type} datastore with #{size}MB free space.")
|
111
|
+
@logger.debug("All datastores: #{datastores.map(&:debug_info)}")
|
112
|
+
@logger.debug("Datastores with enough space: #{available_datastores.map(&:debug_info)}")
|
113
|
+
|
114
|
+
selected_datastore = Util.weighted_random(available_datastores.map { |datastore| [datastore, datastore.free_space] })
|
115
|
+
|
116
|
+
if selected_datastore.nil?
|
117
|
+
raise Bosh::Clouds::NoDiskSpace.new(true), "Couldn't find a #{type} datastore with #{size}MB of free space. Found:\n #{datastores.map(&:debug_info).join("\n ")}\n"
|
118
|
+
end
|
119
|
+
selected_datastore
|
106
120
|
end
|
107
121
|
|
108
122
|
private
|
109
123
|
|
110
|
-
def
|
124
|
+
def get_cluster_mobs
|
111
125
|
cluster_tuples = @client.cloud_searcher.get_managed_objects(
|
112
|
-
Vim::ClusterComputeResource, root: mob, include_name: true
|
113
|
-
|
114
|
-
cluster_tuples
|
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)]
|
115
130
|
end
|
116
131
|
end
|
117
132
|
end
|
@@ -28,7 +28,7 @@ module VSphereCloud
|
|
28
28
|
@lock.synchronize do
|
29
29
|
cluster = @datacenter.clusters[cluster_name]
|
30
30
|
if cluster.nil?
|
31
|
-
raise Bosh::Clouds::
|
31
|
+
raise Bosh::Clouds::CloudError, "Couldn't find cluster '#{cluster_name}'. Found #{@datacenter.clusters.values.map(&:name)}"
|
32
32
|
end
|
33
33
|
|
34
34
|
datastore = cluster.pick_persistent(disk_size_in_mb)
|
@@ -107,11 +107,6 @@ module VSphereCloud
|
|
107
107
|
def pick_ephemeral_datastore(cluster, disk_size_in_mb)
|
108
108
|
@lock.synchronize do
|
109
109
|
datastore = cluster.pick_ephemeral(disk_size_in_mb)
|
110
|
-
if datastore.nil?
|
111
|
-
raise Bosh::Clouds::NoDiskSpace.new(
|
112
|
-
"Not enough ephemeral disk space (#{disk_size_in_mb}MB) in cluster #{cluster.name}")
|
113
|
-
end
|
114
|
-
|
115
110
|
datastore.allocate(disk_size_in_mb)
|
116
111
|
datastore
|
117
112
|
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.
|
4
|
+
version: 1.2941.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-04-
|
11
|
+
date: 2015-04-21 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.2941.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.2941.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.2941.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.2941.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
|
+
8ac133
|
212
212
|
email: support@cloudfoundry.com
|
213
213
|
executables:
|
214
214
|
- vsphere_cpi
|