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
@@ -13,72 +13,66 @@ module Fog
|
|
13
13
|
|
14
14
|
model Fog::Storage::Aliyun::File
|
15
15
|
|
16
|
-
def all(
|
16
|
+
def all(_options = {})
|
17
17
|
requires :directory
|
18
|
-
if directory.key !=
|
19
|
-
prefix = directory.key+
|
18
|
+
if directory.key != '' && directory.key != '.' && !directory.key.nil?
|
19
|
+
prefix = directory.key + '/'
|
20
20
|
end
|
21
|
-
files = service.list_objects(
|
22
|
-
if nil == files
|
23
|
-
|
24
|
-
end
|
25
|
-
data = Array.new
|
21
|
+
files = service.list_objects(prefix: prefix)['Contents']
|
22
|
+
return if nil == files
|
23
|
+
data = []
|
26
24
|
i = 0
|
27
25
|
files.each do |file|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
:object_type => type}
|
43
|
-
i = i + 1
|
44
|
-
end
|
26
|
+
next unless file['Key'][0][-1] != '/'
|
27
|
+
content_length = file['Size'][0].to_i
|
28
|
+
key = file['Key'][0]
|
29
|
+
lastModified = file['LastModified'][0]
|
30
|
+
last_modified = if !lastModified.nil? && lastModified != ''
|
31
|
+
Time.parse(lastModified).localtime
|
32
|
+
end
|
33
|
+
type = file['Type'][0]
|
34
|
+
data[i] = { content_length: content_length,
|
35
|
+
key: key,
|
36
|
+
last_modified: last_modified,
|
37
|
+
etag: file['ETag'][0],
|
38
|
+
object_type: type }
|
39
|
+
i += 1
|
45
40
|
end
|
46
41
|
|
47
42
|
load(data)
|
48
|
-
|
49
43
|
end
|
50
44
|
|
51
|
-
|
45
|
+
alias each_file_this_page each
|
52
46
|
def each
|
53
47
|
if !block_given?
|
54
48
|
self
|
55
49
|
else
|
56
50
|
subset = dup.all
|
57
51
|
|
58
|
-
subset.each_file_this_page {|f| yield f}
|
59
|
-
while subset.length == (subset.limit ||
|
60
|
-
subset = subset.all(:
|
61
|
-
subset.each_file_this_page {|f| yield f}
|
52
|
+
subset.each_file_this_page { |f| yield f }
|
53
|
+
while subset.length == (subset.limit || 10_000)
|
54
|
+
subset = subset.all(marker: subset.last.key)
|
55
|
+
subset.each_file_this_page { |f| yield f }
|
62
56
|
end
|
63
57
|
|
64
58
|
self
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|
68
|
-
def get(key
|
62
|
+
def get(key)
|
69
63
|
requires :directory
|
70
|
-
if directory.key ==
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
64
|
+
object = if directory.key == ''
|
65
|
+
key
|
66
|
+
else
|
67
|
+
directory.key + '/' + key
|
68
|
+
end
|
69
|
+
|
76
70
|
if block_given?
|
77
|
-
pagesNum = (contentLen + Excon::CHUNK_SIZE - 1)/Excon::CHUNK_SIZE
|
78
|
-
|
71
|
+
pagesNum = (contentLen + Excon::CHUNK_SIZE - 1) / Excon::CHUNK_SIZE
|
72
|
+
|
79
73
|
for i in 1..pagesNum
|
80
|
-
_start = (i-1)*
|
81
|
-
_end = i*
|
74
|
+
_start = (i - 1) * Excon::CHUNK_SIZE
|
75
|
+
_end = i * Excon::CHUNK_SIZE - 1
|
82
76
|
range = "#{_start}-#{_end}"
|
83
77
|
data = service.get_object(object, range)
|
84
78
|
chunk = data[:body]
|
@@ -89,37 +83,29 @@ module Fog
|
|
89
83
|
data = service.get_object(object)
|
90
84
|
body = data[:body]
|
91
85
|
end
|
92
|
-
|
93
|
-
contentLen = data[:headers]["Content-Length"].to_i
|
94
|
-
if data[:status] != 200
|
95
|
-
return nil
|
96
|
-
end
|
97
|
-
lastModified = data[:headers]["Last-Modified"]
|
98
|
-
if lastModified != nil && lastModified != ""
|
99
|
-
last_modified = (Time.parse(lastModified)).localtime
|
100
|
-
else
|
101
|
-
last_modified = nil
|
102
|
-
end
|
103
86
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
87
|
+
contentLen = data[:headers]['Content-Length'].to_i
|
88
|
+
return nil if data[:status] != 200
|
89
|
+
lastModified = data[:headers]['Last-Modified']
|
90
|
+
last_modified = if !lastModified.nil? && lastModified != ''
|
91
|
+
Time.parse(lastModified).localtime
|
92
|
+
end
|
93
|
+
|
94
|
+
date = data[:headers]['Date']
|
95
|
+
date = (Time.parse(date).localtime if !date.nil? && date != '')
|
110
96
|
file_data = {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
97
|
+
body: body,
|
98
|
+
content_length: contentLen,
|
99
|
+
key: key,
|
100
|
+
last_modified: last_modified,
|
101
|
+
content_type: data[:headers]['Content-Type'],
|
102
|
+
etag: data[:headers]['ETag'],
|
103
|
+
date: date,
|
104
|
+
connection: data[:headers]['Connection'],
|
105
|
+
accept_ranges: data[:headers]['Accept-Ranges'],
|
106
|
+
server: data[:headers]['Server'],
|
107
|
+
object_type: data[:headers]['x-oss-object-type'],
|
108
|
+
content_disposition: data[:headers]['Content-Disposition']
|
123
109
|
}
|
124
110
|
|
125
111
|
new(file_data)
|
@@ -127,67 +113,61 @@ module Fog
|
|
127
113
|
|
128
114
|
def get_url(key)
|
129
115
|
requires :directory
|
130
|
-
if directory.key ==
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
116
|
+
object = if directory.key == ''
|
117
|
+
key
|
118
|
+
else
|
119
|
+
directory.key + '/' + key
|
120
|
+
end
|
135
121
|
service.get_object_http_url_public(object, 3600)
|
136
122
|
end
|
137
123
|
|
138
124
|
def get_http_url(key, expires, options = {})
|
139
125
|
requires :directory
|
140
|
-
if directory.key ==
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
126
|
+
object = if directory.key == ''
|
127
|
+
key
|
128
|
+
else
|
129
|
+
directory.key + '/' + key
|
130
|
+
end
|
145
131
|
service.get_object_http_url_public(object, expires, options)
|
146
132
|
end
|
147
133
|
|
148
134
|
def get_https_url(key, expires, options = {})
|
149
135
|
requires :directory
|
150
|
-
if directory.key ==
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
136
|
+
object = if directory.key == ''
|
137
|
+
key
|
138
|
+
else
|
139
|
+
directory.key + '/' + key
|
140
|
+
end
|
155
141
|
service.get_object_https_url_public(object, expires, options)
|
156
142
|
end
|
157
143
|
|
158
|
-
def head(key,
|
144
|
+
def head(key, _options = {})
|
159
145
|
requires :directory
|
160
|
-
if directory.key ==
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
146
|
+
object = if directory.key == ''
|
147
|
+
key
|
148
|
+
else
|
149
|
+
directory.key + '/' + key
|
150
|
+
end
|
165
151
|
data = service.head_object(object).data
|
166
|
-
lastModified = data[:headers][
|
167
|
-
if lastModified
|
168
|
-
|
169
|
-
|
170
|
-
last_modified = nil
|
171
|
-
end
|
152
|
+
lastModified = data[:headers]['Last-Modified']
|
153
|
+
last_modified = if !lastModified.nil? && lastModified != ''
|
154
|
+
Time.parse(lastModified).localtime
|
155
|
+
end
|
172
156
|
|
173
|
-
date = data[:headers][
|
174
|
-
|
175
|
-
date = (Time.parse(date)).localtime
|
176
|
-
else
|
177
|
-
date = nil
|
178
|
-
end
|
157
|
+
date = data[:headers]['Date']
|
158
|
+
date = (Time.parse(date).localtime if !date.nil? && date != '')
|
179
159
|
|
180
160
|
file_data = {
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
161
|
+
content_length: data[:headers]['Content-Length'].to_i,
|
162
|
+
key: key,
|
163
|
+
last_modified: last_modified,
|
164
|
+
content_type: data[:headers]['Content-Type'],
|
165
|
+
etag: data[:headers]['ETag'],
|
166
|
+
date: date,
|
167
|
+
connection: data[:headers]['Connection'],
|
168
|
+
accept_ranges: data[:headers]['Accept-Ranges'],
|
169
|
+
server: data[:headers]['Server'],
|
170
|
+
object_type: data[:headers]['x-oss-object-type']
|
191
171
|
}
|
192
172
|
new(file_data)
|
193
173
|
rescue Fog::Storage::Aliyun::NotFound
|
@@ -196,7 +176,7 @@ module Fog
|
|
196
176
|
|
197
177
|
def new(attributes = {})
|
198
178
|
requires :directory
|
199
|
-
super({ :
|
179
|
+
super({ directory: directory }.merge!(attributes))
|
200
180
|
end
|
201
181
|
end
|
202
182
|
end
|
@@ -19,62 +19,36 @@ module Fog
|
|
19
19
|
# * 'RequestId'<~String> - Id of the request
|
20
20
|
#
|
21
21
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/network&allocateeipaddress]
|
22
|
-
def allocate_eip_address(options={})
|
23
|
-
|
22
|
+
def allocate_eip_address(options = {})
|
24
23
|
_action = 'AllocateEipAddress'
|
25
|
-
_sigNonce = randonStr
|
24
|
+
_sigNonce = randonStr
|
26
25
|
_time = Time.new.utc
|
27
26
|
|
28
27
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
29
|
-
_pathURL
|
30
|
-
|
31
|
-
#optional parameters
|
28
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
29
|
+
|
30
|
+
# optional parameters
|
32
31
|
_Bandwidth = options[:bandwidth]
|
33
32
|
if _Bandwidth
|
34
|
-
_parameters['Bandwidth']=_Bandwidth
|
35
|
-
_pathURL += '&Bandwidth='+_Bandwidth
|
33
|
+
_parameters['Bandwidth'] = _Bandwidth
|
34
|
+
_pathURL += '&Bandwidth=' + _Bandwidth
|
36
35
|
end
|
37
|
-
|
36
|
+
|
38
37
|
_InternetChargeType = options[:internet_charge_type]
|
39
|
-
unless _InternetChargeType
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
_pathURL += '&InternetChargeType='+_InternetChargeType
|
44
|
-
|
38
|
+
_InternetChargeType = 'PayByTraffic' unless _InternetChargeType
|
39
|
+
_parameters['InternetChargeType'] = _InternetChargeType
|
40
|
+
_pathURL += '&InternetChargeType=' + _InternetChargeType
|
41
|
+
|
45
42
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
46
|
-
_pathURL += '&Signature='+_signature
|
47
|
-
|
43
|
+
_pathURL += '&Signature=' + _signature
|
44
|
+
|
48
45
|
request(
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
46
|
+
expects: [200, 204],
|
47
|
+
method: 'GET',
|
48
|
+
path: _pathURL
|
52
49
|
)
|
53
50
|
end
|
54
51
|
end
|
55
|
-
|
56
|
-
class Mock
|
57
|
-
def allocate_address(pool = nil)
|
58
|
-
response = Excon::Response.new
|
59
|
-
response.status = 200
|
60
|
-
response.headers = {
|
61
|
-
"X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
|
62
|
-
"Content-Type" => "application/json",
|
63
|
-
"Content-Length" => "105",
|
64
|
-
"Date"=> Date.new
|
65
|
-
}
|
66
|
-
response.body = {
|
67
|
-
"floating_ip" => {
|
68
|
-
"instance_id" => nil,
|
69
|
-
"ip" => "192.168.27.132",
|
70
|
-
"fixed_ip" => nil,
|
71
|
-
"id" => 4,
|
72
|
-
"pool"=>"nova"
|
73
|
-
}
|
74
|
-
}
|
75
|
-
response
|
76
|
-
end
|
77
|
-
end # mock
|
78
52
|
end # aliyun
|
79
|
-
end #compute
|
53
|
+
end # compute
|
80
54
|
end
|
@@ -14,50 +14,26 @@ module Fog
|
|
14
14
|
#
|
15
15
|
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/network&allocatepublicipaddress]
|
16
16
|
def allocate_public_ip_address(server_id)
|
17
|
-
|
18
17
|
_action = 'AllocatePublicIpAddress'
|
19
|
-
_sigNonce = randonStr
|
18
|
+
_sigNonce = randonStr
|
20
19
|
_time = Time.new.utc
|
21
20
|
|
22
21
|
_parameters = defalutParameters(_action, _sigNonce, _time)
|
23
|
-
_pathURL
|
24
|
-
|
25
|
-
_parameters['InstanceId']=server_id
|
26
|
-
|
27
|
-
|
22
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
23
|
+
|
24
|
+
_parameters['InstanceId'] = server_id
|
25
|
+
_pathURL += '&InstanceId=' + server_id
|
26
|
+
|
28
27
|
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
29
|
-
_pathURL += '&Signature='+_signature
|
30
|
-
|
28
|
+
_pathURL += '&Signature=' + _signature
|
29
|
+
|
31
30
|
request(
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
31
|
+
expects: [200, 204],
|
32
|
+
method: 'GET',
|
33
|
+
path: _pathURL
|
35
34
|
)
|
36
35
|
end
|
37
36
|
end
|
38
|
-
|
39
|
-
class Mock
|
40
|
-
def allocate_address(pool = nil)
|
41
|
-
response = Excon::Response.new
|
42
|
-
response.status = 200
|
43
|
-
response.headers = {
|
44
|
-
"X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
|
45
|
-
"Content-Type" => "application/json",
|
46
|
-
"Content-Length" => "105",
|
47
|
-
"Date"=> Date.new
|
48
|
-
}
|
49
|
-
response.body = {
|
50
|
-
"floating_ip" => {
|
51
|
-
"instance_id" => nil,
|
52
|
-
"ip" => "192.168.27.132",
|
53
|
-
"fixed_ip" => nil,
|
54
|
-
"id" => 4,
|
55
|
-
"pool"=>"nova"
|
56
|
-
}
|
57
|
-
}
|
58
|
-
response
|
59
|
-
end
|
60
|
-
end # mock
|
61
37
|
end # aliyun
|
62
|
-
end #compute
|
38
|
+
end # compute
|
63
39
|
end
|
@@ -13,61 +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 associate_eip_address(server_id, allocationId,options={})
|
17
|
-
|
16
|
+
def associate_eip_address(server_id, allocationId, options = {})
|
18
17
|
_action = 'AssociateEipAddress'
|
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
|