Class: Bosh::Agent::ApplyPlan::Plan
- Defined in:
- lib/bosh_agent/apply_plan/plan.rb
Instance Attribute Summary collapse
-
#deployment ⇒ Object
readonly
Returns the value of attribute deployment.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
Instance Method Summary collapse
-
#configure_jobs ⇒ Object
Configure the 1+ job templates (job colocation) They are reversed for the purposes of ensuring monit starts them in the order that they are specified in the original deployment manifest.
- #configured? ⇒ Boolean
- #has_jobs? ⇒ Boolean
- #has_packages? ⇒ Boolean
-
#initialize(spec) ⇒ Plan
constructor
A new instance of Plan.
- #install_jobs ⇒ Object
- #install_packages ⇒ Object
- #is_legacy_spec?(job_spec) ⇒ Boolean
Constructor Details
#initialize(spec) ⇒ Plan
Returns a new instance of Plan.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 9 def initialize(spec) unless spec.is_a?(Hash) raise ArgumentError, "Invalid spec format, Hash expected, " + "#{spec.class} given" end @spec = spec @deployment = spec["deployment"] @jobs = [] @packages = [] @config_binding = Bosh::Agent::Util.config_binding(spec) job_spec = spec["job"] package_specs = spec["packages"] # By default stemcell VM has '' as job # in state.yml, handling this very special case if job_spec && job_spec != "" job_name = job_spec["name"] if is_legacy_spec?(job_spec) @jobs << Job.new(job_name, job_spec["template"], job_spec, @config_binding) else job_spec["templates"].each do |template_spec| @jobs << Job.new(job_name, template_spec["name"], template_spec, @config_binding) end end end if package_specs unless package_specs.is_a?(Hash) raise ArgumentError, "Invalid package specs format " + "in apply spec, Hash expected " + "#{package_specs.class} given" end package_specs.each_pair do |package_name, package_spec| @packages << Package.new(package_spec) end end end |
Instance Attribute Details
#deployment ⇒ Object (readonly)
Returns the value of attribute deployment.
5 6 7 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 5 def deployment @deployment end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
6 7 8 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 6 def jobs @jobs end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
7 8 9 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 7 def packages @packages end |
Instance Method Details
#configure_jobs ⇒ Object
Configure the 1+ job templates (job colocation) They are reversed for the purposes of ensuring monit starts them in the order that they are specified in the original deployment manifest
86 87 88 89 90 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 86 def configure_jobs @jobs.reverse.each_with_index do |job, job_index| job.configure(job_index) end end |
#configured? ⇒ Boolean
64 65 66 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 64 def configured? @spec.key?("configuration_hash") end |
#has_jobs? ⇒ Boolean
56 57 58 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 56 def has_jobs? !@jobs.empty? end |
#has_packages? ⇒ Boolean
60 61 62 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 60 def has_packages? !@packages.empty? end |
#install_jobs ⇒ Object
68 69 70 71 72 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 68 def install_jobs @jobs.each do |job| job.install end end |
#install_packages ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 74 def install_packages @jobs.each do |job| @packages.each do |package| package.install_for_job(job) end end end |
#is_legacy_spec?(job_spec) ⇒ Boolean
52 53 54 |
# File 'lib/bosh_agent/apply_plan/plan.rb', line 52 def is_legacy_spec?(job_spec) return job_spec["template"] && !job_spec["templates"] end |