bosh_openstack_cpi 1.2820.0 → 1.2824.0
Sign up to get free protection for your applications and to get access to all the features.
- data/USAGE.md +2 -0
- data/lib/cloud/openstack.rb +1 -0
- data/lib/cloud/openstack/availability_zone_provider.rb +43 -0
- data/lib/cloud/openstack/cloud.rb +12 -28
- data/lib/cloud/openstack/version.rb +1 -1
- metadata +11 -10
data/USAGE.md
CHANGED
@@ -34,6 +34,8 @@ The registry options are passed to the Openstack CPI by the BOSH director based
|
|
34
34
|
default OpenStack ssh key name to assign to created virtual machines
|
35
35
|
* `default_security_group` (required)
|
36
36
|
default OpenStack security group to assign to created virtual machines
|
37
|
+
* `ignore_server_availability_zone` (optional)
|
38
|
+
When creating a disk, do not use the availability zone of the server, fall back to Openstacks default. Commonly used if Ceph is used for block storage. Defaults to false.
|
37
39
|
|
38
40
|
### Registry options
|
39
41
|
|
data/lib/cloud/openstack.rb
CHANGED
@@ -31,6 +31,7 @@ require "cloud/openstack/dynamic_network"
|
|
31
31
|
require "cloud/openstack/manual_network"
|
32
32
|
require "cloud/openstack/vip_network"
|
33
33
|
require "cloud/openstack/excon_logging_instrumentor"
|
34
|
+
require "cloud/openstack/availability_zone_provider"
|
34
35
|
require "cloud/openstack/redacted_params"
|
35
36
|
|
36
37
|
module Bosh
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Bosh::OpenStackCloud
|
2
|
+
class AvailabilityZoneProvider
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
def initialize(openstack, ignore_server_availability_zone)
|
6
|
+
@openstack = openstack
|
7
|
+
@ignore_server_availability_zone = ignore_server_availability_zone
|
8
|
+
end
|
9
|
+
|
10
|
+
def select(volume_ids, resource_pool_az)
|
11
|
+
if volume_ids && !volume_ids.empty? && constrain_to_server_availability_zone?
|
12
|
+
fog_volume_map = @openstack.volumes
|
13
|
+
volumes = volume_ids.map { |vid| with_openstack { fog_volume_map.get(vid) } }
|
14
|
+
ensure_same_availability_zone(volumes, resource_pool_az)
|
15
|
+
volumes.first.availability_zone
|
16
|
+
else
|
17
|
+
resource_pool_az
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def constrain_to_server_availability_zone?
|
22
|
+
!@ignore_server_availability_zone
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
##
|
28
|
+
# Ensure all supplied availability zones are the same
|
29
|
+
#
|
30
|
+
# @param [Array] disks OpenStack volumes
|
31
|
+
# @param [String] default availability zone specified in
|
32
|
+
# the resource pool (may be nil)
|
33
|
+
# @return [String] availability zone to use or nil
|
34
|
+
# @note this is a private method that is public to make it easier to test
|
35
|
+
def ensure_same_availability_zone(disks, default)
|
36
|
+
zones = disks.map { |disk| disk.availability_zone }
|
37
|
+
zones << default if default
|
38
|
+
zones.uniq!
|
39
|
+
cloud_error "can't use multiple availability zones: %s" %
|
40
|
+
zones.join(', ') unless zones.size == 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -69,6 +69,10 @@ module Bosh::OpenStackCloud
|
|
69
69
|
cloud_error('Unable to connect to the OpenStack Compute API. Check task debug log for details.')
|
70
70
|
end
|
71
71
|
|
72
|
+
@az_provider = Bosh::OpenStackCloud::AvailabilityZoneProvider.new(
|
73
|
+
@openstack,
|
74
|
+
@openstack_properties["ignore_server_availability_zone"])
|
75
|
+
|
72
76
|
glance_params = {
|
73
77
|
:provider => 'OpenStack',
|
74
78
|
:openstack_auth_url => @openstack_properties['auth_url'],
|
@@ -235,7 +239,7 @@ module Bosh::OpenStackCloud
|
|
235
239
|
if flavor.ram
|
236
240
|
# Ephemeral disk size should be at least the double of the vm total memory size, as agent will need:
|
237
241
|
# - vm total memory size for swapon,
|
238
|
-
# - the rest for /
|
242
|
+
# - the rest for /var/vcap/data
|
239
243
|
min_ephemeral_size = (flavor.ram / 1024) * 2
|
240
244
|
if flavor.ephemeral < min_ephemeral_size
|
241
245
|
cloud_error("Flavor `#{resource_pool['instance_type']}' should have at least #{min_ephemeral_size}Gb " +
|
@@ -268,7 +272,7 @@ module Bosh::OpenStackCloud
|
|
268
272
|
:user_data => Yajl::Encoder.encode(user_data(server_name, network_spec))
|
269
273
|
}
|
270
274
|
|
271
|
-
availability_zone =
|
275
|
+
availability_zone = @az_provider.select(disk_locality, resource_pool['availability_zone'])
|
272
276
|
server_params[:availability_zone] = availability_zone if availability_zone
|
273
277
|
|
274
278
|
if @boot_from_volume
|
@@ -410,7 +414,7 @@ module Bosh::OpenStackCloud
|
|
410
414
|
volume_params[:volume_type] = cloud_properties['type']
|
411
415
|
end
|
412
416
|
|
413
|
-
if server_id
|
417
|
+
if server_id && @az_provider.constrain_to_server_availability_zone?
|
414
418
|
server = with_openstack { @openstack.servers.get(server_id) }
|
415
419
|
if server && server.availability_zone
|
416
420
|
volume_params[:availability_zone] = server.availability_zone
|
@@ -448,7 +452,9 @@ module Bosh::OpenStackCloud
|
|
448
452
|
:imageRef => stemcell_id
|
449
453
|
}
|
450
454
|
|
451
|
-
|
455
|
+
if availability_zone && @az_provider.constrain_to_server_availability_zone?
|
456
|
+
volume_params[:availability_zone] = availability_zone
|
457
|
+
end
|
452
458
|
volume_params[:volume_type] = boot_volume_cloud_properties["type"] if boot_volume_cloud_properties["type"]
|
453
459
|
|
454
460
|
@logger.info("Creating new boot volume...")
|
@@ -621,29 +627,7 @@ module Bosh::OpenStackCloud
|
|
621
627
|
# @return [String] availability zone to use or nil
|
622
628
|
# @note this is a private method that is public to make it easier to test
|
623
629
|
def select_availability_zone(volumes, resource_pool_az)
|
624
|
-
|
625
|
-
disks = volumes.map { |vid| with_openstack { @openstack.volumes.get(vid) } }
|
626
|
-
ensure_same_availability_zone(disks, resource_pool_az)
|
627
|
-
disks.first.availability_zone
|
628
|
-
else
|
629
|
-
resource_pool_az
|
630
|
-
end
|
631
|
-
end
|
632
|
-
|
633
|
-
##
|
634
|
-
# Ensure all supplied availability zones are the same
|
635
|
-
#
|
636
|
-
# @param [Array] disks OpenStack volumes
|
637
|
-
# @param [String] default availability zone specified in
|
638
|
-
# the resource pool (may be nil)
|
639
|
-
# @return [String] availability zone to use or nil
|
640
|
-
# @note this is a private method that is public to make it easier to test
|
641
|
-
def ensure_same_availability_zone(disks, default)
|
642
|
-
zones = disks.map { |disk| disk.availability_zone }
|
643
|
-
zones << default if default
|
644
|
-
zones.uniq!
|
645
|
-
cloud_error "can't use multiple availability zones: %s" %
|
646
|
-
zones.join(', ') unless zones.size == 1 || zones.empty?
|
630
|
+
@az_provider.select(volumes, resource_pool_az)
|
647
631
|
end
|
648
632
|
|
649
633
|
private
|
@@ -989,6 +973,6 @@ module Bosh::OpenStackCloud
|
|
989
973
|
end
|
990
974
|
options
|
991
975
|
end
|
992
|
-
|
993
976
|
end
|
994
977
|
end
|
978
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_openstack_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2824.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-
|
12
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.2824.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.2824.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bosh_cpi
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.2824.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.2824.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bosh-registry
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.
|
69
|
+
version: 1.2824.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.
|
77
|
+
version: 1.2824.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: httpclient
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,7 +125,7 @@ dependencies:
|
|
125
125
|
version: 1.1.0
|
126
126
|
description: ! 'BOSH OpenStack CPI
|
127
127
|
|
128
|
-
|
128
|
+
1607a8'
|
129
129
|
email: support@cloudfoundry.com
|
130
130
|
executables:
|
131
131
|
- bosh_openstack_console
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- bin/openstack_cpi
|
138
138
|
- lib/bosh_openstack_cpi.rb
|
139
139
|
- lib/cloud/openstack.rb
|
140
|
+
- lib/cloud/openstack/availability_zone_provider.rb
|
140
141
|
- lib/cloud/openstack/cloud.rb
|
141
142
|
- lib/cloud/openstack/dynamic_network.rb
|
142
143
|
- lib/cloud/openstack/excon_logging_instrumentor.rb
|
@@ -171,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
172
|
version: '0'
|
172
173
|
segments:
|
173
174
|
- 0
|
174
|
-
hash: -
|
175
|
+
hash: -1072403128542098218
|
175
176
|
requirements: []
|
176
177
|
rubyforge_project:
|
177
178
|
rubygems_version: 1.8.23
|