Module: Utils::PartedCommand

Included in:
Parted
Defined in:
lib/utils/parted_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent) ⇒ Object



4
5
6
# File 'lib/utils/parted_command.rb', line 4

def self.included(parent)
  parent.extend(PartedCommand)
end

Instance Method Details

#check_errors(output) ⇒ Object



17
18
19
20
# File 'lib/utils/parted_command.rb', line 17

def check_errors(output)
  return if output =~ /unrecognised disk label/
  fail "parted failed with error #{output}"
end

#parted(*args) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/utils/parted_command.rb', line 8

def parted(*args)
  options = args.last.is_a?(Hash) ? args.delete_at(-1) : {}
  options.merge!({:failonfail => false})
  command = args.dup.unshift(:parted).join(' ')
  @output = Puppet::Util::Execution.execute(command,options)
  check_errors(@output) if @output.exitstatus != 0
  @output
end