Class: Bosh::Agent::ApplyPlan::Job

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/bosh_agent/apply_plan/job.rb

Defined Under Namespace

Classes: ConfigurationError, InstallationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_name, template_name, template_spec, config_binding = nil) ⇒ Job

Initializes a job.

Parameters:

  • job_name (String)

    The name of the job being set up, such as “nats”.

  • template_spec (Hash)

    A hash that came from the apply spec message. This hash contains information about the template that is to be setup in this job. It has keys such as: “name”, “version”, “sha1”, “blobstore_id”

  • config_binding (Bosh::Agent::Util::BindingHelper) (defaults to: nil)

    A binding helper instance.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bosh_agent/apply_plan/job.rb', line 25

def initialize(job_name, template_name, template_spec,
    config_binding = nil)
  validate_spec(template_spec)

  @base_dir = Bosh::Agent::Config.base_dir
  @name = "#{job_name}.#{template_name}"
  @template = template_name
  @version = template_spec['version']
  @checksum = template_spec['sha1']
  @blobstore_id = template_spec['blobstore_id']
  @config_binding = config_binding

  @install_path = File.join(@base_dir, 'data', 'jobs',
                            @template, @version, @checksum)
  @link_path = File.join(@base_dir, 'jobs', @template)
end

Instance Attribute Details

#install_pathObject (readonly)

Returns the value of attribute install_path.



12
13
14
# File 'lib/bosh_agent/apply_plan/job.rb', line 12

def install_path
  @install_path
end

Returns the value of attribute link_path.



13
14
15
# File 'lib/bosh_agent/apply_plan/job.rb', line 13

def link_path
  @link_path
end

#templateObject (readonly)

Returns the value of attribute template.



14
15
16
# File 'lib/bosh_agent/apply_plan/job.rb', line 14

def template
  @template
end

Instance Method Details

#configure(job_index) ⇒ Object



54
55
56
57
58
59
# File 'lib/bosh_agent/apply_plan/job.rb', line 54

def configure(job_index)
  run_post_install_hook
  configure_monit(job_index)
rescue SystemCallError => e
  config_failed("system call error: #{e.message}")
end

#installObject



46
47
48
49
50
51
52
# File 'lib/bosh_agent/apply_plan/job.rb', line 46

def install
  fetch_bits_and_symlink
  bind_configuration
  harden_permissions
rescue SystemCallError => e
  install_failed("system call error: #{e.message}")
end

#prepare_for_installObject



42
43
44
# File 'lib/bosh_agent/apply_plan/job.rb', line 42

def prepare_for_install
  fetch_bits
end