bosh-director 1.3016.0 → 1.3022.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13cd05082e949cce8da88e0ce3b104ab3b5db3cb
4
- data.tar.gz: ad109214ab949c9b1da47ed09609436dcc902eaa
3
+ metadata.gz: 59a2d6077683ae1eaac10b9926fd87139cbf2193
4
+ data.tar.gz: e417875f5b9b4311ca2ffc19cbea42a4b4e673ed
5
5
  SHA512:
6
- metadata.gz: 087eaba75dfd98fa0a496dc5b1d7acd10b4e55743ab056ac0e054013b74628cc749747bee4e6de73ece1d870bc507dfc3b2aa3f97e7331d7b548106c9a6c6732
7
- data.tar.gz: def64e21c02dcc889608d462ce197a0ec746ea05657cc5379685dc82fe6a4bf14cfd21d9d65297b301db7f54f2838d9a297e32a76a3252be9a7e97a883dfde3b
6
+ metadata.gz: fc4627b56956d3e9ce4795286416798815f1475b5542aee9b7de375f1b8c6b64f083b02b93db041e3530ab799f63732bc67bd3e87662e131ffd81c9dcd8216c5
7
+ data.tar.gz: c0d98a660d38ed280d769427e1ba7adb37e66426a2ccd7d46156c582194d0950eb6628a68999e257db3a92dd79871eeb8b29a954d8a29b01d303a82e744f6cec
@@ -0,0 +1,8 @@
1
+ Sequel.migration do
2
+ change do
3
+ alter_table(:packages) do
4
+ set_column_allow_null :blobstore_id, true
5
+ set_column_allow_null :sha1, true
6
+ end
7
+ end
8
+ end
@@ -16,7 +16,9 @@ module Bosh::Director
16
16
  post '/', :consumes => :multipart do
17
17
  options = {
18
18
  rebase: params['rebase'] == 'true',
19
+ compiled: params['compiled'] == 'true',
19
20
  }
21
+
20
22
  task = @release_manager.create_release_from_file_path(current_user, params[:nginx_upload_path], options)
21
23
  redirect "/tasks/#{task.id}"
22
24
  end
@@ -67,7 +67,7 @@ module Bosh::Director
67
67
  JobQueue.new.enqueue(
68
68
  username,
69
69
  Jobs::ExportRelease,
70
- "export release: #{release_name}/#{release_version} for #{stemcell_os}/#{stemcell_version}",
70
+ "export release: '#{release_name}/#{release_version}' for '#{stemcell_os}/#{stemcell_version}'",
71
71
  [deployment_name, release_name, release_version, stemcell_os, stemcell_version])
72
72
  end
73
73
  end
@@ -0,0 +1,43 @@
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+ require 'bosh/director'
4
+
5
+ module Bosh::Director
6
+ class CompiledReleaseDownloader
7
+ def initialize(compiled_packages_group, templates, blobstore_client)
8
+ @compiled_packages_group = compiled_packages_group
9
+ @templates = templates
10
+ @blobstore_client = blobstore_client
11
+ end
12
+
13
+ def download
14
+ @download_dir = Dir.mktmpdir
15
+
16
+ path = File.join(@download_dir, 'compiled_packages')
17
+ FileUtils.mkpath(path)
18
+
19
+ @compiled_packages_group.compiled_packages.each do |compiled_package|
20
+ blobstore_id = compiled_package.blobstore_id
21
+ File.open(File.join(path, "#{compiled_package.package.name}.tgz"), 'w') do |f|
22
+ @blobstore_client.get(blobstore_id, f, sha1: compiled_package.sha1)
23
+ end
24
+ end
25
+
26
+ path = File.join(@download_dir, 'jobs')
27
+ FileUtils.mkpath(path)
28
+
29
+ @templates.each do |template|
30
+ blobstore_id = template.blobstore_id
31
+ File.open(File.join(path, "#{template.name}.tgz"), 'w') do |f|
32
+ @blobstore_client.get(blobstore_id, f, sha1: template.sha1)
33
+ end
34
+ end
35
+
36
+ @download_dir
37
+ end
38
+
39
+ def cleanup
40
+ FileUtils.rm_rf(@download_dir)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,57 @@
1
+ require 'yaml'
2
+ require 'bosh/director'
3
+
4
+ module Bosh::Director
5
+ class CompiledReleaseManifest
6
+ def initialize(compiled_package_group, templates, stemcell)
7
+ @compiled_packages = compiled_package_group
8
+ @templates = templates
9
+ @stemcell = stemcell
10
+ end
11
+
12
+ def generate_manifest
13
+ manifest = {}
14
+
15
+ manifest['compiled_packages'] = @compiled_packages.compiled_packages.map do |compiled_package|
16
+ {
17
+ 'name' => compiled_package.package.name,
18
+ 'version' => compiled_package.package.version,
19
+ 'fingerprint' => compiled_package.package.fingerprint,
20
+ 'sha1' => compiled_package.sha1,
21
+ 'stemcell' => "#{@stemcell.operating_system}/#{@stemcell.version}",
22
+ 'dependencies' => get_dependencies(compiled_package),
23
+ }
24
+ end
25
+
26
+ manifest['jobs'] = @templates.map do |template|
27
+ {
28
+ 'name' => template.name,
29
+ 'version' => template.version,
30
+ 'fingerprint' => template.fingerprint,
31
+ 'sha1' => template.sha1,
32
+ }
33
+ end
34
+
35
+ manifest['commit_hash'] = @compiled_packages.release_version.commit_hash
36
+ manifest['uncommitted_changes'] = @compiled_packages.release_version.uncommitted_changes
37
+ manifest['name'] = @compiled_packages.release_version.release.name
38
+ manifest['version'] = @compiled_packages.release_version.version
39
+
40
+ manifest
41
+ end
42
+
43
+ def get_dependencies(compiled_package)
44
+ dependencies = []
45
+ parser = Yajl::Parser.new
46
+ hash = parser.parse(compiled_package.package.dependency_set_json)
47
+ hash.each do |name|
48
+ dependencies << name
49
+ end
50
+ dependencies
51
+ end
52
+
53
+ def write(dest_path)
54
+ File.open(dest_path, 'w') { |f| f.write(YAML.dump(generate_manifest)) }
55
+ end
56
+ end
57
+ end
@@ -1,6 +1,7 @@
1
1
  require 'securerandom'
