Class: Fog::Compute::QingCloud::Volumes
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::QingCloud::Volumes
- Defined in:
- lib/fog/qingcloud/models/compute/volumes.rb
Constant Summary collapse
- ACTIVE_STATUS =
%w[pending available in-use suspended]
Instance Method Summary collapse
-
#all(filters = filters) ⇒ Object
Used to return all volumes.
-
#get(volume_id) ⇒ Object
Used to retrieve a volume volume_id is required to get the associated volume information.
-
#initialize(attributes) ⇒ Volumes
constructor
Used to create a volume.
- #new(attributes = {}) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Volumes
Used to create a volume. There are 3 arguments and zone and size are required. You can generate a new key_pair as follows: QingCloud.volumes.create(:zone => ‘us-east-1a’, :size => 10)
19 20 21 22 23 |
# File 'lib/fog/qingcloud/models/compute/volumes.rb', line 19 def initialize(attributes) self.filters ||= {} filters['status'] = ACTIVE_STATUS unless filters['status'] super end |
Instance Method Details
#all(filters = filters) ⇒ Object
Used to return all volumes. QingCloud.volumes.all
The volume can be retrieved by running QingCloud.volumes.get(“vol-1e2028b9”). See get method below.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/qingcloud/models/compute/volumes.rb', line 31 def all(filters = filters) unless filters.is_a?(Hash) Fog::Logger.deprecation("all with #{filters.class} param is deprecated, use all('volume-id' => []) instead [light_black](#{caller.first})[/]") filters = {'volume-id' => [*filters]} end self.filters = filters data = service.describe_volumes(filters).body load(data['volume_set'].map {|v| i = v.delete('instance') v['instance_id'] = i['instance_id'] if i v } ) if server self.replace(self.select {|volume| volume.server_id == server.id}) end self end |
#get(volume_id) ⇒ Object
Used to retrieve a volume volume_id is required to get the associated volume information.
You can run the following command to get the details: QingCloud.volumes.get(“vol-1e2028b9”)
Returns
>> QingCloud.volumes.get(“vol-1e2028b9”) <Fog::QingCloud::Compute::Volume
id="vol-1e2028b9",
attached_at=nil,
zone="us-east-1a",
created_at=Tue Nov 23 23:30:29 -0500 2010,
delete_on_termination=nil,
device=nil,
server_id=nil,
size=10,
snapshot_id=nil,
status="available",
tags={}
>
74 75 76 77 78 |
# File 'lib/fog/qingcloud/models/compute/volumes.rb', line 74 def get(volume_id) if volume_id self.class.new(:service => service).all('volume-id' => volume_id).first end end |
#new(attributes = {}) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/fog/qingcloud/models/compute/volumes.rb', line 80 def new(attributes = {}) if server super({ :server => server }.merge!(attributes)) else super end end |