fog-xiaozhu 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +5 -0
  5. data/.rubocop_todo.yml +149 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +4 -0
  9. data/CODE_OF_CONDUCT.md +13 -0
  10. data/Gemfile +4 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +312 -0
  13. data/Rakefile +6 -0
  14. data/bin/console +14 -0
  15. data/bin/setup +7 -0
  16. data/fog-aliyun.gemspec +33 -0
  17. data/lib/fog/aliyun/compute.rb +424 -0
  18. data/lib/fog/aliyun/models/compute/eip_address.rb +57 -0
  19. data/lib/fog/aliyun/models/compute/eip_addresses.rb +28 -0
  20. data/lib/fog/aliyun/models/compute/image.rb +66 -0
  21. data/lib/fog/aliyun/models/compute/images.rb +25 -0
  22. data/lib/fog/aliyun/models/compute/route_entry.rb +26 -0
  23. data/lib/fog/aliyun/models/compute/route_entrys.rb +41 -0
  24. data/lib/fog/aliyun/models/compute/route_table.rb +30 -0
  25. data/lib/fog/aliyun/models/compute/route_tables.rb +27 -0
  26. data/lib/fog/aliyun/models/compute/security_group.rb +81 -0
  27. data/lib/fog/aliyun/models/compute/security_group_rule.rb +47 -0
  28. data/lib/fog/aliyun/models/compute/security_group_rules.rb +23 -0
  29. data/lib/fog/aliyun/models/compute/security_groups.rb +32 -0
  30. data/lib/fog/aliyun/models/compute/server.rb +70 -0
  31. data/lib/fog/aliyun/models/compute/servers.rb +42 -0
  32. data/lib/fog/aliyun/models/compute/snapshot.rb +52 -0
  33. data/lib/fog/aliyun/models/compute/snapshots.rb +38 -0
  34. data/lib/fog/aliyun/models/compute/volume.rb +101 -0
  35. data/lib/fog/aliyun/models/compute/volumes.rb +135 -0
  36. data/lib/fog/aliyun/models/compute/vpc.rb +77 -0
  37. data/lib/fog/aliyun/models/compute/vpcs.rb +80 -0
  38. data/lib/fog/aliyun/models/compute/vrouter.rb +35 -0
  39. data/lib/fog/aliyun/models/compute/vrouters.rb +61 -0
  40. data/lib/fog/aliyun/models/compute/vswitch.rb +70 -0
  41. data/lib/fog/aliyun/models/compute/vswitches.rb +80 -0
  42. data/lib/fog/aliyun/models/storage/directories.rb +39 -0
  43. data/lib/fog/aliyun/models/storage/directory.rb +48 -0
  44. data/lib/fog/aliyun/models/storage/file.rb +192 -0
  45. data/lib/fog/aliyun/models/storage/files.rb +193 -0
  46. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +54 -0
  47. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +39 -0
  48. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +49 -0
  49. data/lib/fog/aliyun/requests/compute/attach_disk.rb +79 -0
  50. data/lib/fog/aliyun/requests/compute/create_disk.rb +137 -0
  51. data/lib/fog/aliyun/requests/compute/create_image.rb +79 -0
  52. data/lib/fog/aliyun/requests/compute/create_security_group.rb +77 -0
  53. data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +63 -0
  54. data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +71 -0
  55. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +63 -0
  56. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +71 -0
  57. data/lib/fog/aliyun/requests/compute/create_server.rb +186 -0
  58. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +46 -0
  59. data/lib/fog/aliyun/requests/compute/create_vpc.rb +46 -0
  60. data/lib/fog/aliyun/requests/compute/create_vpn_connection.rb +58 -0
  61. data/lib/fog/aliyun/requests/compute/create_vpn_customergateway.rb +48 -0
  62. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +54 -0
  63. data/lib/fog/aliyun/requests/compute/delete_disk.rb +41 -0
  64. data/lib/fog/aliyun/requests/compute/delete_image.rb +31 -0
  65. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +51 -0
  66. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +63 -0
  67. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +71 -0
  68. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +63 -0
  69. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +71 -0
  70. data/lib/fog/aliyun/requests/compute/delete_server.rb +48 -0
  71. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +31 -0
  72. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +35 -0
  73. data/lib/fog/aliyun/requests/compute/delete_vpn_connection.rb +35 -0
  74. data/lib/fog/aliyun/requests/compute/delete_vpn_customergateway.rb +35 -0
  75. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +35 -0
  76. data/lib/fog/aliyun/requests/compute/detach_disk.rb +41 -0
  77. data/lib/fog/aliyun/requests/compute/join_security_group.rb +40 -0
  78. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +40 -0
  79. data/lib/fog/aliyun/requests/compute/list_disks.rb +150 -0
  80. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +55 -0
  81. data/lib/fog/aliyun/requests/compute/list_images.rb +82 -0
  82. data/lib/fog/aliyun/requests/compute/list_route_tables.rb +64 -0
  83. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +73 -0
  84. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +78 -0
  85. data/lib/fog/aliyun/requests/compute/list_server_types.rb +77 -0
  86. data/lib/fog/aliyun/requests/compute/list_servers.rb +71 -0
  87. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +97 -0
  88. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +47 -0
  89. data/lib/fog/aliyun/requests/compute/list_vpn_connections.rb +49 -0
  90. data/lib/fog/aliyun/requests/compute/list_vpn_customergateways.rb +43 -0
  91. data/lib/fog/aliyun/requests/compute/list_vpn_gateways.rb +49 -0
  92. data/lib/fog/aliyun/requests/compute/list_vrouters.rb +61 -0
  93. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +50 -0
  94. data/lib/fog/aliyun/requests/compute/list_zones.rb +44 -0
  95. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +73 -0
  96. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +45 -0
  97. data/lib/fog/aliyun/requests/compute/reboot_server.rb +43 -0
  98. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +29 -0
  99. data/lib/fog/aliyun/requests/compute/start_server.rb +41 -0
  100. data/lib/fog/aliyun/requests/compute/stop_server.rb +41 -0
  101. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +49 -0
  102. data/lib/fog/aliyun/requests/storage/copy_object.rb +39 -0
  103. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -0
  104. data/lib/fog/aliyun/requests/storage/delete_container.rb +35 -0
  105. data/lib/fog/aliyun/requests/storage/delete_object.rb +51 -0
  106. data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -0
  107. data/lib/fog/aliyun/requests/storage/get_container.rb +60 -0
  108. data/lib/fog/aliyun/requests/storage/get_containers.rb +64 -0
  109. data/lib/fog/aliyun/requests/storage/get_object.rb +45 -0
  110. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +43 -0
  111. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +43 -0
  112. data/lib/fog/aliyun/requests/storage/head_object.rb +34 -0
  113. data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -0
  114. data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -0
  115. data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -0
  116. data/lib/fog/aliyun/requests/storage/put_container.rb +35 -0
  117. data/lib/fog/aliyun/requests/storage/put_object.rb +189 -0
  118. data/lib/fog/aliyun/storage.rb +233 -0
  119. data/lib/fog/aliyun/version.rb +5 -0
  120. data/lib/fog/aliyun.rb +19 -0
  121. data/lib/fog/bin/aliyun.rb +31 -0
  122. metadata +311 -0
