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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.rubocop_todo.yml +149 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Rakefile +3 -3
  7. data/fog-aliyun.gemspec +16 -13
  8. data/lib/fog/aliyun.rb +8 -8
  9. data/lib/fog/aliyun/compute.rb +99 -113
  10. data/lib/fog/aliyun/models/compute/eip_address.rb +23 -29
  11. data/lib/fog/aliyun/models/compute/eip_addresses.rb +3 -5
  12. data/lib/fog/aliyun/models/compute/image.rb +26 -28
  13. data/lib/fog/aliyun/models/compute/images.rb +2 -6
  14. data/lib/fog/aliyun/models/compute/route_entry.rb +9 -11
  15. data/lib/fog/aliyun/models/compute/route_entrys.rb +7 -7
  16. data/lib/fog/aliyun/models/compute/route_table.rb +10 -11
  17. data/lib/fog/aliyun/models/compute/route_tables.rb +2 -2
  18. data/lib/fog/aliyun/models/compute/security_group.rb +24 -24
  19. data/lib/fog/aliyun/models/compute/security_group_rule.rb +20 -20
  20. data/lib/fog/aliyun/models/compute/security_group_rules.rb +4 -4
  21. data/lib/fog/aliyun/models/compute/security_groups.rb +6 -7
  22. data/lib/fog/aliyun/models/compute/server.rb +42 -43
  23. data/lib/fog/aliyun/models/compute/servers.rb +9 -11
  24. data/lib/fog/aliyun/models/compute/snapshot.rb +15 -15
  25. data/lib/fog/aliyun/models/compute/snapshots.rb +6 -10
  26. data/lib/fog/aliyun/models/compute/volume.rb +36 -40
  27. data/lib/fog/aliyun/models/compute/volumes.rb +7 -11
  28. data/lib/fog/aliyun/models/compute/vpc.rb +18 -19
  29. data/lib/fog/aliyun/models/compute/vpcs.rb +5 -6
  30. data/lib/fog/aliyun/models/compute/vrouter.rb +13 -13
  31. data/lib/fog/aliyun/models/compute/vrouters.rb +4 -5
  32. data/lib/fog/aliyun/models/compute/vswitch.rb +18 -20
  33. data/lib/fog/aliyun/models/compute/vswitches.rb +6 -6
  34. data/lib/fog/aliyun/models/storage/directories.rb +10 -16
  35. data/lib/fog/aliyun/models/storage/directory.rb +8 -8
  36. data/lib/fog/aliyun/models/storage/file.rb +58 -64
  37. data/lib/fog/aliyun/models/storage/files.rb +95 -115
  38. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +18 -44
  39. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +12 -36
  40. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +16 -40
  41. data/lib/fog/aliyun/requests/compute/attach_disk.rb +19 -22
  42. data/lib/fog/aliyun/requests/compute/create_disk.rb +33 -63
  43. data/lib/fog/aliyun/requests/compute/create_image.rb +21 -21
  44. data/lib/fog/aliyun/requests/compute/create_security_group.rb +16 -16
  45. data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +22 -63
  46. data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +23 -61
  47. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +22 -63
  48. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +23 -61
  49. data/lib/fog/aliyun/requests/compute/create_server.rb +76 -78
  50. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +12 -26
  51. data/lib/fog/aliyun/requests/compute/create_vpc.rb +11 -38
  52. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +13 -40
  53. data/lib/fog/aliyun/requests/compute/delete_disk.rb +8 -35
  54. data/lib/fog/aliyun/requests/compute/delete_image.rb +6 -33
  55. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
  56. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +22 -63
  57. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +23 -61
  58. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -62
  59. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +23 -61
  60. data/lib/fog/aliyun/requests/compute/delete_server.rb +15 -15
  61. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +6 -20
  62. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +9 -26
  63. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +9 -25
  64. data/lib/fog/aliyun/requests/compute/detach_disk.rb +11 -27
  65. data/lib/fog/aliyun/requests/compute/join_security_group.rb +15 -16
  66. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +15 -16
  67. data/lib/fog/aliyun/requests/compute/list_disks.rb +24 -43
  68. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +26 -52
  69. data/lib/fog/aliyun/requests/compute/list_images.rb +21 -24
  70. data/lib/fog/aliyun/requests/compute/list_route_tables.rb +16 -19
  71. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +22 -23
  72. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +21 -24
  73. data/lib/fog/aliyun/requests/compute/list_server_types.rb +50 -50
  74. data/lib/fog/aliyun/requests/compute/list_servers.rb +25 -28
  75. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +20 -37
  76. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +12 -29
  77. data/lib/fog/aliyun/requests/compute/list_vrouters.rb +13 -16
  78. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +14 -31
  79. data/lib/fog/aliyun/requests/compute/list_zones.rb +16 -16
  80. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +17 -17
  81. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +11 -39
  82. data/lib/fog/aliyun/requests/compute/reboot_server.rb +15 -16
  83. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +12 -36
  84. data/lib/fog/aliyun/requests/compute/start_server.rb +14 -15
  85. data/lib/fog/aliyun/requests/compute/stop_server.rb +13 -14
  86. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +16 -41
  87. data/lib/fog/aliyun/requests/storage/copy_object.rb +11 -14
  88. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -30
  89. data/lib/fog/aliyun/requests/storage/delete_container.rb +11 -14
  90. data/lib/fog/aliyun/requests/storage/delete_object.rb +20 -22
  91. data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -148
  92. data/lib/fog/aliyun/requests/storage/get_container.rb +26 -38
  93. data/lib/fog/aliyun/requests/storage/get_containers.rb +20 -32
  94. data/lib/fog/aliyun/requests/storage/get_object.rb +12 -12
  95. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +11 -11
  96. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +11 -11
  97. data/lib/fog/aliyun/requests/storage/head_object.rb +11 -11
  98. data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -47
  99. data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -104
  100. data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -23
  101. data/lib/fog/aliyun/requests/storage/put_container.rb +12 -12
  102. data/lib/fog/aliyun/requests/storage/put_object.rb +100 -110
  103. data/lib/fog/aliyun/storage.rb +209 -214
  104. data/lib/fog/aliyun/version.rb +1 -1
  105. data/lib/fog/bin/aliyun.rb +5 -5
  106. metadata +55 -4