2
2
  require 'common/version/release_version'
3
- require 'pp'
3
+ require 'bosh/director/compiled_release_downloader'
4
+ require 'bosh/director/compiled_release_manifest'
4
5
 
5
6
  module Bosh::Director
6
7
  module Jobs
@@ -44,9 +45,14 @@ module Bosh::Director
44
45
  self
45
46
  )
46
47
  package_compile_step.perform
48
+
49
+ tarball_state = create_tarball
50
+ result_file.write(tarball_state.to_json + "\n")
51
+
47
52
  end
48
53
  end
49
54
  end
55
+ "Exported release: #{@release_name}/#{@release_version} for #{@stemcell_os}/#{@stemcell_version}"
50
56
  end
51
57
 
52
58
  def validate_and_prepare
@@ -66,13 +72,6 @@ module Bosh::Director
66
72
  def create_planner
67
73
  modified_deployment_manifest = Psych.load(@targeted_deployment.manifest)
68
74
  cloud_config_model = @targeted_deployment.cloud_config
69
- network_name = cloud_config_model.manifest['networks'][0]['name']
70
-
71
- fake_resource_pool_manifest = {
72
- "name" => "just_for_compiling",
73
- "network" => network_name,
74
- "stemcell" => { "name" => @stemcell.name, "version" => @stemcell.version }
75
- }
76
75
 
77
76
  planner_factory = DeploymentPlan::PlannerFactory.create(Config.event_log, Config.logger)
78
77
  planner = planner_factory.planner_without_vm_binding(
@@ -80,6 +79,13 @@ module Bosh::Director
80
79
  cloud_config_model,
81
80
  {}
82
81
  )
82
+ network_name = planner.networks.first.name
83
+
84
+ fake_resource_pool_manifest = {
85
+ "name" => "just_for_compiling",
86
+ "network" => network_name,
87
+ "stemcell" => { "name" => @stemcell.name, "version" => @stemcell.version }
88
+ }
83
89
 
84
90
  resource_pool = DeploymentPlan::ResourcePool.new(planner, fake_resource_pool_manifest, Config.logger)
85
91
  planner.add_resource_pool(resource_pool)
@@ -91,6 +97,35 @@ module Bosh::Director
91
97
  planner
92
98
  end
93
99
 
