fog-aliyun 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.rubocop_todo.yml +149 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Rakefile +3 -3
  7. data/fog-aliyun.gemspec +16 -13
  8. data/lib/fog/aliyun.rb +8 -8
  9. data/lib/fog/aliyun/compute.rb +99 -113
  10. data/lib/fog/aliyun/models/compute/eip_address.rb +23 -29
  11. data/lib/fog/aliyun/models/compute/eip_addresses.rb +3 -5
  12. data/lib/fog/aliyun/models/compute/image.rb +26 -28
  13. data/lib/fog/aliyun/models/compute/images.rb +2 -6
  14. data/lib/fog/aliyun/models/compute/route_entry.rb +9 -11
  15. data/lib/fog/aliyun/models/compute/route_entrys.rb +7 -7
  16. data/lib/fog/aliyun/models/compute/route_table.rb +10 -11
  17. data/lib/fog/aliyun/models/compute/route_tables.rb +2 -2
  18. data/lib/fog/aliyun/models/compute/security_group.rb +24 -24
  19. data/lib/fog/aliyun/models/compute/security_group_rule.rb +20 -20
  20. data/lib/fog/aliyun/models/compute/security_group_rules.rb +4 -4
  21. data/lib/fog/aliyun/models/compute/security_groups.rb +6 -7
  22. data/lib/fog/aliyun/models/compute/server.rb +42 -43
  23. data/lib/fog/aliyun/models/compute/servers.rb +9 -11
  24. data/lib/fog/aliyun/models/compute/snapshot.rb +15 -15
  25. data/lib/fog/aliyun/models/compute/snapshots.rb +6 -10
  26. data/lib/fog/aliyun/models/compute/volume.rb +36 -40
  27. data/lib/fog/aliyun/models/compute/volumes.rb +7 -11
  28. data/lib/fog/aliyun/models/compute/vpc.rb +18 -19
  29. data/lib/fog/aliyun/models/compute/vpcs.rb +5 -6
  30. data/lib/fog/aliyun/models/compute/vrouter.rb +13 -13
  31. data/lib/fog/aliyun/models/compute/vrouters.rb +4 -5
  32. data/lib/fog/aliyun/models/compute/vswitch.rb +18 -20
  33. data/lib/fog/aliyun/models/compute/vswitches.rb +6 -6
  34. data/lib/fog/aliyun/models/storage/directories.rb +10 -16
  35. data/lib/fog/aliyun/models/storage/directory.rb +8 -8
  36. data/lib/fog/aliyun/models/storage/file.rb +58 -64
  37. data/lib/fog/aliyun/models/storage/files.rb +95 -115
  38. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +18 -44
  39. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +12 -36
  40. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +16 -40
  41. data/lib/fog/aliyun/requests/compute/attach_disk.rb +19 -22
  42. data/lib/fog/aliyun/requests/compute/create_disk.rb +33 -63
  43. data/lib/fog/aliyun/requests/compute/create_image.rb +21 -21
  44. data/lib/fog/aliyun/requests/compute/create_security_group.rb +16 -16
  45. data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +22 -63
  46. data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +23 -61
  47. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +22 -63
  48. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +23 -61
  49. data/lib/fog/aliyun/requests/compute/create_server.rb +76 -78
  50. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +12 -26
  51. data/lib/fog/aliyun/requests/compute/create_vpc.rb +11 -38
  52. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +13 -40
  53. data/lib/fog/aliyun/requests/compute/delete_disk.rb +8 -35
  54. data/lib/fog/aliyun/requests/compute/delete_image.rb +6 -33
  55. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
  56. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +22 -63
  57. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +23 -61
  58. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -62
  59. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +23 -61
  60. data/lib/fog/aliyun/requests/compute/delete_server.rb +15 -15
  61. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +6 -20
  62. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +9 -26
  63. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +9 -25
  64. data/lib/fog/aliyun/requests/compute/detach_disk.rb +11 -27
  65. data/lib/fog/aliyun/requests/compute/join_security_group.rb +15 -16
  66. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +15 -16
  67. data/lib/fog/aliyun/requests/compute/list_disks.rb +24 -43
  68. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +26 -52
  69. data/lib/fog/aliyun/requests/compute/list_images.rb +21 -24
  70. data/lib/fog/aliyun/requests/compute/list_route_tables.rb +16 -19
  71. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +22 -23
  72. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +21 -24
  73. data/lib/fog/aliyun/requests/compute/list_server_types.rb +50 -50
  74. data/lib/fog/aliyun/requests/compute/list_servers.rb +25 -28
  75. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +20 -37
  76. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +12 -29
  77. data/lib/fog/aliyun/requests/compute/list_vrouters.rb +13 -16
  78. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +14 -31
  79. data/lib/fog/aliyun/requests/compute/list_zones.rb +16 -16
  80. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +17 -17
  81. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +11 -39
  82. data/lib/fog/aliyun/requests/compute/reboot_server.rb +15 -16
  83. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +12 -36
  84. data/lib/fog/aliyun/requests/compute/start_server.rb +14 -15
  85. data/lib/fog/aliyun/requests/compute/stop_server.rb +13 -14
  86. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +16 -41
  87. data/lib/fog/aliyun/requests/storage/copy_object.rb +11 -14
  88. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -30
  89. data/lib/fog/aliyun/requests/storage/delete_container.rb +11 -14
  90. data/lib/fog/aliyun/requests/storage/delete_object.rb +20 -22
  91. data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -148
  92. data/lib/fog/aliyun/requests/storage/get_container.rb +26 -38
  93. data/lib/fog/aliyun/requests/storage/get_containers.rb +20 -32
  94. data/lib/fog/aliyun/requests/storage/get_object.rb +12 -12
  95. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +11 -11
  96. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +11 -11
  97. data/lib/fog/aliyun/requests/storage/head_object.rb +11 -11
  98. data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -47
  99. data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -104
  100. data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -23
  101. data/lib/fog/aliyun/requests/storage/put_container.rb +12 -12
  102. data/lib/fog/aliyun/requests/storage/put_object.rb +100 -110
  103. data/lib/fog/aliyun/storage.rb +209 -214
  104. data/lib/fog/aliyun/version.rb +1 -1
  105. data/lib/fog/bin/aliyun.rb +5 -5
  106. metadata +55 -4
