fog-aliyun 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82062a69285f3c3a240f77d49730e674be34e1a4
4
- data.tar.gz: 8054a3818fab3fb5661d45279c88bfd1c3527de3
3
+ metadata.gz: f7c3f28cba2b2acb17e34f8f00a8ed5577bf6c1e
4
+ data.tar.gz: 465522578a4c15f6a1c4b043ee48f89c62dd78bd
5
5
  SHA512:
6
- metadata.gz: '08af5f88a8e2da7ff72366f7fc84f87b135d7d74a1549422fd23cd4c94cdc7ddb778ce2868c351e93d591d1f9a1e9d4219568a4ccda7bda2437c87dd7a020d86'
7
- data.tar.gz: 6db1a3348d5f9a1406fa752be842d17ae507ec915d2baaf3e3bfb37d14aace66d8b76927dc3a43f98819c4e59a7d4efc5f3d9050b9bc1e0d50cfd1db60ffa48e
6
+ metadata.gz: fb70b9d6a7b355632beb07a470c782e2ce53dffd93a9668446648053d24b57b95cd88d5ec262d7dfe34b23be4ed335e08627d9ec9c90292c1dd37b9bd791d71a
7
+ data.tar.gz: 3f2257c4ecbf8842c547e446d3841c048a7ad057c52c39dd1924c6a52f3f754a9edfe2cc373ca5b2ecdcbbe83d92948e932237c57c91aabd030888e6848e6685
data/fog-aliyun.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'fog-aliyun'
8
8
  spec.version = Fog::Aliyun::VERSION
9
9
  spec.authors = ['Qinsi Deng, Jianxun Li, Jane Han']
10
- spec.email = ['dengqs@dtdream.com']
10
+ spec.email = ['dengqinsi@sina.com']
11
11
 
12
12
  spec.summary = 'Fog provider for Aliyun Web Services.'
13
13
  spec.description = 'As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support more aliyun services later.'
@@ -95,7 +95,13 @@ module Fog
95
95
  request :list_vswitchs
96
96
  request :modify_vpc
97
97
  request :modify_vswitch
98
-
98
+ request :list_vpn_gateways
99
+ request :list_vpn_customergateways
100
+ request :list_vpn_connections
101
+ request :create_vpn_customergateway
102
+ request :create_vpn_connection
103
+ request :delete_vpn_customergateway
104
+ request :delete_vpn_connection
99
105
  # VRouter
100
106
  request :list_vrouters
101
107
 
@@ -271,13 +277,21 @@ module Fog
271
277
  @path = uri.path
272
278
  @port = uri.port
273
279
  @scheme = uri.scheme
274
-
280
+
281
+ vpcuri = URI.parse("https://vpc.aliyuncs.com")
282
+ @vpchost = vpcuri.host
283
+ @vpcpath = vpcuri.path
284
+ @vpcport = vpcuri.port
285
+ @vpcscheme = vpcuri.scheme
286
+
275
287
  @persistent = options[:persistent] || false
276
288
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
289
+ @VPCconnection = Fog::Core::Connection.new("#{@vpcscheme}://#{@vpchost}:#{@vpcport}", @persistent, @connection_options)
277
290
  end
278
291
 
279
292
  def reload
280
293
  @connection.reset
294
+ @VPCconnection.reset
281
295
  end
282
296
 
283
297
  def request(params)
@@ -305,6 +319,31 @@ module Fog
305
319
  response
306
320
  end
307
321
 
322
+ def VPCrequest(params)
323
+ begin
324
+ response = @VPCconnection.request(params.merge(headers: {
325
+ 'Content-Type' => 'application/json',
326
+ 'Accept' => 'application/json',
327
+ 'X-Auth-Token' => @auth_token
328
+ }.merge!(params[:headers] || {}),
329
+ path: "#{@path}/#{params[:path]}",
330
+ query: params[:query]))
331
+ rescue Excon::Errors::HTTPStatusError => error
332
+ raise case error
333
+ when Excon::Errors::NotFound
334
+ Fog::Compute::Aliyun::NotFound.slurp(error)
335
+ else
336
+ error
337
+ end
338
+ end
339
+
340
+ if !response.body.empty? && response.get_header('Content-Type') == 'application/json'
341
+ response.body = Fog::JSON.decode(response.body)
342
+ end
343
+
344
+ response
345
+ end
346
+
308
347
  # operation compute-- default URL