100
+ def create_tarball
101
+
102
+ blobstore_client = Bosh::Director::App.instance.blobstores.blobstore
103
+
104
+ compiled_packages_group = CompiledPackageGroup.new(@release_version, @stemcell)
105
+ templates = @release_version.templates.map
106
+
107
+ compiled_release_downloader = CompiledReleaseDownloader.new(compiled_packages_group, templates, blobstore_client)
108
+ download_dir = compiled_release_downloader.download
109
+
110
+ manifest = CompiledReleaseManifest.new(compiled_packages_group, templates, @stemcell)
111
+ manifest.write(File.join(download_dir, 'release.MF'))
112
+
113
+ output_path = File.join(download_dir, "compiled_release_#{Time.now.to_f}.tar.gz")
114
+ archiver = Core::TarGzipper.new
115
+
116
+ archiver.compress(download_dir, ['compiled_packages', 'jobs', 'release.MF'], output_path)
117
+ tarball_file = File.open(output_path, 'r')
118
+
119
+ oid = blobstore_client.create(tarball_file)
120
+
121
+ {
122
+ :blobstore_id => oid,
123
+ :sha1 => Digest::SHA1.file(output_path).hexdigest,
124
+ }
125
+ ensure
126
+ compiled_release_downloader.cleanup unless compiled_release_downloader.nil?
127
+ end
128
+
94
129
  def create_fake_job(planner, fake_resource_pool_manifest, network_name)
