require 'fog/core/collection' require 'fog/aliyun/models/compute/volume' module Fog module Compute class Aliyun class Volumes < Fog::Collection model Fog::Compute::Aliyun::Volume # Used to create a volume. There are 3 arguments and availability_zone and size are required. You can generate a new key_pair as follows: # Aliyun.volumes.create(:size => 10) # # ==== Returns # # # # The volume can be retrieved by running Aliyun.volumes.get("d-25ohde62o"). See get method below. # # Used to return all volumes. # Aliyun.volumes.all # # ==== Returns # # >>Aliyun.volumes.all # [{"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"=>[]} # > # ] # > # # The volume can be retrieved by running Aliyun.volumes.get('d-25x03nah9'). See get method below. # 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 # 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') # [{"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"=>[]} # > # def get(volume_id) if volume_id diskIds = Array.new(1, volume_id) self.class.new(service: service).all(diskIds: diskIds)[0] end end end end end end