309
348
  def defaultAliyunUri(action, sigNonce, time)
310
349
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
@@ -312,6 +351,12 @@ module Fog
312
351
  '?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2014-05-26&Timestamp=' + urlTimeFormat
313
352
  end
314
353
 
354
+ def defaultAliyunVPCUri(action, sigNonce, time)
355
+ parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
356
+ urlTimeFormat = URI.encode(parTimeFormat, ':')
357
+ '?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2016-04-28&Timestamp=' + urlTimeFormat
358
+ end
359
+
315
360
  # generate random num
316
361
  def randonStr
317
362
  numStr = rand(100_000).to_s
@@ -337,6 +382,22 @@ module Fog
337
382
  para
338
383
  end
339
384
 
385
+ def defalutVPCParameters(action, sigNonce, time)
386
+ parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
387
+ para = {
388
+ 'Format' => 'JSON',
389
+ 'Version' => '2016-04-28',
390
+ 'Action' => action,
391
+ 'AccessKeyId' => @aliyun_accesskey_id,
392
+ 'SignatureVersion' => '1.0',
393
+ 'SignatureMethod' => 'HMAC-SHA1',
394
+ 'SignatureNonce' => sigNonce,
395
+ 'RegionId' => @aliyun_region_id,
396
+ 'Timestamp' => parTimeFormat
397
+ }
398
+ para
399
+ end
400
+
340
401
  # compute signature
341
402
  def sign(accessKeySecret, parameters)
342
403
  sortedParameters = parameters.sort
@@ -0,0 +1,58 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_vpn_connection(customergatewayId, vpngatewayId, localsubnet, remotesubnet,options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
7
+ action = 'CreateVpnConnection'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ parameters['CustomerGatewayId'] = customergatewayId
15
+ pathUrl += '&CustomerGatewayId='
16
+ pathUrl += customergatewayId
17
+
18
+ parameters['VpnGatewayId'] = vpngatewayId
19
+ pathUrl += '&VpnGatewayId='
20
+ pathUrl += vpngatewayId
21
+
22
+ parameters['LocalSubnet'] = localsubnet
23
+ pathUrl += '&LocalSubnet='
24
+ pathUrl += localsubnet
25
+
26
+ parameters['RemoteSubnet'] = remotesubnet
27
+ pathUrl += '&RemoteSubnet='
28
+ pathUrl += remotesubnet
29
+
30
+ name = options[:name]
31
+ ipsecconfig = options[:ipsecconfig]
32
+
33
+ if name
34
+ parameters['Name'] = name
35
+ pathUrl += '&Name='
36
+ pathUrl += name
37
+ end
38
+
39
+ if ipsecconfig
40
+ parameters['IpsecConfig'] = ipsecconfig
41
+ pathUrl += '&IpsecConfig='
42
+ pathUrl += ipsecconfig
43
+ end
44
+
45
+ signature = sign(@aliyun_accesskey_secret, parameters)
46
+ pathUrl += '&Signature='
47
+ pathUrl += signature
48
+
49
+ VPCrequest(
50
+ expects: [200, 203],
51
+ method: 'GET',
52
+ path: pathUrl
53
+ )
54
+ end
55
+ end
56
+ end # aliyun
57
+ end # compute
58
+ end # fog
@@ -0,0 +1,48 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_vpn_customergateway(ipaddress, options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
7
+ action = 'CreateCustomerGateway'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ parameters['IpAddress'] = ipaddress
15
+ pathUrl += '&IpAddress='
16
+ pathUrl += ipaddress
17
+
18
+
19
+
20
+ name = options[:name]
21
+ desc = options[:description]
22
+
23
+ if name
24
+ parameters['Name'] = name
25
+ pathUrl += '&Name='
26
+ pathUrl += name
27
+ end
28
+
29
+ if desc
30
+ parameters['Description'] = desc
31
+ pathUrl += '&Description='
32
+ pathUrl += desc
33
+ end
34
+
35
+ signature = sign(@aliyun_accesskey_secret, parameters)
36
+ pathUrl += '&Signature='
37
+ pathUrl += signature
38
+
39
+ VPCrequest(
40
+ expects: [200, 203],
41
+ method: 'GET',
42
+ path: pathUrl
43
+ )
44
+ end
45
+ end
46
+ end # aliyun
47
+ end # compute
48
+ end # fog
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def delete_vpn_connection(vpn_connectionid)
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&deletevswitch]
7
+ action = 'DeleteVpnConnection'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ if vpn_connectionid
15
+ parameters['VpnConnectionId'] = vpn_connectionid
16
+ pathUrl += '&VpnConnectionId='
17
+ pathUrl += vpn_connectionid
18
+ else
19
+ raise ArgumentError, 'Missing required vpn_connectionid'
20
+ end
21
+
22
+ signature = sign(@aliyun_accesskey_secret, parameters)
23
+ pathUrl += '&Signature='
24
+ pathUrl += signature
25
+
26
+ VPCrequest(
27
+ expects: [200, 203],
28
+ method: 'GET',
29
+ path: pathUrl
30
+ )
31
+ end
32
+ end
33
+ end # aliyun
34
+ end # compute
35
+ end # fog
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def delete_vpn_customergateway(vpn_customergatewayid)
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&deletevswitch]
7
+ action = 'DeleteCustomerGateway'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ if vpn_customergatewayid
15
+ parameters['CustomerGatewayId'] = vpn_customergatewayid
16
+ pathUrl += '&CustomerGatewayId='
17
+ pathUrl += vpn_customergatewayid
18
+ else
19
+ raise ArgumentError, 'Missing required vpn_customergatewayid'
20
+ end
21
+
22
+ signature = sign(@aliyun_accesskey_secret, parameters)
23
+ pathUrl += '&Signature='
24
+ pathUrl += signature
25
+
26
+ VPCrequest(
27
+ expects: [200, 203],
28
+ method: 'GET',
29
+ path: pathUrl
30
+ )
31
+ end
32
+ end
33
+ end # aliyun
34
+ end # compute
35
+ end # fog
@@ -18,7 +18,8 @@ module Fog
18
18
  parameters['DiskId'] = diskId