@@ -8,12 +8,12 @@ module Fog
8
8
  model Fog::Compute::Aliyun::SecurityGroupRule
9
9
  attribute :security_group_id
10
10
 
11
- def get(security_group_id,options={})
11
+ def get(security_group_id, options = {})
12
12
  data = Fog::JSON.decode(service.list_security_group_rules(security_group_id, options).body)
13
- self.security_group_id = data["SecurityGroupId"]
14
- permissions = data["Permissions"]["Permission"]
13
+ self.security_group_id = data['SecurityGroupId']
14
+ permissions = data['Permissions']['Permission']
15
15
  permissions.each do |permission|
16
- permission["SecurityGroupId"] = self.security_group_id
16
+ permission['SecurityGroupId'] = self.security_group_id
17
17
  end
18
18
  load(permissions)
19
19
  end
@@ -7,26 +7,25 @@ module Fog
7
7
  class SecurityGroups < Fog::Collection
8
8
  model Fog::Compute::Aliyun::SecurityGroup
9
9
 
10
- def all(options={})
10
+ def all(options = {})
11
11
  data = Fog::JSON.decode(service.list_security_groups(options).body)['SecurityGroups']['SecurityGroup']
12
12
  load(data)
13
- #['Images']['Image']
13
+ # ['Images']['Image']
14
14
  end
15
15
 
16
16
  def get(security_group_id)
17
17
  if security_group_id
18
- data=self.class.new(:service=>service).all()
19
- result=nil
18
+ data = self.class.new(service: service).all
19
+ result = nil
20
20
  data.each do |i|
