Skip to content

Commit

Permalink
Merge pull request #14 from arielsalvo/VolRaceCondition
Browse files Browse the repository at this point in the history
Catching exception when running stat on non-existent volume
  • Loading branch information
plribeiro3000 committed Feb 17, 2016
2 parents 66f35b8 + 1331b6f commit 31a6b1d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/fog/libvirt/requests/compute/list_volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ def volume_to_attributes(vol)
format_type = xml_element(vol.xml_desc, "/volume/target/format", "type") rescue nil # not all volumes have types, e.g. LVM
return nil if format_type == "dir"

{
:pool_name => vol.pool.name,
:key => vol.key,
:id => vol.key,
:path => vol.path,
:name => vol.name,
:format_type => format_type,
:allocation => bytes_to_gb(vol.info.allocation),
:capacity => bytes_to_gb(vol.info.capacity),
}
begin
{
:pool_name => vol.pool.name,
:key => vol.key,
:id => vol.key,
:path => vol.path,
:name => vol.name,
:format_type => format_type,
:allocation => bytes_to_gb(vol.info.allocation),
:capacity => bytes_to_gb(vol.info.capacity),
}
rescue Libvirt::RetrieveError
return nil # If there are issues during stat of volume file
end
end

def bytes_to_gb bytes
Expand Down

0 comments on commit 31a6b1d

Please sign in to comment.