Class: Bosh::Agent::Mounter

Inherits:
Object show all
Defined in:
lib/bosh_agent/mounter.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger, shell_runner = Bosh::Exec) ⇒ Mounter

Returns a new instance of Mounter.



5
6
7
8
# File 'lib/bosh_agent/mounter.rb', line 5

def initialize(logger, shell_runner=Bosh::Exec)
  @logger = logger
  @shell_runner = shell_runner
end

Instance Method Details

#mount(partition, mount_point, options_hash = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bosh_agent/mounter.rb', line 10

def mount(partition, mount_point, options_hash={})
  @logger.info("Mounting: #{partition} #{mount_point}")
  options = build_command_line_options(options_hash)

  results = shell_runner.sh("mount #{options} #{partition} #{mount_point}", on_error: :return)

  if results.failed?
    raise Bosh::Agent::MessageHandlerError,
          "Failed to mount: '#{partition}' '#{mount_point}' Exit status: #{results.exit_status} Output: #{results.output}"
  end
end