fog-aliyun 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +114 -0
  5. data/README.md +61 -3
  6. data/fog-aliyun.gemspec +9 -4
  7. data/lib/fog/aliyun/compute.rb +34 -10
  8. data/lib/fog/aliyun/models/compute/flavor.rb +28 -0
  9. data/lib/fog/aliyun/models/compute/flavors.rb +13 -0
  10. data/lib/fog/aliyun/models/compute/image.rb +3 -1
  11. data/lib/fog/aliyun/models/compute/server.rb +13 -1
  12. data/lib/fog/aliyun/models/compute/servers.rb +2 -1
  13. data/lib/fog/aliyun/models/compute/vpcs.rb +1 -1
  14. data/lib/fog/aliyun/models/storage/directories.rb +34 -17
  15. data/lib/fog/aliyun/models/storage/directory.rb +102 -14
  16. data/lib/fog/aliyun/models/storage/file.rb +130 -120
  17. data/lib/fog/aliyun/models/storage/files.rb +69 -128
  18. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +1 -1
  19. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +1 -1
  20. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +1 -1
  21. data/lib/fog/aliyun/requests/compute/attach_disk.rb +4 -2
  22. data/lib/fog/aliyun/requests/compute/create_disk.rb +2 -2
  23. data/lib/fog/aliyun/requests/compute/create_image.rb +1 -1
  24. data/lib/fog/aliyun/requests/compute/create_security_group.rb +1 -1
  25. data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +5 -3
  26. data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +4 -2
  27. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +5 -3
  28. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +4 -2
  29. data/lib/fog/aliyun/requests/compute/create_server.rb +23 -12
  30. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +1 -1
  31. data/lib/fog/aliyun/requests/compute/create_vpc.rb +4 -2
  32. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +4 -2
  33. data/lib/fog/aliyun/requests/compute/delete_disk.rb +1 -1
  34. data/lib/fog/aliyun/requests/compute/delete_image.rb +1 -1
  35. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +1 -1
  36. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +5 -3
  37. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +4 -2
  38. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +5 -3
  39. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +4 -2
  40. data/lib/fog/aliyun/requests/compute/delete_server.rb +1 -1
  41. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +1 -1
  42. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +1 -1
  43. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +1 -1
  44. data/lib/fog/aliyun/requests/compute/detach_disk.rb +4 -2
  45. data/lib/fog/aliyun/requests/compute/join_security_group.rb +1 -1
  46. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +1 -1
  47. data/lib/fog/aliyun/requests/compute/list_disks.rb +1 -1
  48. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +1 -1
  49. data/lib/fog/aliyun/requests/compute/list_images.rb +1 -1
  50. data/lib/fog/aliyun/requests/compute/list_route_tables.rb +1 -1
  51. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +1 -1
  52. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +1 -1
  53. data/lib/fog/aliyun/requests/compute/list_server_types.rb +3 -3
  54. data/lib/fog/aliyun/requests/compute/list_servers.rb +10 -10
  55. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +1 -1
  56. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +1 -1
  57. data/lib/fog/aliyun/requests/compute/list_vrouters.rb +1 -1
  58. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +1 -1
  59. data/lib/fog/aliyun/requests/compute/list_zones.rb +1 -1
  60. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +4 -2
  61. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +4 -2
  62. data/lib/fog/aliyun/requests/compute/reboot_server.rb +1 -1
  63. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +1 -1
  64. data/lib/fog/aliyun/requests/compute/start_server.rb +1 -1
  65. data/lib/fog/aliyun/requests/compute/stop_server.rb +1 -1
  66. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +1 -1
  67. data/lib/fog/aliyun/requests/storage/abort_multipart_upload.rb +22 -0
  68. data/lib/fog/aliyun/requests/storage/complete_multipart_upload.rb +21 -0
  69. data/lib/fog/aliyun/requests/storage/copy_object.rb +16 -23
  70. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +5 -14
  71. data/lib/fog/aliyun/requests/storage/delete_multiple_objects.rb +20 -0
  72. data/lib/fog/aliyun/requests/storage/delete_object.rb +12 -35
  73. data/lib/fog/aliyun/requests/storage/get_bucket.rb +30 -110
  74. data/lib/fog/aliyun/requests/storage/get_bucket_location.rb +33 -0
  75. data/lib/fog/aliyun/requests/storage/get_object.rb +29 -24
  76. data/lib/fog/aliyun/requests/storage/get_object_acl.rb +30 -0
  77. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +14 -15
  78. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +14 -15
  79. data/lib/fog/aliyun/requests/storage/get_service.rb +13 -0
  80. data/lib/fog/aliyun/requests/storage/head_object.rb +27 -18
  81. data/lib/fog/aliyun/requests/storage/initiate_multipart_upload.rb +19 -0
  82. data/lib/fog/aliyun/requests/storage/list_buckets.rb +8 -26
  83. data/lib/fog/aliyun/requests/storage/list_objects.rb +14 -73
  84. data/lib/fog/aliyun/requests/storage/put_bucket.rb +4 -10
  85. data/lib/fog/aliyun/requests/storage/put_object.rb +18 -162
  86. data/lib/fog/aliyun/requests/storage/upload_part.rb +24 -0
  87. data/lib/fog/aliyun/storage.rb +57 -29
  88. data/lib/fog/aliyun/version.rb +1 -1
  89. data/lib/fog/aliyun.rb +6 -9
  90. data/lib/fog/bin/aliyun.rb +1 -1
  91. metadata +118 -47
  92. data/lib/fog/aliyun/requests/storage/delete_container.rb +0 -33
  93. data/lib/fog/aliyun/requests/storage/get_container.rb +0 -56
  94. data/lib/fog/aliyun/requests/storage/get_containers.rb +0 -60
  95. data/lib/fog/aliyun/requests/storage/put_container.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e8112e65fc18f3f89cf72ff352d04598767cd95e
