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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f039d826c1b8f347bd39065fca8d8c8d1a3a513
4
- data.tar.gz: 883c955e643d7d333571a41ce98f30ce16706a40
3
+ metadata.gz: 82062a69285f3c3a240f77d49730e674be34e1a4
4
+ data.tar.gz: 8054a3818fab3fb5661d45279c88bfd1c3527de3
5
5
  SHA512:
6
- metadata.gz: a315a64cbbd5ae803e0064ac3b063dcab53b7970cf4e6aa0c0ee70abddf0273cc7e9cfde587f627f6bcf5ddc931a9153b883e2f4b6e5ae86f78d0170181cc362
7
- data.tar.gz: e700199fed03abeeec6cd02f7c313ce6fee29c7f72ac6d5aca366ea83621c474f286ce313c4ba3a32ba0b5a75b7170ee798057e3ee0d120ba63fdc3a1d746480
6
+ metadata.gz: '08af5f88a8e2da7ff72366f7fc84f87b135d7d74a1549422fd23cd4c94cdc7ddb778ce2868c351e93d591d1f9a1e9d4219568a4ccda7bda2437c87dd7a020d86'
7
+ data.tar.gz: 6db1a3348d5f9a1406fa752be842d17ae507ec915d2baaf3e3bfb37d14aace66d8b76927dc3a43f98819c4e59a7d4efc5f3d9050b9bc1e0d50cfd1db60ffa48e
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/**/*
4
+
5
+ # inherit_from: .rubocop_todo.yml
@@ -0,0 +1,149 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-05-12 13:44:44 +0800 using RuboCop version 0.40.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # Configuration parameters: AllowSafeAssignment.
11
+ Lint/AssignmentInCondition:
12
+ Exclude:
13
+ - 'lib/fog/aliyun/requests/compute/create_server.rb'
14
+ - 'lib/fog/aliyun/requests/compute/delete_server.rb'
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
19
+ # SupportedStyles: start_of_line, def
20
+ Lint/DefEndAlignment:
21
+ Enabled: false
22
+
23
+ # Offense count: 5
24
+ # Cop supports --auto-correct.
25
+ # Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
26
+ # SupportedStyles: keyword, variable, start_of_line
27
+ Lint/EndAlignment:
28
+ Enabled: false
29
+
30
+ # Offense count: 4
31
+ Lint/RandOne:
32
+ Exclude:
33
+ - 'lib/fog/aliyun/requests/compute/list_images.rb'
34
+ - 'lib/fog/aliyun/requests/compute/list_route_tables.rb'
35
+ - 'lib/fog/aliyun/requests/compute/list_servers.rb'
36
+ - 'lib/fog/aliyun/requests/compute/list_vrouters.rb'
37
+
38
+ # Offense count: 127
39
+ Lint/UnderscorePrefixedVariableName:
40
+ Enabled: false
41
+
42
+ # Offense count: 1
43
+ Lint/UnreachableCode:
44
+ Exclude:
45
+ - 'lib/fog/aliyun/models/storage/directory.rb'
46
+
47
+ # Offense count: 38
48
+ Lint/UselessAssignment:
49
+ Exclude:
50
+ - 'lib/fog/aliyun.rb'
51
+ - 'lib/fog/aliyun/requests/compute/list_disks.rb'
52
+ - 'lib/fog/aliyun/requests/compute/list_security_groups.rb'
53
+ - 'lib/fog/aliyun/requests/storage/delete_object.rb'
54
+ - 'lib/fog/aliyun/requests/storage/get_bucket.rb'
55
+ - 'lib/fog/aliyun/requests/storage/get_container.rb'
56
+ - 'lib/fog/aliyun/requests/storage/get_containers.rb'
57
+ - 'lib/fog/aliyun/requests/storage/get_object_http_url.rb'
58
+ - 'lib/fog/aliyun/requests/storage/get_object_https_url.rb'
59
+ - 'lib/fog/aliyun/requests/storage/list_buckets.rb'
60
+ - 'lib/fog/aliyun/requests/storage/list_objects.rb'
61
+ - 'lib/fog/aliyun/requests/storage/put_bucket.rb'
62
+ - 'lib/fog/aliyun/requests/storage/put_object.rb'
63
+ - 'lib/fog/aliyun/storage.rb'
64
+
65
+ # Offense count: 78
66
+ Metrics/AbcSize:
67
+ Max: 100
68
+
69
+ # Offense count: 5
70
+ # Configuration parameters: CountComments.
71
+ Metrics/ClassLength:
72
+ Max: 154
73
+
74
+ # Offense count: 18
75
+ Metrics/CyclomaticComplexity:
76
+ Max: 15
77
+
78
+ # Offense count: 257
79
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
80
+ # URISchemes: http, https
81
+ Metrics/LineLength:
82
+ Max: 247
83
+
84
+ # Offense count: 110
85
+ # Configuration parameters: CountComments.
86
+ Metrics/MethodLength:
87
+ Max: 97
88
+
89
+ # Offense count: 1
90
+ # Configuration parameters: CountKeywordArgs.
91
+ Metrics/ParameterLists:
92
+ Max: 6
93
+
94
+ # Offense count: 17
95
+ Metrics/PerceivedComplexity:
96
+ Max: 19
97
+
98
+ # Offense count: 1
99
+ Style/ClassVars:
100
+ Exclude:
101
+ - 'lib/fog/bin/aliyun.rb'
102
+
103
+ # Offense count: 138
104
+ Style/Documentation:
105
+ Enabled: false
106
+
107
+ # Offense count: 7
108
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
109
+ # SupportedStyles: for, each
110
+ Style/For:
111
+ Enabled: false
112
+
113
+ # Offense count: 4
114
+ # Configuration parameters: AllowedVariables.
115
+ Style/GlobalVars:
116
+ Exclude:
117
+ - 'lib/fog/aliyun/models/compute/server.rb'
118
+ - 'lib/fog/aliyun/models/compute/vpcs.rb'
119
+ - 'lib/fog/aliyun/models/compute/vrouter.rb'
120
+ - 'lib/fog/aliyun/models/compute/vswitch.rb'
121
+
122
+ # Offense count: 2
123
+ # Configuration parameters: MinBodyLength.
124
+ Style/GuardClause:
125
+ Exclude:
126
+ - 'lib/fog/aliyun/requests/compute/delete_vpc.rb'
127
+ - 'lib/fog/aliyun/requests/compute/delete_vswitch.rb'
128
+
129
+ # Offense count: 2
130
+ Style/IdenticalConditionalBranches:
131
+ Exclude:
132
+ - 'lib/fog/aliyun/models/storage/files.rb'
133
+
134
+ # Offense count: 1
135
+ Style/IfInsideElse:
136
+ Exclude:
137
+ - 'lib/fog/aliyun/models/compute/security_group_rule.rb'
138
+
139
+ # Offense count: 4
140
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
141
+ # SupportedStyles: snake_case, camelCase
142
+ Style/MethodName:
143
+ Enabled: false
144
+
145
+ # Offense count: 741
146
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
147
+ # SupportedStyles: snake_case, camelCase
148
+ Style/VariableName:
149
+ Enabled: false
@@ -0,0 +1 @@
1
+ fog-aliyun
@@ -0,0 +1 @@
1
+ 2.4
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -4,25 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'fog/aliyun/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "fog-aliyun"
7
+ spec.name = 'fog-aliyun'
8
8
  spec.version = Fog::Aliyun::VERSION
