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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +149 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Rakefile +3 -3
- data/fog-aliyun.gemspec +16 -13
- data/lib/fog/aliyun.rb +8 -8
- data/lib/fog/aliyun/compute.rb +99 -113
- data/lib/fog/aliyun/models/compute/eip_address.rb +23 -29
- data/lib/fog/aliyun/models/compute/eip_addresses.rb +3 -5
- data/lib/fog/aliyun/models/compute/image.rb +26 -28
- data/lib/fog/aliyun/models/compute/images.rb +2 -6
- data/lib/fog/aliyun/models/compute/route_entry.rb +9 -11
- data/lib/fog/aliyun/models/compute/route_entrys.rb +7 -7
- data/lib/fog/aliyun/models/compute/route_table.rb +10 -11
- data/lib/fog/aliyun/models/compute/route_tables.rb +2 -2
- data/lib/fog/aliyun/models/compute/security_group.rb +24 -24
- data/lib/fog/aliyun/models/compute/security_group_rule.rb +20 -20
- data/lib/fog/aliyun/models/compute/security_group_rules.rb +4 -4
- data/lib/fog/aliyun/models/compute/security_groups.rb +6 -7
- data/lib/fog/aliyun/models/compute/server.rb +42 -43
- data/lib/fog/aliyun/models/compute/servers.rb +9 -11
- data/lib/fog/aliyun/models/compute/snapshot.rb +15 -15
- data/lib/fog/aliyun/models/compute/snapshots.rb +6 -10
- data/lib/fog/aliyun/models/compute/volume.rb +36 -40
- data/lib/fog/aliyun/models/compute/volumes.rb +7 -11
- data/lib/fog/aliyun/models/compute/vpc.rb +18 -19
- data/lib/fog/aliyun/models/compute/vpcs.rb +5 -6
- data/lib/fog/aliyun/models/compute/vrouter.rb +13 -13
- data/lib/fog/aliyun/models/compute/vrouters.rb +4 -5
- data/lib/fog/aliyun/models/compute/vswitch.rb +18 -20
- data/lib/fog/aliyun/models/compute/vswitches.rb +6 -6
- data/lib/fog/aliyun/models/storage/directories.rb +10 -16
- data/lib/fog/aliyun/models/storage/directory.rb +8 -8
- data/lib/fog/aliyun/models/storage/file.rb +58 -64
- data/lib/fog/aliyun/models/storage/files.rb +95 -115
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +18 -44
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +12 -36
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +16 -40
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +19 -22
- data/lib/fog/aliyun/requests/compute/create_disk.rb +33 -63
- data/lib/fog/aliyun/requests/compute/create_image.rb +21 -21
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +16 -16
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/create_server.rb +76 -78
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +12 -26
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +11 -38
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +13 -40
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +8 -35
- data/lib/fog/aliyun/requests/compute/delete_image.rb +6 -33
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -62
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/delete_server.rb +15 -15
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +6 -20
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +9 -26
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +9 -25
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +11 -27
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +15 -16
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +15 -16
- data/lib/fog/aliyun/requests/compute/list_disks.rb +24 -43
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +26 -52
- data/lib/fog/aliyun/requests/compute/list_images.rb +21 -24
- data/lib/fog/aliyun/requests/compute/list_route_tables.rb +16 -19
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +22 -23
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +21 -24
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +50 -50
- data/lib/fog/aliyun/requests/compute/list_servers.rb +25 -28
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +20 -37
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +12 -29
- data/lib/fog/aliyun/requests/compute/list_vrouters.rb +13 -16
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +14 -31
- data/lib/fog/aliyun/requests/compute/list_zones.rb +16 -16
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +17 -17
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +11 -39
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +15 -16
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +12 -36
- data/lib/fog/aliyun/requests/compute/start_server.rb +14 -15
- data/lib/fog/aliyun/requests/compute/stop_server.rb +13 -14
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +16 -41
- data/lib/fog/aliyun/requests/storage/copy_object.rb +11 -14
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -30
- data/lib/fog/aliyun/requests/storage/delete_container.rb +11 -14
- data/lib/fog/aliyun/requests/storage/delete_object.rb +20 -22
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -148
- data/lib/fog/aliyun/requests/storage/get_container.rb +26 -38
- data/lib/fog/aliyun/requests/storage/get_containers.rb +20 -32
- data/lib/fog/aliyun/requests/storage/get_object.rb +12 -12
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +11 -11
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +11 -11
- data/lib/fog/aliyun/requests/storage/head_object.rb +11 -11
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -47
- data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -104
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -23
- data/lib/fog/aliyun/requests/storage/put_container.rb +12 -12
- data/lib/fog/aliyun/requests/storage/put_object.rb +100 -110
- data/lib/fog/aliyun/storage.rb +209 -214
- data/lib/fog/aliyun/version.rb +1 -1
- data/lib/fog/bin/aliyun.rb +5 -5
- 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[
|
14
|
-
permissions = data[
|
13
|
+
self.security_group_id = data['SecurityGroupId']
|
14
|
+
permissions = data['Permissions']['Permission']
|
15
15
|
permissions.each do |permission|
|
16
|
-
permission[
|
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
|
19
|
-
result=nil
|
18
|
+
data = self.class.new(service: service).all
|
19
|
+
result = nil
|
20
20
|
data.each do |i|
|
21
|
-
if
|
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, :
|
8
|
-
attribute :image_id, :
|
9
|
-
attribute :inner_ip, :
|
10
|
-
attribute :vlan_id, :
|
11
|
-
attribute :eip, :
|
12
|
-
attribute :max_bandwidth_in, :
|
13
|
-
attribute :zone_id, :
|
14
|
-
attribute :internet_charge_type, :
|
15
|
-
attribute :serial_number, :
|
16
|
-
attribute :io_optimized, :
|
17
|
-
attribute :max_bandwidth_out, :
|
18
|
-
attribute :vpc_attributes, :
|
19
|
-
attribute :device_available, :
|
20
|
-
attribute :private_ip, :
|
21
|
-
attribute :security_group_ids
|
22
|
-
attribute :name, :
|
23
|
-
attribute :description, :
|
24
|
-
attribute :network_type, :
|
25
|
-
attribute :public_ip, :
|
26
|
-
attribute :host_name, :
|
27
|
-
attribute :type, :
|
28
|
-
attribute :created_at, :
|
29
|
-
attribute :state, :
|
30
|
-
attribute :cluster_id, :
|
31
|
-
attribute :region_id, :
|
32
|
-
attribute :charge_type, :
|
33
|
-
attribute :operation_locks, :
|
34
|
-
attribute :expired_at, :
|
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
|
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
|
43
|
+
$vpc = Fog::Compute::Aliyun::Vpcs.new(service: service).all('vpcId' => vpc_id)[0]
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
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
|
37
|
-
self.class.new(:service
|
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, :
|
7
|
-
attribute :name, :
|
8
|
-
attribute :description, :
|
9
|
-
attribute :progress, :
|
10
|
-
attribute :volume_id, :
|
11
|
-
attribute :volume_size, :
|
12
|
-
attribute :volume_type, :
|
13
|
-
attribute :product_code
|
14
|
-
attribute :created_at, :
|
15
|
-
attribute :state, :
|
16
|
-
attribute :usage, :
|
17
|
-
attribute :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
|
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
|
-
|
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
|
-
|
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(:
|
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, :
|
21
|
-
attribute :region_id, :
|
22
|
-
attribute :zone_id, :
|
23
|
-
attribute :name, :
|
24
|
-
attribute :description, :
|
25
|
-
attribute :type, :
|
26
|
-
attribute :category, :
|
27
|
-
attribute :size, :
|
28
|
-
attribute :image_id, :
|
29
|
-
attribute :snapshot_id, :
|
30
|
-
attribute :product_code, :
|
31
|
-
attribute :portable, :
|
32
|
-
attribute :state, :
|
33
|
-
attribute :operation_locks, :
|
34
|
-
attribute :server_id, :
|
35
|
-
attribute :device, :
|
36
|
-
attribute :delete_with_instance, :
|
37
|
-
attribute :delete_auto_snapshot, :
|
38
|
-
attribute :enable_auto_snapshot, :
|
39
|
-
attribute :created_at, :
|
40
|
-
attribute :attached_at, :
|
41
|
-
attribute :detached_at, :
|
42
|
-
attribute :expired_at, :
|
43
|
-
attribute :charge_type, :
|
44
|
-
attribute :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
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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(:
|
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
|
-
|