Class: Fog::Compute::Libvirt::Pool
- Defined in:
- lib/fog/libvirt/models/compute/pool.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#active? ⇒ Boolean
Is the pool active or not?.
-
#allocation ⇒ Object
Retrieves the allocated disk space of the pool.
-
#auto_start=(flag) ⇒ Object
Set autostart value of the storage pool (true|false).
-
#auto_start? ⇒ Boolean
Will the pool autostart or not?.
-
#build ⇒ Object
Build this storage pool.
-
#capacity ⇒ Object
Retrieves the capacity of disk space of the pool.
-
#destroy(destroy_options = {}) ⇒ Object
Destroys the storage pool.
-
#initialize(attributes = {}) ⇒ Pool
constructor
Can be created by passing in XML.
-
#name ⇒ Object
Retrieves the name of the pool.
-
#num_of_volumes ⇒ Object
Retrieves the number of volumes available in this pool.
-
#persistent? ⇒ Boolean
Is the pool persistent or not?.
- #save ⇒ Object
-
#shutdown ⇒ Object
Shuts down the pool.
-
#start ⇒ Object
Start the pool = make it active Performs a libvirt create (= start).
- #state ⇒ Object
-
#stop ⇒ Object
Stop the pool = make it non-active Performs a libvirt destroy (= stop).
-
#uuid ⇒ Object
Retrieves the uuid of the pool.
-
#volumes ⇒ Object
Retrieves the volumes of this pool.
-
#xml_desc ⇒ Object
Returns the xml description of the current pool.
Methods inherited from Model
#inspect, #reload, #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
Can be created by passing in XML
17 18 19 20 21 22 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 17 def initialize(attributes={} ) self.xml ||= nil unless attributes[:xml] self.create_persistent ||= true unless attributes[:create_persistent] self.create_auto_build ||= true unless attributes[:create_auto_build] super end |
Instance Method Details
#active? ⇒ Boolean
Is the pool active or not?
96 97 98 99 100 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 96 def active? requires :raw @raw.active? end |
#allocation ⇒ Object
Retrieves the allocated disk space of the pool
136 137 138 139 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 136 def allocation requires :raw @raw.info.allocation end |
#auto_start=(flag) ⇒ Object
Set autostart value of the storage pool (true|false)
89 90 91 92 93 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 89 def auto_start=(flag) requires :raw @raw.auto_start(flag) end |
#auto_start? ⇒ Boolean
Will the pool autostart or not?
103 104 105 106 107 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 103 def auto_start? requires :raw @raw.autostart? end |
#build ⇒ Object
Build this storage pool
67 68 69 70 71 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 67 def build requires :raw @raw.build unless @raw.nil? end |
#capacity ⇒ Object
Retrieves the capacity of disk space of the pool
142 143 144 145 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 142 def capacity requires :raw @raw.info.capacity end |
#destroy(destroy_options = {}) ⇒ Object
Destroys the storage pool
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 74 def destroy( ={}) requires :raw # Shutdown pool if active @raw.destroy if @raw.active? # Delete corresponding data in this pool # @raw.delete # If this is a persistent domain we need to undefine it @raw.undefine if @raw.persistent? end |
#name ⇒ Object
Retrieves the name of the pool
124 125 126 127 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 124 def name requires :raw @raw.name end |
#num_of_volumes ⇒ Object
Retrieves the number of volumes available in this pool
148 149 150 151 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 148 def num_of_volumes requires :raw @raw.num_of_volumes end |
#persistent? ⇒ Boolean
Is the pool persistent or not?
110 111 112 113 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 110 def persistent? requires :raw @raw.persistent? end |
#save ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 24 def save requires :xml unless xml.nil? pool=nil if self.create_persistent pool=connection.raw.define_storage_pool_xml(xml) else pool=connection.raw.create_storage_pool_xml(xml) end self.raw=pool true else raise Fog::Errors::Error.new('Creating a new pool requires proper xml') false end end |
#shutdown ⇒ Object
Shuts down the pool
59 60 61 62 63 64 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 59 def shutdown requires :raw @raw.destroy true end |
#start ⇒ Object
Start the pool = make it active Performs a libvirt create (= start)
44 45 46 47 48 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 44 def start requires :raw @raw.create end |
#state ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 153 def state requires :raw #INACTIVE = INT2NUM(VIR_STORAGE_POOL_INACTIVE) virStoragePoolState #BUILDING = INT2NUM(VIR_STORAGE_POOL_BUILDING) #RUNNING = INT2NUM(VIR_STORAGE_POOL_RUNNING) #DEGRADED = INT2NUM(VIR_STORAGE_POOL_DEGRADED) #INACCESSIBLE = INT2NUM(VIR_STORAGE_POOL_INACCESSIBLE) states=[:inactive, :building,:running,:degrated,:inaccessible] return states[@raw.info.state] end |
#stop ⇒ Object
Stop the pool = make it non-active Performs a libvirt destroy (= stop)
52 53 54 55 56 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 52 def stop requires :raw @raw.destroy end |
#uuid ⇒ Object
Retrieves the uuid of the pool
130 131 132 133 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 130 def uuid requires :raw @raw.uuid end |
#volumes ⇒ Object
Retrieves the volumes of this pool
168 169 170 171 172 173 174 175 176 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 168 def volumes volumes=Array.new @raw.list_volumes.each do |volume| fog_volume=connection.volumes.all(:name => volume).first volumes << fog_volume end return volumes end |
#xml_desc ⇒ Object
Returns the xml description of the current pool
116 117 118 119 120 |
# File 'lib/fog/libvirt/models/compute/pool.rb', line 116 def xml_desc requires :raw @raw.xml_desc unless @raw.nil? end |