bosh-director 1.3202.0 → 1.3213.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrations/director/20151223172000_rename_requires_json.rb +7 -0
  3. data/db/migrations/director/20160106162749_runtime_configs.rb +19 -0
  4. data/db/migrations/director/20160106163433_add_runtime_configs_to_deployments.rb +7 -0
  5. data/db/migrations/director/20160202162216_add_post_start_completed_to_instance.rb +7 -0
  6. data/db/migrations/director/20160210201838_denormalize_compiled_package_stemcell_id_to_stemcell_name_and_version.rb +57 -0
  7. data/db/migrations/director/20160219175840_add_column_teams_to_deployments.rb +8 -0
  8. data/db/migrations/director/20160224222508_add_deployment_name_to_task.rb +7 -0
  9. data/db/migrations/director/20160225182206_rename_post_start_completed.rb +8 -0
  10. data/lib/bosh/director.rb +9 -0
  11. data/lib/bosh/director/api.rb +1 -1
  12. data/lib/bosh/director/api/api_helper.rb +27 -0
  13. data/lib/bosh/director/api/controllers/base_controller.rb +28 -5
  14. data/lib/bosh/director/api/controllers/cloud_configs_controller.rb +4 -3
  15. data/lib/bosh/director/api/controllers/deployments_controller.rb +165 -81
  16. data/lib/bosh/director/api/controllers/locks_controller.rb +1 -1
  17. data/lib/bosh/director/api/controllers/packages_controller.rb +4 -35
  18. data/lib/bosh/director/api/controllers/releases_controller.rb +6 -4
  19. data/lib/bosh/director/api/controllers/runtime_configs_controller.rb +41 -0
  20. data/lib/bosh/director/api/controllers/stemcells_controller.rb +1 -1
  21. data/lib/bosh/director/api/controllers/tasks_controller.rb +72 -5
  22. data/lib/bosh/director/api/deployment_manager.rb +10 -42
  23. data/lib/bosh/director/api/extensions/scoping.rb +11 -24
  24. data/lib/bosh/director/api/instance_lookup.rb +10 -22
  25. data/lib/bosh/director/api/instance_manager.rb +27 -15
  26. data/lib/bosh/director/api/local_identity_provider.rb +0 -8
  27. data/lib/bosh/director/api/problem_manager.rb +7 -19
  28. data/lib/bosh/director/api/property_manager.rb +12 -21
  29. data/lib/bosh/director/api/resurrector_manager.rb +4 -4
  30. data/lib/bosh/director/api/route_configuration.rb +1 -0
  31. data/lib/bosh/director/api/runtime_config_manager.rb +35 -0
  32. data/lib/bosh/director/api/snapshot_manager.rb +2 -2
  33. data/lib/bosh/director/api/task_helper.rb +2 -1
  34. data/lib/bosh/director/api/task_manager.rb +2 -8
  35. data/lib/bosh/director/api/uaa_identity_provider.rb +0 -16
  36. data/lib/bosh/director/blob_util.rb +3 -2
  37. data/lib/bosh/director/cloudcheck_helper.rb +17 -3
  38. data/lib/bosh/director/compile_task.rb +53 -24
  39. data/lib/bosh/director/compile_task_generator.rb +6 -6
  40. data/lib/bosh/director/compiled_package_group.rb +4 -3
  41. data/lib/bosh/director/compiled_release.rb +6 -0
  42. data/lib/bosh/director/compiled_release/manifest.rb +30 -0
  43. data/lib/bosh/director/compiled_release_manifest.rb +3 -3
  44. data/lib/bosh/director/config.rb +11 -1
  45. data/lib/bosh/director/deployment_plan.rb +1 -0
  46. data/lib/bosh/director/deployment_plan/assembler.rb +6 -2
  47. data/lib/bosh/director/deployment_plan/cloud_manifest_parser.rb +26 -10
  48. data/lib/bosh/director/deployment_plan/compilation_config.rb +43 -7
  49. data/lib/bosh/director/deployment_plan/compilation_instance_pool.rb +10 -3
  50. data/lib/bosh/director/deployment_plan/deployment_repo.rb +4 -10
  51. data/lib/bosh/director/deployment_plan/dynamic_network.rb +1 -1
  52. data/lib/bosh/director/deployment_plan/instance.rb +36 -17
  53. data/lib/bosh/director/deployment_plan/instance_plan.rb +13 -2
  54. data/lib/bosh/director/deployment_plan/instance_spec.rb +12 -4
  55. data/lib/bosh/director/deployment_plan/job.rb +73 -39
  56. data/lib/bosh/director/deployment_plan/job_availability_zone_parser.rb +4 -4
  57. data/lib/bosh/director/deployment_plan/job_migrator.rb +7 -7
  58. data/lib/bosh/director/deployment_plan/job_network_parser.rb +6 -6
  59. data/lib/bosh/director/deployment_plan/job_spec_parser.rb +91 -33
  60. data/lib/bosh/director/deployment_plan/links/link.rb +9 -4
  61. data/lib/bosh/director/deployment_plan/links/link_lookup.rb +23 -15
  62. data/lib/bosh/director/deployment_plan/links/link_path.rb +168 -15
  63. data/lib/bosh/director/deployment_plan/links/links_resolver.rb +34 -32
  64. data/lib/bosh/director/deployment_plan/links/template_link.rb +28 -8
  65. data/lib/bosh/director/deployment_plan/manifest_validator.rb +1 -1
  66. data/lib/bosh/director/deployment_plan/network_settings.rb +27 -13
  67. data/lib/bosh/director/deployment_plan/package_validator.rb +9 -5
  68. data/lib/bosh/director/deployment_plan/placement_planner/networks_to_static_ips.rb +4 -4
  69. data/lib/bosh/director/deployment_plan/planner.rb +31 -7
  70. data/lib/bosh/director/deployment_plan/planner_factory.rb +147 -6
  71. data/lib/bosh/director/deployment_plan/runtime_manifest_parser.rb +142 -0
  72. data/lib/bosh/director/deployment_plan/stemcell.rb +2 -2
  73. data/lib/bosh/director/deployment_plan/steps/package_compile_step.rb +3 -2
  74. data/lib/bosh/director/deployment_plan/template.rb +93 -8
  75. data/lib/bosh/director/deployment_plan/update_config.rb +10 -0
  76. data/lib/bosh/director/deployment_plan/vm_extension.rb +27 -0
  77. data/lib/bosh/director/errand/runner.rb +1 -1
  78. data/lib/bosh/director/errors.rb +11 -1
  79. data/lib/bosh/director/instance_updater.rb +46 -57
  80. data/lib/bosh/director/instance_updater/instance_state.rb +9 -0
  81. data/lib/bosh/director/instance_updater/state_applier.rb +18 -5
  82. data/lib/bosh/director/job_queue.rb +2 -2
  83. data/lib/bosh/director/job_renderer.rb +2 -2
  84. data/lib/bosh/director/job_updater.rb +7 -1
  85. data/lib/bosh/director/jobs/attach_disk.rb +2 -2
  86. data/lib/bosh/director/jobs/cloud_check/apply_resolutions.rb +6 -1
  87. data/lib/bosh/director/jobs/cloud_check/scan_and_fix.rb +14 -3
  88. data/lib/bosh/director/jobs/export_release.rb +1 -1
  89. data/lib/bosh/director/jobs/fetch_logs.rb +1 -4
  90. data/lib/bosh/director/jobs/helpers/compiled_package_deleter.rb +1 -2
  91. data/lib/bosh/director/jobs/helpers/stemcell_deleter.rb +0 -16
  92. data/lib/bosh/director/jobs/release/release_job.rb +7 -7
  93. data/lib/bosh/director/jobs/run_errand.rb +5 -5
  94. data/lib/bosh/director/jobs/ssh.rb +3 -3
  95. data/lib/bosh/director/jobs/update_deployment.rb +41 -5
  96. data/lib/bosh/director/jobs/update_release.rb +78 -82
  97. data/lib/bosh/director/jobs/update_stemcell.rb +1 -1
  98. data/lib/bosh/director/jobs/vm_state.rb +34 -21
  99. data/lib/bosh/director/key_generator.rb +54 -0
  100. data/lib/bosh/director/lock.rb +2 -2
  101. data/lib/bosh/director/log_bundles_cleaner.rb +1 -0
  102. data/lib/bosh/director/manifest/changeset.rb +39 -22
  103. data/lib/bosh/director/manifest/diff_lines.rb +1 -27
  104. data/lib/bosh/director/manifest/manifest.rb +22 -7
  105. data/lib/bosh/director/manifest/redactor.rb +44 -0
  106. data/lib/bosh/director/models.rb +1 -0
  107. data/lib/bosh/director/models/compiled_package.rb +21 -15
  108. data/lib/bosh/director/models/deployment.rb +10 -0
  109. data/lib/bosh/director/models/instance.rb +2 -1
  110. data/lib/bosh/director/models/release_version.rb +0 -16
  111. data/lib/bosh/director/models/runtime_config.rb +19 -0
  112. data/lib/bosh/director/models/template.rb +4 -4
  113. data/lib/bosh/director/package_dependencies_manager.rb +22 -0
  114. data/lib/bosh/director/password_helper.rb +18 -0
  115. data/lib/bosh/director/permission_authorizer.rb +50 -30
  116. data/lib/bosh/director/post_deployment_script_runner.rb +40 -0
  117. data/lib/bosh/director/problem_handlers/missing_disk.rb +2 -2
  118. data/lib/bosh/director/problem_resolver.rb +8 -2
  119. data/lib/bosh/director/problem_scanner/scanner.rb +1 -1
  120. data/lib/bosh/director/problem_scanner/vm_scan_stage.rb +1 -1
  121. data/lib/bosh/director/validation_helper.rb +5 -5
  122. data/lib/bosh/director/version.rb +1 -1
  123. data/lib/bosh/director/vm_creator.rb +8 -0
  124. data/lib/cloud/dummy.rb +1 -0
  125. metadata +51 -19
  126. data/lib/bosh/director/api/vm_state_manager.rb +0 -9
  127. data/lib/bosh/director/compiled_package/blob_sha_mismatch_error.rb +0 -5
  128. data/lib/bosh/director/compiled_package/compiled_package.rb +0 -30
