bosh_aws_cpi 1.2809.0 → 1.2810.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cloud/aws/helpers.rb +0 -4
- data/lib/cloud/aws/instance_manager.rb +65 -35
- data/lib/cloud/aws/stemcell_creator.rb +1 -4
- data/lib/cloud/aws/version.rb +1 -1
- metadata +10 -10
data/lib/cloud/aws/helpers.rb
CHANGED
@@ -14,12 +14,46 @@ module Bosh::AwsCloud
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create(agent_id, stemcell_id, resource_pool, networks_spec, disk_locality, environment, options)
|
17
|
+
instance_params = build_instance_params(stemcell_id, resource_pool, networks_spec, disk_locality, options)
|
18
|
+
|
19
|
+
@logger.info("Creating new instance with: #{instance_params.inspect}")
|
20
|
+
|
21
|
+
aws_instance = create_aws_instance(instance_params, resource_pool["spot_bid_price"])
|
22
|
+
|
23
|
+
instance = Instance.new(aws_instance, @registry, @elb, @logger)
|
24
|
+
|
25
|
+
begin
|
26
|
+
# We need to wait here for the instance to be running, as if we are going to
|
27
|
+
# attach to a load balancer, the instance must be running.
|
28
|
+
instance.wait_for_running
|
29
|
+
instance.attach_to_load_balancers(resource_pool['elbs'] || [])
|
30
|
+
rescue => e
|
31
|
+
@logger.warn("Failed to configure instance '#{instance.id}': #{e.inspect}")
|
32
|
+
begin
|
33
|
+
instance.terminate
|
34
|
+
rescue => e
|
35
|
+
@logger.error("Failed to terminate mis-configured instance '#{instance.id}': #{e.inspect}")
|
36
|
+
end
|
37
|
+
raise
|
38
|
+
end
|
39
|
+
|
40
|
+
instance
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [String] instance_id EC2 instance id
|
44
|
+
def find(instance_id)
|
45
|
+
Instance.new(@region.instances[instance_id], @registry, @elb, @logger)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def build_instance_params(stemcell_id, resource_pool, networks_spec, disk_locality, options)
|
17
51
|
instance_params = {count: 1}
|
18
52
|
instance_params[:image_id] = stemcell_id
|
19
53
|
instance_params[:instance_type] = resource_pool["instance_type"]
|
20
54
|
|
21
|
-
|
22
|
-
instance_params[:block_device_mappings] =
|
55
|
+
ephemeral_disk_options = resource_pool.fetch("ephemeral_disk", {})
|
56
|
+
instance_params[:block_device_mappings] = block_device_mapping(ephemeral_disk_options)
|
23
57
|
|
24
58
|
set_user_data_parameter(instance_params, networks_spec)
|
25
59
|
set_key_name_parameter(instance_params, resource_pool["key_name"], options["aws"]["default_key_name"])
|
@@ -32,14 +66,14 @@ module Bosh::AwsCloud
|
|
32
66
|
resource_pool["availability_zone"],
|
33
67
|
(instance_params[:subnet].availability_zone_name if instance_params[:subnet])
|
34
68
|
)
|
69
|
+
instance_params
|
70
|
+
end
|
35
71
|
|
36
|
-
|
37
|
-
|
38
|
-
aws_instance = nil
|
39
|
-
if resource_pool["spot_bid_price"]
|
72
|
+
def create_aws_instance(instance_params, spot_bid_price)
|
73
|
+
if spot_bid_price
|
40
74
|
@logger.info("Launching spot instance...")
|
41
75
|
spot_manager = Bosh::AwsCloud::SpotManager.new(@region)
|
42
|
-
|
76
|
+
spot_manager.create(instance_params, spot_bid_price)
|
43
77
|
else
|
44
78
|
# Retry the create instance operation a couple of times if we are told that the IP
|
45
79
|
# address is in use - it can happen when the director recreates a VM and AWS
|
@@ -49,33 +83,33 @@ module Bosh::AwsCloud
|
|
49
83
|
Bosh::Common.retryable(sleep: instance_create_wait_time, tries: 10, on: errors) do |tries, error|
|
50
84
|
@logger.info("Launching on demand instance...")
|
51
85
|
@logger.warn("IP address was in use: #{error}") if tries > 0
|
52
|
-
|
86
|
+
@region.instances.create(instance_params)
|
53
87
|
end
|
54
88
|
end
|
89
|
+
end
|
55
90
|
|
56
|
-
|
91
|
+
def instance_create_wait_time; 30; end
|
57
92
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
93
|
+
def block_device_mapping(ephemeral_disk_options)
|
94
|
+
ephemeral_volume_size_in_mb = ephemeral_disk_options.fetch('size', 0)
|
95
|
+
ephemeral_volume_size_in_gb = (ephemeral_volume_size_in_mb / 1024.0).ceil
|
96
|
+
ephemeral_volume_type = ephemeral_disk_options.fetch('type', 'standard')
|
97
|
+
|
98
|
+
if ephemeral_volume_size_in_mb > 0
|
99
|
+
[
|
100
|
+
{
|
101
|
+
device_name: '/dev/sdb',
|
102
|
+
ebs: {
|
103
|
+
volume_size: ephemeral_volume_size_in_gb,
|
104
|
+
volume_type: ephemeral_volume_type,
|
105
|
+
delete_on_termination: true,
|
106
|
+
},
|
107
|
+
},
|
108
|
+
]
|
109
|
+
else
|
110
|
+
# m3 instances require that instance storage mappings be specified when the instance is created... [#84893804]
|
111
|
+
{ '/dev/sdb' => 'ephemeral0' }
|
71
112
|
end
|
72
|
-
|
73
|
-
instance
|
74
|
-
end
|
75
|
-
|
76
|
-
# @param [String] instance_id EC2 instance id
|
77
|
-
def find(instance_id)
|
78
|
-
Instance.new(@region.instances[instance_id], @registry, @elb, @logger)
|
79
113
|
end
|
80
114
|
|
81
115
|
def set_key_name_parameter(instance_params, resource_pool_key_name, default_aws_key_name)
|
@@ -100,10 +134,10 @@ module Bosh::AwsCloud
|
|
100
134
|
|
101
135
|
subnet_network_spec = network_spec.values.select { |spec|
|
102
136
|
["manual", nil, "dynamic"].include?(spec["type"]) &&
|
103
|
-
|
137
|
+
spec.fetch("cloud_properties", {}).has_key?("subnet")
|
104
138
|
}.first
|
105
139
|
if subnet_network_spec
|
106
|
-
|
140
|
+
instance_params[:subnet] = @region.subnets[subnet_network_spec["cloud_properties"]["subnet"]]
|
107
141
|
end
|
108
142
|
end
|
109
143
|
|
@@ -120,9 +154,5 @@ module Bosh::AwsCloud
|
|
120
154
|
|
121
155
|
instance_params[:user_data] = Yajl::Encoder.encode(user_data)
|
122
156
|
end
|
123
|
-
|
124
|
-
private
|
125
|
-
|
126
|
-
def instance_create_wait_time; 30; end
|
127
157
|
end
|
128
158
|
end
|
@@ -118,10 +118,7 @@ module Bosh::AwsCloud
|
|
118
118
|
|
119
119
|
params.merge!(
|
120
120
|
:name => "BOSH-#{SecureRandom.uuid}",
|
121
|
-
:architecture => architecture
|
122
|
-
:block_device_mappings => params[:block_device_mappings].merge(
|
123
|
-
default_ephemeral_disk_mapping
|
124
|
-
)
|
121
|
+
:architecture => architecture
|
125
122
|
)
|
126
123
|
|
127
124
|
params
|
data/lib/cloud/aws/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_aws_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2810.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-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.2810.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.2810.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.2810.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.2810.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.2810.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.2810.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: httpclient
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 0.8.2
|
110
110
|
description: ! 'BOSH AWS CPI
|
111
111
|
|
112
|
-
|
112
|
+
06dee6'
|
113
113
|
email: support@cloudfoundry.com
|
114
114
|
executables:
|
115
115
|
- aws_cpi
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
segments:
|
165
165
|
- 0
|
166
|
-
hash:
|
166
|
+
hash: -1480020702912915128
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
169
|
rubygems_version: 1.8.23
|