fog-aliyun 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +309 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fog-aliyun.gemspec +30 -0
- data/lib/fog/aliyun.rb +19 -0
- data/lib/fog/aliyun/compute.rb +346 -0
- data/lib/fog/aliyun/models/compute/vpc.rb +69 -0
- data/lib/fog/aliyun/models/compute/vpcs.rb +89 -0
- data/lib/fog/aliyun/models/compute/vswitch.rb +70 -0
- data/lib/fog/aliyun/models/compute/vswitches.rb +87 -0
- data/lib/fog/aliyun/models/storage/directories.rb +45 -0
- data/lib/fog/aliyun/models/storage/directory.rb +48 -0
- data/lib/fog/aliyun/models/storage/file.rb +197 -0
- data/lib/fog/aliyun/models/storage/files.rb +178 -0
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +79 -0
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +63 -0
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +66 -0
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +82 -0
- data/lib/fog/aliyun/requests/compute/create_disk.rb +135 -0
- data/lib/fog/aliyun/requests/compute/create_image.rb +79 -0
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +77 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +86 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +86 -0
- data/lib/fog/aliyun/requests/compute/create_server.rb +188 -0
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +60 -0
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +73 -0
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +81 -0
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +58 -0
- data/lib/fog/aliyun/requests/compute/delete_image.rb +58 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +51 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +85 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +86 -0
- data/lib/fog/aliyun/requests/compute/delete_server.rb +48 -0
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +45 -0
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +52 -0
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +51 -0
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +51 -0
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +41 -0
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +41 -0
- data/lib/fog/aliyun/requests/compute/list_disks.rb +75 -0
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +81 -0
- data/lib/fog/aliyun/requests/compute/list_images.rb +85 -0
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +74 -0
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +81 -0
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +77 -0
- data/lib/fog/aliyun/requests/compute/list_servers.rb +74 -0
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +86 -0
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +64 -0
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +67 -0
- data/lib/fog/aliyun/requests/compute/list_zones.rb +44 -0
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +73 -0
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +73 -0
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +44 -0
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +53 -0
- data/lib/fog/aliyun/requests/compute/start_server.rb +42 -0
- data/lib/fog/aliyun/requests/compute/stop_server.rb +42 -0
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +56 -0
- data/lib/fog/aliyun/requests/storage/copy_object.rb +42 -0
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -0
- data/lib/fog/aliyun/requests/storage/delete_container.rb +38 -0
- data/lib/fog/aliyun/requests/storage/delete_object.rb +53 -0
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +148 -0
- data/lib/fog/aliyun/requests/storage/get_container.rb +72 -0
- data/lib/fog/aliyun/requests/storage/get_containers.rb +76 -0
- data/lib/fog/aliyun/requests/storage/get_object.rb +45 -0
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +43 -0
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +43 -0
- data/lib/fog/aliyun/requests/storage/head_object.rb +34 -0
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +47 -0
- data/lib/fog/aliyun/requests/storage/list_objects.rb +104 -0
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +23 -0
- data/lib/fog/aliyun/requests/storage/put_container.rb +35 -0
- data/lib/fog/aliyun/requests/storage/put_object.rb +199 -0
- data/lib/fog/aliyun/storage.rb +214 -0
- data/lib/fog/aliyun/version.rb +5 -0
- data/lib/fog/bin/aliyun.rb +31 -0
- metadata +227 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/disk&detachdisk]
|
6
|
+
def detach_disk(instanceId, diskId)
|
7
|
+
action = 'DetachDisk'
|
8
|
+
sigNonce = randonStr()
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
parameters["InstanceId"] = instanceId
|
15
|
+
pathUrl += '&InstanceId='
|
16
|
+
pathUrl += instanceId
|
17
|
+
|
18
|
+
parameters["DiskId"] = diskId
|
19
|
+
pathUrl += '&DiskId='
|
20
|
+
pathUrl += diskId
|
21
|
+
|
22
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
23
|
+
pathUrl += '&Signature='
|
24
|
+
pathUrl += signature
|
25
|
+
|
26
|
+
request(
|
27
|
+
:expects => [200, 203],
|
28
|
+
:method => 'GET',
|
29
|
+
:path => pathUrl
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def attach_volume(volume_id, server_id, device)
|
36
|
+
response = Excon::Response.new
|
37
|
+
response.status = 200
|
38
|
+
data = {
|
39
|
+
'id' => volume_id,
|
40
|
+
'volumeId' => volume_id,
|
41
|
+
'serverId' => server_id,
|
42
|
+
'device' => device
|
43
|
+
}
|
44
|
+
self.data[:volumes][volume_id]['attachments'] << data
|
45
|
+
response.body = { 'volumeAttachment' => data }
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&joinsecuritygroup]
|
6
|
+
def join_security_group(server_id, group_id)
|
7
|
+
|
8
|
+
_action = 'JoinSecurityGroup'
|
9
|
+
_sigNonce = randonStr()
|
10
|
+
_time = Time.new.utc
|
11
|
+
|
12
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
13
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
14
|
+
|
15
|
+
_parameters['InstanceId']=server_id
|
16
|
+
_pathURL += '&InstanceId='+server_id
|
17
|
+
|
18
|
+
_parameters['SecurityGroupId']=group_id
|
19
|
+
_pathURL += '&SecurityGroupId='+group_id
|
20
|
+
|
21
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
22
|
+
_pathURL += '&Signature='+_signature
|
23
|
+
|
24
|
+
request(
|
25
|
+
:expects => [200, 204],
|
26
|
+
:method => 'GET',
|
27
|
+
:path => _pathURL
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Mock
|
33
|
+
def join_security_group(server_id, group_id)
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 200
|
36
|
+
response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&leavesecuritygroup]
|
6
|
+
def leave_security_group(server_id, group_id)
|
7
|
+
|
8
|
+
_action = 'LeaveSecurityGroup'
|
9
|
+
_sigNonce = randonStr()
|
10
|
+
_time = Time.new.utc
|
11
|
+
|
12
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
13
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
14
|
+
|
15
|
+
_parameters['InstanceId']=server_id
|
16
|
+
_pathURL += '&InstanceId='+server_id
|
17
|
+
|
18
|
+
_parameters['SecurityGroupId']=group_id
|
19
|
+
_pathURL += '&SecurityGroupId='+group_id
|
20
|
+
|
21
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
22
|
+
_pathURL += '&Signature='+_signature
|
23
|
+
|
24
|
+
request(
|
25
|
+
:expects => [200, 204],
|
26
|
+
:method => 'GET',
|
27
|
+
:path => _pathURL
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Mock
|
33
|
+
def add_security_group(server_id, group_name)
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 200
|
36
|
+
response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/disk&describedisks]
|
6
|
+
def list_disks(options={})
|
7
|
+
action = 'DescribeDisks'
|
8
|
+
sigNonce = randonStr()
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
pageNumber = options[:pageNumber]
|
15
|
+
pageSize = options[:pageSize]
|
16
|
+
instanceId = options[:instanceId]
|
17
|
+
diskIds = options[:diskIds]
|
18
|
+
|
19
|
+
if instanceId
|
20
|
+
parameters["InstanceId"] = instanceId
|
21
|
+
pathUrl += '&InstanceId='
|
22
|
+
pathUrl += instanceId
|
23
|
+
end
|
24
|
+
|
25
|
+
if diskIds
|
26
|
+
parameters["DiskIds"] = Fog::JSON.encode(diskIds)
|
27
|
+
pathUrl += '&DiskIds='
|
28
|
+
pathUrl += Fog::JSON.encode(diskIds)
|
29
|
+
end
|
30
|
+
|
31
|
+
if pageNumber
|
32
|
+
parameters["PageNumber"] = pageNumber
|
33
|
+
pathUrl += '&PageNumber='
|
34
|
+
pathUrl += pageNumber
|
35
|
+
end
|
36
|
+
|
37
|
+
pageSize = options[:pageSize]
|
38
|
+
unless pageSize
|
39
|
+
pageSize = '50'
|
40
|
+
end
|
41
|
+
parameters["PageSize"] = pageSize
|
42
|
+
pathUrl += '&PageSize='
|
43
|
+
pathUrl += pageSize
|
44
|
+
|
45
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
46
|
+
pathUrl += '&Signature='
|
47
|
+
pathUrl += signature
|
48
|
+
|
49
|
+
request(
|
50
|
+
:expects => [200, 203],
|
51
|
+
:method => 'GET',
|
52
|
+
:path => pathUrl
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Mock
|
58
|
+
def list_zones(*args)
|
59
|
+
Excon::Response.new(
|
60
|
+
:body => { "availabilityZoneInfo" => [
|
61
|
+
{
|
62
|
+
"zoneState" => {
|
63
|
+
"available" => true
|
64
|
+
},
|
65
|
+
"hosts" => nil,
|
66
|
+
"zoneName" => "nova"
|
67
|
+
}
|
68
|
+
] },
|
69
|
+
:status => 200
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/network&describeeipaddress]
|
6
|
+
def list_eip_addresses(options={})
|
7
|
+
|
8
|
+
_action = 'DescribeEipAddresses'
|
9
|
+
_sigNonce = randonStr()
|
10
|
+
_time = Time.new.utc
|
11
|
+
|
12
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
13
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
14
|
+
|
15
|
+
_Status = options[:aliyun_Status]
|
16
|
+
if _Status
|
17
|
+
_parameters['Status']=_Status
|
18
|
+
_pathURL += '&Status='+_Status
|
19
|
+
end
|
20
|
+
|
21
|
+
_EipAddress = options[:aliyun_EipAddress]
|
22
|
+
if _EipAddress
|
23
|
+
_parameters['EipAddress']=_EipAddress
|
24
|
+
_pathURL += '&EipAddress='+_EipAddress
|
25
|
+
end
|
26
|
+
|
27
|
+
_AllocationId = options[:aliyun_AllocationId]
|
28
|
+
if _AllocationId
|
29
|
+
_parameters['AllocationId']=_AllocationId
|
30
|
+
_pathURL += '&AllocationId='+_AllocationId
|
31
|
+
end
|
32
|
+
|
33
|
+
_PageNumber = options[:aliyun_PageNumber]
|
34
|
+
if _PageNumber
|
35
|
+
_parameters['PageNumber']=_PageNumber
|
36
|
+
_pathURL += '&PageNumber='+_PageNumber
|
37
|
+
end
|
38
|
+
|
39
|
+
_PageSize = options[:pageSize]
|
40
|
+
unless _PageSize
|
41
|
+
_PageSize = '50'
|
42
|
+
end
|
43
|
+
_parameters['PageSize']=_PageSize
|
44
|
+
_pathURL += '&PageSize='+_PageSize
|
45
|
+
|
46
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
47
|
+
_pathURL += '&Signature='+_signature
|
48
|
+
|
49
|
+
request(
|
50
|
+
:expects => [200, 204],
|
51
|
+
:method => 'GET',
|
52
|
+
:path => _pathURL
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Mock
|
58
|
+
def allocate_address(pool = nil)
|
59
|
+
response = Excon::Response.new
|
60
|
+
response.status = 200
|
61
|
+
response.headers = {
|
62
|
+
"X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
|
63
|
+
"Content-Type" => "application/json",
|
64
|
+
"Content-Length" => "105",
|
65
|
+
"Date"=> Date.new
|
66
|
+
}
|
67
|
+
response.body = {
|
68
|
+
"floating_ip" => {
|
69
|
+
"instance_id" => nil,
|
70
|
+
"ip" => "192.168.27.132",
|
71
|
+
"fixed_ip" => nil,
|
72
|
+
"id" => 4,
|
73
|
+
"pool"=>"nova"
|
74
|
+
}
|
75
|
+
}
|
76
|
+
response
|
77
|
+
end
|
78
|
+
end # mock
|
79
|
+
end # Aliyun
|
80
|
+
end #compute
|
81
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/image&describeimages]
|
6
|
+
def list_images(options={})
|
7
|
+
|
8
|
+
action = 'DescribeImages'
|
9
|
+
sigNonce = randonStr()
|
10
|
+
time = Time.new.utc
|
11
|
+
|
12
|
+
parameters = defalutParameters(action, sigNonce, time)
|
13
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
14
|
+
|
15
|
+
pageNumber = options[:pageNumber]
|
16
|
+
if pageNumber
|
17
|
+
parameters["PageNumber"] = pageNumber
|
18
|
+
pathUrl += '&PageNumber='
|
19
|
+
pathUrl += pageNumber
|
20
|
+
end
|
21
|
+
|
22
|
+
pageSize = options[:pageSize]
|
23
|
+
unless pageSize
|
24
|
+
pageSize = '50'
|
25
|
+
end
|
26
|
+
parameters["PageSize"] = pageSize
|
27
|
+
pathUrl += '&PageSize='
|
28
|
+
pathUrl += pageSize
|
29
|
+
|
30
|
+
imageId = options[:imangeId]
|
31
|
+
if imageId
|
32
|
+
parameters["ImageId"] = imageId
|
33
|
+
pathUrl += '&ImageId='
|
34
|
+
pathUrl += imageId
|
35
|
+
end
|
36
|
+
|
37
|
+
imageName = options[:imageName]
|
38
|
+
if imageName
|
39
|
+
parameters["ImageName"] = imageName
|
40
|
+
pathUrl += '&ImageName='
|
41
|
+
pathUrl += imageName
|
42
|
+
end
|
43
|
+
|
44
|
+
snapshotId = options[:snapshotId]
|
45
|
+
if snapshotId
|
46
|
+
parameters["SnapshotId"] = snapshotId
|
47
|
+
pathUrl += '&SnapshotId='
|
48
|
+
pathUrl += snapshotId
|
49
|
+
end
|
50
|
+
|
51
|
+
ownerAlias = options[:ownerAlias]
|
52
|
+
if ownerAlias
|
53
|
+
parameters["ImageOwnerAlias"] = ownerAlias
|
54
|
+
pathUrl += '&ImageOwnerAlias='
|
55
|
+
pathUrl += ownerAlias
|
56
|
+
end
|
57
|
+
|
58
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
59
|
+
pathUrl += '&Signature='
|
60
|
+
pathUrl += signature
|
61
|
+
|
62
|
+
request(
|
63
|
+
:expects => [200, 203],
|
64
|
+
:method => 'GET',
|
65
|
+
:path => pathUrl
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class Mock
|
71
|
+
def list_images
|
72
|
+
response = Excon::Response.new
|
73
|
+
data = list_images_detail.body['images']
|
74
|
+
images = []
|
75
|
+
for image in data
|
76
|
+
images << image.reject { |key, value| !['id', 'name', 'links'].include?(key) }
|
77
|
+
end
|
78
|
+
response.status = [200, 203][rand(1)]
|
79
|
+
response.body = { 'images' => images }
|
80
|
+
response
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&describesecuritygroupattribute]
|
6
|
+
def list_security_group_rules(securityGroupId, options = {})
|
7
|
+
|
8
|
+
action = 'DescribeSecurityGroupAttribute'
|
9
|
+
sigNonce = randonStr()
|
10
|
+
time = Time.new.utc
|
11
|
+
|
12
|
+
parameters = defalutParameters(action, sigNonce, time)
|
13
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
14
|
+
|
15
|
+
parameters["SecurityGroupId"] = securityGroupId
|
16
|
+
pathUrl += '&SecurityGroupId='
|
17
|
+
pathUrl += securityGroupId
|
18
|
+
|
19
|
+
nicType = options[:nicType]
|
20
|
+
if nicType
|
21
|
+
parameters["NicType"] = nicType
|
22
|
+
pathUrl += '&NicType='
|
23
|
+
pathUrl += nicType
|
24
|
+
end
|
25
|
+
pageNumber = options[:pageNumber]
|
26
|
+
pageSize = options[:pageSize]
|
27
|
+
if pageNumber
|
28
|
+
parameters["PageNumber"] = pageNumber
|
29
|
+
pathUrl += '&PageNumber='
|
30
|
+
pathUrl += pageNumber
|
31
|
+
end
|
32
|
+
|
33
|
+
if pageSize
|
34
|
+
parameters["PageSize"] = pageSize
|
35
|
+
pathUrl += '&PageSize='
|
36
|
+
pathUrl += pageSize
|
37
|
+
end
|
38
|
+
|
39
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
40
|
+
pathUrl += '&Signature='
|
41
|
+
pathUrl += signature
|
42
|
+
|
43
|
+
request(
|
44
|
+
:expects => [200, 203],
|
45
|
+
:method => 'GET',
|
46
|
+
:path => pathUrl
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Mock
|
52
|
+
def get_security_group(security_group_id)
|
53
|
+
security_group = self.data[:security_groups][security_group_id.to_s]
|
54
|
+
response = Excon::Response.new
|
55
|
+
if security_group
|
56
|
+
response.status = 200
|
57
|
+
response.headers = {
|
58
|
+
"X-Compute-Request-Id" => "req-63a90344-7c4d-42e2-936c-fd748bced1b3",
|
59
|
+
"Content-Type" => "application/json",
|
60
|
+
"Content-Length" => "167",
|
61
|
+
"Date" => Date.new
|
62
|
+
}
|
63
|
+
response.body = {
|
64
|
+
"security_group" => security_group
|
65
|
+
}
|
66
|
+
else
|
67
|
+
raise Fog::Compute::OpenStack::NotFound, "Security group #{security_group_id} does not exist"
|
68
|
+
end
|
69
|
+
response
|
70
|
+
end
|
71
|
+
end # mock
|
72
|
+
end # aliyun
|
73
|
+
end # compute
|
74
|
+
end # fog
|