Class: Bosh::Director::DeploymentPlan::ReleaseVersion
- Includes:
- ValidationHelper
- Defined in:
- lib/bosh/director/deployment_plan/release_version.rb
Instance Attribute Summary collapse
-
#model ⇒ Models::ReleaseVersion
readonly
Release version model.
-
#name ⇒ String
readonly
Release name.
-
#version ⇒ String
readonly
Release version.
Instance Method Summary collapse
-
#bind_model ⇒ void
Looks up release version in database and binds it to the deployment.
-
#bind_templates ⇒ void
Looks up package and template models in DB and binds them to this release spec.
-
#get_package_model_by_name(name) ⇒ Models::Package
Looks up up package model by package name.
-
#get_template_model_by_name(name) ⇒ Models::Template
Looks up up template model by template name.
-
#initialize(deployment_plan, spec) ⇒ ReleaseVersion
constructor
A new instance of ReleaseVersion.
-
#spec ⇒ Hash
Hash representation.
-
#template(name) ⇒ DeploymentPlan::Template
Template with given name used by this release (if any).
-
#templates ⇒ Array<DeploymentPlan::Template>
Returns a list of job templates that need to be included into this release.
-
#use_template_named(template_name) ⇒ Object
Adds template to a list of templates used by this release for the current deployment.
Methods included from ValidationHelper
Constructor Details
#initialize(deployment_plan, spec) ⇒ ReleaseVersion
Returns a new instance of ReleaseVersion.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 16 def initialize(deployment_plan, spec) @deployment_plan = deployment_plan @name = safe_property(spec, 'name', :class => String) @version = safe_property(spec, 'version', :class => String) @model = nil @templates = {} @logger = Config.logger @manager = Api::ReleaseManager.new end |
Instance Attribute Details
#model ⇒ Models::ReleaseVersion (readonly)
Returns Release version model.
11 12 13 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 11 def model @model end |
#name ⇒ String (readonly)
Returns Release name.
7 8 9 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 7 def name @name end |
#version ⇒ String (readonly)
Returns Release version.
9 10 11 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 9 def version @version end |
Instance Method Details
#bind_model ⇒ void
This method returns an undefined value.
Looks up release version in database and binds it to the deployment
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 31 def bind_model deployment = @deployment_plan.model if deployment.nil? raise DirectorError, 'Deployment not bound in the deployment plan' end release = @manager.find_by_name(@name) @model = @manager.find_version(release, @version) @logger.debug("Found release `#{@name}/#{@version}'") unless deployment.release_versions.include?(@model) @logger.debug("Binding release `#{@name}/#{@version}' " + "to deployment `#{deployment.name}'") deployment.add_release_version(@model) end end |
#bind_templates ⇒ void
This method returns an undefined value.
Looks up package and template models in DB and binds them to this release spec
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 51 def bind_templates # ReleaseVersion model needs to be known so we can look up its # templates if @model.nil? raise DirectorError, 'ReleaseVersion model not bound in release spec' end # By now job specs from the deployment manifest should # have been parsed, so we can assume @templates contains # the list of templates that need to be bound @templates.each_value do |template| @logger.debug("Binding template `#{template.name}'") template.bind_models @logger.debug("Bound template `#{template.name}'") end end |
#get_package_model_by_name(name) ⇒ Models::Package
Looks up up package model by package name
91 92 93 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 91 def get_package_model_by_name(name) @model.package_by_name(name) end |
#get_template_model_by_name(name) ⇒ Models::Template
Looks up up template model by template name
79 80 81 82 83 84 85 86 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 79 def get_template_model_by_name(name) @all_templates ||= @model.templates.inject({}) do |hash, template| hash[template.name] = template hash end @all_templates[name] end |
#spec ⇒ Hash
Returns Hash representation.
69 70 71 72 73 74 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 69 def spec { 'name' => @name, 'version' => @version } end |
#template(name) ⇒ DeploymentPlan::Template
Returns Template with given name used by this release (if any).
105 106 107 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 105 def template(name) @templates[name] end |
#templates ⇒ Array<DeploymentPlan::Template>
Returns a list of job templates that need to be included into this release. Note that this is not just a list of all templates existing in the release but rather a list of templates for jobs that are included into current deployment plan.
114 115 116 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 114 def templates @templates.values end |
#use_template_named(template_name) ⇒ Object
Adds template to a list of templates used by this release for the current deployment
98 99 100 |
# File 'lib/bosh/director/deployment_plan/release_version.rb', line 98 def use_template_named(template_name) @templates[template_name] ||= Template.new(self, template_name) end |