bosh-director 1.3160.0 → 1.3163.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-worker +2 -14
- data/db/migrations/director/20150513225143_ip_addresses.rb +11 -0
- data/db/migrations/director/20150702004608_add_links.rb +8 -0
- data/db/migrations/director/20150708231924_add_link_spec.rb +7 -0
- data/db/migrations/director/20150724183256_add_debugging_to_ip_addresses.rb +8 -0
- data/db/migrations/director/20150730225029_add_uuid_to_instances.rb +16 -0
- data/db/migrations/director/20150803215805_add_availabililty_zone_and_cloud_properties_to_instances.rb +8 -0
- data/db/migrations/director/20150804211419_add_compilation_flag_to_instance.rb +7 -0
- data/db/migrations/director/20150918003455_add_bootstrap_node_to_instance.rb +7 -0
- data/db/migrations/director/20151008232214_add_dns_records.rb +7 -0
- data/db/migrations/director/20151015172551_add_orphan_disks_and_snapshots.rb +29 -0
- data/db/migrations/director/20151030222853_add_templates_to_instance.rb +10 -0
- data/db/migrations/director/20151031001039_add_spec_to_instance.rb +19 -0
- data/db/migrations/director/20151109190602_rename_orphan_columns.rb +13 -0
- data/lib/bosh/director.rb +19 -9
- data/lib/bosh/director/agent_client.rb +0 -17
- data/lib/bosh/director/api/cloud_config_manager.rb +7 -5
- data/lib/bosh/director/api/controllers/base_controller.rb +3 -2
- data/lib/bosh/director/api/controllers/cleanup_controller.rb +15 -0
- data/lib/bosh/director/api/controllers/deployments_controller.rb +38 -26
- data/lib/bosh/director/api/controllers/disks_controller.rb +20 -0
- data/lib/bosh/director/api/controllers/info_controller.rb +2 -2
- data/lib/bosh/director/api/controllers/releases_controller.rb +1 -16
- data/lib/bosh/director/api/controllers/stemcells_controller.rb +1 -9
- data/lib/bosh/director/api/deployment_manager.rb +2 -1
- data/lib/bosh/director/api/instance_lookup.rb +17 -0
- data/lib/bosh/director/api/instance_manager.rb +20 -10
- data/lib/bosh/director/api/release_manager.rb +28 -8
- data/lib/bosh/director/api/resurrector_manager.rb +9 -2
- data/lib/bosh/director/api/route_configuration.rb +2 -0
- data/lib/bosh/director/api/snapshot_manager.rb +9 -5
- data/lib/bosh/director/api/stemcell_manager.rb +50 -0
- data/lib/bosh/director/app.rb +1 -1
- data/lib/bosh/director/cloudcheck_helper.rb +119 -132
- data/lib/bosh/director/compile_task.rb +1 -1
- data/lib/bosh/director/compile_task_generator.rb +2 -2
- data/lib/bosh/director/config.rb +21 -12
- data/lib/bosh/director/deployment_deleter.rb +69 -0
- data/lib/bosh/director/deployment_plan.rb +35 -4
- data/lib/bosh/director/deployment_plan/agent_state_migrator.rb +47 -0
- data/lib/bosh/director/deployment_plan/assembler.rb +115 -241
- data/lib/bosh/director/deployment_plan/availability_zone.rb +27 -0
- data/lib/bosh/director/deployment_plan/cloud_manifest_parser.rb +144 -35
- data/lib/bosh/director/deployment_plan/compilation_config.rb +21 -19
- data/lib/bosh/director/deployment_plan/compilation_instance_pool.rb +169 -0
- data/lib/bosh/director/deployment_plan/deployment_repo.rb +4 -8
- data/lib/bosh/director/deployment_plan/deployment_spec_parser.rb +13 -1
- data/lib/bosh/director/deployment_plan/deployment_validator.rb +17 -0
- data/lib/bosh/director/deployment_plan/desired_instance.rb +15 -0
- data/lib/bosh/director/deployment_plan/{disk_pool.rb → disk_type.rb} +14 -19
- data/lib/bosh/director/deployment_plan/dynamic_network.rb +105 -53
- data/lib/bosh/director/deployment_plan/dynamic_network_subnet.rb +13 -0
- data/lib/bosh/director/deployment_plan/env.rb +18 -0
- data/lib/bosh/director/deployment_plan/global_network_resolver.rb +77 -0
- data/lib/bosh/director/deployment_plan/instance.rb +222 -390
- data/lib/bosh/director/deployment_plan/instance_network_reservations.rb +71 -0
- data/lib/bosh/director/deployment_plan/instance_plan.rb +336 -0
- data/lib/bosh/director/deployment_plan/instance_plan_factory.rb +54 -0
- data/lib/bosh/director/deployment_plan/instance_plan_sorter.rb +61 -0
- data/lib/bosh/director/deployment_plan/instance_planner.rb +101 -0
- data/lib/bosh/director/deployment_plan/instance_repository.rb +36 -0
- data/lib/bosh/director/deployment_plan/instance_spec.rb +154 -0
- data/lib/bosh/director/deployment_plan/ip_provider/database_ip_repo.rb +136 -0
- data/lib/bosh/director/deployment_plan/ip_provider/in_memory_ip_repo.rb +81 -0
- data/lib/bosh/director/deployment_plan/ip_provider/ip_provider.rb +153 -0
- data/lib/bosh/director/deployment_plan/ip_provider/ip_provider_factory.rb +22 -0
- data/lib/bosh/director/deployment_plan/job.rb +116 -53
- data/lib/bosh/director/deployment_plan/job_availability_zone_parser.rb +49 -0
- data/lib/bosh/director/deployment_plan/job_migrator.rb +90 -0
- data/lib/bosh/director/deployment_plan/job_network.rb +42 -0
- data/lib/bosh/director/deployment_plan/job_network_parser.rb +118 -0
- data/lib/bosh/director/deployment_plan/job_spec_parser.rb +123 -126
- data/lib/bosh/director/deployment_plan/links/link.rb +30 -0
- data/lib/bosh/director/deployment_plan/links/link_lookup.rb +66 -0
- data/lib/bosh/director/deployment_plan/links/link_path.rb +27 -0
- data/lib/bosh/director/deployment_plan/links/links_resolver.rb +70 -0
- data/lib/bosh/director/deployment_plan/links/template_link.rb +21 -0
- data/lib/bosh/director/deployment_plan/manifest_migrator.rb +3 -17
- data/lib/bosh/director/deployment_plan/manifest_validator.rb +46 -0
- data/lib/bosh/director/deployment_plan/manual_network.rb +70 -97
- data/lib/bosh/director/deployment_plan/manual_network_subnet.rb +148 -0
- data/lib/bosh/director/deployment_plan/network.rb +50 -39
- data/lib/bosh/director/deployment_plan/network_planner.rb +4 -0
- data/lib/bosh/director/deployment_plan/network_planner/plan.rb +26 -0
- data/lib/bosh/director/deployment_plan/network_planner/planner.rb +21 -0
- data/lib/bosh/director/deployment_plan/network_planner/reservation_reconciler.rb +81 -0
- data/lib/bosh/director/deployment_plan/network_planner/vip_static_ips_planner.rb +50 -0
- data/lib/bosh/director/deployment_plan/network_settings.rb +65 -0
- data/lib/bosh/director/deployment_plan/options/skip_drain.rb +7 -0
- data/lib/bosh/director/deployment_plan/package_validator.rb +79 -0
- data/lib/bosh/director/deployment_plan/placement_planner.rb +8 -0
- data/lib/bosh/director/deployment_plan/placement_planner/availability_zone_picker.rb +90 -0
- data/lib/bosh/director/deployment_plan/placement_planner/bruteforce_ip_allocation.rb +124 -0
- data/lib/bosh/director/deployment_plan/placement_planner/index_assigner.rb +32 -0
- data/lib/bosh/director/deployment_plan/placement_planner/networks_to_static_ips.rb +125 -0
- data/lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb +40 -0
- data/lib/bosh/director/deployment_plan/placement_planner/plan.rb +42 -0
- data/lib/bosh/director/deployment_plan/placement_planner/static_ips_availability_zone_picker.rb +237 -0
- data/lib/bosh/director/deployment_plan/placement_planner/unplaced_existing_instances.rb +53 -0
- data/lib/bosh/director/deployment_plan/planner.rb +186 -74
- data/lib/bosh/director/deployment_plan/planner_factory.rb +30 -147
- data/lib/bosh/director/deployment_plan/release_version.rb +3 -3
- data/lib/bosh/director/deployment_plan/resource_pool.rb +2 -174
- data/lib/bosh/director/deployment_plan/stemcell.rb +57 -14
- data/lib/bosh/director/deployment_plan/steps/package_compile_step.rb +28 -135
- data/lib/bosh/director/deployment_plan/steps/update_step.rb +23 -44
- data/lib/bosh/director/deployment_plan/template.rb +15 -4
- data/lib/bosh/director/deployment_plan/vip_network.rb +14 -42
- data/lib/bosh/director/deployment_plan/vm.rb +1 -99
- data/lib/bosh/director/deployment_plan/vm_type.rb +27 -0
- data/lib/bosh/director/disk_manager.rb +268 -0
- data/lib/bosh/director/dns/canonicalizer.rb +28 -0
- data/lib/bosh/director/dns/dns_manager.rb +163 -0
- data/lib/bosh/director/dns/local_dns_repo.rb +20 -0
- data/lib/bosh/director/dns/powerdns.rb +170 -0
- data/lib/bosh/director/errand/job_manager.rb +18 -29
- data/lib/bosh/director/error_ignorer.rb +16 -0
- data/lib/bosh/director/errors.rb +51 -20
- data/lib/bosh/director/event_log.rb +6 -0
- data/lib/bosh/director/instance_deleter.rb +53 -81
- data/lib/bosh/director/instance_reuser.rb +89 -0
- data/lib/bosh/director/instance_updater.rb +139 -281
- data/lib/bosh/director/instance_updater/preparer.rb +8 -5
- data/lib/bosh/director/instance_updater/state_applier.rb +21 -0
- data/lib/bosh/director/ip_util.rb +46 -26
- data/lib/bosh/director/job_renderer.rb +22 -10
- data/lib/bosh/director/job_runner.rb +1 -4
- data/lib/bosh/director/job_updater.rb +47 -35
- data/lib/bosh/director/job_updater_factory.rb +5 -4
- data/lib/bosh/director/jobs/base_job.rb +8 -0
- data/lib/bosh/director/jobs/cleanup_artifacts.rb +93 -0
- data/lib/bosh/director/jobs/delete_deployment.rb +10 -154
- data/lib/bosh/director/jobs/delete_deployment_snapshots.rb +1 -1
- data/lib/bosh/director/jobs/delete_orphan_disks.rb +44 -0
- data/lib/bosh/director/jobs/delete_release.rb +19 -196
- data/lib/bosh/director/jobs/delete_stemcell.rb +10 -76
- data/lib/bosh/director/jobs/export_release.rb +41 -121
- data/lib/bosh/director/jobs/fetch_logs.rb +0 -6
- data/lib/bosh/director/jobs/helpers.rb +10 -0
- data/lib/bosh/director/jobs/helpers/blob_deleter.rb +24 -0
- data/lib/bosh/director/jobs/helpers/compiled_package_deleter.rb +24 -0
- data/lib/bosh/director/jobs/helpers/name_version_release_deleter.rb +48 -0
- data/lib/bosh/director/jobs/helpers/package_deleter.rb +33 -0
- data/lib/bosh/director/jobs/helpers/release_deleter.rb +52 -0
- data/lib/bosh/director/jobs/helpers/release_version_deleter.rb +115 -0
- data/lib/bosh/director/jobs/helpers/releases_to_delete_picker.rb +31 -0
- data/lib/bosh/director/jobs/helpers/stemcell_deleter.rb +61 -0
- data/lib/bosh/director/jobs/helpers/stemcells_to_delete_picker.rb +30 -0
- data/lib/bosh/director/jobs/helpers/template_deleter.rb +20 -0
- data/lib/bosh/director/jobs/release/release_job.rb +18 -7
- data/lib/bosh/director/jobs/run_errand.rb +57 -36
- data/lib/bosh/director/jobs/scheduled_orphan_cleanup.rb +46 -0
- data/lib/bosh/director/jobs/ssh.rb +50 -17
- data/lib/bosh/director/jobs/update_deployment.rb +29 -11
- data/lib/bosh/director/jobs/update_release.rb +25 -4
- data/lib/bosh/director/jobs/vm_state.rb +23 -32
- data/lib/bosh/director/lock.rb +13 -8
- data/lib/bosh/director/logs_fetcher.rb +1 -1
- data/lib/bosh/director/models.rb +3 -0
- data/lib/bosh/director/models/compiled_package.rb +3 -3
- data/lib/bosh/director/models/deployment.rb +10 -0
- data/lib/bosh/director/models/instance.rb +77 -1
- data/lib/bosh/director/models/ip_address.rb +26 -0
- data/lib/bosh/director/models/orphan_disk.rb +23 -0
- data/lib/bosh/director/models/orphan_snapshot.rb +14 -0
- data/lib/bosh/director/models/template.rb +32 -9
- data/lib/bosh/director/models/vm.rb +5 -8
- data/lib/bosh/director/network_reservation.rb +69 -99
- data/lib/bosh/director/problem_handlers/inactive_disk.rb +5 -20
- data/lib/bosh/director/problem_handlers/missing_disk.rb +2 -13
- data/lib/bosh/director/problem_resolver.rb +2 -2
- data/lib/bosh/director/problem_scanner/vm_scan_stage.rb +2 -21
- data/lib/bosh/director/scheduler.rb +23 -6
- data/lib/bosh/director/{instance_updater/stopper.rb → stopper.rb} +24 -18
- data/lib/bosh/director/tagged_logger.rb +30 -0
- data/lib/bosh/director/transactor.rb +9 -0
- data/lib/bosh/director/version.rb +1 -1
- data/lib/bosh/director/vm_creator.rb +91 -19
- data/lib/bosh/director/vm_deleter.rb +25 -0
- data/lib/bosh/director/vm_recreator.rb +15 -0
- data/lib/cloud/dummy.rb +381 -94
- metadata +110 -30
- data/lib/bosh/director/deployment_plan/dns_binder.rb +0 -45
- data/lib/bosh/director/deployment_plan/instance_vm_binder.rb +0 -37
- data/lib/bosh/director/deployment_plan/network_subnet.rb +0 -166
- data/lib/bosh/director/deployment_plan/resource_pools.rb +0 -68
- data/lib/bosh/director/dns_helper.rb +0 -223
- data/lib/bosh/director/instance_updater/network_updater.rb +0 -110
- data/lib/bosh/director/instance_updater/vm_updater.rb +0 -189
- data/lib/bosh/director/problem_handlers/out_of_sync_vm.rb +0 -64
- data/lib/bosh/director/problem_handlers/unbound_instance_vm.rb +0 -85
- data/lib/bosh/director/resource_pool_updater.rb +0 -174
- data/lib/bosh/director/vm_data.rb +0 -63
- data/lib/bosh/director/vm_reuser.rb +0 -63
@@ -0,0 +1,30 @@
|
|
1
|
+
module Bosh::Director
|
2
|
+
module DeploymentPlan
|
3
|
+
# tested in links_resolver_spec
|
4
|
+
|
5
|
+
class Link
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(name, source)
|
9
|
+
@name = name
|
10
|
+
@source = source
|
11
|
+
end
|
12
|
+
|
13
|
+
def spec
|
14
|
+
{
|
15
|
+
'nodes' => @source.needed_instance_plans.map do |instance_plan|
|
16
|
+
instance = instance_plan.instance
|
17
|
+
availability_zone = instance.availability_zone.name if instance.availability_zone
|
18
|
+
{
|
19
|
+
'name' => @source.name,
|
20
|
+
'index' => instance.index,
|
21
|
+
'id' => instance.uuid,
|
22
|
+
'az' => availability_zone,
|
23
|
+
'networks' => instance_plan.network_addresses
|
24
|
+
}
|
25
|
+
end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Bosh::Director
|
2
|
+
module DeploymentPlan
|
3
|
+
# tested in link_resolver_spec
|
4
|
+
|
5
|
+
class LinkLookupFactory
|
6
|
+
def self.create(required_link, link_path, deployment_plan)
|
7
|
+
if link_path.deployment == deployment_plan.name
|
8
|
+
PlannerLinkLookup.new(required_link, link_path, deployment_plan)
|
9
|
+
else
|
10
|
+
deployment = Models::Deployment.find(name: link_path.deployment)
|
11
|
+
unless deployment
|
12
|
+
raise DeploymentInvalidLink, "Link '#{required_link}' references unknown deployment '#{link_path.deployment}'"
|
13
|
+
end
|
14
|
+
|
15
|
+
DeploymentLinkSpecLookup.new(required_link, link_path, deployment.link_spec)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Used to find link source from deployment plan
|
23
|
+
class PlannerLinkLookup
|
24
|
+
def initialize(required_link, link_path, deployment_plan)
|
25
|
+
@required_link = required_link
|
26
|
+
@link_path = link_path
|
27
|
+
@jobs = deployment_plan.jobs
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_link_spec
|
31
|
+
job = @jobs.find { |j| j.name == @link_path.job }
|
32
|
+
return nil unless job
|
33
|
+
|
34
|
+
template = job.templates.find { |t| t.name == @link_path.template }
|
35
|
+
return nil unless template
|
36
|
+
|
37
|
+
found = template.provided_links.find { |p| p.name == @link_path.name && p.type == @required_link.type }
|
38
|
+
return nil unless found
|
39
|
+
|
40
|
+
Link.new(@link_path.name, job).spec
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Used to find link source from link spec in deployment model (saved in DB)
|
45
|
+
class DeploymentLinkSpecLookup
|
46
|
+
def initialize(required_link, link_path, deployment_link_spec)
|
47
|
+
@required_link = required_link
|
48
|
+
@link_path = link_path
|
49
|
+
@deployment_link_spec = deployment_link_spec
|
50
|
+
end
|
51
|
+
|
52
|
+
def find_link_spec
|
53
|
+
job = @deployment_link_spec[@link_path.job]
|
54
|
+
return nil unless job
|
55
|
+
|
56
|
+
template = job[@link_path.template]
|
57
|
+
return nil unless template
|
58
|
+
|
59
|
+
link_path = template.fetch(@link_path.name, {})[@required_link.type]
|
60
|
+
return nil unless link_path
|
61
|
+
|
62
|
+
link_path
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Bosh::Director
|
2
|
+
module DeploymentPlan
|
3
|
+
class LinkPath < Struct.new(:deployment, :job, :template, :name, :path)
|
4
|
+
def self.parse(current_deployment_name, path, logger)
|
5
|
+
parts = path.split('.')
|
6
|
+
|
7
|
+
if parts.size == 3
|
8
|
+
logger.debug("Link '#{path}' does not specify deployment, using current deployment")
|
9
|
+
parts.unshift(current_deployment_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
if parts.size != 4
|
13
|
+
logger.error("Invalid link format: #{path}")
|
14
|
+
raise DeploymentInvalidLink,
|
15
|
+
"Link '#{path}' is invalid. A link must have either 3 or 4 parts: " +
|
16
|
+
"[deployment_name.]job_name.template_name.link_name"
|
17
|
+
end
|
18
|
+
|
19
|
+
new(*parts, path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Bosh::Director
|
2
|
+
module DeploymentPlan
|
3
|
+
class LinksResolver
|
4
|
+
def initialize(deployment_plan, logger)
|
5
|
+
@deployment_plan = deployment_plan
|
6
|
+
@logger = logger
|
7
|
+
end
|
8
|
+
|
9
|
+
def resolve(job)
|
10
|
+
@logger.debug("Resolving links for job '#{job.name}'")
|
11
|
+
|
12
|
+
job.templates.each do |template|
|
13
|
+
resolve_required_links(job, template)
|
14
|
+
save_provided_links(job, template)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def resolve_required_links(job, template)
|
21
|
+
template.required_links.each do |required_link|
|
22
|
+
link_name = required_link.name
|
23
|
+
|
24
|
+
@logger.debug("Looking for link '#{link_name}' for job '#{job.name}'")
|
25
|
+
|
26
|
+
link_path = job.link_path(template.name, link_name)
|
27
|
+
unless link_path
|
28
|
+
raise JobMissingLink,
|
29
|
+
"Link path was not provided for required link '#{link_name}' in job '#{job.name}'"
|
30
|
+
end
|
31
|
+
|
32
|
+
link_lookup = LinkLookupFactory.create(required_link, link_path, @deployment_plan)
|
33
|
+
link_spec = link_lookup.find_link_spec
|
34
|
+
|
35
|
+
unless link_spec
|
36
|
+
raise DeploymentInvalidLink,
|
37
|
+
"Cannot resolve link path '#{link_path}' required for link '#{link_name}' " +
|
38
|
+
"in job '#{job.name}' on template '#{template.name}'"
|
39
|
+
end
|
40
|
+
|
41
|
+
job.add_resolved_link(link_name, link_spec)
|
42
|
+
end
|
43
|
+
|
44
|
+
ensure_provided_links_are_used(job, template)
|
45
|
+
end
|
46
|
+
|
47
|
+
def save_provided_links(job, template)
|
48
|
+
template.provided_links.each do |provided_link|
|
49
|
+
link_spec = Link.new(provided_link.name, job).spec
|
50
|
+
|
51
|
+
@logger.debug("Saving link spec for job '#{job.name}', template: '#{template.name}', " +
|
52
|
+
"link: '#{provided_link}', spec: '#{link_spec}'")
|
53
|
+
|
54
|
+
@deployment_plan.link_spec[job.name][template.name][provided_link.name][provided_link.type] = link_spec
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def ensure_provided_links_are_used(job, template)
|
59
|
+
return if job.link_paths.empty?
|
60
|
+
job.link_paths[template.name].to_a.each do |link_name, _|
|
61
|
+
unless template.required_links.map(&:name).include?(link_name)
|
62
|
+
raise Bosh::Director::UnusedProvidedLink,
|
63
|
+
"Template '#{template.name}' in job '#{job.name}' specifies link '#{link_name}', " +
|
64
|
+
"but the release job does not require it."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Bosh::Director
|
2
|
+
module DeploymentPlan
|
3
|
+
class TemplateLink < Struct.new(:name, :type)
|
4
|
+
def self.parse(link_def)
|
5
|
+
if link_def.is_a?(String)
|
6
|
+
return new(link_def, link_def)
|
7
|
+
end
|
8
|
+
|
9
|
+
if link_def.is_a?(Hash) && link_def.has_key?('name') && link_def.has_key?('type')
|
10
|
+
return new(link_def['name'], link_def['type'])
|
11
|
+
end
|
12
|
+
|
13
|
+
raise JobInvalidLinkSpec, "Link '#{link_def}' must be either string or hash with name and type"
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
"name: #{name}, type: #{type}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,21 +6,17 @@ module Bosh
|
|
6
6
|
migrate_releases(manifest_hash)
|
7
7
|
|
8
8
|
if cloud_config.nil?
|
9
|
-
|
10
|
-
else
|
11
|
-
verify_deployment_without_cloud_config(manifest_hash)
|
12
|
-
cloud_manifest = cloud_config.manifest
|
9
|
+
cloud_config = cloud_manifest_from_deployment_manifest(manifest_hash)
|
13
10
|
end
|
14
11
|
|
15
|
-
[manifest_hash,
|
12
|
+
[manifest_hash, cloud_config]
|
16
13
|
end
|
17
14
|
|
18
15
|
private
|
19
16
|
|
20
|
-
CLOUD_MANIFEST_KEYS = ['resource_pools','compilation','disk_pools','networks']
|
21
17
|
def cloud_manifest_from_deployment_manifest(deployment_manifest)
|
22
18
|
cloud_manifest = {}
|
23
|
-
CLOUD_MANIFEST_KEYS.each do |key|
|
19
|
+
ManifestValidator::CLOUD_MANIFEST_KEYS.each do |key|
|
24
20
|
cloud_manifest[key] = deployment_manifest[key] if deployment_manifest.has_key? key
|
25
21
|
end
|
26
22
|
cloud_manifest
|
@@ -37,16 +33,6 @@ module Bosh
|
|
37
33
|
manifest_hash['releases'] = [legacy_release].compact
|
38
34
|
end
|
39
35
|
end
|
40
|
-
|
41
|
-
def verify_deployment_without_cloud_config(manifest_hash)
|
42
|
-
deployment_cloud_properties = manifest_hash.keys & CLOUD_MANIFEST_KEYS
|
43
|
-
if deployment_cloud_properties.any?
|
44
|
-
raise(
|
45
|
-
Bosh::Director::DeploymentInvalidProperty,
|
46
|
-
"Deployment manifest should not contain cloud config properties: #{deployment_cloud_properties}"
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
36
|
end
|
51
37
|
end
|
52
38
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Bosh
|
2
|
+
module Director
|
3
|
+
module DeploymentPlan
|
4
|
+
class ManifestValidator
|
5
|
+
|
6
|
+
CLOUD_MANIFEST_KEYS = ['resource_pools', 'compilation', 'disk_pools', 'networks']
|
7
|
+
|
8
|
+
def validate(manifest, cloud_config)
|
9
|
+
raise_if_has_key(manifest, 'vm_types')
|
10
|
+
raise_if_has_key(manifest, 'azs')
|
11
|
+
raise_if_has_key(manifest, 'disk_types')
|
12
|
+
|
13
|
+
if cloud_config.nil?
|
14
|
+
if manifest.has_key?('jobs')
|
15
|
+
manifest['jobs'].each do |job|
|
16
|
+
if job.has_key?('migrated_from')
|
17
|
+
raise Bosh::Director::DeploymentInvalidProperty,
|
18
|
+
"Deployment manifest jobs contain 'migrated_from', but it can only be used with cloud-config."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
raise_if_has_key(manifest, 'stemcells')
|
24
|
+
else
|
25
|
+
deployment_cloud_properties = manifest.keys & CLOUD_MANIFEST_KEYS
|
26
|
+
if deployment_cloud_properties.any?
|
27
|
+
raise(
|
28
|
+
Bosh::Director::DeploymentInvalidProperty,
|
29
|
+
"Deployment manifest should not contain cloud config properties: #{deployment_cloud_properties}"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def raise_if_has_key(manifest, property)
|
38
|
+
if manifest.has_key?(property)
|
39
|
+
raise Bosh::Director::DeploymentInvalidProperty,
|
40
|
+
"Deployment manifest contains '#{property}' section, but it can only be used in cloud-config."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,93 +1,35 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh::Director
|
4
2
|
module DeploymentPlan
|
5
3
|
##
|
6
4
|
# Represents a explicitly configured network.
|
7
|
-
class ManualNetwork <
|
5
|
+
class ManualNetwork < NetworkWithSubnets
|
6
|
+
extend ValidationHelper
|
8
7
|
include IpUtil
|
9
|
-
include DnsHelper
|
10
|
-
include ValidationHelper
|
11
8
|
|
12
|
-
|
13
|
-
# Creates a new network.
|
14
|
-
#
|
15
|
-
# @param [DeploymentPlan] deployment associated deployment plan
|
16
|
-
# @param [Hash] network_spec parsed deployment manifest network section
|
17
|
-
def initialize(deployment, network_spec)
|
18
|
-
super
|
9
|
+
attr_reader :subnets
|
19
10
|
|
20
|
-
|
21
|
-
|
11
|
+
def self.parse(network_spec, availability_zones, global_network_resolver, logger)
|
12
|
+
name = safe_property(network_spec, "name", :class => String)
|
22
13
|
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
reserved_ranges = global_network_resolver.reserved_legacy_ranges(name)
|
15
|
+
subnet_specs = safe_property(network_spec, 'subnets', :class => Array)
|
16
|
+
subnets = []
|
17
|
+
subnet_specs.each do |subnet_spec|
|
18
|
+
new_subnet = ManualNetworkSubnet.parse(name, subnet_spec, availability_zones, reserved_ranges)
|
19
|
+
subnets.each do |subnet|
|
26
20
|
if subnet.overlaps?(new_subnet)
|
27
|
-
raise NetworkOverlappingSubnets,
|
28
|
-
"Network `#{name}' has overlapping subnets"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
@subnets << new_subnet
|
32
|
-
end
|
33
|
-
|
34
|
-
# Uncomment line below when integration tests is fixed
|
35
|
-
# raise "Must specify at least one subnet" if @subnets.empty?
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# Reserves a network resource.
|
40
|
-
#
|
41
|
-
# This is either an already used reservation being verified or a new one
|
42
|
-
# waiting to be fulfilled.
|
43
|
-
# @param [NetworkReservation] reservation
|
44
|
-
# @return [Boolean] true if the reservation was fulfilled
|
45
|
-
def reserve(reservation)
|
46
|
-
reservation.reserved = false
|
47
|
-
if reservation.ip
|
48
|
-
find_subnet(reservation.ip) do |subnet|
|
49
|
-
type = subnet.reserve_ip(reservation.ip)
|
50
|
-
if type.nil?
|
51
|
-
reservation.error = NetworkReservation::USED
|
52
|
-
elsif reservation.type && reservation.type != type
|
53
|
-
reservation.error = NetworkReservation::WRONG_TYPE
|
54
|
-
else
|
55
|
-
reservation.type = type
|
56
|
-
reservation.reserved = true
|
57
|
-
end
|
58
|
-
end
|
59
|
-
else
|
60
|
-
unless reservation.dynamic?
|
61
|
-
raise NetworkReservationInvalidType,
|
62
|
-
"New reservations without IPs must be dynamic"
|
63
|
-
end
|
64
|
-
@subnets.each do |subnet|
|
65
|
-
reservation.ip = subnet.allocate_dynamic_ip
|
66
|
-
if reservation.ip
|
67
|
-
reservation.reserved = true
|
68
|
-
break
|
21
|
+
raise NetworkOverlappingSubnets, "Network `#{name}' has overlapping subnets"
|
69
22
|
end
|
70
23
|
end
|
71
|
-
|
72
|
-
reservation.error = NetworkReservation::CAPACITY
|
73
|
-
end
|
24
|
+
subnets << new_subnet
|
74
25
|
end
|
75
|
-
|
26
|
+
validate_all_subnets_use_azs(subnets, name)
|
27
|
+
new(name, subnets, logger)
|
76
28
|
end
|
77
29
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# @return [void]
|
82
|
-
def release(reservation)
|
83
|
-
unless reservation.ip
|
84
|
-
raise NetworkReservationIpMissing,
|
85
|
-
"Can't release reservation without an IP"
|
86
|
-
end
|
87
|
-
|
88
|
-
find_subnet(reservation.ip) do |subnet|
|
89
|
-
subnet.release_ip(reservation.ip)
|
90
|
-
end
|
30
|
+
def initialize(name, subnets, logger)
|
31
|
+
super(name, TaggedLogger.new(logger, 'network-configuration'))
|
32
|
+
@subnets = subnets
|
91
33
|
end
|
92
34
|
|
93
35
|
##
|
@@ -96,41 +38,72 @@ module Bosh::Director
|
|
96
38
|
# @param [NetworkReservation] reservation
|
97
39
|
# @param [Array<String>] default_properties
|
98
40
|
# @return [Hash] network settings that will be passed to the BOSH Agent
|
99
|
-
def network_settings(reservation, default_properties = VALID_DEFAULTS)
|
41
|
+
def network_settings(reservation, default_properties = VALID_DEFAULTS, availability_zone = nil)
|
100
42
|
unless reservation.ip
|
101
43
|
raise NetworkReservationIpMissing,
|
102
44
|
"Can't generate network settings without an IP"
|
103
45
|
end
|
104
46
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
"netmask" => subnet.netmask,
|
111
|
-
"cloud_properties" => subnet.cloud_properties
|
112
|
-
}
|
113
|
-
|
114
|
-
if default_properties
|
115
|
-
config["default"] = default_properties.sort
|
116
|
-
end
|
47
|
+
ip = ip_to_netaddr(reservation.ip)
|
48
|
+
subnet = find_subnet_containing(reservation.ip)
|
49
|
+
unless subnet
|
50
|
+
raise NetworkReservationInvalidIp, "Provided IP '#{ip}' does not belong to any subnet"
|
51
|
+
end
|
117
52
|
|
118
|
-
|
119
|
-
|
53
|
+
config = {
|
54
|
+
"ip" => ip.ip,
|
55
|
+
"netmask" => subnet.netmask,
|
56
|
+
"cloud_properties" => subnet.cloud_properties
|
57
|
+
}
|
58
|
+
|
59
|
+
if default_properties
|
60
|
+
config["default"] = default_properties.sort
|
120
61
|
end
|
62
|
+
|
63
|
+
config["dns"] = subnet.dns if subnet.dns
|
64
|
+
config["gateway"] = subnet.gateway.ip if subnet.gateway
|
121
65
|
config
|
122
66
|
end
|
123
67
|
|
124
|
-
|
68
|
+
def ip_type(cidr_ip)
|
69
|
+
static_ips = @subnets.map { |subnet| subnet.static_ips.to_a }.flatten
|
70
|
+
static_ips.include?(cidr_ip.to_i) ? :static : :dynamic
|
71
|
+
end
|
72
|
+
|
73
|
+
def find_az_names_for_ip(ip)
|
74
|
+
subnet = find_subnet_containing(ip)
|
75
|
+
if subnet
|
76
|
+
return subnet.availability_zone_names
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def manual?
|
81
|
+
true
|
82
|
+
end
|
83
|
+
|
125
84
|
# @param [Integer, NetAddr::CIDR, String] ip
|
126
85
|
# @yield the subnet that contains the IP.
|
127
|
-
def
|
128
|
-
@subnets.
|
129
|
-
|
130
|
-
|
131
|
-
|
86
|
+
def find_subnet_containing(ip)
|
87
|
+
@subnets.find { |subnet| subnet.range.contains?(ip) }
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def self.validate_all_subnets_use_azs(subnets, network_name)
|
93
|
+
subnets_with_azs = []
|
94
|
+
subnets_without_azs = []
|
95
|
+
subnets.each do |subnet|
|
96
|
+
if subnet.availability_zone_names.to_a.empty?
|
97
|
+
subnets_without_azs << subnet
|
98
|
+
else
|
99
|
+
subnets_with_azs << subnet
|
132
100
|
end
|
133
101
|
end
|
102
|
+
|
103
|
+
if subnets_with_azs.size > 0 && subnets_without_azs.size > 0
|
104
|
+
raise JobInvalidAvailabilityZone,
|
105
|
+
"Subnets on network '#{network_name}' must all either specify availability zone or not"
|
106
|
+
end
|
134
107
|
end
|
135
108
|
end
|
136
109
|
end
|