Sha256: a854e8fd86b9ef705d3b582726b5e0c268cb7c32590d7dee4fa1781a579779c9

Contents?: true

Size: 1.97 KB

Versions: 65

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

65 entries across 65 versions & 6 rubygems

Version Path
fog-1.22.0 lib/fog/libvirt/models/compute/pool.rb
fog-1.21.0 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/libvirt/models/compute/pool.rb
fog-1.20.0 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/libvirt/models/compute/pool.rb
fog-1.19.0 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/libvirt/models/compute/pool.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/libvirt/models/compute/pool.rb