Skip to content

Commit

Permalink
Some Ruby 1.8 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalmer committed May 23, 2014
1 parent edf3b3b commit da00c95
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/lvm/vg_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,27 @@ def logical_volumes
private
def vgcfgbackup_output
@vgcfgbackup_output ||= begin
out = nil

Tempfile.open('vg_config') do |tmpf|
cmd = "#{@vgcfgbackup_cmd} -f #{tmpf.path} #{@vg_name}"
Open3.popen3(cmd) do |stdin_fd, stdout_fd, stderr_fd, thr|
stdout = nil
stderr = nil
Open3.popen3(cmd) do |stdin_fd, stdout_fd, stderr_fd|
stdin_fd.close
stdout = stdout_fd.read
stderr = stderr_fd.read
exit_status = thr.value
end

if exit_status != 0
raise RuntimeError,
"Failed to run vgcfgbackup: #{stdout}\n#{stderr}"
end
if $?.exitstatus != 0
raise RuntimeError,
"Failed to run vgcfgbackup: #{stdout}\n#{stderr}"
end

File.read(tmpf.path)
out = File.read(tmpf.path)
end

out
end
end
end

0 comments on commit da00c95

Please sign in to comment.