Class: Bosh::Stemcell::StageRunner
- Inherits:
-
Object
- Object
- Bosh::Stemcell::StageRunner
- Defined in:
- lib/bosh/stemcell/stage_runner.rb
Constant Summary collapse
- REQUIRED_UID =
1000
Instance Method Summary collapse
- #apply(stages) ⇒ Object
- #check_correct_uid ⇒ Object
- #configure(stages) ⇒ Object
- #configure_and_apply(stages, resume_from_stage = nil) ⇒ Object
-
#initialize(options) ⇒ StageRunner
constructor
A new instance of StageRunner.
Constructor Details
#initialize(options) ⇒ StageRunner
Returns a new instance of StageRunner.
8 9 10 11 12 13 |
# File 'lib/bosh/stemcell/stage_runner.rb', line 8 def initialize() @build_path = .fetch(:build_path) @command_env = .fetch(:command_env) @settings_file = .fetch(:settings_file) @work_path = .fetch(:work_path) end |
Instance Method Details
#apply(stages) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bosh/stemcell/stage_runner.rb', line 40 def apply(stages) stages.each do |stage| FileUtils.mkdir_p(work_path) puts "=== Applying '#{stage}' stage ===" puts "== Started #{Time.now.strftime('%a %b %e %H:%M:%S %Z %Y')} ==" begin stage_apply_script = File.join(build_path, 'stages', stage.to_s, 'apply.sh') run_sudo_with_command_env("#{stage_apply_script} #{work_path}") rescue => _ puts "=== You can resume_from the '#{stage}' stage by using resume_from=#{stage} ===" raise end end end |
#check_correct_uid ⇒ Object
15 16 17 18 19 |
# File 'lib/bosh/stemcell/stage_runner.rb', line 15 def check_correct_uid if Process.euid != REQUIRED_UID raise "You must build stemcells as a user with UID #{REQUIRED_UID}. Your effective UID now is #{Process.euid}." end end |
#configure(stages) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bosh/stemcell/stage_runner.rb', line 28 def configure(stages) stages.each do |stage| stage_config_script = File.join(build_path, 'stages', stage.to_s, 'config.sh') puts "=== Configuring '#{stage}' stage ===" puts "== Started #{Time.now.strftime('%a %b %e %H:%M:%S %Z %Y')} ==" if File.exists?(stage_config_script) && File.executable?(stage_config_script) run_sudo_with_command_env("#{stage_config_script} #{settings_file}") end end end |
#configure_and_apply(stages, resume_from_stage = nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bosh/stemcell/stage_runner.rb', line 21 def configure_and_apply(stages, resume_from_stage = nil) check_correct_uid() stages = resume_from(stages, resume_from_stage) configure(stages) apply(stages) end |