21
- if(i.id==security_group_id)
22
- result=i
21
+ if i.id == security_group_id
22
+ result = i
23
23
  break
24
24
  end
25
25
  end
26
26
  result
27
27
  end
28
28
  end
29
-
30
29
  end
31
30
  end
32
31
  end
@@ -4,56 +4,56 @@ module Fog
4
4
  module Compute
5
5
  class Aliyun
6
6
  class Server < Fog::Compute::Server
7
- identity :id, :aliases=>'InstanceId'
8
- attribute :image_id, :aliases => 'ImageId'
9
- attribute :inner_ip, :aliases => 'InnerIpAddress'
10
- attribute :vlan_id, :aliases => 'VlanId'
11
- attribute :eip, :aliases => 'EipAddress'
12
- attribute :max_bandwidth_in, :aliases => 'InternetMaxBandwidthIn'
13
- attribute :zone_id, :aliases => 'ZoneId'
14
- attribute :internet_charge_type, :aliases => 'InternetChargeType'
15
- attribute :serial_number, :aliases => 'SerialNumber'
16
- attribute :io_optimized, :aliases => 'IoOptimized'
17
- attribute :max_bandwidth_out, :aliases => 'InternetMaxBandwidthOut'
18
- attribute :vpc_attributes, :aliases => 'VpcAttributes'
19
- attribute :device_available, :aliases => 'DeviceAvailable'
20
- attribute :private_ip, :aliases => 'PrivateIpAddress'
21
- attribute :security_group_ids,:aliases => 'SecurityGroupIds'
22
- attribute :name, :aliases => 'InstanceName'
23
- attribute :description, :aliases => 'Description'
24
- attribute :network_type, :aliases => 'InstanceNetworkType'
25
- attribute :public_ip, :aliases => 'PublicIpAddress'
26
- attribute :host_name, :aliases => 'HostName'
27
- attribute :type, :aliases => 'InstanceType'
28
- attribute :created_at, :aliases => 'CreationTime'
29
- attribute :state, :aliases => 'Status'
30
- attribute :cluster_id, :aliases => 'ClusterId'
31
- attribute :region_id, :aliases => 'RegionId'
32
- attribute :charge_type, :aliases => 'InstanceChargeType'
33
- attribute :operation_locks, :aliases => 'OperationLocks'
34
- attribute :expired_at, :aliases => 'ExpiredTime'
35
-
7
+ identity :id, aliases: 'InstanceId'
8
+ attribute :image_id, aliases: 'ImageId'
9
+ attribute :inner_ip, aliases: 'InnerIpAddress'
10
+ attribute :vlan_id, aliases: 'VlanId'
11
+ attribute :eip, aliases: 'EipAddress'
12
+ attribute :max_bandwidth_in, aliases: 'InternetMaxBandwidthIn'
13
+ attribute :zone_id, aliases: 'ZoneId'
14
+ attribute :internet_charge_type, aliases: 'InternetChargeType'
15
+ attribute :serial_number, aliases: 'SerialNumber'
16
+ attribute :io_optimized, aliases: 'IoOptimized'
17
+ attribute :max_bandwidth_out, aliases: 'InternetMaxBandwidthOut'
18
+ attribute :vpc_attributes, aliases: 'VpcAttributes'
19
+ attribute :device_available, aliases: 'DeviceAvailable'
20
+ attribute :private_ip, aliases: 'PrivateIpAddress'
21
+ attribute :security_group_ids, aliases: 'SecurityGroupIds'
22
+ attribute :name, aliases: 'InstanceName'
23
+ attribute :description, aliases: 'Description'
24
+ attribute :network_type, aliases: 'InstanceNetworkType'
25
+ attribute :public_ip, aliases: 'PublicIpAddress'
26
+ attribute :host_name, aliases: 'HostName'
27
+ attribute :type, aliases: 'InstanceType'
28
+ attribute :created_at, aliases: 'CreationTime'
29
+ attribute :state, aliases: 'Status'
30
+ attribute :cluster_id, aliases: 'ClusterId'
31
+ attribute :region_id, aliases: 'RegionId'
32
+ attribute :charge_type, aliases: 'InstanceChargeType'
33
+ attribute :operation_locks, aliases: 'OperationLocks'
34
+ attribute :expired_at, aliases: 'ExpiredTime'
35
+
36
36
  def image