9
- spec.authors = ["Qinsi Deng, Jianxun Li, Jane Han"]
10
- spec.email = ["dengqs@dtdream.com"]
9
+ spec.authors = ['Qinsi Deng, Jianxun Li, Jane Han']
10
+ spec.email = ['dengqs@dtdream.com']
11
11
 
12
- spec.summary = %q{Fog provider for Aliyun Web Services.}
13
- spec.description = %q{As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support more aliyun services later.}
14
- spec.homepage = "https://github.com/fog/fog-aliyun"
15
- spec.license = "MIT"
12
+ spec.summary = 'Fog provider for Aliyun Web Services.'
13
+ spec.description = 'As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support more aliyun services later.'
14
+ spec.homepage = 'https://github.com/fog/fog-aliyun'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.3'
25
+ spec.add_development_dependency 'rubocop', '~> 0.40.0'
26
+ spec.add_development_dependency 'mime-types', '~> 2.6', '>= 2.6.2'
27
+ spec.add_development_dependency 'pry-nav'
21
28
 
22
- spec.add_development_dependency "bundler", "~> 1.10"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.3"
25
-
26
29
  spec.add_dependency 'fog-core', '~> 1.27'
27
30
  spec.add_dependency 'fog-json', '~> 1.0'
28
31
  spec.add_dependency 'ipaddress', '~> 0.8'
