Class: Bosh::Director::DeploymentPlan::Stemcell

Inherits:
Object
  • Object
show all
Includes:
ValidationHelper
Defined in:
lib/bosh/director/deployment_plan/stemcell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ValidationHelper

#invalid_type, #safe_property

Constructor Details

#initialize(resource_pool, spec) ⇒ Stemcell

Returns a new instance of Stemcell.

Parameters:



23
24
25
26
27
28
29
30
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 23

def initialize(resource_pool, spec)
  @resource_pool = resource_pool
  @name = safe_property(spec, "name", :class => String)
  @version = safe_property(spec, "version", :class => String)

  @manager = Api::StemcellManager.new
  @model = nil
end

Instance Attribute Details

#modelModels::Stemcell (readonly)

Returns Stemcell DB model.

Returns:



18
19
20
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 18

def model
  @model
end

#nameString (readonly)

Returns Stemcell name.

Returns:

  • (String)

    Stemcell name



12
13
14
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 12

def name
  @name
end

#resource_poolDeploymentPlan::ResourcePool (readonly)

Returns Resource pool.

Returns:



9
10
11
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 9

def resource_pool
  @resource_pool
end

#versionString (readonly)

Returns Stemcell version.

Returns:

  • (String)

    Stemcell version



15
16
17
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 15

def version
  @version
end

Instance Method Details

#bind_modelvoid

This method returns an undefined value.

Looks up the stemcell matching provided spec



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 34

def bind_model
  deployment = @resource_pool.deployment_plan.model
  if deployment.nil?
    raise DirectorError, "Deployment not bound in the deployment plan"
  end

  @model = @manager.find_by_name_and_version(@name, @version)

  unless @model.deployments.include?(deployment)
    @model.add_deployment(deployment)
  end
end

#specObject



47
48
49
50
51
52
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 47

def spec
  {
    "name" => @name,
    "version" => @version
  }
end