Method: Fog::Compute::Libvirt::Volume#save

Defined in:
lib/fog/libvirt/models/compute/volume.rb

#saveObject

Takes a pool and either :xml or other settings

Raises:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fog/libvirt/models/compute/volume.rb', line 64

def save
  requires :pool_name

  raise Fog::Errors::Error.new('Resaving an existing volume may create a duplicate') if key

  xml=xml_from_template if xml.nil?

  begin
    volume=nil
    pool=connection.raw.lookup_storage_pool_by_name(pool_name)
    volume=pool.create_volume_xml(xml)
    self.raw=volume
    true
  rescue
    raise Fog::Errors::Error.new("Error creating volume: #{$!}")
    false
  end

end