Class: Bosh::Director::DeploymentPlan::Stemcell
- Extended by:
- ValidationHelper
- Defined in:
- lib/bosh/director/deployment_plan/stemcell.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #add_stemcell_model ⇒ Object
- #bind_model(deployment_model) ⇒ Object
- #cid ⇒ Object
- #desc ⇒ Object
- #id ⇒ Object
-
#initialize(name_alias, name, os, version) ⇒ Stemcell
constructor
A new instance of Stemcell.
- #is_using_os? ⇒ Boolean
- #spec ⇒ Object
Methods included from ValidationHelper
Constructor Details
#initialize(name_alias, name, os, version) ⇒ Stemcell
Returns a new instance of Stemcell.
29 30 31 32 33 34 35 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 29 def initialize(name_alias, name, os, version) @alias = name_alias @name = name @os = os @version = version @manager = Api::StemcellManager.new end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
6 7 8 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 6 def alias @alias end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
10 11 12 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 10 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 8 def name @name end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
7 8 9 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 7 def os @os end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
9 10 11 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 9 def version @version end |
Class Method Details
.parse(spec) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 12 def self.parse(spec) name_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) version = safe_property(spec, "version", :class => String) 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 new(name_alias, name, os, version) end |
Instance Method Details
#add_stemcell_model ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 53 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_model) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 41 def bind_model(deployment_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
67 68 69 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 67 def cid @model.cid end |
#desc ⇒ Object
63 64 65 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 63 def desc @model.desc end |
#id ⇒ Object
71 72 73 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 71 def id @model.id end |
#is_using_os? ⇒ Boolean
37 38 39 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 37 def is_using_os? !@os.nil? && @name.nil? end |
#spec ⇒ Object
75 76 77 78 79 80 |
# File 'lib/bosh/director/deployment_plan/stemcell.rb', line 75 def spec { "name" => @name, "version" => @version } end |