Class: Bosh::Agent::Message::Prepare

Inherits:
Base show all
Defined in:
lib/bosh_agent/message/prepare.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#base_dir, #handler_error, #logger, #logs_dir, #settings, #store_migration_target, #store_path

Constructor Details

#initialize(apply_spec) ⇒ Prepare

Returns a new instance of Prepare.



7
8
9
10
11
12
13
14
# File 'lib/bosh_agent/message/prepare.rb', line 7

def initialize(apply_spec)
  @platform = Bosh::Agent::Config.platform
  @apply_spec = apply_spec

  unless @apply_spec.is_a?(Hash)
    raise ArgumentError, "invalid spec, Hash expected, #{@apply_spec.class} given"
  end
end

Class Method Details

.process(args) ⇒ Object



3
4
5
# File 'lib/bosh_agent/message/prepare.rb', line 3

def self.process(args)
  new(*args).run
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
# File 'lib/bosh_agent/message/prepare.rb', line 16

def run
  plan = Bosh::Agent::ApplyPlan::Plan.new(@apply_spec)
  plan.jobs.each(&:prepare_for_install)
  plan.packages.each(&:prepare_for_install)
  {}
rescue Exception => e
  raise Bosh::Agent::MessageHandlerError, "#{e.inspect}\n#{e.backtrace}"
end