37
37
  requires image_id
38
- Fog::Compute::Aliyun::Image.new(:service=>service).all(:imageId => image_id)[0]
38
+ Fog::Compute::Aliyun::Image.new(service: service).all(imageId: image_id)[0]
39
39
  end
40
40
 
41
41
  def vpc
42
42
  requires :vpc_id
43
- $vpc=Fog::Compute::Aliyun::Vpcs.new(:service=>service).all('vpcId'=>vpc_id)[0]
43
+ $vpc = Fog::Compute::Aliyun::Vpcs.new(service: service).all('vpcId' => vpc_id)[0]
44
44
  end
45
45
 
46
- # {"ImageId"=>"ubuntu1404_32_20G_aliaegis_20150325.vhd", "InnerIpAddress"=>{"IpAddress"=>["10.171.90.171"]},
47
- # "VlanId"=>"", "InstanceId"=>"i-25d1ry3jz",
48
- # "EipAddress"=>{"IpAddress"=>"", "AllocationId"=>"", "InternetChargeType"=>""},
49
- # "InternetMaxBandwidthIn"=>-1, "ZoneId"=>"cn-beijing-a", "InternetChargeType"=>"PayByTraffic",
50
- # "SerialNumber"=>"9b332890-35e8-45c9-8e52-14e1156a4f58", "IoOptimized"=>false, "InternetMaxBandwidthOut"=>1,
51
- # "VpcAttributes"=>{"NatIpAddress"=>"", "PrivateIpAddress"=>{"IpAddress"=>[]}, "VSwitchId"=>"", "VpcId"=>""},
52
- # "DeviceAvailable"=>true, "SecurityGroupIds"=>{"SecurityGroupId"=>["sg-25rgacf5p"]}, "InstanceName"=>"iZ25d1ry3jzZ",
53
- # "Description"=>"", "InstanceNetworkType"=>"classic", "PublicIpAddress"=>{"IpAddress"=>["123.57.73.19"]},
54
- # "HostName"=>"iZ25d1ry3jzZ", "InstanceType"=>"ecs.t1.small", "CreationTime"=>"2015-10-13T14:57Z", "Status"=>"Stopped",
55
- # "ClusterId"=>"", "RegionId"=>"cn-beijing", "InstanceChargeType"=>"PostPaid", "OperationLocks"=>{
56
- # "LockReason"=>[{"LockReason"=>"financial"}]}, "ExpiredTime"=>"2015-10-14T20:53Z"}
46
+ # {"ImageId"=>"ubuntu1404_32_20G_aliaegis_20150325.vhd", "InnerIpAddress"=>{"IpAddress"=>["10.171.90.171"]},
47
+ # "VlanId"=>"", "InstanceId"=>"i-25d1ry3jz",
48
+ # "EipAddress"=>{"IpAddress"=>"", "AllocationId"=>"", "InternetChargeType"=>""},
49
+ # "InternetMaxBandwidthIn"=>-1, "ZoneId"=>"cn-beijing-a", "InternetChargeType"=>"PayByTraffic",
50
+ # "SerialNumber"=>"9b332890-35e8-45c9-8e52-14e1156a4f58", "IoOptimized"=>false, "InternetMaxBandwidthOut"=>1,
51
+ # "VpcAttributes"=>{"NatIpAddress"=>"", "PrivateIpAddress"=>{"IpAddress"=>[]}, "VSwitchId"=>"", "VpcId"=>""},
52
+ # "DeviceAvailable"=>true, "SecurityGroupIds"=>{"SecurityGroupId"=>["sg-25rgacf5p"]}, "InstanceName"=>"iZ25d1ry3jzZ",
53
+ # "Description"=>"", "InstanceNetworkType"=>"classic", "PublicIpAddress"=>{"IpAddress"=>["123.57.73.19"]},
54
+ # "HostName"=>"iZ25d1ry3jzZ", "InstanceType"=>"ecs.t1.small", "CreationTime"=>"2015-10-13T14:57Z", "Status"=>"Stopped",
55
+ # "ClusterId"=>"", "RegionId"=>"cn-beijing", "InstanceChargeType"=>"PostPaid", "OperationLocks"=>{
56
+ # "LockReason"=>[{"LockReason"=>"financial"}]}, "ExpiredTime"=>"2015-10-14T20:53Z"}
57
57
 
