Class: MotherBrain::Upgrade::Worker
- Inherits:
-
Object
- Object
- MotherBrain::Upgrade::Worker
show all
- Extended by:
- Forwardable
- Includes:
- Celluloid, MB::Mixin::AttributeSetting, MB::Mixin::Locks, MB::Mixin::Services, Logging
- Defined in:
- lib/mb/upgrade/worker.rb
Overview
Upgrades a plugin by pinning cookbook versions and default attributes (based on the plugin components’ version attributes).
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
add_argument_header, dev, filename, #log_exception, logger, #logger, reset, set_logger, setup
Constructor Details
#initialize(job, environment_name, plugin, options = {}) ⇒ Worker
Returns a new instance of Worker.
40
41
42
43
44
45
|
# File 'lib/mb/upgrade/worker.rb', line 40
def initialize(job, environment_name, plugin, options = {})
@job = job
@environment_name = environment_name
@plugin = plugin
@options = options
end
|
Instance Attribute Details
#environment_name ⇒ String
15
16
17
|
# File 'lib/mb/upgrade/worker.rb', line 15
def environment_name
@environment_name
end
|
18
19
20
|
# File 'lib/mb/upgrade/worker.rb', line 18
def job
@job
end
|
#options ⇒ Hash
21
22
23
|
# File 'lib/mb/upgrade/worker.rb', line 21
def options
@options
end
|
24
25
26
|
# File 'lib/mb/upgrade/worker.rb', line 24
def plugin
@plugin
end
|
Instance Method Details
#run ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/mb/upgrade/worker.rb', line 54
def run
job.set_status("Starting")
job.report_running
assert_environment_exists
chef_synchronize(chef_environment: environment_name, force: options[:force], job: job) do
if component_versions.any?
job.set_status("Setting component versions")
set_component_versions(environment_name, plugin, component_versions)
end
if cookbook_versions.any?
job.set_status("Setting cookbook versions")
set_cookbook_versions(environment_name, cookbook_versions)
end
if environment_attributes.any?
job.set_status("Setting environment attributes")
set_environment_attributes(environment_name, environment_attributes)
end
if environment_attributes_file
job.set_status("Setting environment attributes from #{environment_attributes_file}")
set_environment_attributes_from_file(environment_name, environment_attributes_file)
end
run_chef if nodes.any?
end
job.report_success
rescue => ex
job.report_failure(ex)
ensure
job.terminate if job && job.alive?
end
|