@@ -11,7 +11,7 @@ module Bosh::Director
11
11
  def generate!(compile_tasks, job, template, package, stemcell)
12
12
  # Our assumption here is that package dependency graph
13
13
  # has no cycles: this is being enforced on release upload.
14
- # Other than that it's a vanilla DFS.
14
+ # Other than that it's a vanilla Depth-First Search (DFS).
15
15
 
16
16
  @logger.info("Checking whether package `#{package.desc}' needs to be compiled for stemcell `#{stemcell.model.desc}'")
17
17
  task_key = [package.id, stemcell.id]
@@ -23,10 +23,10 @@ module Bosh::Director
23
23
  end
24
24
 
25
25
  release_version = template.release.model
26
-
27
- transitive_dependencies = release_version.transitive_dependencies(package)
28
- package_dependency_key = Models::CompiledPackage.create_dependency_key(transitive_dependencies)
29
- package_cache_key = Models::CompiledPackage.create_cache_key(package, transitive_dependencies, stemcell.model)
26
+ package_dependency_manager = PackageDependenciesManager.new(release_version)
27
+ transitive_dependencies = package_dependency_manager.transitive_dependencies(package)
28
+ package_dependency_key = KeyGenerator.new.dependency_key_from_models(package, release_version)
29
+ package_cache_key = Models::CompiledPackage.create_cache_key(package, transitive_dependencies, stemcell.model.sha1)
30
30
 
