mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
- ERB has a problem with a variable called type, it expands it on ruby 1.8 to .class
- If the key or the volume is not found, maybe because the pool has not yet been started, the volumes should return nil
This commit is contained in:
parent
d07d3144d6
commit
dbfb17373f
3 changed files with 8 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
<allocation unit="<%= allocate_unit %>"><%= allocate %></allocation>
|
||||
<capacity unit="<%= size_unit %>"><%= size %></capacity>
|
||||
<target>
|
||||
<format type="<%= type %>"/>
|
||||
<format type="<%= vol_type %>"/>
|
||||
<permissions>
|
||||
<owner>0</owner>
|
||||
<group>0</group>
|
||||
|
|
|
@ -107,6 +107,11 @@ module Fog
|
|||
def xml_from_template(template_options)
|
||||
|
||||
# We only want specific variables for ERB
|
||||
|
||||
# we can't use an option of name type
|
||||
# This clashes with ruby 1.8 Erb.type which is equivalent of .class
|
||||
new_template_options={:vol_type => template_options[:type]}.merge(template_options)
|
||||
|
||||
vars = ErbBinding.new(template_options)
|
||||
template_path=File.join(File.dirname(__FILE__),"templates","volume.xml.erb")
|
||||
template=File.open(template_path).readlines.join
|
||||
|
|
|
@ -24,6 +24,8 @@ module Fog
|
|||
volume=self.get_by_name(filter[:name]) if filter.has_key?(:name)
|
||||
volume=self.get_by_key(filter[:key]) if filter.has_key?(:key)
|
||||
volume=self.get_by_path(filter[:path]) if filter.has_key?(:path)
|
||||
return nil if volume.nil?
|
||||
|
||||
rescue ::Libvirt::RetrieveError
|
||||
return nil
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue