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,31 +3,30 @@ 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/vpc&modifyvpcattribute]
|
6
|
-
def modify_vpc(vpcId,options={})
|
7
|
-
|
6
|
+
def modify_vpc(vpcId, options = {})
|
8
7
|
action = 'ModifyVpcAttribute'
|
9
|
-
sigNonce = randonStr
|
8
|
+
sigNonce = randonStr
|
10
9
|
time = Time.new.utc
|
11
10
|
|
12
11
|
parameters = defalutParameters(action, sigNonce, time)
|
13
12
|
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
14
13
|
|
15
|
-
parameters[
|
14
|
+
parameters['VpcId'] = vpcId
|
16
15
|
pathUrl += '&VpcId='
|
17
|
-
pathUrl += URI.encode(vpcId,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
16
|
+
pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
18
17
|
name = options[:name]
|
19
18
|
desc = options[:description]
|
20
19
|
|
21
20
|
if name
|
22
|
-
parameters[
|
21
|
+
parameters['VpcName'] = name
|
23
22
|
pathUrl += '&VpcName='
|
24
|
-
pathUrl += name
|
23
|
+
pathUrl += name
|
25
24
|
end
|
26
25
|
|
27
26
|
if desc
|
28
|
-
parameters[
|
27
|
+
parameters['Description'] = desc
|
29
28
|
pathUrl += '&Description='
|
30
|
-
pathUrl += desc
|
29
|
+
pathUrl += desc
|
31
30
|
end
|
32
31
|
|
33
32
|
signature = sign(@aliyun_accesskey_secret, parameters)
|
@@ -35,19 +34,19 @@ module Fog
|
|
35
34
|
pathUrl += signature
|
36
35
|
|
37
36
|
request(
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
37
|
+
expects: [200, 203],
|
38
|
+
method: 'GET',
|
39
|
+
path: pathUrl
|
41
40
|
)
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
class Mock
|
46
|
-
def modify_vpc(
|
47
|
-
Fog::Identity::OpenStack.new(:
|
45
|
+
def modify_vpc(_vpcId, _options = {})
|
46
|
+
Fog::Identity::OpenStack.new(openstack_auth_url: credentials[:openstack_auth_url])
|
48
47
|
tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
|
49
48
|
security_group_id = Fog::Mock.random_numbers(2).to_i + 1
|
50
|
-
|
49
|
+
data[:security_groups][security_group_id.to_s] = {
|
51
50
|
'tenant_id' => tenant_id,
|
52
51
|
'rules' => [],
|
53
52
|
'id' => security_group_id,
|
@@ -61,9 +60,10 @@ module Fog
|
|
61
60
|
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
|
62
61
|
'Content-Type' => 'application/json',
|
63
62
|
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
64
|
-
'Date' => Date.new
|
63
|
+
'Date' => Date.new
|
64
|
+
}
|
65
65
|
response.body = {
|
66
|
-
'security_group' =>
|
66
|
+
'security_group' => data[:security_groups][security_group_id.to_s]
|
67
67
|
}
|
68
68
|
response
|
69
69
|
end
|
@@ -3,31 +3,30 @@ 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/vswitch&modifyvswitchattribute]
|
6
|
-
def
|
7
|
-
|
6
|
+
def modify_switch(vSwitchId, options = {})
|
8
7
|
action = 'ModifyVSwitchAttribute'
|
9
|
-
sigNonce = randonStr
|
8
|
+
sigNonce = randonStr
|
10
9
|
time = Time.new.utc
|
11
10
|
|
12
11
|
parameters = defalutParameters(action, sigNonce, time)
|
13
12
|
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
14
13
|
|
15
|
-
parameters[
|
14
|
+
parameters['VSwitchId'] = vSwitchId
|
16
15
|
pathUrl += '&VSwitchId='
|
17
|
-
pathUrl += URI.encode(vpcId,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
16
|
+
pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
18
17
|
name = options[:name]
|
19
18
|
desc = options[:description]
|
20
19
|
|
21
20
|
if name
|
22
|
-
parameters[
|
21
|
+
parameters['VSwitchName'] = name
|
23
22
|
pathUrl += '&VSwitchName='
|
24
|
-
pathUrl += name
|
23
|
+
pathUrl += name
|
25
24
|
end
|
26
25
|
|
27
26
|
if desc
|
28
|
-
parameters[
|
27
|
+
parameters['Description'] = desc
|
29
28
|
pathUrl += '&Description='
|
30
|
-
pathUrl += desc
|
29
|
+
pathUrl += desc
|
31
30
|
end
|
32
31
|
|
33
32
|
signature = sign(@aliyun_accesskey_secret, parameters)
|
@@ -35,39 +34,12 @@ module Fog
|
|
35
34
|
pathUrl += signature
|
36
35
|
|
37
36
|
request(
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
37
|
+
expects: [200, 203],
|
38
|
+
method: 'GET',
|
39
|
+
path: pathUrl
|
41
40
|
)
|
42
41
|
end
|
43
42
|
end
|
44
|
-
|
45
|
-
class Mock
|
46
|
-
def modify_vpc(vpcId, options={})
|
47
|
-
Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
|
48
|
-
tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
|
49
|
-
security_group_id = Fog::Mock.random_numbers(2).to_i + 1
|
50
|
-
self.data[:security_groups][security_group_id.to_s] = {
|
51
|
-
'tenant_id' => tenant_id,
|
52
|
-
'rules' => [],
|
53
|
-
'id' => security_group_id,
|
54
|
-
'name' => name,
|
55
|
-
'description' => description
|
56
|
-
}
|
57
|
-
|
58
|
-
response = Excon::Response.new
|
59
|
-
response.status = 200
|
60
|
-
response.headers = {
|
61
|
-
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
|
62
|
-
'Content-Type' => 'application/json',
|
63
|
-
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
64
|
-
'Date' => Date.new}
|
65
|
-
response.body = {
|
66
|
-
'security_group' => self.data[:security_groups][security_group_id.to_s]
|
67
|
-
}
|
68
|
-
response
|
69
|
-
end
|
70
|
-
end # mock
|
71
43
|
end # aliyun
|
72
44
|
end # compute
|
73
45
|
end # fog
|
@@ -4,36 +4,35 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&rebootinstance]
|
6
6
|
def reboot_server(server_id, options = {})
|
7
|
-
|
8
7
|
_action = 'RebootInstance'
|
9
|
-
_sigNonce = randonStr
|
8
|
+
_sigNonce = randonStr
|
10
9
|
_time = Time.new.utc
|
11
10
|
|
12
11
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
13
|
-
_pathURL
|
14
|
-
|
15
|
-
_parameters['InstanceId']=server_id
|
16
|
-
_pathURL += '&InstanceId='+server_id
|
17
|
-
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
14
|
+
_parameters['InstanceId'] = server_id
|
15
|
+
_pathURL += '&InstanceId=' + server_id
|
16
|
+
|
18
17
|
_ForceStop = options[:aliyun_ForceStop]
|
19
18
|
if _ForceStop
|
20
|
-
_parameters['ForceStop']=_ForceStop
|
21
|
-
_pathURL += '&ForceStop='+_ForceStop
|
19
|
+
_parameters['ForceStop'] = _ForceStop
|
20
|
+
_pathURL += '&ForceStop=' + _ForceStop
|
22
21
|
end
|
23
|
-
|
22
|
+
|
24
23
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
25
|
-
_pathURL += '&Signature='+_signature
|
26
|
-
|
24
|
+
_pathURL += '&Signature=' + _signature
|
25
|
+
|
27
26
|
request(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
27
|
+
expects: [200, 204],
|
28
|
+
method: 'GET',
|
29
|
+
path: _pathURL
|
31
30
|
)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
class Mock
|
36
|
-
def reboot_server(
|
35
|
+
def reboot_server(_server_id, _type = 'SOFT')
|
37
36
|
response = Excon::Response.new
|
38
37
|
response.status = 202
|
39
38
|
response
|
@@ -2,52 +2,28 @@ module Fog
|
|
2
2
|
module Compute
|
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/network&releaseeipaddress]
|
6
6
|
def release_eip_address(allocationId)
|
7
|
-
|
8
7
|
_action = 'ReleaseEipAddress'
|
9
|
-
_sigNonce = randonStr
|
8
|
+
_sigNonce = randonStr
|
10
9
|
_time = Time.new.utc
|
11
10
|
|
12
11
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
13
|
-
_pathURL
|
14
|
-
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
15
14
|
_parameters['AllocationId'] = allocationId
|
16
|
-
_pathURL += '&AllocationId='+allocationId
|
17
|
-
|
15
|
+
_pathURL += '&AllocationId=' + allocationId
|
16
|
+
|
18
17
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
19
|
-
_pathURL += '&Signature='+_signature
|
20
|
-
|
18
|
+
_pathURL += '&Signature=' + _signature
|
19
|
+
|
21
20
|
request(
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
21
|
+
expects: [200, 204],
|
22
|
+
method: 'GET',
|
23
|
+
path: _pathURL
|
25
24
|
)
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
29
|
-
class Mock
|
30
|
-
def allocate_address(pool = nil)
|
31
|
-
response = Excon::Response.new
|
32
|
-
response.status = 200
|
33
|
-
response.headers = {
|
34
|
-
"X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
|
35
|
-
"Content-Type" => "application/json",
|
36
|
-
"Content-Length" => "105",
|
37
|
-
"Date"=> Date.new
|
38
|
-
}
|
39
|
-
response.body = {
|
40
|
-
"floating_ip" => {
|
41
|
-
"instance_id" => nil,
|
42
|
-
"ip" => "192.168.27.132",
|
43
|
-
"fixed_ip" => nil,
|
44
|
-
"id" => 4,
|
45
|
-
"pool"=>"nova"
|
46
|
-
}
|
47
|
-
}
|
48
|
-
response
|
49
|
-
end
|
50
|
-
end # mock
|
51
27
|
end # aliyun
|
52
|
-
end #compute
|
28
|
+
end # compute
|
53
29
|
end
|
@@ -8,35 +8,34 @@ module Fog
|
|
8
8
|
# * server_id <~String> - The ID of the server to be started.
|
9
9
|
# === Returns
|
10
10
|
# * success <~Boolean>
|
11
|
-
|
11
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&staetinstance]
|
12
12
|
def start_server(server_id)
|
13
|
-
|
14
13
|
_action = 'StartInstance'
|
15
|
-
_sigNonce = randonStr
|
14
|
+
_sigNonce = randonStr
|
16
15
|
_time = Time.new.utc
|
17
16
|
|
18
17
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
19
|
-
_pathURL
|
20
|
-
|
21
|
-
_parameters['InstanceId']=server_id
|
22
|
-
_pathURL += '&InstanceId='+server_id
|
23
|
-
|
18
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
19
|
+
|
20
|
+
_parameters['InstanceId'] = server_id
|
21
|
+
_pathURL += '&InstanceId=' + server_id
|
22
|
+
|
24
23
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
25
|
-
_pathURL += '&Signature='+_signature
|
26
|
-
|
24
|
+
_pathURL += '&Signature=' + _signature
|
25
|
+
|
27
26
|
request(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
27
|
+
expects: [200, 204],
|
28
|
+
method: 'GET',
|
29
|
+
path: _pathURL
|
31
30
|
)
|
32
31
|
end # def start_server
|
33
32
|
end # class Real
|
34
33
|
|
35
34
|
class Mock
|
36
|
-
def start_server(
|
35
|
+
def start_server(_server_id)
|
37
36
|
true
|
38
37
|
end # def start_server
|
39
38
|
end # class Mock
|
40
39
|
end # class aliyun
|
41
40
|
end # module Compute
|
42
|
-
end # module Fog
|
41
|
+
end # module Fog
|
@@ -10,33 +10,32 @@ module Fog
|
|
10
10
|
# * success <~Boolean>
|
11
11
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&stopinstance]
|
12
12
|
def stop_server(server_id)
|
13
|
-
|
14
13
|
_action = 'StopInstance'
|
15
|
-
_sigNonce = randonStr
|
14
|
+
_sigNonce = randonStr
|
16
15
|
_time = Time.new.utc
|
17
16
|
|
18
17
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
19
|
-
_pathURL
|
20
|
-
|
21
|
-
_parameters['InstanceId']=server_id
|
22
|
-
_pathURL += '&InstanceId='+server_id
|
23
|
-
|
18
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
19
|
+
|
20
|
+
_parameters['InstanceId'] = server_id
|
21
|
+
_pathURL += '&InstanceId=' + server_id
|
22
|
+
|
24
23
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
25
|
-
_pathURL += '&Signature='+_signature
|
26
|
-
|
24
|
+
_pathURL += '&Signature=' + _signature
|
25
|
+
|
27
26
|
request(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
27
|
+
expects: [200, 204],
|
28
|
+
method: 'GET',
|
29
|
+
path: _pathURL
|
31
30
|
)
|
32
31
|
end # def stop_server
|
33
32
|
end # class Real
|
34
33
|
|
35
34
|
class Mock
|
36
|
-
def stop_server(
|
35
|
+
def stop_server(_server_id)
|
37
36
|
true
|
38
37
|
end # def stop_server
|
39
38
|
end # class Mock
|
40
39
|
end # class aliyun
|
41
40
|
end # module Compute
|
42
|
-
end # module Fog
|
41
|
+
end # module Fog
|
@@ -13,62 +13,37 @@ module Fog
|
|
13
13
|
# * 'RequestId'<~String> - Id of the request
|
14
14
|
#
|
15
15
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/network&associateeipaddresss]
|
16
|
-
def unassociate_eip_address(server_id, allocationId, options={})
|
17
|
-
|
16
|
+
def unassociate_eip_address(server_id, allocationId, options = {})
|
18
17
|
_action = 'UnassociateEipAddress'
|
19
|
-
_sigNonce = randonStr
|
18
|
+
_sigNonce = randonStr
|
20
19
|
_time = Time.new.utc
|
21
20
|
|
22
|
-
type=options['instance_type']
|
21
|
+
type = options['instance_type']
|
23
22
|
|
24
23
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
25
|
-
_pathURL
|
26
|
-
|
24
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
25
|
+
|
27
26
|
_parameters['InstanceId'] = server_id
|
28
|
-
_pathURL += '&InstanceId='+server_id
|
29
|
-
|
27
|
+
_pathURL += '&InstanceId=' + server_id
|
28
|
+
|
30
29
|
_parameters['AllocationId'] = allocationId
|
31
|
-
_pathURL += '&AllocationId='+allocationId
|
30
|
+
_pathURL += '&AllocationId=' + allocationId
|
32
31
|
|
33
32
|
if type
|
34
33
|
_parameters['InstanceType'] = type
|
35
|
-
_pathURL += 'InstanceType='+type
|
34
|
+
_pathURL += 'InstanceType=' + type
|
36
35
|
end
|
37
|
-
|
36
|
+
|
38
37
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
39
|
-
_pathURL += '&Signature='+_signature
|
40
|
-
|
38
|
+
_pathURL += '&Signature=' + _signature
|
39
|
+
|
41
40
|
request(
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
41
|
+
expects: [200, 204],
|
42
|
+
method: 'GET',
|
43
|
+
path: _pathURL
|
45
44
|
)
|
46
45
|
end
|
47
46
|
end
|
48
|
-
|
49
|
-
class Mock
|
50
|
-
def allocate_address(pool = nil)
|
51
|
-
response = Excon::Response.new
|
52
|
-
response.status = 200
|
53
|
-
response.headers = {
|
54
|
-
"X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
|
55
|
-
"Content-Type" => "application/json",
|
56
|
-
"Content-Length" => "105",
|
57
|
-
"Date"=> Date.new
|
58
|
-
}
|
59
|
-
response.body = {
|
60
|
-
"floating_ip" => {
|
61
|
-
"instance_id" => nil,
|
62
|
-
"ip" => "192.168.27.132",
|
63
|
-
"fixed_ip" => nil,
|
64
|
-
"id" => 4,
|
65
|
-
"pool"=>"nova"
|
66
|
-
}
|
67
|
-
}
|
68
|
-
response
|
69
|
-
end
|
70
|
-
end # mock
|
71
47
|
end # aliyun
|
72
|
-
end #compute
|
48
|
+
end # compute
|
73
49
|
end
|
74
|
-
|