31
31
  task = CompileTask.new(package, stemcell, job, package_dependency_key, package_cache_key)
32
32
 
@@ -36,7 +36,7 @@ module Bosh::Director
36
36
  end
37
37
 
38
38
  @logger.info("Processing package `#{package.desc}' dependencies")
39
- dependencies = release_version.dependencies(package)
39
+ dependencies = package_dependency_manager.dependencies(package)
40
40
  dependencies.each do |dependency|
41
41
  @logger.info("Package `#{package.desc}' depends on package `#{dependency.desc}'")
42
42
  dependency_task = generate!(compile_tasks, job, template, dependency, stemcell)
@@ -7,11 +7,12 @@ module Bosh::Director
7
7
 
8
8
  def compiled_packages
9
9
  @compiled_packages ||= @release_version.packages.map do |package|
10
- transitive_dependencies = @release_version.transitive_dependencies(package)
11
- package_dependency_key = Bosh::Director::Models::CompiledPackage.create_dependency_key(transitive_dependencies)
10
+ package_dependency_key = KeyGenerator.new.dependency_key_from_models(package, @release_version)
11
+
12
12
  Models::CompiledPackage[
13
13
  :package_id => package.id,
14
- :stemcell_id => @stemcell.id,
14
+ :stemcell_os => @stemcell.operating_system,
15
+ :stemcell_version => @stemcell.version,
15
16
  :dependency_key => package_dependency_key
16
17
  ]
17
18
  end.compact