19
19
  pathUrl += '&DiskId='
20
20
  pathUrl += diskId
21
-
21
+
22
+ device = _options[:device]
22
23
  if device
23
24
  parameters['Device'] = device
24
25
  pathUrl += '&Device='
@@ -0,0 +1,49 @@
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&describevpcs]
6
+ def list_vpn_connections(options = {})
7
+ action = 'DescribeVpnConnections'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ _VpnGatewayId = options[:vpngatewayId]
15
+ if _VpnGatewayId
16
+ parameters['VpnGatewayId'] = _VpnGatewayId
17
+ pathUrl += '&VpnGatewayId='
18
+ pathUrl += _VpnGatewayId
19
+ end
20
+
21
+ pageNumber = options[:pageNumber]
22
+ pageSize = options[:pageSize]
23
+ if pageNumber
24
+ parameters['PageNumber'] = pageNumber
25
+ pathUrl += '&PageNumber='
26
+ pathUrl += pageNumber
27
+ end
28
+
29
+ pageSize = '50' unless pageSize
30
+ parameters['PageSize'] = pageSize
31
+ pathUrl += '&PageSize='
32
+ pathUrl += pageSize
33
+
34
+ signature = sign(@aliyun_accesskey_secret, parameters)
35
+ pathUrl += '&Signature='
36
+ pathUrl += signature
37
+
38
+ VPCrequest(
39
+ expects: [200, 203],
40
+ method: 'GET',
41
+ path: pathUrl
42
+ )
43
+ end
44
+ end
45
+
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,43 @@
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&describevpcs]
6
+ def list_vpn_customergateways(options = {})
7
+ action = 'DescribeCustomerGateways'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+
15
+ pageNumber = options[:pageNumber]
16
+ pageSize = options[:pageSize]
17
+ if pageNumber
18
+ parameters['PageNumber'] = pageNumber
19
+ pathUrl += '&PageNumber='
20
+ pathUrl += pageNumber
21
+ end
22
+
23
+ pageSize = '50' unless pageSize
24
+ parameters['PageSize'] = pageSize
25
+ pathUrl += '&PageSize='
26
+ pathUrl += pageSize
27
+
28
+ signature = sign(@aliyun_accesskey_secret, parameters)
29
+ pathUrl += '&Signature='
30
+ pathUrl += signature
31
+
32
+ VPCrequest(
33
+ expects: [200, 203],
34
+ method: 'GET',
35
+ path: pathUrl
36
+ )
37
+ end
38
+ end
39
+
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,49 @@
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&describevpcs]
6
+ def list_vpn_gateways(options = {})
7
+ action = 'DescribeVpnGateways'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ _VpcId = options[:vpcId]
15
+ if _VpcId
16
+ parameters['VpcId'] = _VpcId
17
+ pathUrl += '&VpcId='
18
+ pathUrl += _VpcId
19
+ end
20
+
21
+ pageNumber = options[:pageNumber]
22
+ pageSize = options[:pageSize]
23
+ if pageNumber
24
+ parameters['PageNumber'] = pageNumber
25
+ pathUrl += '&PageNumber='
26
+ pathUrl += pageNumber
27
+ end
28
+
29
+ pageSize = '50' unless pageSize
30
+ parameters['PageSize'] = pageSize
31
+ pathUrl += '&PageSize='
32
+ pathUrl += pageSize
33
+
34
+ signature = sign(@aliyun_accesskey_secret, parameters)
35
+ pathUrl += '&Signature='
36
+ pathUrl += signature
37
+
38
+ VPCrequest(
39
+ expects: [200, 203],
40
+ method: 'GET',
41
+ path: pathUrl
42
+ )
43
+ end
44
+ end
45
+
46
+
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Aliyun
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-aliyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qinsi Deng, Jianxun Li, Jane Han
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-21 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,7 +159,7 @@ dependencies:
159
159
  description: As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support
