bosh-director 1.3048.0 → 1.3050.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bosh/director/api/controllers/packages_controller.rb +19 -1
- data/lib/bosh/director/api/controllers/releases_controller.rb +1 -2
- data/lib/bosh/director/api/route_configuration.rb +0 -4
- data/lib/bosh/director/api.rb +0 -1
- data/lib/bosh/director/deployment_plan/planner_factory.rb +41 -27
- data/lib/bosh/director/errors.rb +1 -0
- data/lib/bosh/director/jobs/delete_release.rb +4 -4
- data/lib/bosh/director/jobs/export_release.rb +53 -5
- data/lib/bosh/director/jobs/update_release.rb +132 -82
- data/lib/bosh/director/version.rb +1 -1
- data/lib/bosh/director.rb +0 -1
- data/lib/cloud/dummy.rb +39 -3
- metadata +23 -31
- data/lib/bosh/director/api/compiled_package_group_manager.rb +0 -17
- data/lib/bosh/director/api/controllers/compiled_packages_controller.rb +0 -63
- data/lib/bosh/director/compiled_package/compiled_package_inserter.rb +0 -45
- data/lib/bosh/director/compiled_package/compiled_packages_export.rb +0 -35
- data/lib/bosh/director/compiled_package_downloader.rb +0 -33
- data/lib/bosh/director/compiled_package_manifest.rb +0 -31
- data/lib/bosh/director/compiled_packages_exporter.rb +0 -24
- data/lib/bosh/director/jobs/import_compiled_packages.rb +0 -44
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.
|
4
|
+
version: 1.3050.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-08-
|
11
|
+
date: 2015-08-20 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.
|
33
|
+
version: 1.3050.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.
|
40
|
+
version: 1.3050.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.
|
47
|
+
version: 1.3050.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.
|
54
|
+
version: 1.3050.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.
|
61
|
+
version: 1.3050.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.
|
68
|
+
version: 1.3050.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.
|
75
|
+
version: 1.3050.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.
|
82
|
+
version: 1.3050.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.
|
89
|
+
version: 1.3050.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.
|
96
|
+
version: 1.3050.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.
|
103
|
+
version: 1.3050.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.
|
110
|
+
version: 1.3050.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.
|
117
|
+
version: 1.3050.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.
|
124
|
+
version: 1.3050.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.
|
131
|
+
version: 1.3050.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.
|
138
|
+
version: 1.3050.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.
|
145
|
+
version: 1.3050.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.
|
152
|
+
version: 1.3050.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: bosh_vcloud_cpi
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 1.
|
201
|
+
version: 1.31.0
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.
|
208
|
+
version: 1.31.0
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: httpclient
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -572,7 +572,7 @@ dependencies:
|
|
572
572
|
version: '0'
|
573
573
|
description: |-
|
574
574
|
BOSH Director
|
575
|
-
|
575
|
+
b92cdc
|
576
576
|
email: support@cloudfoundry.com
|
577
577
|
executables:
|
578
578
|
- bosh-director
|
@@ -638,11 +638,9 @@ files:
|
|
638
638
|
- lib/bosh/director/api/api_helper.rb
|
639
639
|
- lib/bosh/director/api/backup_manager.rb
|
640
640
|
- lib/bosh/director/api/cloud_config_manager.rb
|
641
|
-
- lib/bosh/director/api/compiled_package_group_manager.rb
|
642
641
|
- lib/bosh/director/api/controllers/backups_controller.rb
|
643
642
|
- lib/bosh/director/api/controllers/base_controller.rb
|
644
643
|
- lib/bosh/director/api/controllers/cloud_configs_controller.rb
|
645
|
-
- lib/bosh/director/api/controllers/compiled_packages_controller.rb
|
646
644
|
- lib/bosh/director/api/controllers/deployments_controller.rb
|
647
645
|
- lib/bosh/director/api/controllers/info_controller.rb
|
648
646
|
- lib/bosh/director/api/controllers/locks_controller.rb
|
@@ -687,12 +685,7 @@ files:
|
|
687
685
|
- lib/bosh/director/compiled_package.rb
|
688
686
|
- lib/bosh/director/compiled_package/blob_sha_mismatch_error.rb
|
689
687
|
- lib/bosh/director/compiled_package/compiled_package.rb
|
690
|
-
- lib/bosh/director/compiled_package/compiled_package_inserter.rb
|
691
|
-
- lib/bosh/director/compiled_package/compiled_packages_export.rb
|
692
|
-
- lib/bosh/director/compiled_package_downloader.rb
|
693
688
|
- lib/bosh/director/compiled_package_group.rb
|
694
|
-
- lib/bosh/director/compiled_package_manifest.rb
|
695
|
-
- lib/bosh/director/compiled_packages_exporter.rb
|
696
689
|
- lib/bosh/director/compiled_release_downloader.rb
|
697
690
|
- lib/bosh/director/compiled_release_manifest.rb
|
698
691
|
- lib/bosh/director/config.rb
|
@@ -773,7 +766,6 @@ files:
|
|
773
766
|
- lib/bosh/director/jobs/delete_stemcell.rb
|
774
767
|
- lib/bosh/director/jobs/export_release.rb
|
775
768
|
- lib/bosh/director/jobs/fetch_logs.rb
|
776
|
-
- lib/bosh/director/jobs/import_compiled_packages.rb
|
777
769
|
- lib/bosh/director/jobs/release/release_job.rb
|
778
770
|
- lib/bosh/director/jobs/run_errand.rb
|
779
771
|
- lib/bosh/director/jobs/scheduled_backup.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'securerandom'
|
2
|
-
|
3
|
-
module Bosh::Director
|
4
|
-
module Api
|
5
|
-
class CompiledPackageGroupManager
|
6
|
-
include ApiHelper
|
7
|
-
|
8
|
-
def create_from_file_path(username, path)
|
9
|
-
unless File.exists?(path)
|
10
|
-
raise DirectorError, "Failed to import compiled packages: file not found - #{path}"
|
11
|
-
end
|
12
|
-
|
13
|
-
JobQueue.new.enqueue(username, Jobs::ImportCompiledPackages, 'import compiled packages', [path])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'bosh/director/api/compiled_package_group_manager'
|
4
|
-
require 'bosh/director/api/controllers/base_controller'
|
5
|
-
require 'bosh/director/api/stemcell_manager'
|
6
|
-
require 'bosh/director/compiled_package_group'
|
7
|
-
require 'bosh/director/compiled_packages_exporter'
|
8
|
-
require 'bosh/director/stale_file_killer'
|
9
|
-
require 'bosh/director/jobs/import_compiled_packages'
|
10
|
-
|
11
|
-
module Bosh::Director
|
12
|
-
module Api::Controllers
|
13
|
-
class CompiledPackagesController < BaseController
|
14
|
-
def initialize(config, compiled_package_group_manager)
|
15
|
-
super(config)
|
16
|
-
@compiled_package_group_manager = compiled_package_group_manager
|
17
|
-
end
|
18
|
-
|
19
|
-
post '/export', consumes: :json do
|
20
|
-
stemcell = find_stemcell_by_name_and_version
|
21
|
-
release_version = find_release_version_by_name_and_version
|
22
|
-
|
23
|
-
output_dir = File.join(Dir.tmpdir, 'compiled_packages')
|
24
|
-
FileUtils.mkdir_p(output_dir)
|
25
|
-
|
26
|
-
killer = StaleFileKiller.new(output_dir)
|
27
|
-
killer.kill
|
28
|
-
|
29
|
-
compiled_packages = CompiledPackageGroup.new(release_version, stemcell)
|
30
|
-
blobstore_client = App.instance.blobstores.blobstore
|
31
|
-
exporter = CompiledPackagesExporter.new(compiled_packages, blobstore_client)
|
32
|
-
|
33
|
-
output_path = File.join(output_dir, "compiled_packages_#{Time.now.to_f}.tar.gz")
|
34
|
-
exporter.export(output_path)
|
35
|
-
|
36
|
-
send_file(output_path, type: :tgz)
|
37
|
-
end
|
38
|
-
|
39
|
-
post '/import', consumes: :multipart do
|
40
|
-
task = @compiled_package_group_manager.create_from_file_path(current_user, params[:nginx_upload_path])
|
41
|
-
redirect "/tasks/#{task.id}"
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def find_stemcell_by_name_and_version
|
47
|
-
stemcell_manager = Api::StemcellManager.new
|
48
|
-
stemcell_manager.find_by_name_and_version(
|
49
|
-
body_params['stemcell_name'], body_params['stemcell_version'])
|
50
|
-
end
|
51
|
-
|
52
|
-
def find_release_version_by_name_and_version
|
53
|
-
release_manager = Api::ReleaseManager.new
|
54
|
-
release = release_manager.find_by_name(body_params['release_name'])
|
55
|
-
release_manager.find_version(release, body_params['release_version'])
|
56
|
-
end
|
57
|
-
|
58
|
-
def body_params
|
59
|
-
@body_params ||= JSON.load(request.body)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'bosh/director/compiled_package'
|
2
|
-
|
3
|
-
module Bosh::Director::CompiledPackage
|
4
|
-
class CompiledPackageInserter
|
5
|
-
def initialize(blobstore_client)
|
6
|
-
@blobstore_client = blobstore_client
|
7
|
-
end
|
8
|
-
|
9
|
-
def insert(compiled_package, release_version)
|
10
|
-
package = Bosh::Director::Models::Package[fingerprint: compiled_package.package_fingerprint]
|
11
|
-
raise ArgumentError, [compiled_package.inspect, release_version.inspect].inspect unless package
|
12
|
-
|
13
|
-
stemcell = Bosh::Director::Models::Stemcell[sha1: compiled_package.stemcell_sha1]
|
14
|
-
|
15
|
-
transitive_dependencies = release_version.transitive_dependencies(package)
|
16
|
-
package_dependency_key = Bosh::Director::Models::CompiledPackage.create_dependency_key(transitive_dependencies)
|
17
|
-
|
18
|
-
compiled_package_model = Bosh::Director::Models::CompiledPackage[
|
19
|
-
package: package,
|
20
|
-
stemcell: stemcell,
|
21
|
-
dependency_key: package_dependency_key,
|
22
|
-
]
|
23
|
-
|
24
|
-
return if compiled_package_model
|
25
|
-
|
26
|
-
oid = File.open(compiled_package.blob_path) do |f|
|
27
|
-
@blobstore_client.create(f)
|
28
|
-
end
|
29
|
-
|
30
|
-
begin
|
31
|
-
Bosh::Director::Models::CompiledPackage.create(
|
32
|
-
blobstore_id: oid,
|
33
|
-
package: package,
|
34
|
-
stemcell: stemcell,
|
35
|
-
sha1: compiled_package.sha1,
|
36
|
-
dependency_key: package_dependency_key,
|
37
|
-
build: Bosh::Director::Models::CompiledPackage.generate_build_number(package, stemcell),
|
38
|
-
)
|
39
|
-
rescue
|
40
|
-
@blobstore_client.delete(oid)
|
41
|
-
raise
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'bosh/director/compiled_package'
|
2
|
-
require 'bosh/director/compiled_package/compiled_package'
|
3
|
-
|
4
|
-
module Bosh::Director::CompiledPackage
|
5
|
-
class CompiledPackagesExport
|
6
|
-
def initialize(options={})
|
7
|
-
@file = options.fetch(:file)
|
8
|
-
@exec = options.fetch(:exec, Bosh::Exec)
|
9
|
-
end
|
10
|
-
|
11
|
-
def extract
|
12
|
-
tmp_dir = Dir.mktmpdir
|
13
|
-
|
14
|
-
@exec.sh("tar -C #{tmp_dir} -xf #{@file}")
|
15
|
-
|
16
|
-
manifest = YAML.load_file("#{tmp_dir}/compiled_packages.MF")
|
17
|
-
packages = []
|
18
|
-
|
19
|
-
manifest['compiled_packages'].each do |p|
|
20
|
-
packages << CompiledPackage.new(
|
21
|
-
package_name: p['package_name'],
|
22
|
-
package_fingerprint: p['package_fingerprint'],
|
23
|
-
sha1: p['compiled_package_sha1'],
|
24
|
-
stemcell_sha1: p['stemcell_sha1'],
|
25
|
-
blobstore_id: p['blobstore_id'],
|
26
|
-
blob_path: File.join(tmp_dir, 'compiled_packages', 'blobs', p['blobstore_id']),
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
yield manifest, packages
|
31
|
-
|
32
|
-
FileUtils.rm_rf(tmp_dir)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'bosh/director'
|
4
|
-
require 'bosh/director/compiled_package_manifest'
|
5
|
-
|
6
|
-
module Bosh::Director
|
7
|
-
class CompiledPackageDownloader
|
8
|
-
def initialize(compiled_package_group, blobstore_client)
|
9
|
-
@compiled_package_group = compiled_package_group
|
10
|
-
@blobstore_client = blobstore_client
|
11
|
-
end
|
12
|
-
|
13
|
-
def download
|
14
|
-
@download_dir = Dir.mktmpdir
|
15
|
-
|
16
|
-
blobs_path = File.join(@download_dir, 'compiled_packages', 'blobs')
|
17
|
-
FileUtils.mkpath(blobs_path)
|
18
|
-
|
19
|
-
@compiled_package_group.compiled_packages.each do |compiled_package|
|
20
|
-
blobstore_id = compiled_package.blobstore_id
|
21
|
-
File.open(File.join(blobs_path, blobstore_id), 'w') do |f|
|
22
|
-
@blobstore_client.get(blobstore_id, f, sha1: compiled_package.sha1)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
@download_dir
|
27
|
-
end
|
28
|
-
|
29
|
-
def cleanup
|
30
|
-
FileUtils.rm_rf(@download_dir)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'bosh/director'
|
3
|
-
|
4
|
-
module Bosh::Director
|
5
|
-
class CompiledPackageManifest
|
6
|
-
def initialize(group)
|
7
|
-
@compiled_package_group = group
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_h
|
11
|
-
{
|
12
|
-
'release_name' => @compiled_package_group.release_version.release.name,
|
13
|
-
'release_version' => @compiled_package_group.release_version.version,
|
14
|
-
'release_commit_hash' => @compiled_package_group.release_version.commit_hash,
|
15
|
-
'compiled_packages' => @compiled_package_group.compiled_packages.map do |compiled_package|
|
16
|
-
{
|
17
|
-
'package_name' => compiled_package.package.name,
|
18
|
-
'package_fingerprint' => compiled_package.package.fingerprint,
|
19
|
-
'compiled_package_sha1' => compiled_package.sha1,
|
20
|
-
'stemcell_sha1' => @compiled_package_group.stemcell_sha1,
|
21
|
-
'blobstore_id' => compiled_package.blobstore_id,
|
22
|
-
}
|
23
|
-
end
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def write(dest_path)
|
28
|
-
File.open(dest_path, 'w') { |f| f.write(YAML.dump(to_h)) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'bosh/director/core/tar_gzipper'
|
2
|
-
require 'bosh/director/compiled_package_downloader'
|
3
|
-
|
4
|
-
module Bosh::Director
|
5
|
-
class CompiledPackagesExporter
|
6
|
-
def initialize(compiled_package_group, blobstore_client)
|
7
|
-
@compiled_package_group = compiled_package_group
|
8
|
-
@blobstore_client = blobstore_client
|
9
|
-
end
|
10
|
-
|
11
|
-
def export(output_path)
|
12
|
-
downloader = CompiledPackageDownloader.new(@compiled_package_group, @blobstore_client)
|
13
|
-
download_dir = downloader.download
|
14
|
-
|
15
|
-
manifest = CompiledPackageManifest.new(@compiled_package_group)
|
16
|
-
manifest.write(File.join(download_dir, 'compiled_packages.MF'))
|
17
|
-
|
18
|
-
archiver = Core::TarGzipper.new
|
19
|
-
archiver.compress(download_dir, ['compiled_packages', 'compiled_packages.MF'], output_path)
|
20
|
-
ensure
|
21
|
-
downloader.cleanup
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'bosh/director/compiled_package/compiled_packages_export'
|
2
|
-
require 'bosh/director/compiled_package/compiled_package_inserter'
|
3
|
-
|
4
|
-
module Bosh::Director
|
5
|
-
module Jobs
|
6
|
-
class ImportCompiledPackages < BaseJob
|
7
|
-
@queue = :normal
|
8
|
-
|
9
|
-
def self.job_type
|
10
|
-
:import_compiled_packages
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize(compiled_packages_path)
|
14
|
-
@compiled_packages_path = compiled_packages_path
|
15
|
-
@blobstore_client = Bosh::Director::App.instance.blobstores.blobstore
|
16
|
-
end
|
17
|
-
|
18
|
-
def perform
|
19
|
-
export = Bosh::Director::CompiledPackage::CompiledPackagesExport.new(file: @compiled_packages_path)
|
20
|
-
|
21
|
-
export.extract do |manifest, packages|
|
22
|
-
release_name = manifest.fetch('release_name')
|
23
|
-
release_version_version = manifest.fetch('release_version')
|
24
|
-
|
25
|
-
release = Bosh::Director::Models::Release[name: release_name]
|
26
|
-
if release.nil?
|
27
|
-
raise ReleaseNotFound, "Release version `#{release}/#{release_version_version}' doesn't exist"
|
28
|
-
end
|
29
|
-
|
30
|
-
release_version = Bosh::Director::Api::ReleaseManager.new.find_version(release, release_version_version)
|
31
|
-
inserter = Bosh::Director::CompiledPackage::CompiledPackageInserter.new(@blobstore_client)
|
32
|
-
|
33
|
-
packages.each { |p| p.check_blob_sha }
|
34
|
-
|
35
|
-
packages.each do |package|
|
36
|
-
inserter.insert(package, release_version)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
ensure
|
40
|
-
FileUtils.rm_rf(@compiled_packages_path)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|