@@ -0,0 +1,6 @@
1
+ module Bosh::Director
2
+ module CompiledRelease
3
+ end
4
+ end
5
+
6
+ require 'bosh/director/compiled_release/manifest'
@@ -0,0 +1,30 @@
1
+ module Bosh::Director
2
+ module CompiledRelease
3
+ class Manifest
4
+ def initialize(manifest_hash)
5
+ @manifest = manifest_hash
6
+ end
7
+
8
+ def has_matching_package(package_name, stemcell_os, stemcell_version, dependency_key)
9
+
10
+ "#{stemcell_os}/#{stemcell_version}" == stemcell_os_and_version(package_name) &&
11
+ dependency_key == dependency_key(package_name)
12
+ end
13
+
14
+ def dependency_key(package_name)
15
+ KeyGenerator.new.dependency_key_from_manifest(package_name, @manifest['compiled_packages'])
16
+ end
17
+
18
+ private
19
+
20
+ def meta_data(package_name)
21
+ @manifest['compiled_packages'].find { |p| p['name'] == package_name }
22
+ end
23
+
24
+ def stemcell_os_and_version(package_name)
25
+ meta_data = meta_data(package_name)
26
+ meta_data.nil? ? nil : meta_data['stemcell']
27
+ end
28
+ end
29
+ end
30
+ end
@@ -42,11 +42,11 @@ module Bosh::Director
42
42
 
43
43
  def get_dependencies(compiled_package)
44
44
  dependencies = []
45
- parser = Yajl::Parser.new
46
- hash = parser.parse(compiled_package.package.dependency_set_json)
47
- hash.each do |name|
45
+
46
+ compiled_package.package.dependency_set.each do |name|
48
47
  dependencies << name
49
48
  end
49
+
50
50
  dependencies
51
51
  end
52
52
 
@@ -33,7 +33,10 @@ module Bosh::Director
33
33
  :max_vm_create_tries,
34
34
  :nats_uri,
35
35
  :default_ssh_options,
36
- :keep_unreachable_vms
36
+ :keep_unreachable_vms,
37
+ :enable_post_deploy,
38
+ :generate_vm_passwords,
39
+ :remove_dev_tools,
37
40
  )
38
41
 
