fog-aliyun 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +149 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Rakefile +3 -3
- data/fog-aliyun.gemspec +16 -13
- data/lib/fog/aliyun.rb +8 -8
- data/lib/fog/aliyun/compute.rb +99 -113
- data/lib/fog/aliyun/models/compute/eip_address.rb +23 -29
- data/lib/fog/aliyun/models/compute/eip_addresses.rb +3 -5
- data/lib/fog/aliyun/models/compute/image.rb +26 -28
- data/lib/fog/aliyun/models/compute/images.rb +2 -6
- data/lib/fog/aliyun/models/compute/route_entry.rb +9 -11
- data/lib/fog/aliyun/models/compute/route_entrys.rb +7 -7
- data/lib/fog/aliyun/models/compute/route_table.rb +10 -11
- data/lib/fog/aliyun/models/compute/route_tables.rb +2 -2
- data/lib/fog/aliyun/models/compute/security_group.rb +24 -24
- data/lib/fog/aliyun/models/compute/security_group_rule.rb +20 -20
- data/lib/fog/aliyun/models/compute/security_group_rules.rb +4 -4
- data/lib/fog/aliyun/models/compute/security_groups.rb +6 -7
- data/lib/fog/aliyun/models/compute/server.rb +42 -43
- data/lib/fog/aliyun/models/compute/servers.rb +9 -11
- data/lib/fog/aliyun/models/compute/snapshot.rb +15 -15
- data/lib/fog/aliyun/models/compute/snapshots.rb +6 -10
- data/lib/fog/aliyun/models/compute/volume.rb +36 -40
- data/lib/fog/aliyun/models/compute/volumes.rb +7 -11
- data/lib/fog/aliyun/models/compute/vpc.rb +18 -19
- data/lib/fog/aliyun/models/compute/vpcs.rb +5 -6
- data/lib/fog/aliyun/models/compute/vrouter.rb +13 -13
- data/lib/fog/aliyun/models/compute/vrouters.rb +4 -5
- data/lib/fog/aliyun/models/compute/vswitch.rb +18 -20
- data/lib/fog/aliyun/models/compute/vswitches.rb +6 -6
- data/lib/fog/aliyun/models/storage/directories.rb +10 -16
- data/lib/fog/aliyun/models/storage/directory.rb +8 -8
- data/lib/fog/aliyun/models/storage/file.rb +58 -64
- data/lib/fog/aliyun/models/storage/files.rb +95 -115
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +18 -44
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +12 -36
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +16 -40
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +19 -22
- data/lib/fog/aliyun/requests/compute/create_disk.rb +33 -63
- data/lib/fog/aliyun/requests/compute/create_image.rb +21 -21
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +16 -16
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/create_server.rb +76 -78
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +12 -26
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +11 -38
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +13 -40
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +8 -35
- data/lib/fog/aliyun/requests/compute/delete_image.rb +6 -33
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +22 -63
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -62
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +23 -61
- data/lib/fog/aliyun/requests/compute/delete_server.rb +15 -15
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +6 -20
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +9 -26
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +9 -25
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +11 -27
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +15 -16
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +15 -16
- data/lib/fog/aliyun/requests/compute/list_disks.rb +24 -43
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +26 -52
- data/lib/fog/aliyun/requests/compute/list_images.rb +21 -24
- data/lib/fog/aliyun/requests/compute/list_route_tables.rb +16 -19
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +22 -23
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +21 -24
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +50 -50
- data/lib/fog/aliyun/requests/compute/list_servers.rb +25 -28
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +20 -37
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +12 -29
- data/lib/fog/aliyun/requests/compute/list_vrouters.rb +13 -16
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +14 -31
- data/lib/fog/aliyun/requests/compute/list_zones.rb +16 -16
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +17 -17
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +11 -39
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +15 -16
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +12 -36
- data/lib/fog/aliyun/requests/compute/start_server.rb +14 -15
- data/lib/fog/aliyun/requests/compute/stop_server.rb +13 -14
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +16 -41
- data/lib/fog/aliyun/requests/storage/copy_object.rb +11 -14
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -30
- data/lib/fog/aliyun/requests/storage/delete_container.rb +11 -14
- data/lib/fog/aliyun/requests/storage/delete_object.rb +20 -22
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -148
- data/lib/fog/aliyun/requests/storage/get_container.rb +26 -38
- data/lib/fog/aliyun/requests/storage/get_containers.rb +20 -32
- data/lib/fog/aliyun/requests/storage/get_object.rb +12 -12
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +11 -11
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +11 -11
- data/lib/fog/aliyun/requests/storage/head_object.rb +11 -11
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -47
- data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -104
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -23
- data/lib/fog/aliyun/requests/storage/put_container.rb +12 -12
- data/lib/fog/aliyun/requests/storage/put_object.rb +100 -110
- data/lib/fog/aliyun/storage.rb +209 -214
- data/lib/fog/aliyun/version.rb +1 -1
- data/lib/fog/bin/aliyun.rb +5 -5
- metadata +55 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82062a69285f3c3a240f77d49730e674be34e1a4
|
4
|
+
data.tar.gz: 8054a3818fab3fb5661d45279c88bfd1c3527de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08af5f88a8e2da7ff72366f7fc84f87b135d7d74a1549422fd23cd4c94cdc7ddb778ce2868c351e93d591d1f9a1e9d4219568a4ccda7bda2437c87dd7a020d86'
|
7
|
+
data.tar.gz: 6db1a3348d5f9a1406fa752be842d17ae507ec915d2baaf3e3bfb37d14aace66d8b76927dc3a43f98819c4e59a7d4efc5f3d9050b9bc1e0d50cfd1db60ffa48e
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -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
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
fog-aliyun
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4
|
data/Rakefile
CHANGED
data/fog-aliyun.gemspec
CHANGED
@@ -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 =
|
7
|
+
spec.name = 'fog-aliyun'
|
8
8
|
spec.version = Fog::Aliyun::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Qinsi Deng, Jianxun Li, Jane Han']
|
10
|
+
spec.email = ['dengqs@dtdream.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
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 =
|
18
|
+
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
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'
|
data/lib/fog/aliyun.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
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,
|
7
|
+
ret = autoload :Aliyun, 'fog/aliyun/compute'
|
8
8
|
end
|
9
9
|
|
10
10
|
module Storage
|
11
|
-
ret = autoload :Aliyun,
|
11
|
+
ret = autoload :Aliyun, 'fog/aliyun/storage'
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
module Aliyun
|
15
15
|
extend Fog::Provider
|
16
|
-
service(:compute,
|
17
|
-
service(:storage,
|
16
|
+
service(:compute, 'Compute')
|
17
|
+
service(:storage, 'Storage')
|
18
18
|
end
|
19
19
|
end
|
data/lib/fog/aliyun/compute.rb
CHANGED
@@ -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
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
121
|
+
last_modified: {
|
122
|
+
images: {},
|
123
|
+
servers: {},
|
124
|
+
key_pairs: {},
|
125
|
+
security_groups: {},
|
126
|
+
addresses: {}
|
137
127
|
},
|
138
|
-
:
|
139
|
-
|
140
|
-
|
141
|
-
|
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' =>
|
144
|
-
'updated' =>
|
133
|
+
'status' => 'ACTIVE',
|
134
|
+
'updated' => '',
|
145
135
|
'minRam' => 0,
|
146
136
|
'minDisk' => 0,
|
147
137
|
'metadata' => {},
|
148
|
-
'links' => [{
|
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
|
-
:
|
152
|
-
:
|
153
|
-
:
|
141
|
+
servers: {},
|
142
|
+
key_pairs: {},
|
143
|
+
security_groups: {
|
154
144
|
'0' => {
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
{
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
:
|
171
|
-
:
|
172
|
-
:
|
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' =>
|
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' =>
|
175
|
+
'ram' => 51_200
|
186
176
|
},
|
187
|
-
:
|
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
|
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 +
|
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
|
-
{ :
|
228
|
-
:
|
229
|
-
:
|
230
|
-
:
|
231
|
-
:
|
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 =
|
272
|
-
missing_credentials << :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
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
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
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
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?
|
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(
|
326
|
-
urlTimeFormat = URI.encode(parTimeFormat,':')
|
327
|
-
|
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(
|
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+
|
335
|
-
|
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(
|
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'
|
346
|
-
'SignatureVersion'=>'1.0',
|
347
|
-
'SignatureMethod'=>'HMAC-SHA1',
|
348
|
-
'SignatureNonce'=>sigNonce,
|
349
|
-
'RegionId'
|
350
|
-
'Timestamp'=>parTimeFormat
|
351
|
-
|
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
|
340
|
+
# compute signature
|
341
|
+
def sign(accessKeySecret, parameters)
|
356
342
|
sortedParameters = parameters.sort
|
357
343
|
canonicalizedQueryString = ''
|
358
|
-
sortedParameters.each do |
|
359
|
-
|
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(
|
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
|
-
|
358
|
+
encodedSig
|
373
359
|
end
|
374
360
|
end
|
375
361
|
end
|