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
@@ -3,63 +3,55 @@ module Fog
|
|
3
3
|
class Aliyun
|
4
4
|
class Real
|
5
5
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&authorizesecuritygroup]
|
6
|
-
def delete_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option={})
|
6
|
+
def delete_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option = {})
|
7
7
|
action = 'RevokeSecurityGroupEgress'
|
8
|
-
sigNonce = randonStr
|
8
|
+
sigNonce = randonStr
|
9
9
|
time = Time.new.utc
|
10
10
|
|
11
11
|
parameters = defalutParameters(action, sigNonce, time)
|
12
12
|
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
-
|
14
|
-
parameters[
|
13
|
+
|
14
|
+
parameters['SecurityGroupId'] = securitygroup_id
|
15
15
|
pathUrl += '&SecurityGroupId='
|
16
16
|
pathUrl += securitygroup_id
|
17
17
|
|
18
|
-
parameters[
|
18
|
+
parameters['DestGroupId'] = dest_group_id
|
19
19
|
pathUrl += '&DestGroupId='
|
20
20
|
pathUrl += dest_group_id
|
21
21
|
|
22
22
|
nicType = 'intranet'
|
23
|
-
parameters[
|
23
|
+
parameters['NicType'] = nicType
|
24
24
|
pathUrl += '&NicType='
|
25
25
|
pathUrl += nicType
|
26
|
-
|
26
|
+
|
27
27
|
portRange = option[:portRange]
|
28
|
-
unless portRange
|
29
|
-
|
30
|
-
end
|
31
|
-
parameters["PortRange"] = portRange
|
28
|
+
portRange = '-1/-1' unless portRange
|
29
|
+
parameters['PortRange'] = portRange
|
32
30
|
pathUrl += '&PortRange='
|
33
|
-
pathUrl += URI.encode(portRange,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
34
|
-
|
31
|
+
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
32
|
+
|
35
33
|
protocol = option[:protocol]
|
36
|
-
unless protocol
|
37
|
-
|
38
|
-
end
|
39
|
-
parameters["IpProtocol"] = protocol
|
34
|
+
protocol = 'all' unless protocol
|
35
|
+
parameters['IpProtocol'] = protocol
|
40
36
|
pathUrl += '&IpProtocol='
|
41
37
|
pathUrl += protocol
|
42
38
|
|
43
39
|
destGOAccount = option[:destGroupOwnerAccount]
|
44
40
|
if sourceGOAccount
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
parameters['DestGroupOwnerAccount'] = destGOAccount
|
42
|
+
pathUrl += '&DestGroupOwnerAccount='
|
43
|
+
pathUrl += destGOAccount
|
48
44
|
end
|
49
45
|
|
50
46
|
policy = option[:policy]
|
51
|
-
unless policy
|
52
|
-
|
53
|
-
end
|
54
|
-
parameters["Policy"] = policy
|
47
|
+
policy = 'accept' unless policy
|
48
|
+
parameters['Policy'] = policy
|
55
49
|
pathUrl += '&Policy='
|
56
50
|
pathUrl += policy
|
57
51
|
|
58
52
|
priority = option[:priority]
|
59
|
-
unless priority
|
60
|
-
|
61
|
-
end
|
62
|
-
parameters["Priority"] = priority
|
53
|
+
priority = '1' unless priority
|
54
|
+
parameters['Priority'] = priority
|
63
55
|
pathUrl += '&Priority='
|
64
56
|
pathUrl += priority
|
65
57
|
|
@@ -68,42 +60,12 @@ module Fog
|
|
68
60
|
pathUrl += signature
|
69
61
|
|
70
62
|
request(
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
63
|
+
expects: [200, 203],
|
64
|
+
method: 'GET',
|
65
|
+
path: pathUrl
|
74
66
|
)
|
75
67
|
end
|
76
68
|
end
|
77
|
-
|
78
|
-
class Mock
|
79
|
-
def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)
|
80
|
-
parent_group_id = parent_group_id.to_i
|
81
|
-
response = Excon::Response.new
|
82
|
-
response.status = 200
|
83
|
-
response.headers = {
|
84
|
-
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
|
85
|
-
'Content-Type' => 'application/json',
|
86
|
-
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
87
|
-
'Date' => Date.new
|
88
|
-
}
|
89
|
-
rule = {
|
90
|
-
'id' => Fog::Mock.random_numbers(2).to_i,
|
91
|
-
'from_port' => from_port,
|
92
|
-
'group' => group_id || {},
|
93
|
-
'ip_protocol' => ip_protocol,
|
94
|
-
'to_port' => to_port,
|
95
|
-
'parent_group_id' => parent_group_id,
|
96
|
-
'ip_range' => {
|
97
|
-
'cidr' => cidr
|
98
|
-
}
|
99
|
-
}
|
100
|
-
self.data[:security_groups][parent_group_id.to_s]['rules'].push(rule)
|
101
|
-
response.body = {
|
102
|
-
'security_group_rule' => rule
|
103
|
-
}
|
104
|
-
response
|
105
|
-
end
|
106
|
-
end # mock
|
107
69
|
end # aliyun
|
108
70
|
end # compute
|
109
71
|
end # fog
|
@@ -2,58 +2,48 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Aliyun
|
4
4
|
class Real
|
5
|
-
def delete_security_group_ip_rule(securitygroup_id,sourceCidrIp, nicType, option={})
|
5
|
+
def delete_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, option = {})
|
6
6
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&revokesecuritygroup]
|
7
7
|
action = 'RevokeSecurityGroup'
|
8
|
-
sigNonce = randonStr
|
8
|
+
sigNonce = randonStr
|
9
9
|
time = Time.new.utc
|
10
10
|
|
11
11
|
parameters = defalutParameters(action, sigNonce, time)
|
12
12
|
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
-
|
14
|
-
parameters[
|
13
|
+
|
14
|
+
parameters['SecurityGroupId'] = securitygroup_id
|
15
15
|
pathUrl += '&SecurityGroupId='
|
16
16
|
pathUrl += securitygroup_id
|
17
17
|
|
18
|
-
parameters[
|
18
|
+
parameters['SourceCidrIp'] = sourceCidrIp
|
19
19
|
pathUrl += '&SourceCidrIp='
|
20
|
-
pathUrl += URI.encode(sourceCidrIp,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
21
|
-
unless nicType
|
22
|
-
|
23
|
-
end
|
24
|
-
parameters["NicType"] = nicType
|
20
|
+
pathUrl += URI.encode(sourceCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
21
|
+
nicType = 'intranet' unless nicType
|
22
|
+
parameters['NicType'] = nicType
|
25
23
|
pathUrl += '&NicType='
|
26
24
|
pathUrl += nicType
|
27
|
-
|
25
|
+
|
28
26
|
portRange = option[:portRange]
|
29
|
-
unless portRange
|
30
|
-
|
31
|
-
end
|
32
|
-
parameters["PortRange"] = portRange
|
27
|
+
portRange = '-1/-1' unless portRange
|
28
|
+
parameters['PortRange'] = portRange
|
33
29
|
pathUrl += '&PortRange='
|
34
|
-
pathUrl += URI.encode(portRange,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
35
|
-
|
30
|
+
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
31
|
+
|
36
32
|
protocol = option[:protocol]
|
37
|
-
unless protocol
|
38
|
-
|
39
|
-
end
|
40
|
-
parameters["IpProtocol"] = protocol
|
33
|
+
protocol = 'all' unless protocol
|
34
|
+
parameters['IpProtocol'] = protocol
|
41
35
|
pathUrl += '&IpProtocol='
|
42
36
|
pathUrl += protocol
|
43
37
|
|
44
38
|
policy = option[:policy]
|
45
|
-
unless policy
|
46
|
-
|
47
|
-
end
|
48
|
-
parameters["Policy"] = policy
|
39
|
+
policy = 'accept' unless policy
|
40
|
+
parameters['Policy'] = policy
|
49
41
|
pathUrl += '&Policy='
|
50
42
|
pathUrl += policy
|
51
43
|
|
52
44
|
priority = option[:priority]
|
53
|
-
unless priority
|
54
|
-
|
55
|
-
end
|
56
|
-
parameters["Priority"] = priority
|
45
|
+
priority = '1' unless priority
|
46
|
+
parameters['Priority'] = priority
|
57
47
|
pathUrl += '&Priority='
|
58
48
|
pathUrl += priority
|
59
49
|
|
@@ -62,42 +52,12 @@ module Fog
|
|
62
52
|
pathUrl += signature
|
63
53
|
|
64
54
|
request(
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
55
|
+
expects: [200, 203],
|
56
|
+
method: 'GET',
|
57
|
+
path: pathUrl
|
68
58
|
)
|
69
59
|
end
|
70
60
|
end
|
71
|
-
|
72
|
-
class Mock
|
73
|
-
def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)
|
74
|
-
parent_group_id = parent_group_id.to_i
|
75
|
-
response = Excon::Response.new
|
76
|
-
response.status = 200
|
77
|
-
response.headers = {
|
78
|
-
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
|
79
|
-
'Content-Type' => 'application/json',
|
80
|
-
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
81
|
-
'Date' => Date.new
|
82
|
-
}
|
83
|
-
rule = {
|
84
|
-
'id' => Fog::Mock.random_numbers(2).to_i,
|
85
|
-
'from_port' => from_port,
|
86
|
-
'group' => group_id || {},
|
87
|
-
'ip_protocol' => ip_protocol,
|
88
|
-
'to_port' => to_port,
|
89
|
-
'parent_group_id' => parent_group_id,
|
90
|
-
'ip_range' => {
|
91
|
-
'cidr' => cidr
|
92
|
-
}
|
93
|
-
}
|
94
|
-
self.data[:security_groups][parent_group_id.to_s]['rules'].push(rule)
|
95
|
-
response.body = {
|
96
|
-
'security_group_rule' => rule
|
97
|
-
}
|
98
|
-
response
|
99
|
-
end
|
100
|
-
end # mock
|
101
61
|
end # aliyun
|
102
62
|
end # compute
|
103
63
|
end # fog
|
@@ -2,64 +2,56 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Aliyun
|
4
4
|
class Real
|
5
|
-
def delete_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option={})
|
5
|
+
def delete_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option = {})
|
6
6
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&revokesecuritygroup]
|
7
7
|
action = 'RevokeSecurityGroup'
|
8
|
-
sigNonce = randonStr
|
8
|
+
sigNonce = randonStr
|
9
9
|
time = Time.new.utc
|
10
10
|
|
11
11
|
parameters = defalutParameters(action, sigNonce, time)
|
12
12
|
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
-
|
14
|
-
parameters[
|
13
|
+
|
14
|
+
parameters['SecurityGroupId'] = securitygroup_id
|
15
15
|
pathUrl += '&SecurityGroupId='
|
16
16
|
pathUrl += securitygroup_id
|
17
17
|
|
18
|
-
parameters[
|
18
|
+
parameters['SourceGroupId'] = source_securitygroup_id
|
19
19
|
pathUrl += '&SourceGroupId='
|
20
20
|
pathUrl += source_securitygroup_id
|
21
21
|
|
22
22
|
nicType = 'intranet'
|
23
|
-
parameters[
|
23
|
+
parameters['NicType'] = nicType
|
24
24
|
pathUrl += '&NicType='
|
25
25
|
pathUrl += nicType
|
26
|
-
|
26
|
+
|
27
27
|
portRange = option[:portRange]
|
28
|
-
unless portRange
|
29
|
-
|
30
|
-
end
|
31
|
-
parameters["PortRange"] = portRange
|
28
|
+
portRange = '-1/-1' unless portRange
|
29
|
+
parameters['PortRange'] = portRange
|
32
30
|
pathUrl += '&PortRange='
|
33
|
-
pathUrl += URI.encode(portRange,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
34
|
-
|
31
|
+
pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
32
|
+
|
35
33
|
protocol = option[:protocol]
|
36
|
-
unless protocol
|
37
|
-
|
38
|
-
end
|
39
|
-
parameters["IpProtocol"] = protocol
|
34
|
+
protocol = 'all' unless protocol
|
35
|
+
parameters['IpProtocol'] = protocol
|
40
36
|
pathUrl += '&IpProtocol='
|
41
37
|
pathUrl += protocol
|
42
38
|
|
43
39
|
sourceGOAccount = option[:sourceGroupOwnerAccount]
|
44
40
|
if sourceGOAccount
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
parameters['SourceGroupOwnerAccount'] = sourceGOAccount
|
42
|
+
pathUrl += '&SourceGroupOwnerAccount='
|
43
|
+
pathUrl += sourceGOAccount
|
48
44
|
end
|
49
45
|
|
50
46
|
policy = option[:policy]
|
51
|
-
unless policy
|
52
|
-
|
53
|
-
end
|
54
|
-
parameters["Policy"] = policy
|
47
|
+
policy = 'accept' unless policy
|
48
|
+
parameters['Policy'] = policy
|
55
49
|
pathUrl += '&Policy='
|
56
50
|
pathUrl += policy
|
57
51
|
|
58
52
|
priority = option[:priority]
|
59
|
-
unless priority
|
60
|
-
|
61
|
-
end
|
62
|
-
parameters["Priority"] = priority
|
53
|
+
priority = '1' unless priority
|
54
|
+
parameters['Priority'] = priority
|
63
55
|
pathUrl += '&Priority='
|
64
56
|
pathUrl += priority
|
65
57
|
|
@@ -68,42 +60,12 @@ module Fog
|
|
68
60
|
pathUrl += signature
|
69
61
|
|
70
62
|
request(
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
63
|
+
expects: [200, 203],
|
64
|
+
method: 'GET',
|
65
|
+
path: pathUrl
|
74
66
|
)
|
75
67
|
end
|
76
68
|
end
|
77
|
-
|
78
|
-
class Mock
|
79
|
-
def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)
|
80
|
-
parent_group_id = parent_group_id.to_i
|
81
|
-
response = Excon::Response.new
|
82
|
-
response.status = 200
|
83
|
-
response.headers = {
|
84
|
-
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
|
85
|
-
'Content-Type' => 'application/json',
|
86
|
-
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
87
|
-
'Date' => Date.new
|
88
|
-
}
|
89
|
-
rule = {
|
90
|
-
'id' => Fog::Mock.random_numbers(2).to_i,
|
91
|
-
'from_port' => from_port,
|
92
|
-
'group' => group_id || {},
|
93
|
-
'ip_protocol' => ip_protocol,
|
94
|
-
'to_port' => to_port,
|
95
|
-
'parent_group_id' => parent_group_id,
|
96
|
-
'ip_range' => {
|
97
|
-
'cidr' => cidr
|
98
|
-
}
|
99
|
-
}
|
100
|
-
self.data[:security_groups][parent_group_id.to_s]['rules'].push(rule)
|
101
|
-
response.body = {
|
102
|
-
'security_group_rule' => rule
|
103
|
-
}
|
104
|
-
response
|
105
|
-
end
|
106
|
-
end # mock
|
107
69
|
end # aliyun
|
108
70
|
end # compute
|
109
71
|
end # fog
|
@@ -5,22 +5,22 @@ module Fog
|
|
5
5
|
def delete_server(server_id)
|
6
6
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&deleteinstance]
|
7
7
|
_action = 'DeleteInstance'
|
8
|
-
_sigNonce = randonStr
|
8
|
+
_sigNonce = randonStr
|
9
9
|
_time = Time.new.utc
|
10
10
|
|
11
11
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
12
|
-
_pathURL
|
13
|
-
|
14
|
-
_parameters['InstanceId']=server_id
|
15
|
-
|
16
|
-
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
14
|
+
_parameters['InstanceId'] = server_id
|
15
|
+
_pathURL += '&InstanceId=' + server_id
|
16
|
+
|
17
17
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
18
|
-
_pathURL += '&Signature='+_signature
|
19
|
-
|
18
|
+
_pathURL += '&Signature=' + _signature
|
19
|
+
|
20
20
|
request(
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
21
|
+
expects: [200, 204],
|
22
|
+
method: 'GET',
|
23
|
+
path: _pathURL
|
24
24
|
)
|
25
25
|
end
|
26
26
|
end
|
@@ -28,13 +28,13 @@ module Fog
|
|
28
28
|
class Mock
|
29
29
|
def delete_server(server_id)
|
30
30
|
response = Excon::Response.new
|
31
|
-
if server = list_servers_detail.body['servers'].find {|_| _['id'] == server_id}
|
31
|
+
if server = list_servers_detail.body['servers'].find { |_| _['id'] == server_id }
|
32
32
|
if server['status'] == 'BUILD'
|
33
33
|
response.status = 409
|
34
|
-
raise(Excon::Errors.status_error({:
|
34
|
+
raise(Excon::Errors.status_error({ expects: 204 }, response))
|
35
35
|
else
|
36
|
-
|
37
|
-
|
36
|
+
data[:last_modified][:servers].delete(server_id)
|
37
|
+
data[:servers].delete(server_id)
|
38
38
|
response.status = 204
|
39
39
|
end
|
40
40
|
response
|
@@ -5,13 +5,13 @@ module Fog
|
|
5
5
|
def delete_snapshot(snapshotId)
|
6
6
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/snapshot&deletesnapshot]
|
7
7
|
action = 'DeleteSnapshot'
|
8
|
-
sigNonce = randonStr
|
8
|
+
sigNonce = randonStr
|
9
9
|
time = Time.new.utc
|
10
10
|
|
11
11
|
parameters = defalutParameters(action, sigNonce, time)
|
12
12
|
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
-
|
14
|
-
parameters[
|
13
|
+
|
14
|
+
parameters['SnapshotId'] = snapshotId
|
15
15
|
pathUrl += '&SnapshotId='
|
16
16
|
pathUrl += snapshotId
|
17
17
|
|
@@ -20,26 +20,12 @@ module Fog
|
|
20
20
|
pathUrl += signature
|
21
21
|
|
22
22
|
request(
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
23
|
+
expects: [200, 203],
|
24
|
+
method: 'GET',
|
25
|
+
path: pathUrl
|
26
26
|
)
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
class Mock
|
31
|
-
def list_images
|
32
|
-
response = Excon::Response.new
|
33
|
-
data = list_images_detail.body['images']
|
34
|
-
images = []
|
35
|
-
for image in data
|
36
|
-
images << image.reject { |key, value| !['id', 'name', 'links'].include?(key) }
|
37
|
-
end
|
38
|
-
response.status = [200, 203][rand(1)]
|
39
|
-
response.body = { 'images' => images }
|
40
|
-
response
|
41
|
-
end
|
42
|
-
end
|
43
29
|
end
|
44
30
|
end
|
45
31
|
end
|