39
42
  attr_reader(
@@ -163,6 +166,9 @@ module Bosh::Director
163
166
  @ignore_missing_gateway = config['ignore_missing_gateway']
164
167
 
165
168
  @keep_unreachable_vms = config.fetch('keep_unreachable_vms', false)
169
+ @enable_post_deploy = config.fetch('enable_post_deploy', false)
170
+ @generate_vm_passwords = config.fetch('generate_vm_passwords', false)
171
+ @remove_dev_tools = config['remove_dev_tools']
166
172
 
167
173
  Bosh::Clouds::Config.configure(self)
168
174
 
@@ -458,6 +464,10 @@ module Bosh::Director
458
464
  Config.configure(hash)
459
465
  end
460
466
 
467
+ def get_uuid_provider
468
+ Bosh::Director::Api::DirectorUUIDProvider.new(Config)
469
+ end
470
+
461
471
  private
462
472
 
463
473
  attr_reader :hash
@@ -22,6 +22,7 @@ require 'bosh/director/deployment_plan/release_version'
22
22
  require 'bosh/director/deployment_plan/resource_pool'
23
23
  require 'bosh/director/deployment_plan/env'
24
24
  require 'bosh/director/deployment_plan/vm_type'
25
+ require 'bosh/director/deployment_plan/vm_extension'
25
26
  require 'bosh/director/deployment_plan/stemcell'
26
27
  require 'bosh/director/deployment_plan/template'
27
28
  require 'bosh/director/deployment_plan/update_config'
@@ -13,7 +13,7 @@ module Bosh::Director
13
13
  @dns_manager = dns_manager
14
14
  end
15
15
 
16
- def bind_models
16
+ def bind_models(skip_links_binding = false)
17
17
  @logger.info('Binding models')
18
18
  bind_releases
19
19
 
@@ -43,7 +43,11 @@ module Bosh::Director
43
43
  bind_properties
44
44
  bind_instance_networks
45
45
  bind_dns
46
- bind_links
46
+
47
+ if (!skip_links_binding)
48
+ bind_links
49
+ end
50
+
47
51
  end
48
52
 
49
53
  private
@@ -13,8 +13,9 @@ module Bosh::Director
13
13
  networks = parse_networks(cloud_manifest, global_network_resolver, azs)
14
14
  resource_pools = parse_resource_pools(cloud_manifest)
15
15
  vm_types = parse_vm_types(cloud_manifest)
16
+ vm_extensions = parse_vm_extensions(cloud_manifest)
16
17
  disk_types = parse_disk_types(cloud_manifest)
17
- compilation_config = parse_compilation(cloud_manifest, networks, az_list, vm_types)
18
+ compilation_config = parse_compilation(cloud_manifest, networks, az_list, vm_types, vm_extensions)
18
19
 
19
20
  CloudPlanner.new({
20
21
  availability_zones_list: az_list,
@@ -24,6 +25,7 @@ module Bosh::Director
24
25
  compilation: compilation_config,
25
26
  resource_pools: resource_pools,
26
27
  vm_types: vm_types,
28
+ vm_extensions: vm_extensions,
27
29
  disk_types: disk_types,
28
30
  logger: @logger,
29
31
  })
@@ -39,7 +41,7 @@ module Bosh::Director
39
41
 
40
42
  duplicates = detect_duplicates(parsed_availability_zones) { |az| az.name }
41
43
  unless duplicates.empty?
42
- raise DeploymentDuplicateAvailabilityZoneName, "Duplicate az name `#{duplicates.first.name}'"
44
+ raise DeploymentDuplicateAvailabilityZoneName, "Duplicate az name '#{duplicates.first.name}'"
43
45
  end
44
46
 
45
47
  parsed_availability_zones
@@ -63,27 +65,27 @@ module Bosh::Director
63
65
  VipNetwork.new(network_spec, @logger)
64
66
  else
65
67
  raise DeploymentInvalidNetworkType,
66
- "Invalid network type `#{type}'"
68
+ "Invalid network type '#{type}'"
67
69
  end
68
70
  end
69
71
 
70
72
  duplicates = detect_duplicates(parsed_networks) { |network| network.canonical_name }
71
73
  unless duplicates.empty?
72
- raise DeploymentCanonicalNetworkNameTaken, "Invalid network name `#{duplicates.first.name}', canonical name already taken"
74
+ raise DeploymentCanonicalNetworkNameTaken, "Invalid network name '#{duplicates.first.name}', canonical name already taken"
73
75
  end
74
76
 
75
77
  parsed_networks
76
78
  end
77
79
 
78
- def parse_compilation(cloud_manifest, networks, az_list, vm_types)
80
+ def parse_compilation(cloud_manifest, networks, az_list, vm_types, vm_extensions)
79
81
  compilation_spec = safe_property(cloud_manifest, 'compilation', :class => Hash)
80
- config = CompilationConfig.new(compilation_spec, az_list, vm_types)
82
+ config = CompilationConfig.new(compilation_spec, az_list, vm_types, vm_extensions)
81
83
 
82
84
  compilation_network = networks.find { |network| network.name == config.network_name }
83
85
  if compilation_network.nil?
84
86
  raise CompilationConfigUnknownNetwork,
85
87
  "Compilation config references an unknown " +
86
- "network `#{config.network_name}'"
88
+ "network '#{config.network_name}'"
87
89
  end
88
90
 
89
91
  unless compilation_network.has_azs?([config.availability_zone_name])
@@ -111,7 +113,7 @@ module Bosh::Director
111
113
 
112
114
  duplicates = detect_duplicates(parsed_resource_pools) { |rp| rp.name }
113
115
  unless duplicates.empty?
114
- raise DeploymentDuplicateResourcePoolName, "Duplicate resource pool name `#{duplicates.first.name}'"
116
+ raise DeploymentDuplicateResourcePoolName, "Duplicate resource pool name '#{duplicates.first.name}'"
115
117
  end
116
118
 
117
119
  parsed_resource_pools
@@ -126,12 +128,26 @@ module Bosh::Director
126
128
 
127
129
  duplicates = detect_duplicates(parsed_vm_types) { |vmt| vmt.name }
128
130
  unless duplicates.empty?
129
- raise DeploymentDuplicateVmTypeName, "Duplicate vm type name `#{duplicates.first.name}'"
131
+ raise DeploymentDuplicateVmTypeName, "Duplicate vm type name '#{duplicates.first.name}'"
130
132
  end
131
133
 
132
134
  parsed_vm_types
133
135
  end
134
136
 
137
+ def parse_vm_extensions(cloud_manifest)
138
+ vm_extensions = safe_property(cloud_manifest, 'vm_extensions', :class => Array, :optional => true, :default => [])
139
+
140
+ parsed_vm_extensions = vm_extensions.map do |vmt_spec|
141
+ VmExtension.new(vmt_spec)
142
+ end
143
+
144
+ duplicates = detect_duplicates(parsed_vm_extensions) { |vmt| vmt.name }
145
+ unless duplicates.empty?
146
+ raise DeploymentDuplicateVmExtensionName, "Duplicate vm extension name '#{duplicates.first.name}'"
147
+ end
148
+
149
+ parsed_vm_extensions
150
+ end
135
151
 
136
152
  def parse_disk_types(cloud_manifest)
137
153
  disk_pools = safe_property(cloud_manifest, 'disk_pools', :class => Array, :optional => true, :default => [])
@@ -158,7 +174,7 @@ module Bosh::Director
158
174
 
159
175
  duplicates = detect_duplicates(parsed_disk_types) { |dp| dp.name }
160
176
  unless duplicates.empty?
161
- raise DeploymentDuplicateDiskTypeName, "Duplicate disk #{disk_source} name `#{duplicates.first.name}'"
177
+ raise DeploymentDuplicateDiskTypeName, "Duplicate disk #{disk_source} name '#{duplicates.first.name}'"
162
178
  end
163
179
 
164
180
  parsed_disk_types
@@ -23,7 +23,9 @@ module Bosh::Director
23
23
 
24
24
  attr_reader :vm_type
25
25
 
26
- def initialize(compilation_config, azs_list, vm_types = [])
26
+ attr_reader :vm_extensions
27
+
28
+ def initialize(compilation_config, azs_list, vm_types = [], vm_extensions = [])
27
29
  @workers = safe_property(compilation_config, 'workers', class: Integer, min: 1)
28
30
 
29
31
  @network_name = safe_property(compilation_config, 'network', class: String)
@@ -37,33 +39,67 @@ module Bosh::Director
37
39
  compilation_config, 'cloud_properties', class: Hash, default: {})