4
- data.tar.gz: b066bbda00dd2dca8ce98df46390a96d7cc84796
2
+ SHA256:
3
+ metadata.gz: 902530b35b7b3b8213965642cb9994b53399a02e65cf75270fc30f9f4a662ad2
4
+ data.tar.gz: 9a413e6577adbed08130870c7e7aa751ceb80aec8bb53d42eb43f694cff56a0e
5
5
  SHA512:
6
- metadata.gz: fe59bca5c4b8831600e06588444637efd12426a88535d742b140b44cdb05dde0049bf1af41cd06fd307137327c50c3d6ad2265cc7ba8e8d8c1ecbb6e6b5722b5
7
- data.tar.gz: 96e3d984bba498615c0939a75182ff8d0d0f290642307e646bcb3c4d4c965f5c60483b01003d195ae8d6034027092192cfda40ef860777bdf1b17e4b77967e00
6
+ metadata.gz: 3d8a867a2cd5be94ec813a8ee11371eed34530aff2554227590c5fdcae9b0ebb197f421ecd7716c38fd9cc930f91f5b2390b28b247fd9dca2cc87f08c4d3311f
7
+ data.tar.gz: dc7c248af9cb3388bf2453f8c4096935dafa3ca251c86d75da251c61feda0980d36fd01241a53b4bbff97f0460df609e9634062bc73df851e8510b6368d6e653
data/.gitignore CHANGED
@@ -23,3 +23,5 @@ tmp
23
23
  *.a
24
24
  mkmf.log