95
130
  fake_job_spec_for_compiling = {
96
131
  "name" => "dummy-job-for-compilation",
@@ -114,3 +149,4 @@ module Bosh::Director
114
149
  end
115
150
  end
116
151
  end
152
+
@@ -8,6 +8,7 @@ module Bosh::Director
8
8
  include DownloadHelper
9
9
 
10
10
  @queue = :normal
11
+ @compiled_release = false
11
12
 
12
13
  attr_accessor :release_model
13
14
 
@@ -32,6 +33,13 @@ module Bosh::Director
32
33
 
33
34
  @rebase = !!options['rebase']
34
35
  @skip_if_exists = !!options['skip_if_exists']
36
+ @compiled_release = !!options['compiled']
37
+
38
+ if @compiled_release
39
+ @packages_folder = "compiled_packages"
40
+ else
41
+ @packages_folder = "packages"
42
+ end
35
43
 
36
44
  @manifest = nil
37
45
  @name = nil
@@ -54,7 +62,9 @@ module Bosh::Director
54
62
 
55
63
  single_step_stage("Verifying manifest") { verify_manifest(release_dir) }
56
64
 
57
- with_release_lock(@name) { process_release(release_dir) }
65
+ with_release_lock(@name) {
66
+ process_release(release_dir)
67
+ }
58
68
 
59
69
  if @rebase && @packages_unchanged && @jobs_unchanged
60
70
  raise DirectorError, "Rebase is attempted without any job or package changes"
@@ -152,14 +162,14 @@ module Bosh::Director
152
162
  @release_version_model.save
153
163
 
154
164
  single_step_stage("Resolving package dependencies") do
155
- resolve_package_dependencies(@manifest["packages"])
165
+ resolve_package_dependencies(@manifest[@packages_folder])
156
166
  end
157
167
 
158
168
  @packages = {}
159
169
  process_packages(release_dir)
160
170
  process_jobs(release_dir)
161
171
 
162
- event_log.begin_stage("Release has been created", 1)
172
+ event_log.begin_stage(@compiled_release ? "Compiled Release has been created" : "Release has been created", 1)
163
173
  event_log.track("#{@name}/#{@version}") {}
164
174
  end
165
175
 
@@ -168,7 +178,7 @@ module Bosh::Director
168
178
  def normalize_manifest
169
179
  Bosh::Director.hash_string_vals(@manifest, 'name', 'version')
170
180
 
171
- @manifest['packages'].each { |p| Bosh::Director.hash_string_vals(p, 'name', 'version', 'sha1') }
181
+ @manifest[@packages_folder].each { |p| Bosh::Director.hash_string_vals(p, 'name', 'version', 'sha1') }
172
182
  @manifest['jobs'].each { |j| Bosh::Director.hash_string_vals(j, 'name', 'version', 'sha1') }
173
183
  end
174
184
 
@@ -207,7 +217,7 @@ module Bosh::Director
207
217
  new_packages = []
208
218
  existing_packages = []
209
219
 
210
- @manifest["packages"].each do |package_meta|
220
+ @manifest[@packages_folder].each do |package_meta|
211
221
  # Checking whether we might have the same bits somewhere
212
222
  packages = Models::Package.where(fingerprint: package_meta["fingerprint"]).all
213
223
 
@@ -262,7 +272,13 @@ module Bosh::Director
262
272
  package_desc = "#{package_meta["name"]}/#{package_meta["version"]}"
263
273
  event_log.track(package_desc) do
264
274
  logger.info("Creating new package `#{package_desc}'")
265
- package = create_package(package_meta, release_dir)
275
+
276
+ if @compiled_release
277
+ package = create_package_for_compiled_release(package_meta, release_dir)
278
+ else
279
+ package = create_package(package_meta, release_dir)
280
+ end
281
+
266
282
  register_package(package)
267
283
  end
268
284
  end
@@ -282,6 +298,26 @@ module Bosh::Director
282
298
  end
283
299
  end
284
300
 
301
+ def create_package_for_compiled_release(package_meta, release_dir)
302
+ name, version = package_meta["name"], package_meta["version"]
303
+ desc = "package `#{name}/#{version}'"
304
+
305
+ package_attrs = {
306
+ :release => @release_model,
307
+ :name => name,
308
+ :sha1 => nil,
309
+ :blobstore_id => nil,
310
+ :fingerprint => package_meta["fingerprint"],
311
+ :version => version
312
+ }
313
+
314
+ package = Models::Package.new(package_attrs)
315
+ package.dependency_set = package_meta["dependencies"]
316
+
317
+ logger.info("Creating #{desc} from provided bits")
318
+ package.save
319
+ end
320
+
285
321
  # Creates package in DB according to given metadata
286
322
  # @param [Hash] package_meta Package metadata
287
323
  # @param [String] release_dir local path to the unpacked release
@@ -18,7 +18,7 @@ module Bosh::Director::Models
18
18
  end
19
19
 
20
20
  def validate
21
- validates_presence [:release_id, :name, :version, :blobstore_id, :sha1]
21
+ validates_presence [:release_id, :name, :version]
22
22
  validates_unique [:release_id, :name, :version]
23
23
  validates_format VALID_ID, [:name, :version]
24
24
  end
@@ -46,7 +46,7 @@ module Bosh::Director
46
46
  end
47
47
 
48
48
  # If VM is present we try to unmount and detach disk from VM
49
- if @vm.cid && cloud.has_vm?(@vm.cid)
49
+ if @vm && @vm.cid && cloud.has_vm?(@vm.cid)
50
50
  agent_client = agent_client(@vm)
51
51
  disk_list = []
52
52
 
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.3016.0'
3
+ VERSION = '1.3022.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3016.0
4
+ version: 1.3022.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-14 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt-ruby
@@ -30,126 +30,126 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3016.0
33
+ version: 1.3022.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3016.0
40
+ version: 1.3022.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bosh-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3016.0
47
+ version: 1.3022.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3016.0
54
+ version: 1.3022.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bosh-director-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3016.0
61
+ version: 1.3022.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3016.0
68
+ version: 1.3022.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bosh_common
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.3016.0
75
+ version: 1.3022.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.3016.0
82
+ version: 1.3022.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bosh-template
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.3016.0
89
+ version: 1.3022.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.3016.0
96
+ version: 1.3022.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bosh_cpi
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.3016.0
103
+ version: 1.3022.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.3016.0
110
+ version: 1.3022.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bosh_openstack_cpi
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.3016.0
117
+ version: 1.3022.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.3016.0
124
+ version: 1.3022.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bosh_aws_cpi
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3016.0
131
+ version: 1.3022.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.3016.0
138
+ version: 1.3022.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: bosh_vsphere_cpi
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.3016.0
145
+ version: 1.3022.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.3016.0
152
+ version: 1.3022.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: bosh_vcloud_cpi
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -572,7 +572,7 @@ dependencies:
572
572
  version: '0'
573
573
  description: |-
574
574
  BOSH Director
575
- 10557b
575
+ 6073a7
576
576
  email: support@cloudfoundry.com
577
577
  executables:
578
578
  - bosh-director
@@ -629,6 +629,7 @@ files:
629
629
  - db/migrations/director/20150401184803_add_cloud_config_to_deployments.rb
630
630
  - db/migrations/director/20150611193110_add_trusted_certs_sha1_to_vms.rb
631
631
  - db/migrations/director/20150619135210_add_os_name_and_version_to_stemcells.rb
632
+ - db/migrations/director/20150716170926_allow_null_on_blobstore_id_and_sha1_on_package.rb
632
633
  - db/migrations/dns/20120123234908_initial.rb
633
634
  - lib/bosh/director.rb
634
635
  - lib/bosh/director/agent_client.rb
@@ -692,6 +693,8 @@ files:
692
693
  - lib/bosh/director/compiled_package_group.rb
693
694
  - lib/bosh/director/compiled_package_manifest.rb
694
695
  - lib/bosh/director/compiled_packages_exporter.rb
696
+ - lib/bosh/director/compiled_release_downloader.rb
697
+ - lib/bosh/director/compiled_release_manifest.rb
695
698
  - lib/bosh/director/config.rb
696
699
  - lib/bosh/director/cycle_helper.rb
697
700
  - lib/bosh/director/db_backup.rb