58
58
  # @!attribute [rw] personality
59
59
  # @note This attribute is only used for server creation. This field will be nil on subsequent retrievals.
@@ -64,7 +64,6 @@ module Fog
64
64
  # }]
65
65
  # @see #create
66
66
  # @see http://docs.openstack.org/api/openstack-compute/2/content/Server_Personality-d1e2543.html
67
-
68
67
  end
69
68
  end
70
69
  end
@@ -5,11 +5,10 @@ module Fog
5
5
  module Compute
6
6
  class Aliyun
7
7
  class Servers < Fog::Collection
8
-
9
8
  model Fog::Compute::Aliyun::Server
10
9
 
11
10
  def all(options = {})
12
- data = Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance']
11
+ Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance']
13
12
  end
14
13
 
15
14
  # Creates a new server and populates ssh keys
@@ -25,19 +24,18 @@ module Fog
25
24
  # :public_key_path => '~/.ssh/fog_rsa.pub',
26
25
  # :private_key_path => '~/.ssh/fog_rsa'
27
26
  #
28
- # def bootstrap(new_attributes = {})
29
- # server = create(new_attributes)
30
- # server.wait_for { ready? }
31
- # server.setup(:password => server.password)
32
- # server
33
- # end
27
+ # def bootstrap(new_attributes = {})
28
+ # server = create(new_attributes)
29
+ # server.wait_for { ready? }
30
+ # server.setup(:password => server.password)
31
+ # server
32
+ # end
34
33
 
35
34
  def get(server_id)
36
- if(server_id)
37
- self.class.new(:service=>service).all(:instanceId=>server_id)[0]
35
+ if server_id
36
+ self.class.new(service: service).all(instanceId: server_id)[0]
38
37
  end
39
38
  end
40
-
41
39
  end
42
40
  end
43
41
  end
@@ -3,18 +3,18 @@ module Fog
3
3
  module Compute
4
4
  class Aliyun
5
5
  class Snapshot < Fog::Model
6
- identity :id, :aliases => 'SnapshotId'
7
- attribute :name, :aliases => 'SnapshotName'
8
- attribute :description, :aliases => 'Description'
9
- attribute :progress, :aliases => 'Progress'
10
- attribute :volume_id, :aliases => 'SourceDiskId'
11
- attribute :volume_size, :aliases => 'SourceDiskSize'
12
- attribute :volume_type, :aliases => 'SourceDiskType'
13
- attribute :product_code,:aliases => 'ProductCode'
14
- attribute :created_at, :aliases => 'CreationTime'
15
- attribute :state, :aliases => 'Status'
16
- attribute :usage, :aliases => 'Usage'
17
- attribute :tags, :aliases => 'Tags'
6
+ identity :id, aliases: 'SnapshotId'
7
+ attribute :name, aliases: 'SnapshotName'
8
+ attribute :description, aliases: 'Description'
9
+ attribute :progress, aliases: 'Progress'
10
+ attribute :volume_id, aliases: 'SourceDiskId'
11
+ attribute :volume_size, aliases: 'SourceDiskSize'
12
+ attribute :volume_type, aliases: 'SourceDiskType'
13
+ attribute :product_code, aliases: 'ProductCode'
14
+ attribute :created_at, aliases: 'CreationTime'
15
+ attribute :state, aliases: 'Status'
16
+ attribute :usage, aliases: 'Usage'
17
+ attribute :tags, aliases: 'Tags'
18
18
 
