Class: Fog::Compute::Libvirt::Pool

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/libvirt/models/compute/pool.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

#initialize(attributes = {}) ⇒ Pool

Returns a new instance of Pool.



21
22
23
24
25
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 21

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

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml.



8
9
10
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 8

def xml
  @xml
end

Instance Method Details

#active?Boolean

Is the pool active or not?

Returns:

  • (Boolean)


64
65
66
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 64

def active?
  active
end

#auto_start?Boolean

Will the pool autostart or not?

Returns:

  • (Boolean)


69
70
71
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 69

def auto_start?
  autostart
end

#buildObject

Build this storage pool



51
52
53
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 51

def build
  connection.pool_action uuid, :build
end

#destroyObject

Destroys the storage pool



56
57
58
59
60
61
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 56

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

#persistent?Boolean

Is the pool persistent or not?

Returns:

  • (Boolean)


74
75
76
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 74

def persistent?
  persistent
end

#saveObject

Raises:



27
28
29
30
31
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 27

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

#shutdownObject

Shuts down the pool



46
47
48
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 46

def shutdown
  stop
end

#startObject

Start the pool = make it active Performs a libvirt create (= start)



35
36
37
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 35

def start
  connection.pool_action uuid, :create
end

#stopObject

Stop the pool = make it non-active Performs a libvirt destroy (= stop)



41
42
43
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 41

def stop
  connection.pool_action uuid, :destroy
end

#volumesObject

Retrieves the volumes of this pool



79
80
81
# File 'lib/rackspace-fog/libvirt/models/compute/pool.rb', line 79

def volumes
  connection.list_pool_volumes uuid
end