@@ -0,0 +1,137 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ # Create a disk with assigned size.
6
+ #
7
+ # ==== Parameters
8
+ # * size<~String> - the size of the disk (GB).--cloud:5~2000GB,cloud_efficiency: 20~2048GB,cloud_ssd:20~1024GB
9
+ # * options<~hash>
10
+ # * :name - The name of the disk,default nil. If not nil, it must start with english or chinise character.
11
+ # The length should be within [2,128]. It can contain digits,'.','_' or '-'.It shouldn't start with 'http://' or 'https://'
12
+ # * :description - The name of the disk,default nil. If not nil, the length should be within [2,255].It shouldn't start with 'http://' or 'https://'
13
+ # * :category - Default 'cloud'. can be set to 'cloud','cloud_efficiency' or 'cloud_ssd'
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'RequestId'<~String> - Id of the request
18
+ # * 'DiskId'<~String> - Id of the created disk
19
+ #
20
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/disk&createdisk]
21
+ def create_disk(size, options = {})
22
+ action = 'CreateDisk'
23
+ sigNonce = randonStr
24
+ time = Time.new.utc
25
+
26
+ parameters = defalutParameters(action, sigNonce, time)
27
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
28
+
29
+ parameters['ZoneId'] = @aliyun_zone_id
30
+ pathUrl += '&ZoneId='
31
+ pathUrl += @aliyun_zone_id
32
+
33
+ parameters['Size'] = size
34
+ pathUrl += '&Size='
35
+ pathUrl += size
36
+
37
+ name = options[:name]
38
+ desc = options[:description]
39
+ category = options[:category]
40
+
41
+ if name
42
+ parameters['DiskName'] = name
43
+ pathUrl += '&DiskName='
44
+ pathUrl += name
45
+ end
46
+
47
+ if desc
48
+ parameters['Description'] = desc
49
+ pathUrl += '&Description='
50
+ pathUrl += desc
51
+ end
52
+
53
+ if category
54
+ parameters['DiskCategory'] = category
55
+ pathUrl += 'DiskCategory'
56
+ pathUrl += category
57
+ end
58
+
59
+ signature = sign(@aliyun_accesskey_secret, parameters)
60
+ pathUrl += '&Signature='
61
+ pathUrl += signature
62
+
63
+ request(
64
+ expects: [200, 203],
65
+ method: 'GET',
66
+ path: pathUrl
67
+ ).merge(options)
68
+ end
69
+
70
+ # Create a disk By the snapshot with given snapshot_id.
71
+ #
72
+ # ==== Parameters
73
+ # * snapshotId<~String> - the snapshot_id
74
+ # * options<~hash>
75
+ # * :name - The name of the disk,default nil. If not nil, it must start with english or chinise character.
76
+ # The length should be within [2,128]. It can contain digits,'.','_' or '-'.It shouldn't start with 'http://' or 'https://'
77
+ # * :description - The name of the disk,default nil. If not nil, the length should be within [2,255].It shouldn't start with 'http://' or 'https://'
78
+ # * :category - Default 'cloud'. can be set to 'cloud','cloud_efficiency' or 'cloud_ssd'
79
+ # ==== Returns
80
+ # * response<~Excon::Response>:
81
+ # * body<~Hash>:
82
+ # * 'RequestId'<~String> - Id of the request
83
+ # * 'DiskId'<~String> - Id of the created disk
84
+ #
85
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/disk&createdisk]
86
+ def create_disk_by_snapshot(snapshotId, options = {})
87
+ action = 'CreateDisk'
88
+ sigNonce = randonStr
89
+ time = Time.new.utc
90
+
91
+ parameters = defalutParameters(action, sigNonce, time)
92
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
93
+
94
+ parameters['ZoneId'] = @aliyun_zone_id
95
+ pathUrl += '&ZoneId='
96
+ pathUrl += @aliyun_zone_id
97
+
98
+ parameters['SnapshotId'] = snapshotId
99
+ pathUrl += '&SnapshotId='
100
+ pathUrl += snapshotId
101
+
102
+ name = options[:name]
103
+ desc = options[:description]
104
+ category = options[:category]
105
+
106
+ if name
107
+ parameters['DiskName'] = name
108
+ pathUrl += '&DiskName='
109
+ pathUrl += name
110
+ end
111
+
112
+ if desc
113
+ parameters['Description'] = desc
114
+ pathUrl += '&Description='
115
+ pathUrl += desc
116
+ end
117
+
118
+ if category
119
+ parameters['DiskCategory'] = category
120
+ pathUrl += 'DiskCategory'
121
+ pathUrl += category
122
+ end
123
+
124
+ signature = sign(@aliyun_accesskey_secret, parameters)
125
+ pathUrl += '&Signature='
126
+ pathUrl += signature
127
+
128
+ request(
129
+ expects: [200, 203],
130
+ method: 'GET',
131
+ path: pathUrl
132
+ )
133
+ end
134
+ end
135
+ end # aliyun
136
+ end # compute
137
+ end # fog
@@ -0,0 +1,79 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/image&createimage]
6
+ def create_image(snapshotId, options = {})
7
+ action = 'CreateImage'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['SnapshotId'] = snapshotId
15
+ pathUrl += '&SnapshotId='
16
+ pathUrl += snapshotId
17
+
18
+ name = options[:name]
19
+ if name
20
+ parameters['ImageName'] = name
21
+ pathUrl += '&ImageName='
22
+ pathUrl += name
23
+ end
24
+
25
+ desc = options[:description]
26
+ if desc
27
+ parameters['Description'] = desc
28
+ pathUrl += '&Description='
29
+ pathUrl += desc
30
+ end
31
+
32
+ version = options[:version]
33
+ if version
34
+ parameters['ImageVersion'] = version
35
+ pathUrl += '&ImageVersion='
36
+ pathUrl += version
37
+ end
38
+
39
+ signature = sign(@aliyun_accesskey_secret, parameters)
40
+ pathUrl += '&Signature='
41
+ pathUrl += signature
42
+
43
+ request(
44
+ expects: [200, 203],
45
+ method: 'GET',
46
+ path: pathUrl
47
+ )
48
+ end
49
+ end
50
+
51
+ class Mock
52
+ def create_image(server_id, name, metadata = {})
53
+ response = Excon::Response.new
54
+ response.status = 202
55
+
56
+ img_id = Fog::Mock.random_numbers(6).to_s
57
+
58
+ data = {
59
+ 'id' => img_id,
60
+ 'server' => { 'id' => '3', 'links' => [{ 'href' => "http://nova1:8774/admin/servers/#{server_id}", 'rel' => 'bookmark' }] },
61
+ 'links' => [{ 'href' => "http://nova1:8774/v1.1/admin/images/#{img_id}", 'rel' => 'self' }, { 'href' => "http://nova1:8774/admin/images/#{img_id}", 'rel' => 'bookmark' }],
62
+ 'metadata' => metadata || {},
63
+ 'name' => name || "server_#{rand(999)}",
64
+ 'progress' => 0,
65
+ 'status' => 'SAVING',
66
+ 'minDisk' => 0,
67
+ 'minRam' => 0,
68
+ 'updated' => '',
69
+ 'created' => ''
70
+ }
71
+ self.data[:last_modified][:images][data['id']] = Time.now
72
+ self.data[:images][data['id']] = data
73
+ response.body = { 'image' => data }
74
+ response
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,77 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/securitygroup&createsecuritygroup]
6
+ def create_security_group(options = {})
7
+ action = 'CreateSecurityGroup'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ name = options[:name]
15
+ desc = options[:description]
16
+ vpcid = options[:vpcId]
17
+
18
+ if name
19
+ parameters['SecurityGroupName'] = name
20
+ pathUrl += '&SecurityGroupName='
21
+ pathUrl += name
22
+ end
23
+
24
+ if desc
25
+ parameters['Description'] = desc
26
+ pathUrl += '&Description='
27
+ pathUrl += desc
28
+ end
29
+
30
+ if vpcid
31
+ parameters['VpcId'] = vpcid
32
+ pathUrl += '&VpcId='
33
+ pathUrl += vpcid
34
+ end
35
+
36
+ signature = sign(@aliyun_accesskey_secret, parameters)
37
+ pathUrl += '&Signature='
38
+ pathUrl += signature
39
+
40
+ request(
41
+ expects: [200, 203],
42
+ method: 'GET',
43
+ path: pathUrl
44
+ )
45
+ end
46
+ end
47
+
48
+ class Mock
49
+ def create_security_group(name, description)
50
+ Fog::Identity::OpenStack.new(openstack_auth_url: credentials[:openstack_auth_url])
51
+ tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
52
+ security_group_id = Fog::Mock.random_numbers(2).to_i + 1
53
+ data[:security_groups][security_group_id.to_s] = {
54
+ 'tenant_id' => tenant_id,
55
+ 'rules' => [],
56
+ 'id' => security_group_id,
57
+ 'name' => name,
58
+ 'description' => description
59
+ }
60
+
61
+ response = Excon::Response.new
62
+ response.status = 200
63
+ response.headers = {
64
+ 'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
65
+ 'Content-Type' => 'application/json',
66
+ 'Content-Length' => Fog::Mock.random_numbers(3).to_s,
67
+ 'Date' => Date.new
68
+ }
69
+ response.body = {
70
+ 'security_group' => data[:security_groups][security_group_id.to_s]
71
+ }
72
+ response
73
+ end
74
+ end # mock
75
+ end # aliyun
76
+ end # compute
77
+ end # fog
@@ -0,0 +1,63 @@
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/securitygroup&authorizesecuritygroup]
6
+ def create_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {})
7
+ action = 'AuthorizeSecurityGroupEgress'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['SecurityGroupId'] = securitygroup_id
15
+ pathUrl += '&SecurityGroupId='
16
+ pathUrl += securitygroup_id
17
+
18
+ parameters['DestCidrIp'] = destCidrIp
19
+ pathUrl += '&DestCidrIp='
20
+ pathUrl += URI.encode(destCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
21
+ nicType = 'intranet' unless nicType
22
+ parameters['NicType'] = nicType
23
+ pathUrl += '&NicType='
24
+ pathUrl += nicType
25
+
26
+ portRange = option[:portRange]
27
+ portRange = '-1/-1' unless portRange
28
+ parameters['PortRange'] = portRange
29
+ pathUrl += '&PortRange='
30
+ pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
31
+
32
+ protocol = option[:protocol]
33
+ protocol = 'all' unless protocol
34
+ parameters['IpProtocol'] = protocol
35
+ pathUrl += '&IpProtocol='
36
+ pathUrl += protocol
37
+
38
+ policy = option[:policy]
39
+ policy = 'accept' unless policy
40
+ parameters['Policy'] = policy
41
+ pathUrl += '&Policy='
42
+ pathUrl += policy
43
+
44
+ priority = option[:priority]
45
+ priority = '1' unless priority
46
+ parameters['Priority'] = priority
47
+ pathUrl += '&Priority='
48
+ pathUrl += priority
49
+
50
+ signature = sign(@aliyun_accesskey_secret, parameters)
51
+ pathUrl += '&Signature='
52
+ pathUrl += signature
53
+
54
+ request(
55
+ expects: [200, 203],
56
+ method: 'GET',
57
+ path: pathUrl
58
+ )
59
+ end
60
+ end
61
+ end # aliyun
62
+ end # compute
63
+ end # fog
@@ -0,0 +1,71 @@
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/securitygroup&authorizesecuritygroup]
6
+ def create_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option = {})
7
+ action = 'AuthorizeSecurityGroupEgress'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['SecurityGroupId'] = securitygroup_id
15
+ pathUrl += '&SecurityGroupId='
16
+ pathUrl += securitygroup_id
17
+
18
+ parameters['DestGroupId'] = dest_group_id
19
+ pathUrl += '&DestGroupId='
20
+ pathUrl += dest_group_id
21
+
22
+ nicType = 'intranet'
23
+ parameters['NicType'] = nicType
24
+ pathUrl += '&NicType='
25
+ pathUrl += nicType
26
+
27
+ portRange = option[:portRange]
28
+ portRange = '-1/-1' unless portRange
29
+ parameters['PortRange'] = portRange
30
+ pathUrl += '&PortRange='
31
+ pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
32
+
33
+ protocol = option[:protocol]
34
+ protocol = 'all' unless protocol
35
+ parameters['IpProtocol'] = protocol
36
+ pathUrl += '&IpProtocol='
37
+ pathUrl += protocol
38
+
39
+ destGOAccount = option[:destGroupOwnerAccount]
40
+ if sourceGOAccount
41
+ parameters['DestGroupOwnerAccount'] = destGOAccount
42
+ pathUrl += '&DestGroupOwnerAccount='
43
+ pathUrl += destGOAccount
44
+ end
45
+
46
+ policy = option[:policy]
47
+ policy = 'accept' unless policy
48
+ parameters['Policy'] = policy
49
+ pathUrl += '&Policy='
50
+ pathUrl += policy
51
+
52
+ priority = option[:priority]
53
+ priority = '1' unless priority
54
+ parameters['Priority'] = priority
55
+ pathUrl += '&Priority='
56
+ pathUrl += priority
57
+
58
+ signature = sign(@aliyun_accesskey_secret, parameters)
59
+ pathUrl += '&Signature='
60
+ pathUrl += signature
61
+
62
+ request(
63
+ expects: [200, 203],
64
+ method: 'GET',
65
+ path: pathUrl
66
+ )
67
+ end
68
+ end
69
+ end # aliyun
70
+ end # compute
71
+ end # fog
@@ -0,0 +1,63 @@
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/securitygroup&authorizesecuritygroup]
6
+ def create_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, option = {})
7
+ action = 'AuthorizeSecurityGroup'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['SecurityGroupId'] = securitygroup_id
15
+ pathUrl += '&SecurityGroupId='
16
+ pathUrl += securitygroup_id
17
+
18
+ parameters['SourceCidrIp'] = sourceCidrIp
19
+ pathUrl += '&SourceCidrIp='
20
+ pathUrl += URI.encode(sourceCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
21
+ nicType = 'intranet' unless nicType
22
+ parameters['NicType'] = nicType
23
+ pathUrl += '&NicType='
24
+ pathUrl += nicType
25
+
26
+ portRange = option[:portRange]
27
+ portRange = '-1/-1' unless portRange
28
+ parameters['PortRange'] = portRange
29
+ pathUrl += '&PortRange='
30
+ pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
31
+
32
+ protocol = option[:protocol]
33
+ protocol = 'all' unless protocol
34
+ parameters['IpProtocol'] = protocol
35
+ pathUrl += '&IpProtocol='
36
+ pathUrl += protocol
37
+
38
+ policy = option[:policy]
39
+ policy = 'accept' unless policy
40
+ parameters['Policy'] = policy
41
+ pathUrl += '&Policy='
42
+ pathUrl += policy
43
+
44
+ priority = option[:priority]
45
+ priority = '1' unless priority
46
+ parameters['Priority'] = priority
47
+ pathUrl += '&Priority='
48
+ pathUrl += priority
49
+
50
+ signature = sign(@aliyun_accesskey_secret, parameters)
51
+ pathUrl += '&Signature='
52
+ pathUrl += signature
53
+
54
+ request(
55
+ expects: [200, 203],
56
+ method: 'GET',
57
+ path: pathUrl
58
+ )
59
+ end
60
+ end
61
+ end # aliyun
62
+ end # compute
63
+ end # fog
@@ -0,0 +1,71 @@
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/securitygroup&authorizesecuritygroup]
6
+ def create_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option = {})
7
+ action = 'AuthorizeSecurityGroup'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['SecurityGroupId'] = securitygroup_id
15
+ pathUrl += '&SecurityGroupId='
16
+ pathUrl += securitygroup_id
17
+
18
+ parameters['SourceGroupId'] = source_securitygroup_id
19
+ pathUrl += '&SourceGroupId='
20
+ pathUrl += source_securitygroup_id
21
+
22
+ nicType = 'intranet'
23
+ parameters['NicType'] = nicType
24
+ pathUrl += '&NicType='
25
+ pathUrl += nicType
26
+
27
+ portRange = option[:portRange]
28
+ portRange = '-1/-1' unless portRange
29
+ parameters['PortRange'] = portRange
30
+ pathUrl += '&PortRange='
31
+ pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
32
+
33
+ protocol = option[:protocol]
34
+ protocol = 'all' unless protocol
35
+ parameters['IpProtocol'] = protocol
36
+ pathUrl += '&IpProtocol='
37
+ pathUrl += protocol
38
+
39
+ sourceGOAccount = option[:sourceGroupOwnerAccount]
40
+ if sourceGOAccount
41
+ parameters['SourceGroupOwnerAccount'] = sourceGOAccount
42
+ pathUrl += '&SourceGroupOwnerAccount='
43
+ pathUrl += sourceGOAccount
44
+ end
45
+
46
+ policy = option[:policy]
47
+ policy = 'accept' unless policy
48
+ parameters['Policy'] = policy
49
+ pathUrl += '&Policy='
50
+ pathUrl += policy
51
+
52
+ priority = option[:priority]
53
+ priority = '1' unless priority
54
+ parameters['Priority'] = priority
55
+ pathUrl += '&Priority='
56
+ pathUrl += priority
57
+
58
+ signature = sign(@aliyun_accesskey_secret, parameters)
59
+ pathUrl += '&Signature='
60
+ pathUrl += signature
61
+
62
+ request(
63
+ expects: [200, 203],
64
+ method: 'GET',
65
+ path: pathUrl
66
+ )
67
+ end
68
+ end
69
+ end # aliyun
70
+ end # compute
71
+ end # fog