19
19
  def destroy
20
20
  requires :id
@@ -26,11 +26,11 @@ module Fog
26
26
  state == 'accomplished'
27
27
  end
28
28
 
29
- def save(options={})
29
+ def save(options = {})
30
30
  # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
31
31
  requires :volume_id
32
32
  options[:name] = name if name
33
- options[:description]=description if description
33
+ options[:description] = description if description
34
34
  data = Fog::JSON.decode(service.create_snapshot(volume_id, options).body)
35
35
  merge_attributes(data)
36
36
  true
@@ -38,7 +38,7 @@ module Fog
38
38
 
39
39
  def volume
40
40
  requires :volume_id
41
- Fog::Compute::Aliyun::Volumes.new(:service=>service).all(:diskIds=>[volume_id])[0]
41
+ Fog::Compute::Aliyun::Volumes.new(service: service).all(diskIds: [volume_id])[0]
42
42
  end
43
43
 
44
44
  private
@@ -13,27 +13,23 @@ module Fog
13
13
  # super
14
14
  # end
15
15
 
16
- def all(filters_arg = {})
16
+ def all(filters_arg = {})
17
17
  unless filters_arg.is_a?(Hash)
18
18
  Fog::Logger.deprecation("all with #{filters_arg.class} param is deprecated, use all('snapshotIds' => []) instead [light_black](#{caller.first})[/]")
19
- filters_arg = {'snapshotIds' => [*filters_arg]}
19
+ filters_arg = { 'snapshotIds' => [*filters_arg] }
20
20
  end
21
21
  volume_id = filters_arg[:volume_id]
22
22
  volume_type = filters_arg[:volume_type]
23
- if volume_id
24
- filters_arg[:diskId]=volume_id
25
- end
26
- if volume_type
27
- filters_arg[:sourseDiskType]=volume_type
28
- end
23
+ filters_arg[:diskId] = volume_id if volume_id
24
+ filters_arg[:sourseDiskType] = volume_type if volume_type
29
25
  data = Fog::JSON.decode(service.list_snapshots(filters_arg).body)['Snapshots']['Snapshot']
30
26
  load(data)
31
27
  end
32
28
 
33
29
  def get(snapshot_id)
34
30
  if snapshot_id
35
- snapshotIds=Array.new(1,snapshot_id)
36
- self.class.new(:service => service).all(:snapshotIds => snapshotIds)[0]
31
+ snapshotIds = Array.new(1, snapshot_id)
32
+ self.class.new(service: service).all(snapshotIds: snapshotIds)[0]
37
33
  end
38
34
  end
39
35
  end
@@ -3,7 +3,6 @@ module Fog
3
3
  module Compute
4
4
  class Aliyun
5
5
  class Volume < Fog::Model
6
-
7
6
  # "ImageId": "",
8
7
  # "InstanceId": "",
9
8
  # "OperationLocks": {
@@ -17,32 +16,31 @@ module Fog
17
16
  # "Status": "Available",
18
17
  # "Type": "data",
19
18
 