160
160
  more aliyun services later.
161
161
  email:
162
- - dengqs@dtdream.com
162
+ - dengqinsi@sina.com
163
163
  executables: []
164
164
  extensions: []
165
165
  extra_rdoc_files: []
@@ -223,6 +223,8 @@ files:
223
223
  - lib/fog/aliyun/requests/compute/create_server.rb
224
224
  - lib/fog/aliyun/requests/compute/create_snapshot.rb
225
225
  - lib/fog/aliyun/requests/compute/create_vpc.rb
226
+ - lib/fog/aliyun/requests/compute/create_vpn_connection.rb
227
+ - lib/fog/aliyun/requests/compute/create_vpn_customergateway.rb
226
228
  - lib/fog/aliyun/requests/compute/create_vswitch.rb
227
229
  - lib/fog/aliyun/requests/compute/delete_disk.rb
228
230
  - lib/fog/aliyun/requests/compute/delete_image.rb
@@ -234,6 +236,8 @@ files:
234
236
  - lib/fog/aliyun/requests/compute/delete_server.rb
235
237
  - lib/fog/aliyun/requests/compute/delete_snapshot.rb
236
238
  - lib/fog/aliyun/requests/compute/delete_vpc.rb
239
+ - lib/fog/aliyun/requests/compute/delete_vpn_connection.rb
240
+ - lib/fog/aliyun/requests/compute/delete_vpn_customergateway.rb
237
241
  - lib/fog/aliyun/requests/compute/delete_vswitch.rb
238
242
  - lib/fog/aliyun/requests/compute/detach_disk.rb
239
243
  - lib/fog/aliyun/requests/compute/join_security_group.rb
@@ -248,6 +252,9 @@ files:
248
252
  - lib/fog/aliyun/requests/compute/list_servers.rb
249
253
  - lib/fog/aliyun/requests/compute/list_snapshots.rb
250
254
  - lib/fog/aliyun/requests/compute/list_vpcs.rb
255
+ - lib/fog/aliyun/requests/compute/list_vpn_connections.rb
256
+ - lib/fog/aliyun/requests/compute/list_vpn_customergateways.rb
257
+ - lib/fog/aliyun/requests/compute/list_vpn_gateways.rb
251
258
  - lib/fog/aliyun/requests/compute/list_vrouters.rb
252
259
  - lib/fog/aliyun/requests/compute/list_vswitchs.rb
253
260
  - lib/fog/aliyun/requests/compute/list_zones.rb
@@ -297,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
304
  version: '0'
298
305
  requirements: []
299
306
  rubyforge_project:
300
- rubygems_version: 2.6.10
307
+ rubygems_version: 2.6.14
301
308
  signing_key:
302
309
  specification_version: 4
303
310
  summary: Fog provider for Aliyun Web Services.