@@ -1,19 +1,19 @@
1
- require "fog/core"
2
- require "fog/json"
3
- require "fog/aliyun/version"
1
+ require 'fog/core'
2
+ require 'fog/json'
3
+ require 'fog/aliyun/version'
4
4
 
5
5
  module Fog
6
6
  module Compute
7
- ret = autoload :Aliyun, "fog/aliyun/compute"
7
+ ret = autoload :Aliyun, 'fog/aliyun/compute'
8
8
  end
9
9
 
10
10
  module Storage
11
- ret = autoload :Aliyun, "fog/aliyun/storage"
11
+ ret = autoload :Aliyun, 'fog/aliyun/storage'
12
12
  end
13
-
13
+
14
14
  module Aliyun
15
15
  extend Fog::Provider
16
- service(:compute, "Compute")
17
- service(:storage, "Storage")
16
+ service(:compute, 'Compute')
17
+ service(:storage, 'Storage')
18
18
  end
19
19
  end
@@ -1,8 +1,8 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class Aliyun < Fog::Service
4
- recognizes :aliyun_url,
5
- :aliyun_accesskey_id,
4
+ recognizes :aliyun_url,
5
+ :aliyun_accesskey_id,
6
6
  :aliyun_accesskey_secret,
7
7
  :aliyun_region_id,
8
8
  :aliyun_zone_id
@@ -39,32 +39,27 @@ module Fog
39
39
  #
40
40
  request_path 'fog/aliyun/requests/compute'
41
41
 
42
-
43
42
  # Server CRUD
44
43
  request :list_servers
45
44
  request :list_server_types
46
45
  request :create_server
47
46
  request :delete_server
48
47
 
49
-
50
48
  # Server Actions
51
49
  request :reboot_server
52
50
  request :start_server
53
51
  request :stop_server
54
52
 
55
-
56
- #SnapShoot CRUD
53
+ # SnapShoot CRUD
57
54
  request :list_snapshots
58
55
  request :create_snapshot
59
56
  request :delete_snapshot
60
57
 
61
-
62
58
  # Image CRUD
63
59
  request :list_images
64
60
  request :create_image
65
61
  request :delete_image
66
62
 
67
-
68
63
  # Eip
69
64
  request :list_eip_addresses
70
65
  request :allocate_eip_address
@@ -72,7 +67,6 @@ module Fog
72
67
  request :associate_eip_address
73
68
  request :unassociate_eip_address
74
69
 
75
-
76
70
  # Security Group
77
71
  request :list_security_groups
78
72
  request :list_security_group_rules
@@ -89,11 +83,9 @@ module Fog
89
83
  request :join_security_group
90
84
  request :leave_security_group
91
85
 
92
-
93
86
  # Zones
94
87
  request :list_zones
95
88
 
96
-
97
89
  # VPC
98
90
  request :create_vpc
99
91
  request :delete_vpc
@@ -104,21 +96,19 @@ module Fog
104
96
  request :modify_vpc
105
97
  request :modify_vswitch
106
98
 
107
- #VRouter
99
+ # VRouter
108
100
  request :list_vrouters
109
101
 
110
- #RouteTable
102
+ # RouteTable
111
103
  request :list_route_tables
112
104
 
113
-
114
- #clouddisk
105
+ # clouddisk
115
106
  request :list_disks
116
107
  request :create_disk
117
108
  request :delete_disk
118
109
  request :attach_disk
119
110
  request :detach_disk
120
111
 
121
-
122
112
  class Mock
123
113
  attr_reader :auth_token
124
114
  attr_reader :auth_token_expiration
@@ -128,51 +118,51 @@ module Fog
128
118
  def self.data