20
- identity :id, :aliases => 'DiskId'
21
- attribute :region_id, :aliases => 'RegionId'
22
- attribute :zone_id, :aliases => 'ZoneId'
23
- attribute :name, :aliases => 'DiskName'
24
- attribute :description, :aliases => 'Description'
25
- attribute :type, :aliases => 'Type'
26
- attribute :category, :aliases => 'Category'
27
- attribute :size, :aliases => 'Size'
28
- attribute :image_id, :aliases => 'ImageId'
29
- attribute :snapshot_id, :aliases => 'SourceSnapshotId'
30
- attribute :product_code, :aliases => 'ProductCode'
31
- attribute :portable, :aliases => 'Portable'
32
- attribute :state, :aliases => 'Status'
33
- attribute :operation_locks, :aliases => 'OperationLocks'
34
- attribute :server_id, :aliases => 'InstanceId'
35
- attribute :device, :aliases => 'Device'
36
- attribute :delete_with_instance, :aliases => 'DeleteWithInstance'
37
- attribute :delete_auto_snapshot, :aliases => 'DeleteAutoSnapshot'
38
- attribute :enable_auto_snapshot, :aliases => 'EnableAutoSnapshot'
39
- attribute :created_at, :aliases => 'CreationTime'
40
- attribute :attached_at, :aliases => 'AttachedTime'
41
- attribute :detached_at, :aliases => 'DetachedTime'
42
- attribute :expired_at, :aliases => 'ExpiredTime'
43
- attribute :charge_type, :aliases => 'DiskChargeType'
44
- attribute :tags, :aliases => 'Tags'
45
-
19
+ identity :id, aliases: 'DiskId'
20
+ attribute :region_id, aliases: 'RegionId'
21
+ attribute :zone_id, aliases: 'ZoneId'
22
+ attribute :name, aliases: 'DiskName'
23
+ attribute :description, aliases: 'Description'
24
+ attribute :type, aliases: 'Type'
25
+ attribute :category, aliases: 'Category'
26
+ attribute :size, aliases: 'Size'
27
+ attribute :image_id, aliases: 'ImageId'
28
+ attribute :snapshot_id, aliases: 'SourceSnapshotId'
29
+ attribute :product_code, aliases: 'ProductCode'
30
+ attribute :portable, aliases: 'Portable'
31
+ attribute :state, aliases: 'Status'
32
+ attribute :operation_locks, aliases: 'OperationLocks'
33
+ attribute :server_id, aliases: 'InstanceId'
34
+ attribute :device, aliases: 'Device'
35
+ attribute :delete_with_instance, aliases: 'DeleteWithInstance'
36
+ attribute :delete_auto_snapshot, aliases: 'DeleteAutoSnapshot'
37
+ attribute :enable_auto_snapshot, aliases: 'EnableAutoSnapshot'
38
+ attribute :created_at, aliases: 'CreationTime'
39
+ attribute :attached_at, aliases: 'AttachedTime'
40
+ attribute :detached_at, aliases: 'DetachedTime'
41
+ attribute :expired_at, aliases: 'ExpiredTime'
42
+ attribute :charge_type, aliases: 'DiskChargeType'
43
+ attribute :tags, aliases: 'Tags'
46
44
 
47
45
  def destroy
48
46
  requires :id
@@ -56,50 +54,48 @@ module Fog
56
54
  state == 'Available'
57
55
  end
58
56
 
59
- def save(options={})
57
+ def save(options = {})
60
58
  # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
61
59
  # requires :availability_zone
62
60
  requires_one :size, :snapshot_id
63
61
  options[:name] = name if name
64
- options[:description]=description if description
62
+ options[:description] = description if description
65
63
  if snapshot_id
66
- data=Fog::JSON.decode(service.create_disk_by_snapshot(snapshot_id,options).body)
64
+ data = Fog::JSON.decode(service.create_disk_by_snapshot(snapshot_id, options).body)
67
65
  merge_attributes(data)
68
66
  elsif size
69
- data = Fog::JSON.decode(service.create_disk(size,options).body)
67
+ data = Fog::JSON.decode(service.create_disk(size, options).body)
70
68
  merge_attributes(data)
71
- end
72
-
69
+ end
70
+
73
71
  true
74
72
  end
75
73
 
76
74
  def image
77
75
  requires :image_id
78
- Fog::Compute::Aliyun::Images.new(:service=>service).all(:imageId=>image_id)[0]
79
- end
76
+ Fog::Compute::Aliyun::Images.new(service: service).all(imageId: image_id)[0]
77
+ end
80
78
 
81
79
  def snapshots
