Sha256: e148315c78bb1c3688c9fe92edfaf266d61d6b0a3cd1d919de051b403eefc579

Contents?: true

Size: 1.97 KB

Versions: 30

Compression:

Stored size: 1.97 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class Libvirt
      class Pool < Fog::Model
        attr_reader :xml

        identity :uuid

        attribute :persistent
        attribute :autostart
        attribute :active
        attribute :name
        attribute :allocation
        attribute :capacity
        attribute :num_of_volumes
        attribute :state

        def initialize(attributes={} )
          # Can be created by passing in XML
          @xml = attributes.delete(:xml)
          super(attributes)
        end

        def save
          raise Fog::Errors::Error.new('Creating a new pool requires proper xml') unless xml
          self.uuid = (persistent ? service.define_pool(xml) : service.create_pool(xml)).uuid
          reload
        end

        # Start the pool = make it active
        # Performs a libvirt create (= start)
        def start
          service.pool_action uuid, :create
        end

        # Stop the pool = make it non-active
        # Performs a libvirt destroy (= stop)
        def stop
          service.pool_action uuid, :destroy
        end

        # Shuts down the pool
        def shutdown
          stop
        end

        # Build this storage pool
        def build
          service.pool_action uuid, :build
        end

        # Destroys the storage pool
        def destroy
          # Shutdown pool if active
          service.pool_action uuid, :destroy if active?
          # If this is a persistent domain we need to undefine it
          service.pool_action uuid, :undefine if persistent?
        end

        # Is the pool active or not?
        def active?
          active
        end

        # Will the pool autostart or not?
        def auto_start?
          autostart
        end

        # Is the pool persistent or not?
        def persistent?
          persistent
        end

        # Retrieves the volumes of this pool
        def volumes
          service.list_pool_volumes uuid
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
fog-libvirt-0.5.0 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.4.2 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.4.1 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.4.0 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.3.0 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.2.0 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.1.0 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.0.4 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.0.3 lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.0.2 lib/fog/libvirt/models/compute/pool.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/libvirt/models/compute/pool.rb
fog-libvirt-0.0.1 lib/fog/libvirt/models/compute/pool.rb
fog-1.29.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.28.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.27.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.26.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.25.0 lib/fog/libvirt/models/compute/pool.rb
nsidc-fog-1.24.1 lib/fog/libvirt/models/compute/pool.rb
fog-1.24.0 lib/fog/libvirt/models/compute/pool.rb
ns-fog-1.22.11 lib/fog/libvirt/models/compute/pool.rb