25
25
  gemfiles/*.lock
26
+ morethan100m
27
+ *.log
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.1
1
+ 3.0.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,114 @@
1
+ ## 0.4.1 (Unreleased)
2
+ ## 0.4.0 (August 17, 2022)
3
+
4
+ IMPROVEMENTS:
5
+ - Ruby 3 [GH-158](https://github.com/fog/fog-aliyun/pull/158)
6
+
7
+ ## 0.3.19 (August 17, 2020)
8
+
9
+ IMPROVEMENTS:
10
+
11
+ - Upgrade oss ruby sdk to support setting log level [GH-152](https://github.com/fog/fog-aliyun/pull/152)
12
+
13
+ ## 0.3.18 (August 03, 2020)
14
+
15
+ IMPROVEMENTS:
16
+
17
+ - reconstruct perform test [GH-148](https://github.com/fog/fog-aliyun/pull/148)
18
+ - Reconstruct fog-aliyun by using oss [GH-147](https://github.com/fog/fog-aliyun/pull/147)
19
+ - reconstruct cover case test [GH-146](https://github.com/fog/fog-aliyun/pull/146)
20
+ - reconstruct case test [GH-144](https://github.com/fog/fog-aliyun/pull/144)
21
+ - reconstruct parts two of file [GH-143](https://github.com/fog/fog-aliyun/pull/143)
22
+ - implement blobstore for cloud_controller_ng [GH-142](https://github.com/fog/fog-aliyun/pull/142)
23
+ - reconstruct parts of file [GH-141](https://github.com/fog/fog-aliyun/pull/141)
24
+ - reconstruct the files [GH-140](https://github.com/fog/fog-aliyun/pull/140)
25
+ - reconstruct the directory [GH-139](https://github.com/fog/fog-aliyun/pull/139)
26
+ - reconstruct the directories [GH-138](https://github.com/fog/fog-aliyun/pull/138)
27
+ - improve files.get code [GH-137](https://github.com/fog/fog-aliyun/pull/137)
28
+ - add testcase for testing head notexistfile [GH-136](https://github.com/fog/fog-aliyun/pull/136)
29
+ - improve head_object using oss sdk [GH-135](https://github.com/fog/fog-aliyun/pull/135)
30
+
31
+ BUG FIXES:
32
+
33
+ - fix files all options problem [GH-149](https://github.com/fog/fog-aliyun/pull/149)
34
+
35
+ ## 0.3.17 (July 06, 2020)
36
+
37
+ IMPROVEMENTS:
38
+ - adater oss_sdk_log_path [GH-125](https://github.com/fog/fog-aliyun/pull/125)
39
+ - update ruby sdk to 0.7.3 [GH-124](https://github.com/fog/fog-aliyun/pull/124)
40
+ - adapter maxkeys conversion problem [GH-123](https://github.com/fog/fog-aliyun/pull/123)
41
+ - [Enhance tests][Auth & Connectivity scenarios] Test that API cannot be accessed using incorrect credentials [GH-117](https://github.com/fog/fog-aliyun/pull/117)
42
+ - [Enhance tests][Auth & Connectivity scenarios] Test that API can be accessed using valid credentials [GH-116](https://github.com/fog/fog-aliyun/pull/116)
43
+ - adapter custom log environment variable [GH-114](https://github.com/fog/fog-aliyun/pull/114)
44
+ - [Enhance tests][Buckets scenarios] (NEGATIVE TEST) Test that error is thrown when trying to access non-existing bucket [GH-110](https://github.com/fog/fog-aliyun/pull/110)
45
+ - [Enhance tests][Buckets scenarios] (NEGATIVE TEST) Test that error is thrown when trying to create already existing bucket [GH-109](https://github.com/fog/fog-aliyun/pull/109)
46
+ - [Enhance tests][Buckets scenarios] Test that it is possible to destroy a bucket [GH-108](https://github.com/fog/fog-aliyun/pull/108)
47
+ - [Enhance tests][Buckets scenarios] Test that it is possible to create a new bucket [GH-107](https://github.com/fog/fog-aliyun/pull/107)
48
+ - [Enhance tests][Buckets scenarios] Test that it is possible to list all buckets [GH-105](https://github.com/fog/fog-aliyun/pull/105)
49
+ - [Enhance tests][Files & Directory scenarios] Test getting bucket when directory exists named with the same name as a bucket [GH-101](https://github.com/fog/fog-aliyun/pull/101)
50
+ - [Enhance tests][Files & Directory scenarios] Test file copy operations [GH-100](https://github.com/fog/fog-aliyun/pull/100)
51
+ - reset the last PR [GH-133](https://github.com/fog/fog-aliyun/pull/133)
52
+ - improve put_object_with_body and head_object using sdk do_request [GH-131](https://github.com/fog/fog-aliyun/pull/131)
53
+
54
+ BUG FIXES:
55
+ - fix max key again [GH-128](https://github.com/fog/fog-aliyun/pull/128)
56
+ - fix downloading object when pushing app twice [GH-127](https://github.com/fog/fog-aliyun/pull/127)
57
+ - fix max key [GH-126](https://github.com/fog/fog-aliyun/pull/126)
58
+ - fix max-keys conversion problem [GH-121](https://github.com/fog/fog-aliyun/pull/121)
59
+ - fix @aliyun_oss_sdk_log_path is nil [GH-132](https://github.com/fog/fog-aliyun/pull/132)
60
+
61
+ ## 0.3.16 (June 18, 2020)
62
+
63
+ IMPROVEMENTS:
64
+ - [Enhance tests][Files & Directory scenarios] Test get nested directories and files in nested directory [GH-98](https://github.com/fog/fog-aliyun/pull/98)
65
+ - remove get_bucket_location and use ruby sdk to improve performance when uploading object [GH-97](https://github.com/fog/fog-aliyun/pull/97)
66
+ - using bucket_exist to checking bucket [GH-95](https://github.com/fog/fog-aliyun/pull/95)
67
+ - add change log [GH-94](https://github.com/fog/fog-aliyun/pull/94)
68
+
69
+ BUG FIXES:
70
+ - fix delete all of files bug when specifying a prefix [GH-102](https://github.com/fog/fog-aliyun/pull/102)
71
+
72
+ ## 0.3.15 (June 05, 2020)
73
+
74
+ BUG FIXES:
75
+ - change dependence ruby sdk to gems [GH-92](https://github.com/fog/fog-aliyun/pull/92)
76
+
77
+ ## 0.3.13 (June 02, 2020)
78
+
79
+ IMPROVEMENTS:
80
+ - using ruby sdk to delete object [GH-90](https://github.com/fog/fog-aliyun/pull/90)
81
+
82
+ ## 0.3.12 (May 28, 2020 )
83
+
84
+ BUG FIXES:
85
+ - add missing dependence [GH-88](https://github.com/fog/fog-aliyun/pull/88)
86
+
87
+ ## 0.3.11 (May 25, 2020)
88
+
89
+ IMPROVEMENTS:
90
+ - using oss ruby sdk to improve downloading object performance [GH-86](https://github.com/fog/fog-aliyun/pull/86)
91
+ - Add performance tests [GH-85](https://github.com/fog/fog-aliyun/pull/85)
92
+ - [Enhance tests][Entity operations]Add tests for each type of entity that validates the CURD operations [GH-84](https://github.com/fog/fog-aliyun/pull/84)
93
+ - [Enhance tests][Auth & Connectivity scenarios] Test region is selected according to provider configuration [GH-83](https://github.com/fog/fog-aliyun/pull/83)
94
+ - [Enhance tests][Files & Directory scenarios] test file listing using parameters such as prefix, marker, delimeter and maxKeys [GH-82](https://github.com/fog/fog-aliyun/pull/82)
95
+ - [Enhance tests][Files & Directory scenarios]test directory listing using parameters such as prefix, marker, delimeter and maxKeys [GH-81](https://github.com/fog/fog-aliyun/pull/81)
96
+ - [Enhance tests][Files & Directory scenarios]Test that it is possible to upload (write) large file (multi part upload) [GH-79](https://github.com/fog/fog-aliyun/pull/79)
97
+ - upgrade deprecated code [GH-78](https://github.com/fog/fog-aliyun/pull/78)
98
+ - improve fog/integration_spec [GH-77](https://github.com/fog/fog-aliyun/pull/77)
99
+ - [Enhance tests][Files & Directory scenarios]Test that it is possible to upload (write) a file [GH-76](https://github.com/fog/fog-aliyun/pull/76)
100
+ - upgrade deprecated code [GH-74](https://github.com/fog/fog-aliyun/pull/74)
101
+ - support https scheme [GH-71](https://github.com/fog/fog-aliyun/pull/71)
102
+ - [Enhance tests][Files & Directory scenarios]Test that it is possible to destroy a file/directory [GH-69](https://github.com/fog/fog-aliyun/pull/69)
103
+ - improve fog/integration_spec [GH-68](https://github.com/fog/fog-aliyun/pull/68)
104
+ - Implement basic integration tests [GH-66](https://github.com/fog/fog-aliyun/pull/66)
105
+
106
+ ## 0.3.10 (May 07, 2020)
107
+
108
+ IMPROVEMENTS:
109
+ - Set max limitation to 1000 when get objects [GH-64](https://github.com/fog/fog-aliyun/pull/64)
110
+
111
+ ## 0.3.9 (May 07, 2020)
112
+
113
+ BUG FIXES:
114
+ - diectories.get supports options to filter the specified objects [GH-62](https://github.com/fog/fog-aliyun/pull/62)
data/README.md CHANGED
@@ -30,9 +30,9 @@ Since it's a bad practice to have your credentials in source code, you should lo
30
30
 
31
31
  ```
32
32
  default:
33
- :aliyun_accesskey_id: <YOUR_ACCESS_KEY_ID>,
34
- :aliyun_accesskey_secret: <YOUR_SECRET_ACCESS_KEY>,
35
- :aliyun_region_id: <YOUR_TARGET_REGION>
33
+ aliyun_accesskey_id: "<YOUR_ACCESS_KEY_ID>"
34
+ aliyun_accesskey_secret: "<YOUR_SECRET_ACCESS_KEY>"
35
+ aliyun_region_id: "<YOUR_TARGET_REGION>"
36
36
  ```
37
37
 
38
38
  ### Connecting to OSS
@@ -307,6 +307,64 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
307
307
 
308
308
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
309
309
 
310
+ ## Testing
311
+
312
+
313
+
314
+ To run test suite use the following command:
315
+
316
+ ```
317
+ rake spec
318
+ ```
319
+
320
+ ### Code coverage
321
+
322
+ To run test suite with code coverage:
323
+
324
+ ```
325
+ export COVERAGE=true
326
+ rake spec
327
+ ```
328
+
329
+ The result will be generated in `coverage` folder.
330
+
331
+ ### Integration tests
332
+
333
+ To run integration tests please prepare a set of AliCloud credentials to be used by integration tests.
334
+
335
+ Define the credentials and bucket in `~/.fog` file in using following format:
336
+
337
+ ```
338
+ default:
339
+ aliyun_accesskey_id: "...access key..." # You can create a set of credentials
340
+ aliyun_accesskey_secret: "...secret..." # using Alicloud console portal
341
+ aliyun_region_id: "...region name..." # Example: cn-shanghai
342
+ aliyun_oss_bucket: "...name of the bucket..." # Example: fog-integration-test-bucket
343
+ ```
344
+
345
+ WARNING: Do NOT use any productive account credentials and buckets for the testing, it may be harmful to your data!
346
+
347
+ The tests are using [https://github.com/aliyun/aliyun-cli#installation](Aliyun CLI) to setup integration bucket and content for tests,
348
+ please install it locally before running integration tests.
349
+
350
+ Aliyun CLI will be configured automatically as part of test execution using the credentials provided for fog connection.
351
+
352
+ Then run the test suite with `INTEGRATION` environment variable to activate integration tests:
353
+
354
+ ```
355
+ export INTEGRATION=true
356
+ rake spec
357
+ ```
358
+
359
+ ### Performance test
360
+
361
+ Performance tests are providing memory consumption report for download/upload operations.
362
+
363
+ ```
364
+ export PERFORMANCE=true
365
+ rake spec
366
+ ```
367
+
310
368
  ## License
311
369
 
312
370
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/fog-aliyun.gemspec CHANGED
@@ -7,10 +7,10 @@ require 'fog/aliyun/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'fog-aliyun'
9
9
  spec.version = Fog::Aliyun::VERSION
10
- spec.authors = ['Qinsi Deng, Jianxun Li, Jane Han']
11
- spec.email = ['dengqinsi@sina.com']
10
+ spec.authors = ['Qinsi Deng, Jianxun Li, Jane Han, Guimin He']
11
+ spec.email = ['dengqinsi@sina.com', 'guimin.hgm@alibaba-inc.com']
12
12
 
13
- spec.summary = 'Fog provider for Aliyun Web Services.'
13
+ spec.summary = 'Fog provider for Alibaba Cloud Web Services.'
14
14
  spec.description = 'As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support more aliyun services later.'
15
15
  spec.homepage = 'https://github.com/fog/fog-aliyun'
16
16
  spec.license = 'MIT'
@@ -21,12 +21,17 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ['lib']
22
22
 
23
23
  spec.add_development_dependency 'bundler'
24
- spec.add_development_dependency 'mime-types', '~> 2.6', '>= 2.6.2'
24
+ spec.add_development_dependency 'mime-types', '~> 3.4'
25
25
  spec.add_development_dependency 'pry-nav'
26
26
  spec.add_development_dependency 'rake'
27
27
  spec.add_development_dependency 'rspec'
28
28
  spec.add_development_dependency 'rubocop'
29
+ spec.add_development_dependency 'simplecov'
30
+ spec.add_development_dependency 'memory_profiler'
31
+ spec.add_development_dependency 'aliyun-sdk', '~> 0.8.0'
29
32
 
33
+ spec.add_dependency 'addressable', '~> 2.8.0'
34
+ spec.add_dependency 'aliyun-sdk', '~> 0.8.0'
30
35
  spec.add_dependency 'fog-core'
31
36
  spec.add_dependency 'fog-json'
32
37
  spec.add_dependency 'ipaddress', '~> 0.8'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'addressable'
4
+
3
5
  module Fog
4
6
  module Compute
5
7
  class Aliyun < Fog::Service
@@ -36,7 +38,8 @@ module Fog
36
38
  collection :route_tables
37
39
  model :route_entry
38
40
  collection :route_entrys
39
-
41
+ model :flavor
42
+ collection :flavors
40
43
  ## REQUESTS
41
44
  #
42
45
  request_path 'fog/aliyun/requests/compute'
@@ -117,6 +120,9 @@ module Fog
117
120
  request :attach_disk
118
121
  request :detach_disk
119
122
 
123
+ # PublicIpAddress
124
+ request :allocate_public_ip_address
125
+
120
126
  class Mock
121
127
  attr_reader :auth_token
122
128
  attr_reader :auth_token_expiration
@@ -271,7 +277,6 @@ module Fog
271
277
  missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
272
278
  missing_credentials << :aliyun_region_id unless @aliyun_region_id
273
279
  missing_credentials << :aliyun_url unless @aliyun_url
274
- missing_credentials << :aliyun_zone_id unless @aliyun_zone_id
275
280
  raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
276
281
 
277
282
  @connection_options = options[:connection_options] || {}
@@ -347,13 +352,27 @@ module Fog
347
352
  # operation compute-- default URL
348
353
  def defaultAliyunUri(action, sigNonce, time)
349
354
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
350
- urlTimeFormat = URI.encode(parTimeFormat, ':')
355
+ urlTimeFormat = Addressable::URI.encode_component(parTimeFormat, Addressable::URI::CharacterClasses::UNRESERVED + '|')
351
356
  '?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
352
357
  end
353
358
 
359
+ def defaultAliyunQueryParameters(action, sigNonce, time)
360
+ {
361
+ Format: 'JSON',
362
+ AccessKeyId: @aliyun_accesskey_id,
363
+ Action: action,
364
+ SignatureMethod: 'HMAC-SHA1',
365
+ RegionId: @aliyun_region_id,
366
+ SignatureNonce: sigNonce,
367
+ SignatureVersion: '1.0',
368
+ Version: '2014-05-26',
369
+ Timestamp: time.strftime('%Y-%m-%dT%H:%M:%SZ')
370
+ }
371
+ end
372
+
354
373
  def defaultAliyunVPCUri(action, sigNonce, time)
355
374
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
356
- urlTimeFormat = URI.encode(parTimeFormat, ':')
375
+ urlTimeFormat = Addressable::URI.encode_component(parTimeFormat, Addressable::URI::CharacterClasses::UNRESERVED + '|')
357
376
  '?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
377
  end
359
378
 
@@ -366,7 +385,7 @@ module Fog
366
385
  end
367
386
 
368
387
  # operation compute--collection of default parameters
369
- def defalutParameters(action, sigNonce, time)
388
+ def defaultParameters(action, sigNonce, time)
370
389
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
371
390
  para = {
372
391
  'Format' => 'JSON',
@@ -399,24 +418,29 @@ module Fog
399
418
  end
400
419
 
401
420
  # compute signature
421
+ # This method should be considered deprecated and replaced with sign_without_encoding, which is better for using querystring hashes and not
422
+ # building querystrings with string concatination.
402
423
  def sign(accessKeySecret, parameters)
424
+ signature = sign_without_encoding(accessKeySecret, parameters)
425
+ Addressable::URI.encode_component(signature, Addressable::URI::CharacterClasses::UNRESERVED + '|')
426
+ end
427
+
428
+ def sign_without_encoding(accessKeySecret, parameters)
403
429
  sortedParameters = parameters.sort
404
430
  canonicalizedQueryString = ''
405
431
  sortedParameters.each do |k, v|
406
- canonicalizedQueryString += '&' + URI.encode(k, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ') + '=' + URI.encode(v, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
432
+ canonicalizedQueryString += '&' + Addressable::URI.encode_component(k, Addressable::URI::CharacterClasses::UNRESERVED + '|') + '=' + Addressable::URI.encode_component(v, Addressable::URI::CharacterClasses::UNRESERVED + '|')
407
433
  end
408
434
 
409
435
  canonicalizedQueryString[0] = ''
410
- stringToSign = 'GET&%2F&' + URI.encode(canonicalizedQueryString, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
436
+ stringToSign = 'GET&%2F&' + Addressable::URI.encode_component(canonicalizedQueryString, Addressable::URI::CharacterClasses::UNRESERVED + '|')
411
437
  key = accessKeySecret + '&'
412
438
 
413
439
  digVer = OpenSSL::Digest.new('sha1')
414
440
  digest = OpenSSL::HMAC.digest(digVer, key, stringToSign)
415
441
  signature = Base64.encode64(digest)
416
442
  signature[-1] = ''
417
- encodedSig = URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
418
-
419
- encodedSig
443
+ signature
420
444
  end
421
445
  end
422
446
  end
@@ -0,0 +1,28 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Aliyun
6
+ class Flavor < Fog::Model
7
+ attribute :base_line_credit, aliases: 'BaseLineCredit'
8
+ attribute :cpu_core_count, aliases: 'CpuCoreCount'
9
+ attribute :eni_private_ip_quantitiy, aliases: 'EniPrivateIpAddressQuantity'
10
+ attribute :eni_quantity, aliases: 'EniQuantity'
11
+ attribute :gpu_amount, aliases: 'GPUAmount'
12
+ attribute :gpu_spec, aliases: 'GPUSpec'
13
+ attribute :intial_credit, aliases: 'IntialCredit'
14
+ attribute :instance_bandwidth_rx, aliases: 'InstanceBandwidthRx'
15
+ attribute :instance_bandwidth_tx, aliases: 'InstanceBandwidthTx'
16
+ attribute :instance_family_level, aliases: 'InstanceFamilyLevel'
17
+ attribute :instance_pps_rx, aliases: 'InstancePpsRx'
18
+ attribute :instance_pps_tx, aliases: 'InstancePpsTx'
19
+ attribute :instance_type_family, alieses: 'InstanceTypeFamily'
20
+ attribute :instance_type_id, aliases: 'InstanceTypeId'
21
+ attribute :local_storage_amount, aliases: 'LocalStorageAmount'
22
+ attribute :local_storage_capacity, aliases: 'LocalStorageCapacity'
23
+ attribute :local_storage_category, aliases: 'LocalStorageCategory'
24
+ attribute :memory_size, alieses: 'MemorySize'
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Flavors < Fog::Collection
5
+ model Fog::Compute::Aliyun::Flavor
6
+ def all
7
+ data = Fog::JSON.decode(service.list_server_types.body)['InstanceTypes']['InstanceType']
8
+ load(data)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -29,7 +29,9 @@ module Fog
29
29
  attribute :snapshot_id, aliases: 'SnapshotId'
30
30
 
31
31
  def initialize(attributes)
32
- self.snapshot_id = attributes['DiskDeviceMappings']['DiskDeviceMapping'][0]['SnapshotId']
32
+ unless attributes['DiskDeviceMappings']['DiskDeviceMapping'].empty?
33
+ self.snapshot_id = attributes['DiskDeviceMappings']['DiskDeviceMapping'][0]['SnapshotId']
34
+ end
33
35
  super
34
36
  end
35
37
 
@@ -34,9 +34,12 @@ module Fog
34
34
  attribute :charge_type, aliases: 'InstanceChargeType'
35
35
  attribute :operation_locks, aliases: 'OperationLocks'
36
36
  attribute :expired_at, aliases: 'ExpiredTime'
37
+ attribute :vswitch_id, aliases: 'VSwitchId'
38
+ attribute :key_pair_name, aliases: 'KeyPairName'
39
+ attribute :user_data, aliases: 'UserData'
37
40
 
38
41
  def image
39
- requires image_id
42
+ requires :image_id
40
43
  Fog::Compute::Aliyun::Image.new(service: service).all(imageId: image_id)[0]
41
44
  end
42
45
 
@@ -45,6 +48,15 @@ module Fog
45
48
  $vpc = Fog::Compute::Aliyun::Vpcs.new(service: service).all('vpcId' => vpc_id)[0]
46
49
  end
47
50
 
51
+ def save(options = {})
52
+ requires :image_id, :security_group_ids, :type
53
+ options[:VSwitchId] = vswitch_id if vswitch_id
54
+ options[:KeyPairName] = key_pair_name if key_pair_name
55
+ options[:UserData] = user_data if user_data
56
+ options[:InstanceName] = name if name
57
+ data = Fog::JSON.decode(service.create_server(image_id, security_group_ids, type, options).body)
58
+ merge_attributes(data)
59
+ end
48
60
  # {"ImageId"=>"ubuntu1404_32_20G_aliaegis_20150325.vhd", "InnerIpAddress"=>{"IpAddress"=>["10.171.90.171"]},
49
61
  # "VlanId"=>"", "InstanceId"=>"i-25d1ry3jz",
50
62
  # "EipAddress"=>{"IpAddress"=>"", "AllocationId"=>"", "InternetChargeType"=>""},
@@ -10,7 +10,8 @@ module Fog
10
10
  model Fog::Compute::Aliyun::Server
11
11
 
12
12
  def all(options = {})
13
- Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance']
13
+ data = Fog::JSON.decode(service.list_servers(options).body)['Instances']['Instance']
14
+ load(data)
14
15
  end
15
16
 
16
17
  # Creates a new server and populates ssh keys
@@ -72,7 +72,7 @@ module Fog
72
72
  #
73
73
 
74
74
  def get(vpcId)
75
- $vpc = self.class.new(service: service).all('vpcId' => vpcId)[0] if vpcId
75
+ $vpc = self.class.new(service: service).all(:vpcId => vpcId)[0] if vpcId
76
76
  end
77
77
  end
78
78
  end
@@ -4,36 +4,53 @@ require 'fog/core/collection'
4
4
  require 'fog/aliyun/models/storage/directory'
5
5
 
6
6
  module Fog
7
- module Storage
8
- class Aliyun
7
+ module Aliyun
8
+ class Storage
9
9
  class Directories < Fog::Collection
10
- model Fog::Storage::Aliyun::Directory
10
+ model Fog::Aliyun::Storage::Directory
11
11
 
12
12
  def all
13
- containers = service.get_containers
14
- return nil if containers.nil?
13
+ buckets = service.get_service[0]
14
+ return nil if buckets.size < 1
15
15
  data = []
16
16
  i = 0
17
- containers.each do |entry|
18
- key = entry['Prefix'][0]
19
- key[-1] = ''
20
- data[i] = { key: key }
17
+ buckets.each do |b|
18
+ data[i] = { key: b.name }
21
19
  i += 1
22
20
  end
23
-
24
21
  load(data)
25
22
  end
26
23
 
24
+
27
25
  def get(key, options = {})
28
- if !key.nil? && key != '' && key != '.'
29
- dir = key + '/'
30
- ret = service.head_object(dir, options)
31
- new(key: key) if ret.data[:status] == 200
26
+ data = service.get_bucket(key, options)
27
+
28
+ directory = new(:key => key, :is_persisted => true)
29
+
30
+ options = data[1]
31
+ options[:max_keys] = options[:limit]
32
+ directory.files.merge_attributes(options)
33
+
34
+ objects = []
35
+ i = 0
36
+ data[0].each do |o|
37
+ objects[i] = {
38
+ 'Key' => o.key,
39
+ 'Type' => o.type,
40
+ 'Size' => o.size,
41
+ 'ETag' => o.etag,
42
+ 'LastModified' => o.last_modified
43
+ }
44
+ i += 1
45
+ end
46
+ directory.files.load(objects)
47
+ directory
48
+ rescue AliyunOssSdk::ServerError => error
49
+ if error.error_code == "NoSuchBucket"
50
+ nil
32
51
  else
33
- new(key: '')
52
+ raise(error)
34
53
  end
35
- rescue Fog::Storage::Aliyun::NotFound
36
- nil
37
54
  end
38
55
  end
39
56
  end