38
40
  @env = safe_property(compilation_config, 'env', class: Hash, optional: true, default: {})
39
41
 
42
+ parse_availability_zone(azs_list, compilation_config)
43
+
44
+ parse_vm_type(compilation_config, vm_types)
45
+
46
+ parse_vm_extensions(compilation_config, vm_extensions)
47
+
48
+ end
49
+
50
+ def availability_zone_name
51
+ @availability_zone.nil? ? nil : @availability_zone.name
52
+ end
53
+
54
+ private
55
+
56
+ def parse_availability_zone(azs_list, compilation_config)
40
57
  az_name = safe_property(compilation_config, 'az', class: String, optional: true)
41
58
  @availability_zone = azs_list[az_name]
42
59
  if az_name && !az_name.empty? && @availability_zone.nil?
43
60
  raise Bosh::Director::CompilationConfigInvalidAvailabilityZone,
44
- "Compilation config references unknown az '#{az_name}'. Known azs are: [#{azs_list.keys.join(', ')}]"
61
+ "Compilation config references unknown az '#{az_name}'. Known azs are: [#{azs_list.keys.join(', ')}]"
45
62
  end
63
+ end
46
64
 
65
+ def parse_vm_type(compilation_config, vm_types)
47
66
  vm_type_name = safe_property(compilation_config, 'vm_type', class: String, optional: true)
48
-
49
67
  if vm_type_name
50
68
  @vm_type = vm_types.find { |vm_type| vm_type.name == vm_type_name }
51
69
 
52
70
  if @vm_type.nil?
53
71
  vm_types_names = vm_types.map { |vm_type| vm_type.name }
54
72
  raise Bosh::Director::CompilationConfigInvalidVmType,
55
- "Compilation config references unknown vm type '#{vm_type_name}'. Known vm types are: #{vm_types_names.join(', ')}"
73
+ "Compilation config references unknown vm type '#{vm_type_name}'. Known vm types are: #{vm_types_names.join(', ')}"
56
74
  end
57
75
 
58
76
  unless @cloud_properties.empty?
59
77
  raise Bosh::Director::CompilationConfigCloudPropertiesNotAllowed,
60
- "Compilation config is using vm type '#{@vm_type.name}' and should not be configuring cloud_properties."
78
+ "Compilation config is using vm type '#{@vm_type.name}' and should not be configuring cloud_properties."
61
79
  end
62
80
  end
63
81
  end
64
82
 