82
80
  requires :id
83
- Fog::Compute::Aliyun::Snapshots.new(:service=>service).all(:volume_id=>id)
81
+ Fog::Compute::Aliyun::Snapshots.new(service: service).all(volume_id: id)
84
82
  end
85
83
 
86
84
  def source
87
85
  requires :snapshot_id
88
- Fog::Compute::Aliyun::Snapshots.new(:service=>service).all(:snapshotIds => [snapshot_id])[0]
86
+ Fog::Compute::Aliyun::Snapshots.new(service: service).all(snapshotIds: [snapshot_id])[0]
89
87
  end
90
88
 
91
89
  private
92
90
 
93
91
  def source=(new_source)
94
- self.snapshot_id=new_source.id
92
+ self.snapshot_id = new_source.id
95
93
  end
96
94
 
97
95
  def image=(new_image)
98
96
  self.image_id = new_image.id
99
97
  end
100
-
101
98
  end
102
99
  end
103
100
  end
104
101
  end
105
-
@@ -5,7 +5,6 @@ module Fog
5
5
  module Compute
6
6
  class Aliyun
7
7
  class Volumes < Fog::Collection
8
-
9
8
  model Fog::Compute::Aliyun::Volume
10
9
 
11
10
  # 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:
@@ -13,7 +12,7 @@ module Fog
13
12
  #
14
13
  # ==== Returns
15
14
  #
16
- #<Fog::AWS::Compute::Volume
15
+ # <Fog::AWS::Compute::Volume
17
16
  # id="vol-1e2028b9",
18
17
  # attached_at=nil,
19
18
  # availability_zone="us-east-1a",
@@ -25,18 +24,17 @@ module Fog
25
24
  # snapshot_id=nil,
26
25
  # state="creating",
27
26
  # tags=nil
28
- #>
27
+ # >
29
28
  #
30
29
  # The volume can be retrieved by running Aliyun.volumes.get("d-25ohde62o"). See get method below.
31
30
  #
32
31
 
33
-
34
32
  # Used to return all volumes.
35
33
  # Aliyun.volumes.all
36
34
  #
37
35
  # ==== Returns
38
36
  #
39
- #>>Aliyun.volumes.all
37
+ # >>Aliyun.volumes.all
40
38
  # <Fog::Compute::Aliyun::Volumes
41
39
  # [
42
40
  # <Fog::Compute::Aliyun::Volume
@@ -76,7 +74,7 @@ module Fog
76
74
  def all(filters_arg = {})
77
75
  unless filters_arg.is_a?(Hash)
78
76
  Fog::Logger.deprecation("all with #{filters_arg.class} param is deprecated, use all('diskIds' => []) instead [light_black](#{caller.first})[/]")
79
- filters_arg = {'diskIds' => [*filters_arg]}
77
+ filters_arg = { 'diskIds' => [*filters_arg] }
80
78
  end
81
79
  data = Fog::JSON.decode(service.list_disks(filters_arg).body)['Disks']['Disk']
82
80
  load(data)
@@ -95,7 +93,7 @@ module Fog
95
93
  #
96
94
  # ==== Returns
97
95
  #
98
- #>> Aliyun.volumes.get('d-25ohde62o')
96
+ # >> Aliyun.volumes.get('d-25ohde62o')
99
97
  # <Fog::Compute::Aliyun::Volume
100
98
  # id="d-25ohde62o",
101
99
  # region_id="cn-beijing",
@@ -127,13 +125,11 @@ module Fog
127
125
 
128
126
  def get(volume_id)
129
127
  if volume_id
130
- diskIds=Array.new(1,volume_id)
131
- self.class.new(:service => service).all(:diskIds => diskIds)[0]
128
+ diskIds = Array.new(1, volume_id)
129
+ self.class.new(service: service).all(diskIds: diskIds)[0]
132
130
  end
133
131
  end
134
-
135
132
  end
136
133
  end
137
134
  end
138
135
  end
139
-