Sha256: 0f64b50ecab31bac452d9035c4205917362722f044bb50a71310a2e4afa19886

Contents?: true

Size: 1.99 KB

Versions: 14

Compression:

Stored size: 1.99 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 ? connection.define_pool(xml) : connection.create_pool(xml)).uuid
          reload
        end

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

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

        # Shuts down the pool
        def shutdown
          stop
        end

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

        # Destroys the storage pool
        def destroy
          # Shutdown pool if active
          connection.pool_action uuid, :destroy if active?
          # If this is a persistent domain we need to undefine it
          connection.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
          connection.list_pool_volumes uuid
        end

      end

    end
  end

end

Version data entries

14 entries across 14 versions & 8 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/libvirt/models/compute/pool.rb
fog-nirvanix-1.8.1 lib/fog/libvirt/models/compute/pool.rb
fog-parser-fix-1.6.1 lib/fog/libvirt/models/compute/pool.rb
fog-test-again-1.6.0 lib/fog/libvirt/models/compute/pool.rb
fog-parser-fix-1.6.0 lib/fog/libvirt/models/compute/pool.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/libvirt/models/compute/pool.rb
fog-sgonyea-1.8.1 lib/fog/libvirt/models/compute/pool.rb
fog-1.8.0 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/libvirt/models/compute/pool.rb
fog-1.7.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.6.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.5.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.4.0 lib/fog/libvirt/models/compute/pool.rb
michiels-fog-1.3.1 lib/fog/libvirt/models/compute/pool.rb