@@ -13,72 +13,66 @@ module Fog
13
13
 
14
14
  model Fog::Storage::Aliyun::File
15
15
 
16
- def all(options = {})
16
+ def all(_options = {})
17
17
  requires :directory
18
- if directory.key != "" && directory.key != "." && directory.key != nil
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({:prefix => prefix})["Contents"]
22
- if nil == files
23
- return
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
- if file["Key"][0][-1] != "/"
29
- content_length = file["Size"][0].to_i
30
- key = file["Key"][0]
31
- lastModified = file["LastModified"][0]
32
- if lastModified != nil && lastModified != ""
33
- last_modified = (Time.parse(lastModified)).localtime
34
- else
35
- last_modified = nil
36
- end
37
- type = file["Type"][0]
38
- data[i] = {:content_length => content_length,
39
- :key => key,
40
- :last_modified => last_modified,
41
- :etag => file["ETag"][0],
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
- alias_method :each_file_this_page, :each
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 || 10000)
60
- subset = subset.all(:marker => subset.last.key)
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, &block)
62
+ def get(key)
69
63
  requires :directory
70
- if directory.key == ""
71
- object = key
72
- else
73
- object = directory.key+"/"+key
74
- end
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)*(Excon::CHUNK_SIZE)
81
- _end = i*(Excon::CHUNK_SIZE) - 1
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
- date = data[:headers]["Date"]
105
- if date != nil && date != ""
106
- date = (Time.parse(date)).localtime
107
- else
108
- date = nil
109
- end
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
- :body => body,
112
- :content_length => contentLen,
113
- :key => key,
114
- :last_modified => last_modified,
115
- :content_type => data[:headers]["Content-Type"],
116
- :etag => data[:headers]["ETag"],
117
- :date => date,
118
- :connection => data[:headers]["Connection"],
119
- :accept_ranges => data[:headers]["Accept-Ranges"],
120
- :server => data[:headers]["Server"],
121
- :object_type => data[:headers]["x-oss-object-type"],
122
- :content_disposition => data[:headers]["Content-Disposition"]
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
- object = key
132
- else
133
- object = directory.key+"/"+key
134
- end
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
- object = key
142
- else
143
- object = directory.key+"/"+key
144
- end
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
- object = key
152
- else
153
- object = directory.key+"/"+key
154
- end
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, options = {})
144
+ def head(key, _options = {})
159
145
  requires :directory
160
- if directory.key == ""
161
- object = key
162
- else
163
- object = directory.key+"/"+key
164
- end
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]["Last-Modified"]
167
- if lastModified != nil && lastModified != ""
168
- last_modified = (Time.parse(lastModified)).localtime
169
- else
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]["Date"]
174
- if date != nil && date != ""
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
- :content_length => data[:headers]["Content-Length"].to_i,
182
- :key => key,
183
- :last_modified => last_modified,
184
- :content_type => data[:headers]["Content-Type"],
185
- :etag => data[:headers]["ETag"],
186
- :date => date,
187
- :connection => data[:headers]["Connection"],
188
- :accept_ranges => data[:headers]["Accept-Ranges"],
189
- :server => data[:headers]["Server"],
190
- :object_type => data[:headers]["x-oss-object-type"]
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({ :directory => directory }.merge!(attributes))
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 = defaultAliyunUri(_action, _sigNonce, _time)
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
- _InternetChargeType = 'PayByTraffic'
41
- end
42
- _parameters['InternetChargeType']=_InternetChargeType
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
- :expects => [200, 204],
50
- :method => 'GET',
51
- :path => _pathURL
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 = defaultAliyunUri(_action, _sigNonce, _time)
24
-
25
- _parameters['InstanceId']=server_id
26
- _pathURL += '&InstanceId='+server_id
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
- :expects => [200, 204],
33
- :method => 'GET',
34
- :path => _pathURL
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 = defaultAliyunUri(_action, _sigNonce, _time)
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
- :expects => [200, 204],
43
- :method => 'GET',
44
- :path => _pathURL
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