Class: Bosh::Director::Api::StemcellManager

Inherits:
Object
  • Object
show all
Includes:
ApiHelper
Defined in:
lib/bosh/director/api/stemcell_manager.rb

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



28
29
30
31
32
33
34
# File 'lib/bosh/director/api/stemcell_manager.rb', line 28

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



24
25
26
# File 'lib/bosh/director/api/stemcell_manager.rb', line 24

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



36
37
38
39
40
# File 'lib/bosh/director/api/stemcell_manager.rb', line 36

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

#stemcell_exists?(name, version) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/bosh/director/api/stemcell_manager.rb', line 17

def stemcell_exists?(name, version)
  find_by_name_and_version(name, version)
  true
rescue StemcellNotFound
  false
end