Class: Fog::Compute::Aliyun::Volumes

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/aliyun/models/compute/volumes.rb

Instance Method Summary collapse

Instance Method Details

#all(filters_arg = {}) ⇒ Object

The volume can be retrieved by running Aliyun.volumes.get(‘d-25x03nah9’). See get method below.



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fog/aliyun/models/compute/volumes.rb', line 76

def all(filters_arg = {})
  unless filters_arg.is_a?(Hash)
    Fog::Logger.deprecation("all with #{filters_arg.class} param is deprecated, use all('diskIds' => []) instead [light_black](#{caller.first})[/]")
    filters_arg = { 'diskIds' => [*filters_arg] }
  end
  data = Fog::JSON.decode(service.list_disks(filters_arg).body)['Disks']['Disk']
  load(data)
  # load(data['volumeSet'])
  # 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: Aliyun.volumes.get(‘d-25x03nah9’)

Returns

>> Aliyun.volumes.get(‘d-25ohde62o’)

<Fog::Compute::Aliyun::Volume
    id="d-25ohde62o",
    region_id="cn-beijing",
    zone_id="cn-beijing-a",
    name="",
    description="",
    type="data",
    category="cloud",
    size=10,
    image_id="",
    snapshot_id="",
    product_code="",
    portable=true,
    state="In_use",
    operation_locks={"OperationLock"=>[{"LockReason"=>"financial"}]},
    server_id="i-25l758pg4",
    device="/dev/xvdc",
    delete_with_instance=false,
    delete_auto_snapshot=true,
    enable_auto_snapshot=true,
    created_at="2015-08-03T11:35:10Z",
    attached_at="2015-08-03T11:35:15Z",
    detached_at="",
    expired_at="2015-09-29T15:45Z",
    charge_type="PostPaid",
    tags={"Tag"=>[]}
  >


128
129
130
131
132
133
# File 'lib/fog/aliyun/models/compute/volumes.rb', line 128

def get(volume_id)
  if volume_id
    diskIds = Array.new(1, volume_id)
    self.class.new(service: service).all(diskIds: diskIds)[0]
  end
end