129
119
  @data ||= Hash.new do |hash, key|
130
120
  hash[key] = {
131
- :last_modified => {
132
- :images => {},
133
- :servers => {},
134
- :key_pairs => {},
135
- :security_groups => {},
136
- :addresses => {}
121
+ last_modified: {
122
+ images: {},
123
+ servers: {},
124
+ key_pairs: {},
125
+ security_groups: {},
126
+ addresses: {}
137
127
  },
138
- :images => {
139
- "0e09fbd6-43c5-448a-83e9-0d3d05f9747e" => {
140
- "id"=>"0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
141
- "name"=>"cirros-0.3.0-x86_64-blank",
128
+ images: {
129
+ '0e09fbd6-43c5-448a-83e9-0d3d05f9747e' => {
130
+ 'id' => '0e09fbd6-43c5-448a-83e9-0d3d05f9747e',
131
+ 'name' => 'cirros-0.3.0-x86_64-blank',
142
132
  'progress' => 100,
143
- 'status' => "ACTIVE",
144
- 'updated' => "",
133
+ 'status' => 'ACTIVE',
134
+ 'updated' => '',
145
135
  'minRam' => 0,
146
136
  'minDisk' => 0,
147
137
  'metadata' => {},
148
- 'links' => [{"href"=>"http://nova1:8774/v1.1/admin/images/1", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/images/2", "rel"=>"bookmark"}]
138
+ 'links' => [{ 'href' => 'http://nova1:8774/v1.1/admin/images/1', 'rel' => 'self' }, { 'href' => 'http://nova1:8774/admin/images/2', 'rel' => 'bookmark' }]
149
139
  }
150
140
  },
151
- :servers => {},
152
- :key_pairs => {},
153
- :security_groups => {
141
+ servers: {},
142
+ key_pairs: {},
143
+ security_groups: {
154
144
  '0' => {
155
- "id" => 0,
156
- "tenant_id" => Fog::Mock.random_hex(8),
157
- "name" => "default",
158
- "description" => "default",
159
- "rules" => [
160
- { "id" => 0,
161
- "parent_group_id" => 0,
162
- "from_port" => 68,
163
- "to_port" => 68,
164
- "ip_protocol" => "udp",
165
- "ip_range" => { "cidr" => "0.0.0.0/0" },
166
- "group" => {}, },
167
- ],
168
- },
145
+ 'id' => 0,
146
+ 'tenant_id' => Fog::Mock.random_hex(8),
147
+ 'name' => 'default',
148
+ 'description' => 'default',
149
+ 'rules' => [
150
+ { 'id' => 0,
151
+ 'parent_group_id' => 0,
152
+ 'from_port' => 68,
153
+ 'to_port' => 68,
154
+ 'ip_protocol' => 'udp',
155
+ 'ip_range' => { 'cidr' => '0.0.0.0/0' },
156
+ 'group' => {} }
157
+ ]
158
+ }
169
159
  },
170
- :server_security_group_map => {},
171
- :addresses => {},
172
- :quota => {
160
+ server_security_group_map: {},
161
+ addresses: {},
162
+ quota: {
173
163
  'security_group_rules' => 20,
174
164
  'security_groups' => 10,
175
- 'injected_file_content_bytes' => 10240,
165
+ 'injected_file_content_bytes' => 10_240,
176
166
  'injected_file_path_bytes' => 256,
177
167
  'injected_files' => 5,
178
168
  'metadata_items' => 128,
@@ -182,9 +172,9 @@ module Fog
182
172
  'gigabytes' => 5000,
183
173
  'volumes' => 10,
184
174
  'cores' => 20,
185
- 'ram' => 51200
175
+ 'ram' => 51_200
186
176
  },
187
- :volumes => {}
177
+ volumes: {}
188
178
  }
189
179
  end
190
180
  end
@@ -193,17 +183,17 @@ module Fog
193
183
  @data = nil
194
184
  end
195
185
 
196
- def initialize(options={})
186
+ def initialize(options = {})
197
187
  @openstack_username = options[:openstack_username]
198
188
  @openstack_user_domain = options[:openstack_user_domain] || options[:openstack_domain]
199
- @openstack_project_domain = options[:openstack_project_domain] || options[:openstack_domain] || 'Default'
189
+ @openstack_project_domain = options[:openstack_project_domain] || options[:openstack_domain] || 'Default'
200
190
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
201
191
 
202
192
  @current_tenant = options[:openstack_tenant]
203
193
  @current_tenant_id = options[:openstack_tenant_id]
204
194
 
205
195
  @auth_token = Fog::Mock.random_base64(64)
206
- @auth_token_expiration = (Time.now.utc + 86400).iso8601
196
+ @auth_token_expiration = (Time.now.utc + 86_400).iso8601
207
197
 
208
198
  management_url = URI.parse(options[:openstack_auth_url])
209
199
  management_url.port = 8774
@@ -224,16 +214,15 @@ module Fog
224
214
  end
225
215
 
226
216
  def credentials
227
- { :provider => 'openstack',
228
- :openstack_auth_url => @openstack_auth_uri.to_s,
229
- :openstack_auth_token => @auth_token,
230
- :openstack_management_url => @openstack_management_url,
231
- :openstack_identity_endpoint => @openstack_identity_public_endpoint }
217
+ { provider: 'openstack',
218
+ openstack_auth_url: @openstack_auth_uri.to_s,
219
+ openstack_auth_token: @auth_token,
220
+ openstack_management_url: @openstack_management_url,
221
+ openstack_identity_endpoint: @openstack_identity_public_endpoint }
232
222
  end
233
223
  end
234
224
 
235
225
  class Real
236
-
237
226
  # Initialize connection to ECS
238
227
  #
239
228
  # ==== Notes
@@ -258,18 +247,17 @@ module Fog
258
247
  attr_reader :aliyun_url
259
248
  attr_reader :aliyun_zone_id
260
249
 
261
- def initialize(options={})
262
-
263
- #initialize the parameters
250
+ def initialize(options = {})
251
+ # initialize the parameters
264
252
  @aliyun_url = options[:aliyun_url]
265
253
  @aliyun_accesskey_id = options[:aliyun_accesskey_id]
266
254
  @aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
267
255
  @aliyun_region_id = options[:aliyun_region_id]
268
256
  @aliyun_zone_id = options[:aliyun_zone_id]
269
257
 
270
- #check for the parameters
271
- missing_credentials = Array.new
272
- missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
258
+ # check for the parameters
259
+ missing_credentials = []
260
+ missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
273
261
  missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
274
262
  missing_credentials << :aliyun_region_id unless @aliyun_region_id
275
263
  missing_credentials << :aliyun_url unless @aliyun_url
@@ -277,7 +265,7 @@ module Fog
277
265
  raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
278
266
 
279
267
  @connection_options = options[:connection_options] || {}
280
-
268
+
281
269
  uri = URI.parse(@aliyun_url)
282
270
  @host = uri.host
283
271
  @path = uri.path
@@ -286,7 +274,6 @@ module Fog
286
274
 
287
275
  @persistent = options[:persistent] || false
288
276
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
289
-
290
277
  end
291
278
 
292
279
  def reload
@@ -295,81 +282,80 @@ module Fog
295
282
 
296
283
  def request(params)
297
284
  begin
298
- response = @connection.request(params.merge({
299
- :headers => {
300
- 'Content-Type' => 'application/json',
301
- 'Accept' => 'application/json',
302
- 'X-Auth-Token' => @auth_token
303
- }.merge!(params[:headers] || {}),
304
- :path => "#{@path}/#{params[:path]}",
305
- :query => params[:query]
306
- }))
285
+ response = @connection.request(params.merge(headers: {
286
+ 'Content-Type' => 'application/json',
287
+ 'Accept' => 'application/json',
288
+ 'X-Auth-Token' => @auth_token
289
+ }.merge!(params[:headers] || {}),
290
+ path: "#{@path}/#{params[:path]}",
291
+ query: params[:query]))
307
292
  rescue Excon::Errors::HTTPStatusError => error
308
293
  raise case error
309
- when Excon::Errors::NotFound
310
- Fog::Compute::Aliyun::NotFound.slurp(error)
311
- else
312
- error
294
+ when Excon::Errors::NotFound
295
+ Fog::Compute::Aliyun::NotFound.slurp(error)
296
+ else
297
+ error
313
298
  end
314
299
  end
315
300
 
316
- if !response.body.empty? and response.get_header('Content-Type') == 'application/json'
301
+ if !response.body.empty? && response.get_header('Content-Type') == 'application/json'
317
302
  response.body = Fog::JSON.decode(response.body)
318
303
  end
319
304
 
320
305
  response
321
306
  end
322
-
323
- #operation compute-- default URL
307
+
308
+ # operation compute-- default URL
324
309
  def defaultAliyunUri(action, sigNonce, time)
325
- parTimeFormat = time.strftime("%Y-%m-%dT%H:%M:%SZ")
326
- urlTimeFormat = URI.encode(parTimeFormat,':')
327
- return '?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
310
+ parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
311
+ urlTimeFormat = URI.encode(parTimeFormat, ':')
312
+ '?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
328
313
  end
329
314
 
330
- #generate random num
331
- def randonStr ()
332
- numStr = rand(100000).to_s
315
+ # generate random num
316
+ def randonStr
317
+ numStr = rand(100_000).to_s
333
318
  timeStr = Time.now.to_f.to_s
334
- ranStr = timeStr+"-"+numStr
335
- return ranStr
319
+ ranStr = timeStr + '-' + numStr
320
+ ranStr
336
321
  end
337
322
 
338
- #operation compute--collection of default parameters
323
+ # operation compute--collection of default parameters
339
324
  def defalutParameters(action, sigNonce, time)
340
- parTimeFormat = time.strftime("%Y-%m-%dT%H:%M:%SZ")
325
+ parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
341
326
  para = {
342
- 'Format'=>'JSON',
343
- 'Version'=>'2014-05-26',
344
- 'Action'=>action,
345
- 'AccessKeyId'=>@aliyun_accesskey_id,
346
- 'SignatureVersion'=>'1.0',
347
- 'SignatureMethod'=>'HMAC-SHA1',
348
- 'SignatureNonce'=>sigNonce,
349
- 'RegionId'=>@aliyun_region_id,
350
- 'Timestamp'=>parTimeFormat};
351
- return para
327
+ 'Format' => 'JSON',
328
+ 'Version' => '2014-05-26',
329
+ 'Action' => action,
330
+ 'AccessKeyId' => @aliyun_accesskey_id,
331
+ 'SignatureVersion' => '1.0',
332
+ 'SignatureMethod' => 'HMAC-SHA1',
333
+ 'SignatureNonce' => sigNonce,
334
+ 'RegionId' => @aliyun_region_id,
335
+ 'Timestamp' => parTimeFormat
336
+ }
337
+ para
352
338
  end
353
339
 
354
- #compute signature
355
- def sign (accessKeySecret,parameters)
340
+ # compute signature
341
+ def sign(accessKeySecret, parameters)
356
342
  sortedParameters = parameters.sort
357
343
  canonicalizedQueryString = ''
358
- sortedParameters.each do | k, v |
359
- canonicalizedQueryString += '&' + URI.encode(k,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ') + '=' + URI.encode(v,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
344
+ sortedParameters.each do |k, v|
345
+ canonicalizedQueryString += '&' + URI.encode(k, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ') + '=' + URI.encode(v, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
360
346
  end
361
347
 
362
348
  canonicalizedQueryString[0] = ''
363
- stringToSign = 'GET&%2F&' + URI.encode(canonicalizedQueryString,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
349
+ stringToSign = 'GET&%2F&' + URI.encode(canonicalizedQueryString, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
364
350
  key = accessKeySecret + '&'
365
351
 
366
- digVer = OpenSSL::Digest.new("sha1")
352
+ digVer = OpenSSL::Digest.new('sha1')
367
353
  digest = OpenSSL::HMAC.digest(digVer, key, stringToSign)
368
354
  signature = Base64.encode64(digest)
369
355
  signature[-1] = ''
370
- encodedSig = URI.encode(signature,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
356
+ encodedSig = URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
371
357
 
372
- return encodedSig
358
+ encodedSig
373
359
  end
374
360
  end
375
361
  end