bosh-director 1.3215.4.0 → 1.3232.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bosh-director-console +1 -1
- data/bin/bosh-director-drain-workers +8 -2
- data/bin/bosh-director-worker +34 -53
- data/db/migrations/director/20110617211923_add_deployments_release_versions.rb +2 -2
- data/db/migrations/director/20120524175805_add_task_type.rb +23 -23
- data/db/migrations/director/20130531172604_add_director_attributes.rb +1 -2
- data/db/migrations/director/20140116002324_pivot_director_attributes.rb +1 -2
- data/db/migrations/director/20160210201838_denormalize_compiled_package_stemcell_id_to_stemcell_name_and_version.rb +7 -9
- data/db/migrations/director/20160211174110_add_events.rb +22 -0
- data/db/migrations/director/20160324181932_create_delayed_jobs.rb +22 -0
- data/db/migrations/director/20160324182211_add_locks.rb +15 -0
- data/db/migrations/director/20160329201256_set_instances_with_nil_serial_to_false.rb +15 -0
- data/db/migrations/director/20160331225404_backfill_stemcell_os.rb +9 -0
- data/db/migrations/director/20160411104407_add_task_started_at.rb +9 -0
- data/lib/bosh/director.rb +9 -2
- data/lib/bosh/director/agent_client.rb +22 -9
- data/lib/bosh/director/api.rb +0 -1
- data/lib/bosh/director/api/api_helper.rb +1 -1
- data/lib/bosh/director/api/controllers/base_controller.rb +5 -1
- data/lib/bosh/director/api/controllers/cloud_configs_controller.rb +18 -2
- data/lib/bosh/director/api/controllers/deployments_controller.rb +16 -9
- data/lib/bosh/director/api/controllers/events_controller.rb +37 -0
- data/lib/bosh/director/api/controllers/locks_controller.rb +7 -11
- data/lib/bosh/director/api/controllers/packages_controller.rb +1 -1
- data/lib/bosh/director/api/controllers/runtime_configs_controller.rb +18 -2
- data/lib/bosh/director/api/controllers/tasks_controller.rb +7 -2
- data/lib/bosh/director/api/deployment_lookup.rb +1 -1
- data/lib/bosh/director/api/deployment_manager.rb +1 -1
- data/lib/bosh/director/api/event_manager.rb +68 -0
- data/lib/bosh/director/api/extensions/scoping.rb +2 -2
- data/lib/bosh/director/api/extensions/syslog_request_logger.rb +75 -0
- data/lib/bosh/director/api/instance_lookup.rb +2 -2
- data/lib/bosh/director/api/instance_manager.rb +2 -2
- data/lib/bosh/director/api/local_identity_provider.rb +8 -0
- data/lib/bosh/director/api/property_manager.rb +6 -5
- data/lib/bosh/director/api/release_manager.rb +3 -3
- data/lib/bosh/director/api/resource_manager.rb +2 -2
- data/lib/bosh/director/api/resurrector_manager.rb +1 -1
- data/lib/bosh/director/api/route_configuration.rb +1 -0
- data/lib/bosh/director/api/stemcell_manager.rb +5 -5
- data/lib/bosh/director/api/task_manager.rb +1 -0
- data/lib/bosh/director/api/task_remover.rb +1 -1
- data/lib/bosh/director/api/uaa_identity_provider.rb +9 -1
- data/lib/bosh/director/api/user/database_user_manager.rb +1 -1
- data/lib/bosh/director/app.rb +1 -1
- data/lib/bosh/director/arp_flusher.rb +23 -0
- data/lib/bosh/director/cloudcheck_helper.rb +4 -3
- data/lib/bosh/director/compile_task.rb +6 -6
- data/lib/bosh/director/compile_task_generator.rb +6 -6
- data/lib/bosh/director/compiled_release_downloader.rb +4 -4
- data/lib/bosh/director/config.rb +29 -87
- data/lib/bosh/director/deployment_deleter.rb +6 -6
- data/lib/bosh/director/deployment_plan/agent_state_migrator.rb +2 -2
- data/lib/bosh/director/deployment_plan/assembler.rb +1 -1
- data/lib/bosh/director/deployment_plan/compilation_instance_pool.rb +26 -1
- data/lib/bosh/director/deployment_plan/deployment_repo.rb +1 -1
- data/lib/bosh/director/deployment_plan/disk_type.rb +1 -1
- data/lib/bosh/director/deployment_plan/instance.rb +2 -2
- data/lib/bosh/director/deployment_plan/instance_plan.rb +2 -2
- data/lib/bosh/director/deployment_plan/instance_spec.rb +2 -0
- data/lib/bosh/director/deployment_plan/ip_provider/ip_provider.rb +7 -3
- data/lib/bosh/director/deployment_plan/job.rb +12 -10
- data/lib/bosh/director/deployment_plan/job_spec_parser.rb +4 -4
- data/lib/bosh/director/deployment_plan/links/link.rb +1 -0
- data/lib/bosh/director/deployment_plan/links/link_path.rb +18 -19
- data/lib/bosh/director/deployment_plan/links/links_resolver.rb +2 -0
- data/lib/bosh/director/deployment_plan/links/template_link.rb +1 -1
- data/lib/bosh/director/deployment_plan/manual_network.rb +1 -1
- data/lib/bosh/director/deployment_plan/manual_network_subnet.rb +6 -6
- data/lib/bosh/director/deployment_plan/planner.rb +3 -3
- data/lib/bosh/director/deployment_plan/planner_factory.rb +38 -40
- data/lib/bosh/director/deployment_plan/release_version.rb +5 -5
- data/lib/bosh/director/deployment_plan/runtime_manifest_parser.rb +22 -18
- data/lib/bosh/director/deployment_plan/steps/package_compile_step.rb +14 -16
- data/lib/bosh/director/deployment_plan/steps/update_step.rb +5 -5
- data/lib/bosh/director/deployment_plan/template.rb +61 -1
- data/lib/bosh/director/deployment_plan/update_config.rb +1 -1
- data/lib/bosh/director/disk_manager.rb +49 -40
- data/lib/bosh/director/dns/canonicalizer.rb +2 -2
- data/lib/bosh/director/dns/dns_manager.rb +2 -2
- data/lib/bosh/director/dns/powerdns.rb +2 -2
- data/lib/bosh/director/download_helper.rb +5 -5
- data/lib/bosh/director/errand/job_manager.rb +5 -6
- data/lib/bosh/director/errand/result.rb +1 -1
- data/lib/bosh/director/errand/runner.rb +2 -3
- data/lib/bosh/director/event_log.rb +1 -7
- data/lib/bosh/director/ext.rb +0 -6
- data/lib/bosh/director/instance_deleter.rb +23 -2
- data/lib/bosh/director/instance_updater.rb +62 -6
- data/lib/bosh/director/instance_updater/state_applier.rb +2 -2
- data/lib/bosh/director/job_queue.rb +4 -2
- data/lib/bosh/director/job_runner.rb +3 -8
- data/lib/bosh/director/jobs/backup.rb +1 -1
- data/lib/bosh/director/jobs/base_job.rb +10 -6
- data/lib/bosh/director/jobs/cleanup_artifacts.rb +6 -6
- data/lib/bosh/director/jobs/db_job.rb +87 -0
- data/lib/bosh/director/jobs/delete_deployment.rb +23 -2
- data/lib/bosh/director/jobs/delete_deployment_snapshots.rb +1 -1
- data/lib/bosh/director/jobs/delete_orphan_disks.rb +2 -2
- data/lib/bosh/director/jobs/delete_release.rb +2 -2
- data/lib/bosh/director/jobs/delete_stemcell.rb +1 -1
- data/lib/bosh/director/jobs/export_release.rb +4 -2
- data/lib/bosh/director/jobs/fetch_logs.rb +1 -1
- data/lib/bosh/director/jobs/helpers/blob_deleter.rb +1 -1
- data/lib/bosh/director/jobs/helpers/name_version_release_deleter.rb +3 -3
- data/lib/bosh/director/jobs/helpers/release_version_deleter.rb +1 -1
- data/lib/bosh/director/jobs/helpers/stemcell_deleter.rb +2 -12
- data/lib/bosh/director/jobs/release/release_job.rb +13 -28
- data/lib/bosh/director/jobs/run_errand.rb +6 -6
- data/lib/bosh/director/jobs/scheduled_backup.rb +1 -1
- data/lib/bosh/director/jobs/scheduled_events_cleanup.rb +31 -0
- data/lib/bosh/director/jobs/scheduled_orphan_cleanup.rb +1 -1
- data/lib/bosh/director/jobs/snapshot_deployment.rb +4 -1
- data/lib/bosh/director/jobs/ssh.rb +36 -14
- data/lib/bosh/director/jobs/update_deployment.rb +28 -6
- data/lib/bosh/director/jobs/update_release.rb +31 -41
- data/lib/bosh/director/jobs/update_stemcell.rb +4 -4
- data/lib/bosh/director/jobs/vm_state.rb +1 -2
- data/lib/bosh/director/lock.rb +30 -55
- data/lib/bosh/director/logs_fetcher.rb +2 -3
- data/lib/bosh/director/manifest/changeset.rb +88 -42
- data/lib/bosh/director/manifest/manifest.rb +1 -1
- data/lib/bosh/director/models.rb +3 -0
- data/lib/bosh/director/models/event.rb +18 -0
- data/lib/bosh/director/models/lock.rb +9 -0
- data/lib/bosh/director/models/release_version.rb +3 -1
- data/lib/bosh/director/problem_handlers/base.rb +3 -3
- data/lib/bosh/director/problem_handlers/inactive_disk.rb +4 -4
- data/lib/bosh/director/problem_handlers/missing_disk.rb +3 -3
- data/lib/bosh/director/problem_handlers/missing_vm.rb +1 -1
- data/lib/bosh/director/problem_handlers/mount_info_mismatch.rb +3 -3
- data/lib/bosh/director/problem_handlers/unresponsive_agent.rb +2 -2
- data/lib/bosh/director/problem_resolver.rb +5 -5
- data/lib/bosh/director/problem_scanner/problem_register.rb +1 -1
- data/lib/bosh/director/problem_scanner/scanner.rb +3 -2
- data/lib/bosh/director/scheduler.rb +3 -3
- data/lib/bosh/director/sequel.rb +1 -3
- data/lib/bosh/director/stopper.rb +1 -1
- data/lib/bosh/director/validation_helper.rb +60 -37
- data/lib/bosh/director/version.rb +1 -1
- data/lib/bosh/director/vm_creator.rb +39 -7
- data/lib/bosh/director/vm_deleter.rb +29 -2
- data/lib/bosh/director/vm_metadata_updater.rb +4 -0
- data/lib/bosh/director/worker.rb +52 -0
- metadata +47 -61
- data/lib/bosh/director/manifest/redactor.rb +0 -44
@@ -19,27 +19,27 @@ module Bosh::Director
|
|
19
19
|
event_log_stage = @event_log.begin_stage('Deleting instances', instance_plans.size)
|
20
20
|
instance_deleter.delete_instance_plans(instance_plans, event_log_stage, max_threads: @max_threads)
|
21
21
|
|
22
|
-
@event_log.begin_stage('Removing deployment artifacts', 3)
|
22
|
+
event_log_stage = @event_log.begin_stage('Removing deployment artifacts', 3)
|
23
23
|
|
24
|
-
|
24
|
+
event_log_stage.advance_and_track('Detaching stemcells') do
|
25
25
|
@logger.info('Detaching stemcells')
|
26
26
|
deployment_model.remove_all_stemcells
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
event_log_stage.advance_and_track('Detaching releases') do
|
30
30
|
@logger.info('Detaching releases')
|
31
31
|
deployment_model.remove_all_release_versions
|
32
32
|
end
|
33
33
|
|
34
|
-
@event_log.begin_stage('Deleting properties', deployment_model.properties.count)
|
34
|
+
event_log_stage = @event_log.begin_stage('Deleting properties', deployment_model.properties.count)
|
35
35
|
@logger.info('Deleting deployment properties')
|
36
36
|
deployment_model.properties.each do |property|
|
37
|
-
|
37
|
+
event_log_stage.advance_and_track(property.name) do
|
38
38
|
property.destroy
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
event_log_stage.advance_and_track('Destroying deployment') do
|
43
43
|
@logger.info('Destroying deployment')
|
44
44
|
deployment_model.destroy
|
45
45
|
end
|
@@ -24,9 +24,9 @@ module Bosh::Director
|
|
24
24
|
|
25
25
|
def verify_state(instance, state)
|
26
26
|
unless state.kind_of?(Hash)
|
27
|
-
@logger.error("Invalid state for
|
27
|
+
@logger.error("Invalid state for '#{instance.vm_cid}': #{state.pretty_inspect}")
|
28
28
|
raise AgentInvalidStateFormat,
|
29
|
-
"VM
|
29
|
+
"VM '#{instance.vm_cid}' returns invalid state: " +
|
30
30
|
"expected Hash, got #{state.class}"
|
31
31
|
end
|
32
32
|
end
|
@@ -129,7 +129,7 @@ module Bosh::Director
|
|
129
129
|
|
130
130
|
if stemcell.nil?
|
131
131
|
raise DirectorError,
|
132
|
-
"Stemcell not bound for resource pool
|
132
|
+
"Stemcell not bound for resource pool '#{resource_pool.name}'"
|
133
133
|
end
|
134
134
|
|
135
135
|
stemcell.bind_model(@deployment_plan.model)
|
@@ -88,7 +88,7 @@ module Bosh::Director
|
|
88
88
|
instance_memo = InstanceMemo.new(@instance_provider, stemcell)
|
89
89
|
@instance_reuser.add_in_use_instance(instance_memo, stemcell)
|
90
90
|
else
|
91
|
-
@logger.info("Reusing compilation VM
|
91
|
+
@logger.info("Reusing compilation VM '#{instance_memo.instance.model.vm_cid}' for stemcell '#{stemcell.model.desc}'")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
return instance_memo
|
@@ -139,9 +139,34 @@ module Bosh::Director
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def create_instance(instance_plan)
|
142
|
+
instance_model = instance_plan.instance.model
|
143
|
+
parent_id = add_event(instance_model.deployment.name, instance_model.name)
|
142
144
|
@deployment_plan.ip_provider.reserve(instance_plan.network_plans.first.reservation)
|
143
145
|
@vm_creator.create_for_instance_plan(instance_plan, [])
|
144
146
|
instance_plan.instance
|
147
|
+
rescue Exception => e
|
148
|
+
raise e
|
149
|
+
ensure
|
150
|
+
add_event(instance_model.deployment.name, instance_model.name, parent_id, e )
|
151
|
+
end
|
152
|
+
|
153
|
+
private
|
154
|
+
|
155
|
+
def add_event(deployment_name, instance_name = nil, parent_id = nil, error = nil)
|
156
|
+
user = Config.current_job.username
|
157
|
+
event = Config.current_job.event_manager.create_event(
|
158
|
+
{
|
159
|
+
parent_id: parent_id,
|
160
|
+
user: user,
|
161
|
+
action: 'create',
|
162
|
+
object_type: 'instance',
|
163
|
+
object_name: instance_name,
|
164
|
+
task: Config.current_job.task_id,
|
165
|
+
deployment: deployment_name,
|
166
|
+
instance: instance_name,
|
167
|
+
error: error
|
168
|
+
})
|
169
|
+
event.id
|
145
170
|
end
|
146
171
|
end
|
147
172
|
|
@@ -25,7 +25,7 @@ module Bosh::Director
|
|
25
25
|
Bosh::Director::Models::Deployment.each do |other|
|
26
26
|
if Canonicalizer.canonicalize(other.name) == canonical_name
|
27
27
|
raise DeploymentCanonicalNameTaken,
|
28
|
-
"Invalid deployment name
|
28
|
+
"Invalid deployment name '#{attributes[:name]}', canonical name already taken ('#{canonical_name}')"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
Bosh::Director::Models::Deployment.create(attributes)
|
@@ -39,7 +39,7 @@ module Bosh::Director
|
|
39
39
|
disk_size = safe_property(dp_spec, 'disk_size', class: Integer)
|
40
40
|
if disk_size < 0
|
41
41
|
raise DiskTypeInvalidDiskSize,
|
42
|
-
"Disk types
|
42
|
+
"Disk types '#{name}' references an invalid persistent disk size '#{disk_size}'"
|
43
43
|
end
|
44
44
|
|
45
45
|
cloud_properties = safe_property(dp_spec, 'cloud_properties', class: Hash, default: {})
|
@@ -341,12 +341,12 @@ module Bosh::Director
|
|
341
341
|
|
342
342
|
def check_model_bound
|
343
343
|
if @model.nil?
|
344
|
-
raise DirectorError, "Instance
|
344
|
+
raise DirectorError, "Instance '#{self}' model is not bound"
|
345
345
|
end
|
346
346
|
end
|
347
347
|
|
348
348
|
def check_model_not_bound
|
349
|
-
raise DirectorError, "Instance
|
349
|
+
raise DirectorError, "Instance '#{self}' model is already bound" if @model
|
350
350
|
end
|
351
351
|
|
352
352
|
def log_changes(method_sym, old_state, new_state)
|
@@ -298,7 +298,7 @@ module Bosh
|
|
298
298
|
|
299
299
|
def disk_size
|
300
300
|
if @instance.model.nil?
|
301
|
-
raise DirectorError, "Instance
|
301
|
+
raise DirectorError, "Instance '#{@instance}' model is not bound"
|
302
302
|
end
|
303
303
|
|
304
304
|
if @instance.model.persistent_disk
|
@@ -310,7 +310,7 @@ module Bosh
|
|
310
310
|
|
311
311
|
def disk_cloud_properties
|
312
312
|
if @instance.model.nil?
|
313
|
-
raise DirectorError, "Instance
|
313
|
+
raise DirectorError, "Instance '#{@instance}' model is not bound"
|
314
314
|
end
|
315
315
|
|
316
316
|
if @instance.model.persistent_disk
|
@@ -30,6 +30,7 @@ module Bosh::Director
|
|
30
30
|
'env' => job.env.spec,
|
31
31
|
'packages' => job.package_spec,
|
32
32
|
'properties' => job.properties,
|
33
|
+
'properties_need_filtering' => true,
|
33
34
|
'dns_domain_name' => dns_manager.dns_domain_name,
|
34
35
|
'links' => job.link_spec,
|
35
36
|
'address' => instance_plan.network_settings.network_address,
|
@@ -112,6 +113,7 @@ module Bosh::Director
|
|
112
113
|
'az',
|
113
114
|
'networks',
|
114
115
|
'properties',
|
116
|
+
'properties_need_filtering',
|
115
117
|
'dns_domain_name',
|
116
118
|
'links',
|
117
119
|
'persistent_disk',
|
@@ -92,7 +92,7 @@ module Bosh::Director
|
|
92
92
|
end
|
93
93
|
|
94
94
|
@logger.debug('Reserving existing ips')
|
95
|
-
network, subnet = find_network_and_subnet_containing(reservation.ip)
|
95
|
+
network, subnet = find_network_and_subnet_containing(reservation.ip, reservation.network.name)
|
96
96
|
if subnet
|
97
97
|
@logger.debug("Marking existing IP #{format_ip(reservation.ip)} as reserved")
|
98
98
|
reservation.resolve_network(network)
|
@@ -140,8 +140,12 @@ module Bosh::Director
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
def find_network_and_subnet_containing(cidr_ip)
|
144
|
-
@networks.values.
|
143
|
+
def find_network_and_subnet_containing(cidr_ip, network_name)
|
144
|
+
networks = @networks.values.dup
|
145
|
+
|
146
|
+
networks.unshift(networks.find { |network| network.name == network_name }).compact!
|
147
|
+
|
148
|
+
networks.select(&:manual?).each do |network|
|
145
149
|
subnet = network.subnets.find { |subnet| subnet.is_reservable?(cidr_ip) }
|
146
150
|
return [network, subnet] if subnet
|
147
151
|
end
|
@@ -184,8 +184,6 @@ module Bosh::Director
|
|
184
184
|
"blobstore_id" => first_template.blobstore_id
|
185
185
|
}
|
186
186
|
|
187
|
-
result['template_scoped_properties'] = first_template.template_scoped_properties[@name] unless first_template.template_scoped_properties[@name].nil?
|
188
|
-
|
189
187
|
if first_template.logs
|
190
188
|
result["logs"] = first_template.logs
|
191
189
|
end
|
@@ -199,8 +197,6 @@ module Bosh::Director
|
|
199
197
|
"blobstore_id" => template.blobstore_id
|
200
198
|
}
|
201
199
|
|
202
|
-
template_entry['template_scoped_properties'] = template.template_scoped_properties[@name] unless template.template_scoped_properties[@name].nil?
|
203
|
-
|
204
200
|
if template.logs
|
205
201
|
template_entry["logs"] = template.logs
|
206
202
|
end
|
@@ -347,8 +343,12 @@ module Bosh::Director
|
|
347
343
|
# @param [Hash] collection All properties collection
|
348
344
|
# @return [Hash] Properties required by templates included in this job
|
349
345
|
def filter_properties(collection)
|
350
|
-
if @templates.none? { |template| template.properties
|
351
|
-
|
346
|
+
if @templates.none? { |template| template.properties}
|
347
|
+
result = {}
|
348
|
+
@templates.each do |template|
|
349
|
+
result[template.name] = collection
|
350
|
+
end
|
351
|
+
return result
|
352
352
|
end
|
353
353
|
|
354
354
|
if @templates.all? { |template| template.properties }
|
@@ -356,9 +356,9 @@ module Bosh::Director
|
|
356
356
|
end
|
357
357
|
|
358
358
|
raise JobIncompatibleSpecs,
|
359
|
-
|
360
|
-
|
361
|
-
|
359
|
+
"Instance group '#{name}' has specs with conflicting property definition styles between" +
|
360
|
+
" its job spec templates. This may occur if colocating jobs, one of which has a spec file including" +
|
361
|
+
" 'properties' and one which doesn't."
|
362
362
|
end
|
363
363
|
|
364
364
|
def extract_template_properties(collection)
|
@@ -370,11 +370,13 @@ module Bosh::Director
|
|
370
370
|
# make them available to other templates in the same deployment job. That can
|
371
371
|
# be done by checking @template_scoped_properties variable of each
|
372
372
|
# template
|
373
|
+
result[template.name] ||= {}
|
373
374
|
if template.has_template_scoped_properties(@name)
|
374
375
|
template.bind_template_scoped_properties(@name)
|
376
|
+
result[template.name] = template.template_scoped_properties[@name]
|
375
377
|
else
|
376
378
|
template.properties.each_pair do |name, definition|
|
377
|
-
copy_property(result, collection, name, definition["default"])
|
379
|
+
copy_property(result[template.name], collection, name, definition["default"])
|
378
380
|
end
|
379
381
|
end
|
380
382
|
end
|
@@ -165,23 +165,23 @@ module Bosh::Director
|
|
165
165
|
|
166
166
|
if current_template_model.consumes != nil
|
167
167
|
current_template_model.consumes.each do |consumes|
|
168
|
-
template.
|
168
|
+
template.add_link_from_release(@job.name,'consumes', consumes["name"], consumes)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
if current_template_model.provides != nil
|
172
172
|
current_template_model.provides.each do |provides|
|
173
|
-
template.
|
173
|
+
template.add_link_from_release(@job.name, 'provides', provides["name"], provides)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
177
|
provides_links = safe_property(template_spec, 'provides', class: Hash, optional: true)
|
178
178
|
provides_links.to_a.each do |link_name, source|
|
179
|
-
template.
|
179
|
+
template.add_link_from_manifest(@job.name, "provides", link_name, source)
|
180
180
|
end
|
181
181
|
|
182
182
|
consumes_links = safe_property(template_spec, 'consumes', class: Hash, optional: true)
|
183
183
|
consumes_links.to_a.each do |link_name, source|
|
184
|
-
template.
|
184
|
+
template.add_link_from_manifest(@job.name, 'consumes', link_name, source)
|
185
185
|
end
|
186
186
|
|
187
187
|
if template_spec.has_key?("properties")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Bosh::Director
|
2
2
|
module DeploymentPlan
|
3
3
|
class LinkPath
|
4
|
-
attr_reader :deployment, :job, :template, :name, :path, :skip
|
4
|
+
attr_reader :deployment, :job, :template, :name, :path, :skip, :manual_spec
|
5
5
|
|
6
6
|
def initialize(deployment_plan, job_name, template_name)
|
7
7
|
@deployment_plan = deployment_plan
|
@@ -13,10 +13,11 @@ module Bosh::Director
|
|
13
13
|
@name = nil
|
14
14
|
@path = nil
|
15
15
|
@skip = false
|
16
|
+
@manual_spec = nil
|
16
17
|
end
|
17
18
|
|
18
19
|
def parse(link_info)
|
19
|
-
# in case the link was explicitly set to the string
|
20
|
+
# in case the link was explicitly set to the string 'nil', do not add it
|
20
21
|
# to the link paths, even if the link provider exist, since the user intent
|
21
22
|
# was explicitly set to not consume any link
|
22
23
|
|
@@ -27,6 +28,11 @@ module Bosh::Director
|
|
27
28
|
|
28
29
|
if link_info.has_key?("from")
|
29
30
|
link_path = fulfill_explicit_link(link_info)
|
31
|
+
elsif link_info.has_key?("instances") || link_info.has_key?('properties')
|
32
|
+
@manual_spec = {}
|
33
|
+
@manual_spec['instances'] = link_info['instances']
|
34
|
+
@manual_spec['properties'] = link_info['properties']
|
35
|
+
return
|
30
36
|
else
|
31
37
|
link_path = fulfill_implicit_link(link_info)
|
32
38
|
end
|
@@ -74,24 +80,17 @@ module Bosh::Director
|
|
74
80
|
else
|
75
81
|
# Only raise an exception if no linkpath was found, and the link is not optional
|
76
82
|
if !link_info["optional"]
|
77
|
-
raise "Can't find link with type
|
83
|
+
raise "Can't find link with type '#{link_type}' for job '#{@consumes_job_name}' in deployment '#{@deployment_plan.name}'#{" and network '#{link_network}''" unless link_network.to_s.empty?}"
|
78
84
|
end
|
79
85
|
end
|
80
86
|
end
|
81
87
|
|
82
88
|
def fulfill_explicit_link(link_info)
|
83
|
-
|
89
|
+
from_name = link_info['from']
|
84
90
|
link_network = link_info['network']
|
85
|
-
|
86
|
-
from_name = parts.shift
|
87
|
-
|
88
|
-
if parts.size >= 1 # given a deployment name
|
89
|
-
deployment_name = from_name
|
90
|
-
from_name = parts.shift
|
91
|
-
if parts.size >= 1
|
92
|
-
raise "From string #{from_where} is poorly formatted. It should look like 'link_name' or 'deployment_name.link_name'"
|
93
|
-
end
|
91
|
+
deployment_name = link_info['deployment']
|
94
92
|
|
93
|
+
if !deployment_name.nil?
|
95
94
|
if deployment_name == @deployment_plan.name
|
96
95
|
link_path = get_link_path_from_deployment_plan(from_name, link_network)
|
97
96
|
else
|
@@ -100,6 +99,7 @@ module Bosh::Director
|
|
100
99
|
else # given no deployment name
|
101
100
|
link_path = get_link_path_from_deployment_plan(from_name, link_network) # search the jobs for the current deployment for a provides
|
102
101
|
end
|
102
|
+
|
103
103
|
link_path[:name] = from_name
|
104
104
|
return link_path
|
105
105
|
end
|
@@ -113,7 +113,7 @@ module Bosh::Director
|
|
113
113
|
template.link_infos[job.name]['provides'].to_a.each do |provides_name, source|
|
114
114
|
link_name = source.has_key?("as") ? source['as'] : source['name']
|
115
115
|
if link_name == name
|
116
|
-
found_link_paths.push({:deployment => @deployment_plan.name, :job => job.name, :template => template.name, :name => name})
|
116
|
+
found_link_paths.push({:deployment => @deployment_plan.name, :job => job.name, :template => template.name, :name => source['name'], :as => source['as']})
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -121,14 +121,13 @@ module Bosh::Director
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
if found_link_paths.size == 1
|
124
|
-
return found_link_paths[0]
|
124
|
+
return {:deployment => found_link_paths[0][:deployment], :job => found_link_paths[0][:job], :template => found_link_paths[0][:template], :name => found_link_paths[0][:as].nil? ? found_link_paths[0][:name] : found_link_paths[0][:as]}
|
125
125
|
elsif found_link_paths.size > 1
|
126
126
|
all_link_paths = ""
|
127
127
|
found_link_paths.each do |link_path|
|
128
|
-
all_link_paths = all_link_paths + "\n #{link_path[:
|
128
|
+
all_link_paths = all_link_paths + "\n #{link_path[:name]}#{" aliased as '#{link_path[:as]}'" unless link_path[:as].nil?} (job: #{link_path[:template]}, instance group: #{link_path[:job]})"
|
129
129
|
end
|
130
|
-
|
131
|
-
raise "Cannot resolve ambiguous link '#{link_str}' in deployment #{@deployment_plan.name}:#{all_link_paths}"
|
130
|
+
raise "Cannot resolve ambiguous link '#{name}' (job: #{@consumes_template_name}, instance group: #{@consumes_job_name}). All of these match: #{all_link_paths}"
|
132
131
|
else
|
133
132
|
raise "Can't resolve link '#{name}' in instance group '#{@consumes_job_name}' on job '#{@consumes_template_name}' in deployment '#{@deployment_plan.name}'#{" and network '#{link_network}'" unless link_network.to_s.empty?}."
|
134
133
|
end
|
@@ -177,4 +176,4 @@ module Bosh::Director
|
|
177
176
|
|
178
177
|
end
|
179
178
|
end
|
180
|
-
end
|
179
|
+
end
|
@@ -29,6 +29,8 @@ module Bosh::Director
|
|
29
29
|
if !consumed_link.optional
|
30
30
|
raise JobMissingLink, "Link path was not provided for required link '#{link_name}' in instance group '#{job.name}'"
|
31
31
|
end
|
32
|
+
elsif !link_path.manual_spec.nil?
|
33
|
+
job.add_resolved_link(link_name, link_path.manual_spec)
|
32
34
|
else
|
33
35
|
link_network = template.consumes_link_info(job.name, link_name)['network']
|
34
36
|
link_lookup = LinkLookupFactory.create(consumed_link, link_path, @deployment_plan, link_network, job.name, template.name)
|
@@ -23,7 +23,7 @@ module Bosh::Director
|
|
23
23
|
def self.parse_provides_link(link_def)
|
24
24
|
if link_def.is_a?(Hash) && link_def.has_key?('type') && link_def.has_key?('name')
|
25
25
|
if link_def.has_key?('optional')
|
26
|
-
raise JobInvalidLinkSpec, "Link '#{link_def['name']}' of type '#{link_def['type']}' is a provides link, not allowed to have
|
26
|
+
raise JobInvalidLinkSpec, "Link '#{link_def['name']}' of type '#{link_def['type']}' is a provides link, not allowed to have 'optional' key"
|
27
27
|
elsif link_def.has_key?('as')
|
28
28
|
return new(link_def['as'], link_def['type'], false, link_def['shared'] || false)
|
29
29
|
else
|
@@ -18,7 +18,7 @@ module Bosh::Director
|
|
18
18
|
new_subnet = ManualNetworkSubnet.parse(name, subnet_spec, availability_zones, reserved_ranges)
|
19
19
|
subnets.each do |subnet|
|
20
20
|
if subnet.overlaps?(new_subnet)
|
21
|
-
raise NetworkOverlappingSubnets, "Network
|
21
|
+
raise NetworkOverlappingSubnets, "Network '#{name}' has overlapping subnets"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
subnets << new_subnet
|
@@ -16,7 +16,7 @@ module Bosh::Director
|
|
16
16
|
|
17
17
|
if range.size <= 1
|
18
18
|
raise NetworkInvalidRange,
|
19
|
-
"Invalid network range
|
19
|
+
"Invalid network range '#{range_property}', " +
|
20
20
|
"should include at least 2 IPs"
|
21
21
|
end
|
22
22
|
|
@@ -61,8 +61,8 @@ module Bosh::Director
|
|
61
61
|
each_ip(reserved_property) do |ip|
|
62
62
|
unless range.contains?(ip)
|
63
63
|
raise NetworkReservedIpOutOfRange,
|
64
|
-
"Reserved IP
|
65
|
-
"network
|
64
|
+
"Reserved IP '#{format_ip(ip)}' is out of " +
|
65
|
+
"network '#{network_name}' range"
|
66
66
|
end
|
67
67
|
restricted_ips.add(ip)
|
68
68
|
end
|
@@ -71,11 +71,11 @@ module Bosh::Director
|
|
71
71
|
each_ip(static_property) do |ip|
|
72
72
|
if restricted_ips.include?(ip)
|
73
73
|
raise NetworkStaticIpOutOfRange,
|
74
|
-
"Static IP
|
74
|
+
"Static IP '#{format_ip(ip)}' is in network '#{network_name}' reserved range"
|
75
75
|
end
|
76
76
|
unless range.contains?(ip)
|
77
77
|
raise NetworkStaticIpOutOfRange,
|
78
|
-
"Static IP
|
78
|
+
"Static IP '#{format_ip(ip)}' is out of network '#{network_name}' range"
|
79
79
|
end
|
80
80
|
static_ips.add(ip)
|
81
81
|
end
|
@@ -138,7 +138,7 @@ module Bosh::Director
|
|
138
138
|
|
139
139
|
def self.invalid_gateway(network_name, reason)
|
140
140
|
raise NetworkInvalidGateway,
|
141
|
-
"Invalid gateway for network
|
141
|
+
"Invalid gateway for network '#{network_name}': #{reason}"
|
142
142
|
end
|
143
143
|
|
144
144
|
def self.check_validity_of_subnet_availability_zone(availability_zone_name, availability_zones, network_name)
|