Class: Bosh::Director::Api::StemcellManager
Constant Summary
Constants included
from ApiHelper
ApiHelper::READ_CHUNK_SIZE
Instance Method Summary
collapse
Methods included from ApiHelper
#check_available_disk_space, #json_decode, #json_encode, #send_disposable_file, #start_task, #write_file
Instance Method Details
#create_stemcell_from_file_path(username, stemcell_path) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/bosh/director/api/stemcell_manager.rb', line 38
def create_stemcell_from_file_path(username, stemcell_path)
unless File.exists?(stemcell_path)
raise DirectorError, "Failed to create stemcell: file not found - #{stemcell_path}"
end
JobQueue.new.enqueue(username, Jobs::UpdateStemcell, 'create stemcell', [stemcell_path])
end
|
#create_stemcell_from_url(username, stemcell_url) ⇒ Object
34
35
36
|
# File 'lib/bosh/director/api/stemcell_manager.rb', line 34
def create_stemcell_from_url(username, stemcell_url)
JobQueue.new.enqueue(username, Jobs::UpdateStemcell, 'create stemcell', [stemcell_url, { remote: true }])
end
|
#delete_stemcell(username, stemcell, options = {}) ⇒ Object
46
47
48
49
50
|
# File 'lib/bosh/director/api/stemcell_manager.rb', line 46
def delete_stemcell(username, stemcell, options={})
description = "delete stemcell: #{stemcell.name}/#{stemcell.version}"
JobQueue.new.enqueue(username, Jobs::DeleteStemcell, description, [stemcell.name, stemcell.version, options])
end
|
#find_by_name_and_version(name, version) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/bosh/director/api/stemcell_manager.rb', line 8
def find_by_name_and_version(name, version)
stemcell = Models::Stemcell[:name => name, :version => version]
if stemcell.nil?
raise StemcellNotFound,
"Stemcell `#{name}/#{version}' doesn't exist"
end
stemcell
end
|
#find_by_os_and_version(os, version) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/bosh/director/api/stemcell_manager.rb', line 17
def find_by_os_and_version(os, version)
stemcell = Bosh::Director::Models::Stemcell.
dataset.order(:name)[:operating_system => os, :version => version]
if stemcell.nil?
raise StemcellNotFound,
"Stemcell version `#{version}' for OS `#{os}' doesn't exist"
end
stemcell
end
|
#stemcell_exists?(name, version) ⇒ Boolean
27
28
29
30
31
32
|
# File 'lib/bosh/director/api/stemcell_manager.rb', line 27
def stemcell_exists?(name, version)
find_by_name_and_version(name, version)
true
rescue StemcellNotFound
false
end
|