65
- def availability_zone_name
66
- @availability_zone.nil? ? nil : @availability_zone.name
83
+ def parse_vm_extensions(compilation_config, vm_extensions)
84
+ @vm_extensions = []
85
+
86
+ vm_extension_names = safe_property(compilation_config, 'vm_extensions', class: Array, optional: true)
87
+ Array(vm_extension_names).each { |vm_extension_name|
88
+ vm_extension = vm_extensions.find { |vm_extension| vm_extension.name == vm_extension_name }
89
+
90
+ if vm_extension.nil?
91
+ vm_extensions_names = vm_extensions.map { |vm_extension| vm_extension.name }
92
+ raise Bosh::Director::CompilationConfigInvalidVmExtension,
93
+ "Compilation config references unknown vm extension '#{vm_extension_name}'. Known vm extensions are: #{vm_extensions_names.join(', ')}"
94
+ end
95
+
96
+ if @vm_type.nil?
97
+ raise Bosh::Director::CompilationConfigVmTypeRequired,
98
+ "Compilation config is using vm extension '#{vm_extension.name}' and must configure a vm type."
99
+ end
100
+
101
+ @vm_extensions.push(vm_extension)
102
+ }
67
103
  end
68
104
  end
69
105
  end
@@ -115,9 +115,11 @@ module Bosh::Director
115
115
  vm_type = CompilationVmType.new(@deployment_plan.compilation.cloud_properties)
116
116
  end
117
117
 
118
+ vm_extensions = @deployment_plan.compilation.vm_extensions
119
+
118
120
  env = Env.new(@deployment_plan.compilation.env)
119
121
 
120
- compile_job = CompilationJob.new(vm_type, stemcell, env, @deployment_plan.compilation.network_name)
122
+ compile_job = CompilationJob.new(vm_type, vm_extensions, stemcell, env, @deployment_plan.compilation.network_name)
121
123
  availability_zone = @deployment_plan.compilation.availability_zone
122
124
  instance = Instance.create_from_job(compile_job, 0, 'started', @deployment_plan.model, {}, availability_zone, @logger)
123
125
  instance.bind_new_instance_model
@@ -174,11 +176,12 @@ module Bosh::Director
174
176
  end
175
177
 
176
178
  class CompilationJob
177
- attr_reader :vm_type, :stemcell, :env, :name
179
+ attr_reader :vm_type, :vm_extensions, :stemcell, :env, :name
178
180
  attr_reader :instance_plans
179
181
 
180
- def initialize(vm_type, stemcell, env, compilation_network_name)
182
+ def initialize(vm_type, vm_extensions, stemcell, env, compilation_network_name)
181
183
  @vm_type = vm_type
184
+ @vm_extensions = vm_extensions
182
185
  @stemcell = stemcell
183
186
  @env = env
184
187
  @network = compilation_network_name
@@ -219,6 +222,10 @@ module Bosh::Director
219
222
  {}
220
223
  end
221
224
 
225
+ def update_spec
226
+ nil
227
+ end
228
+
222
229
  def persistent_disk_type
223
230
  nil
224
231
  end
@@ -1,24 +1,18 @@
1
1
  module Bosh::Director
2
2
  module DeploymentPlan
3
3
  class DeploymentRepo
4
- def initialize
5
- @permission_authorizer = Bosh::Director::PermissionAuthorizer.new
6
- end
7
4
 
8
5
  def find_or_create_by_name(name, options={})
9
6
  attributes = {name: name}
10
7
  deployment = Bosh::Director::Models::Deployment.find(attributes)
11
8
 
12
- if options['scopes']
13
- attributes.merge!(scopes: options['scopes'].join(','))
14
- end
9
+ return deployment if deployment
15
10
 
16
- if options['scopes'] && deployment
17
- @permission_authorizer.raise_error_if_unauthorized(options['scopes'], deployment.scopes.split(','))
11
+ if options['scopes']
12
+ team_scopes = Bosh::Director::Models::Deployment.transform_admin_team_scope_to_teams(options['scopes'])
13
+ attributes.merge!(teams: team_scopes.join(','))
18
14
  end
19
15
 
20
- return deployment if deployment
21
-
22
16
  create_for_attributes(attributes)
23
17
  end
24
18
 
@@ -124,7 +124,7 @@ module Bosh::Director
124
124
  def validate_reference_from_job!(job_network_spec, job_name)
125
125
  if job_network_spec.has_key?('static_ips')
126
126
  raise JobStaticIPNotSupportedOnDynamicNetwork,
127
- "Job '#{job_name}' using dynamic network '#{name}' cannot specify static IP(s)"
127
+ "Instance group '#{job_name}' using dynamic network '#{name}' cannot specify static IP(s)"
128
128
  end
