Class: Bosh::Director::DeploymentPlan::Stemcell
- Includes:
- ValidationHelper
- Defined in:
- lib/bosh/director/deployment_plan/stemcell.rb
Instance Attribute Summary collapse
-
#model ⇒ Models::Stemcell
readonly
Stemcell DB model.
-
#name ⇒ String
readonly
Stemcell name.
-
#resource_pool ⇒ DeploymentPlan::ResourcePool
readonly
Resource pool.
-
#version ⇒ String
readonly
Stemcell version.
Instance Method Summary collapse
-
#bind_model ⇒ void
Looks up the stemcell matching provided spec.
-
#initialize(resource_pool, spec) ⇒ Stemcell
constructor
A new instance of Stemcell.
- #spec ⇒ Object
Methods included from ValidationHelper
Constructor Details
#initialize(resource_pool, spec) ⇒ Stemcell
Returns a new instance of Stemcell.
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
#model ⇒ Models::Stemcell (readonly)
Returns Stemcell DB model.
18 19 20 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 18 def model @model end |
#name ⇒ String (readonly)
Returns Stemcell name.
12 13 14 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 12 def name @name end |
#resource_pool ⇒ DeploymentPlan::ResourcePool (readonly)
Returns Resource pool.
9 10 11 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 9 def resource_pool @resource_pool end |
#version ⇒ String (readonly)
Returns Stemcell version.
15 16 17 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 15 def version @version end |
Instance Method Details
#bind_model ⇒ void
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 |
#spec ⇒ Object
47 48 49 50 51 52 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 47 def spec { "name" => @name, "version" => @version } end |