Class: Bosh::Director::DeploymentPlan::Stemcell
- Includes:
- ValidationHelper
- Defined in:
- lib/bosh/director/deployment_plan/stemcell.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#model ⇒ Models::Stemcell
readonly
Stemcell DB model.
-
#name ⇒ String
readonly
Stemcell name.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#version ⇒ String
readonly
Stemcell version.
Instance Method Summary collapse
- #add_stemcell_model ⇒ Object
-
#bind_model(deployment_plan) ⇒ void
Looks up the stemcell matching provided spec.
- #cid ⇒ Object
- #desc ⇒ Object
- #id ⇒ Object
-
#initialize(spec) ⇒ Stemcell
constructor
A new instance of Stemcell.
- #is_using_os? ⇒ Boolean
- #spec ⇒ Object
Methods included from ValidationHelper
Constructor Details
#initialize(spec) ⇒ Stemcell
Returns a new instance of Stemcell.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 21 def initialize(spec) @alias = safe_property(spec, "alias", :class => String, :optional => true) @name = safe_property(spec, "name", :class => String, :optional => true) @os = safe_property(spec, "os", :class => String, :optional => true) if @name.nil? && @os.nil? raise ValidationMissingField, "Required property `os' or `name' was not specified in object (#{spec})" end if !@name.nil? && !@os.nil? raise StemcellBothNameAndOS, "Properties `os' and `name' are both specified for stemcell, choose one. (#{spec})" end @version = safe_property(spec, "version", :class => String) @manager = Api::StemcellManager.new @model = nil end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
8 9 10 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 8 def alias @alias end |
#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 |
#os ⇒ Object (readonly)
Returns the value of attribute os.
9 10 11 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 9 def os @os 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
#add_stemcell_model ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 60 def add_stemcell_model @model = is_using_os? ? @manager.find_by_os_and_version(@os, @version) : @manager.find_by_name_and_version(@name, @version) @name = @model.name @os = @model. @version = @model.version end |
#bind_model(deployment_plan) ⇒ void
This method returns an undefined value.
Looks up the stemcell matching provided spec
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 47 def bind_model(deployment_plan) deployment_model = deployment_plan.model if deployment_model.nil? raise DirectorError, "Deployment not bound in the deployment plan" end add_stemcell_model unless @model.deployments.include?(deployment_model) @model.add_deployment(deployment_model) end end |
#cid ⇒ Object
74 75 76 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 74 def cid @model.cid end |
#desc ⇒ Object
70 71 72 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 70 def desc @model.desc end |
#id ⇒ Object
78 79 80 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 78 def id @model.id end |
#is_using_os? ⇒ Boolean
41 42 43 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 41 def is_using_os? !@os.nil? && @name.nil? end |
#spec ⇒ Object
82 83 84 85 86 87 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 82 def spec { "name" => @name, "version" => @version } end |