129
129
  end
130
130
 
@@ -25,8 +25,6 @@ module Bosh::Director
25
25
  # @return [String] job state
26
26
  attr_reader :virtual_state
27
27
 
28
- attr_reader :current_state
29
-
30
28
  attr_reader :availability_zone
31
29
 
32
30
  attr_reader :existing_network_reservations
@@ -37,6 +35,7 @@ module Bosh::Director
37
35
  index,
38
36
  virtual_state,
39
37
  job.vm_type,
38
+ job.vm_extensions,
40
39
  job.stemcell,
41
40
  job.env,
42
41
  job.compilation?,
@@ -52,6 +51,7 @@ module Bosh::Director
52
51
  index,
53
52
  virtual_state,
54
53
  vm_type,
54
+ vm_extensions,
55
55
  stemcell,
56
56
  env,
57
57
  compilation,
@@ -66,6 +66,7 @@ module Bosh::Director
66
66
  @deployment_model = deployment_model
67
67
  @job_name = job_name
68
68
  @vm_type = vm_type
69
+ @vm_extensions = vm_extensions
69
70
  @stemcell = stemcell
70
71
  @env = env
71
72
  @compilation = compilation
@@ -73,6 +74,9 @@ module Bosh::Director
73
74
  @configuration_hash = nil
74
75
  @template_hashes = nil
75
76
  @vm = nil
77
+
78
+ # This state is coming from the agent, we
79
+ # only need networks and job_state from it.
76
80
  @current_state = instance_state || {}
77
81
 
78
82
  # reservation generated from current state/DB
@@ -124,6 +128,10 @@ module Bosh::Director
124
128
  @vm_type
125
129
  end
126
130
 
131
+ def vm_extensions
132
+ @vm_extensions
133
+ end
134
+
127
135
  def stemcell
128
136
  @stemcell
129
137
  end
@@ -198,31 +206,30 @@ module Bosh::Director
198
206
  changed
199
207
  end
200
208
 
201
- ##
202
- # @return [Boolean] returns true if the expected configuration hash
203
- # differs from the one provided by the VM
204
- def configuration_changed?
205
- changed = configuration_hash != @current_state['configuration_hash']
206
- log_changes(__method__, @current_state['configuration_hash'], configuration_hash) if changed
207
- changed
208
- end
209
-
210
209
  def current_job_spec
211
- @current_state['job']
210
+ @model.spec['job']
212
211
  end
213
212
 
214
213
  def current_packages
215
- @current_state['packages']
214
+ @model.spec['packages']
216
215
  end
217
216
 
218
217
  def current_job_state
219
218
  @current_state['job_state']
220
219
  end
221
220
 
221
+ def current_networks
222
+ @current_state['networks']
223
+ end
224
+
222
225
  def update_state
223
226
  @model.update(state: state)
224
227
  end
225
228
 
229
+ def dirty?
230
+ !@model.update_completed
231
+ end
232
+
226
233
  def update_description
227
234
  @model.update(job: job_name, index: index)
228
235
  end
@@ -269,11 +276,19 @@ module Bosh::Director
269
276
  end
270
277
 
271
278
  def cloud_properties
272
- if @availability_zone.nil?
273
- vm_type.cloud_properties
274
- else
275
- @availability_zone.cloud_properties.merge(vm_type.cloud_properties)
279
+ merged_cloud_properties = nil
280
+
281
+ if !@availability_zone.nil?
282
+ merged_cloud_properties = merge_cloud_properties(merged_cloud_properties, @availability_zone.cloud_properties)
283
+ end
284
+
285
+ merged_cloud_properties = merge_cloud_properties(merged_cloud_properties, vm_type.cloud_properties)
286
+
287
+ Array(vm_extensions).each do |vm_extension|
288
+ merged_cloud_properties = merge_cloud_properties(merged_cloud_properties, vm_extension.cloud_properties)
276
289
  end
290
+
291
+ merged_cloud_properties
277
292
  end
278
293
 
279
294
  def availability_zone_name
@@ -294,6 +309,10 @@ module Bosh::Director
294
309
 
295
310
  private
296
311
 
312
+ def merge_cloud_properties(merged_cloud_properties, new_cloud_properties)
313
+ merged_cloud_properties.nil? ? new_cloud_properties : merged_cloud_properties.merge(new_cloud_properties)
314
+ end
315
+
297
316
  # Looks up instance model in DB
298
317
  # @return [Models::Instance]
299
318
  def find_or_create_model