Method: Fog::Compute::Libvirt::Volume#initialize
- Defined in:
- lib/fog/libvirt/models/compute/volume.rb
#initialize(attributes = {}) ⇒ Volume
Can be created by passing in :xml => “<xml to create volume>” A volume always belongs to a pool, :pool_name => “<name of pool>”
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/libvirt/models/compute/volume.rb', line 32 def initialize(attributes={} ) self.xml ||= nil unless attributes[:xml] self.key = nil self.format_type ||= "raw" unless attributes[:format_type] extension = self.format_type=="raw" ? "img" : self.format_type self.name ||= "fog-#{SecureRandom.random_number*10E14.to_i.round}.#{extension}" unless attributes[:name] self.capacity ||= "10G" unless attributes[:capacity] self.allocation ||= "1G" unless attributes[:allocation] super #We need a connection to calculate the poolname #This is why we do this after super self.pool_name ||= default_pool_name unless attributes[:pool_name] end |