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,44 @@
|
|
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/region&describezones]
|
6
|
+
def list_zones()
|
7
|
+
action = 'DescribeZones'
|
8
|
+
sigNonce = randonStr()
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
15
|
+
pathUrl += '&Signature='
|
16
|
+
pathUrl += signature
|
17
|
+
|
18
|
+
request(
|
19
|
+
:expects => [200, 203],
|
20
|
+
:method => 'GET',
|
21
|
+
:path => pathUrl
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
def list_zones(*args)
|
28
|
+
Excon::Response.new(
|
29
|
+
:body => { "availabilityZoneInfo" => [
|
30
|
+
{
|
31
|
+
"zoneState" => {
|
32
|
+
"available" => true
|
33
|
+
},
|
34
|
+
"hosts" => nil,
|
35
|
+
"zoneName" => "nova"
|
36
|
+
}
|
37
|
+
] },
|
38
|
+
:status => 200
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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/vpc&modifyvpcattribute]
|
6
|
+
def modify_vpc(vpcId,options={})
|
7
|
+
|
8
|
+
action = 'ModifyVpcAttribute'
|
9
|
+
sigNonce = randonStr()
|
10
|
+
time = Time.new.utc
|
11
|
+
|
12
|
+
parameters = defalutParameters(action, sigNonce, time)
|
13
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
14
|
+
|
15
|
+
parameters["VpcId"] = vpcId
|
16
|
+
pathUrl += '&VpcId='
|
17
|
+
pathUrl += URI.encode(vpcId,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
18
|
+
name = options[:name]
|
19
|
+
desc = options[:description]
|
20
|
+
|
21
|
+
if name
|
22
|
+
parameters["VpcName"] = name
|
23
|
+
pathUrl += '&VpcName='
|
24
|
+
pathUrl += name
|
25
|
+
end
|
26
|
+
|
27
|
+
if desc
|
28
|
+
parameters["Description"] = desc
|
29
|
+
pathUrl += '&Description='
|
30
|
+
pathUrl += desc
|
31
|
+
end
|
32
|
+
|
33
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
34
|
+
pathUrl += '&Signature='
|
35
|
+
pathUrl += signature
|
36
|
+
|
37
|
+
request(
|
38
|
+
:expects => [200, 203],
|
39
|
+
:method => 'GET',
|
40
|
+
:path => pathUrl
|
41
|
+
)
|
42
|
+
end
|
43
|
+
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
|
+
end # Aliyun
|
72
|
+
end # compute
|
73
|
+
end # fog
|
@@ -0,0 +1,73 @@
|
|
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/vswitch&modifyvswitchattribute]
|
6
|
+
def modify_vpc(vSwitchId,options={})
|
7
|
+
|
8
|
+
action = 'ModifyVSwitchAttribute'
|
9
|
+
sigNonce = randonStr()
|
10
|
+
time = Time.new.utc
|
11
|
+
|
12
|
+
parameters = defalutParameters(action, sigNonce, time)
|
13
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
14
|
+
|
15
|
+
parameters["VSwitchId"] = vSwitchId
|
16
|
+
pathUrl += '&VSwitchId='
|
17
|
+
pathUrl += URI.encode(vpcId,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
18
|
+
name = options[:name]
|
19
|
+
desc = options[:description]
|
20
|
+
|
21
|
+
if name
|
22
|
+
parameters["VSwitchName"] = name
|
23
|
+
pathUrl += '&VSwitchName='
|
24
|
+
pathUrl += name
|
25
|
+
end
|
26
|
+
|
27
|
+
if desc
|
28
|
+
parameters["Description"] = desc
|
29
|
+
pathUrl += '&Description='
|
30
|
+
pathUrl += desc
|
31
|
+
end
|
32
|
+
|
33
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
34
|
+
pathUrl += '&Signature='
|
35
|
+
pathUrl += signature
|
36
|
+
|
37
|
+
request(
|
38
|
+
:expects => [200, 203],
|
39
|
+
:method => 'GET',
|
40
|
+
:path => pathUrl
|
41
|
+
)
|
42
|
+
end
|
43
|
+
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
|
+
end # Aliyun
|
72
|
+
end # compute
|
73
|
+
end # fog
|
@@ -0,0 +1,44 @@
|
|
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&rebootinstance]
|
6
|
+
def reboot_server(server_id, options = {})
|
7
|
+
|
8
|
+
_action = 'RebootInstance'
|
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
|
+
_ForceStop = options[:aliyun_ForceStop]
|
19
|
+
if _ForceStop
|
20
|
+
_parameters['ForceStop']=_ForceStop
|
21
|
+
_pathURL += '&ForceStop='+_ForceStop
|
22
|
+
end
|
23
|
+
|
24
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
25
|
+
_pathURL += '&Signature='+_signature
|
26
|
+
|
27
|
+
request(
|
28
|
+
:expects => [200, 204],
|
29
|
+
:method => 'GET',
|
30
|
+
:path => _pathURL
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
def reboot_server(server_id, type = 'SOFT')
|
37
|
+
response = Excon::Response.new
|
38
|
+
response.status = 202
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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&releaseeipaddress]
|
6
|
+
def release_eip_address(allocationId)
|
7
|
+
|
8
|
+
_action = 'ReleaseEipAddress'
|
9
|
+
_sigNonce = randonStr()
|
10
|
+
_time = Time.new.utc
|
11
|
+
|
12
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
13
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
14
|
+
|
15
|
+
_parameters['AllocationId'] = allocationId
|
16
|
+
_pathURL += '&AllocationId='+allocationId
|
17
|
+
|
18
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
19
|
+
_pathURL += '&Signature='+_signature
|
20
|
+
|
21
|
+
request(
|
22
|
+
:expects => [200, 204],
|
23
|
+
:method => 'GET',
|
24
|
+
:path => _pathURL
|
25
|
+
)
|
26
|
+
end
|
27
|
+
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
|
+
end # Aliyun
|
52
|
+
end #compute
|
53
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# Start the server.
|
6
|
+
#
|
7
|
+
# === Parameters
|
8
|
+
# * server_id <~String> - The ID of the server to be started.
|
9
|
+
# === Returns
|
10
|
+
# * success <~Boolean>
|
11
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&staetinstance]
|
12
|
+
def start_server(server_id)
|
13
|
+
|
14
|
+
_action = 'StartInstance'
|
15
|
+
_sigNonce = randonStr()
|
16
|
+
_time = Time.new.utc
|
17
|
+
|
18
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
19
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
20
|
+
|
21
|
+
_parameters['InstanceId']=server_id
|
22
|
+
_pathURL += '&InstanceId='+server_id
|
23
|
+
|
24
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
25
|
+
_pathURL += '&Signature='+_signature
|
26
|
+
|
27
|
+
request(
|
28
|
+
:expects => [200, 204],
|
29
|
+
:method => 'GET',
|
30
|
+
:path => _pathURL
|
31
|
+
)
|
32
|
+
end # def start_server
|
33
|
+
end # class Real
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
def start_server(server_id)
|
37
|
+
true
|
38
|
+
end # def start_server
|
39
|
+
end # class Mock
|
40
|
+
end # class Aliyun
|
41
|
+
end # module Compute
|
42
|
+
end # module Fog
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# Stop the server.
|
6
|
+
#
|
7
|
+
# === Parameters
|
8
|
+
# * server_id <~String> - The ID of the server to be stopped.
|
9
|
+
# === Returns
|
10
|
+
# * success <~Boolean>
|
11
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&stopinstance]
|
12
|
+
def stop_server(server_id)
|
13
|
+
|
14
|
+
_action = 'StopInstance'
|
15
|
+
_sigNonce = randonStr()
|
16
|
+
_time = Time.new.utc
|
17
|
+
|
18
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
19
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
20
|
+
|
21
|
+
_parameters['InstanceId']=server_id
|
22
|
+
_pathURL += '&InstanceId='+server_id
|
23
|
+
|
24
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
25
|
+
_pathURL += '&Signature='+_signature
|
26
|
+
|
27
|
+
request(
|
28
|
+
:expects => [200, 204],
|
29
|
+
:method => 'GET',
|
30
|
+
:path => _pathURL
|
31
|
+
)
|
32
|
+
end # def stop_server
|
33
|
+
end # class Real
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
def stop_server(server_id)
|
37
|
+
true
|
38
|
+
end # def stop_server
|
39
|
+
end # class Mock
|
40
|
+
end # class Aliyun
|
41
|
+
end # module Compute
|
42
|
+
end # module Fog
|
@@ -0,0 +1,56 @@
|
|
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&unassociateeipaddress]
|
6
|
+
def unassociate_eip_address(server_id, allocationId)
|
7
|
+
|
8
|
+
_action = 'UnassociateEipAddress'
|
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['AllocationId'] = allocationId
|
19
|
+
_pathURL += '&AllocationId='+allocationId
|
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 allocate_address(pool = nil)
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 200
|
36
|
+
response.headers = {
|
37
|
+
"X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
|
38
|
+
"Content-Type" => "application/json",
|
39
|
+
"Content-Length" => "105",
|
40
|
+
"Date"=> Date.new
|
41
|
+
}
|
42
|
+
response.body = {
|
43
|
+
"floating_ip" => {
|
44
|
+
"instance_id" => nil,
|
45
|
+
"ip" => "192.168.27.132",
|
46
|
+
"fixed_ip" => nil,
|
47
|
+
"id" => 4,
|
48
|
+
"pool"=>"nova"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
response
|
52
|
+
end
|
53
|
+
end # mock
|
54
|
+
end # aliyun
|
55
|
+
end #compute
|
56
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# Copy object
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * source_bucket<~String> - Name of source bucket
|
9
|
+
# * source_object<~String> - Name of source object
|
10
|
+
# * target_bucket<~String> - Name of bucket to create copy in
|
11
|
+
# * target_object<~String> - Name for new copy of object
|
12
|
+
# * options<~Hash> - Additional headers options={}
|
13
|
+
def copy_object(source_bucket, source_object, target_bucket, target_object, options = {})
|
14
|
+
options = options.reject {|key, value| value.nil?}
|
15
|
+
bucket = options[:bucket]
|
16
|
+
bucket ||= @aliyun_oss_bucket
|
17
|
+
source_bucket ||= bucket
|
18
|
+
target_bucket ||= bucket
|
19
|
+
headers = { 'x-oss-copy-source' => "/#{source_bucket}/#{source_object}" }
|
20
|
+
location = get_bucket_location(target_bucket)
|
21
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
22
|
+
resource = target_bucket+'/'+target_object
|
23
|
+
request({
|
24
|
+
:expects => [200, 203],
|
25
|
+
:headers => headers,
|
26
|
+
:method => 'PUT',
|
27
|
+
:path => target_object,
|
28
|
+
:bucket => target_bucket,
|
29
|
+
:resource => resource,
|
30
|
+
:endpoint => endpoint
|
31
|
+
})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
def copy_object(source_bucket, source_object, target_bucket, target_object)
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|