Class: Bosh::Director::Api::ReleaseManager
- Includes:
- ApiHelper
- Defined in:
- lib/bosh/director/api/release_manager.rb
Constant Summary collapse
- RELEASE_TGZ =
'release.tgz'
Constants included from ApiHelper
Instance Method Summary collapse
- #create_release(user, release_bundle, options = {}) ⇒ Object
- #delete_release(user, release, options = {}) ⇒ Object
-
#find_by_name(name) ⇒ Models::Release
Finds release by name.
-
#find_version(release, version) ⇒ Models::ReleaseVersion
Release version model.
Methods included from ApiHelper
#check_available_disk_space, #json_decode, #json_encode, #send_disposable_file, #start_task, #write_file
Instance Method Details
#create_release(user, release_bundle, options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bosh/director/api/release_manager.rb', line 51 def create_release(user, release_bundle, = {}) release_dir = Dir.mktmpdir('release') if ['remote'] ['location'] = release_bundle else unless check_available_disk_space(release_dir, release_bundle.size) raise NotEnoughDiskSpace, 'Uploading release archive failed. ' + "Insufficient space on BOSH director in #{release_dir}" end write_file(File.join(release_dir, RELEASE_TGZ), release_bundle) end JobQueue.new.enqueue(user, Jobs::UpdateRelease, 'create release', [release_dir, ]) end |
#delete_release(user, release, options = {}) ⇒ Object
68 69 70 |
# File 'lib/bosh/director/api/release_manager.rb', line 68 def delete_release(user, release, = {}) JobQueue.new.enqueue(user, Jobs::DeleteRelease, "delete release: #{release.name}", [release.name, ]) end |
#find_by_name(name) ⇒ Models::Release
Finds release by name
12 13 14 15 16 17 18 |
# File 'lib/bosh/director/api/release_manager.rb', line 12 def find_by_name(name) release = Models::Release[:name => name] if release.nil? raise ReleaseNotFound, "Release `#{name}' doesn't exist" end release end |
#find_version(release, version) ⇒ Models::ReleaseVersion
Returns Release version model.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bosh/director/api/release_manager.rb', line 24 def find_version(release, version) dataset = release.versions_dataset release_version = dataset.filter(:version => version).first if release_version.nil? begin new_formatted_version = Bosh::Common::Version::ReleaseVersion.parse(version) rescue SemiSemantic::ParseError raise ReleaseVersionInvalid, "Release version invalid: #{version}" end if version == new_formatted_version.to_s old_formatted_version = new_formatted_version.to_old_format if old_formatted_version release_version = dataset.filter(:version => old_formatted_version).first end else release_version = dataset.filter(:version => new_formatted_version.to_s).first end if release_version.nil? raise ReleaseVersionNotFound, "Release version `#{release.name}/#{version}' doesn't exist" end end release_version end |