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,186 @@
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/instance&createinstance]
6
+ def create_server(imageId, securityGroupId, instanceType, options = {})
7
+ _action = 'CreateInstance'
8
+ _sigNonce = randonStr
9
+ _time = Time.new.utc
10
+
11
+ _parameters = defalutParameters(_action, _sigNonce, _time)
12
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
13
+
14
+ _parameters['ImageId'] = imageId
15
+ _pathURL += '&ImageId=' + imageId
16
+
17
+ _parameters['InstanceType'] = instanceType
18
+ _pathURL += '&InstanceType=' + instanceType
19
+
20
+ _parameters['SecurityGroupId'] = securityGroupId
21
+ _pathURL += '&SecurityGroupId=' + securityGroupId
22
+
23
+ _ZoneId = options[:ZoneId]
24
+ if _ZoneId
25
+ _parameters['ZoneId'] = _ZoneId
26
+ _pathURL += '&ZoneId=' + _ZoneId
27
+ end
28
+
29
+ _InstanceName = options[:InstanceName]
30
+ if _InstanceName
31
+ _parameters['InstanceName'] = _InstanceName
32
+ _pathURL += '&InstanceName=' + _InstanceName
33
+ end
34
+
35
+ _Description = options[:Description]
36
+ if _Description
37
+ _parameters['Description'] = _Description
38
+ _pathURL += '&Description=' + _Description
39
+ end
40
+
41
+ _InternetChargeType = options[:InternetChargeType]
42
+ if _InternetChargeType
43
+ _parameters['InternetChargeType'] = _InternetChargeType
44
+ _pathURL += '&InternetChargeType=' + _InternetChargeType
45
+ end
46
+
47
+ _HostName = options[:HostName]
48
+ if _HostName
49
+ _parameters['HostName'] = _HostName
50
+ _pathURL += '&HostName=' + _HostName
51
+ end
52
+
53
+ _Password = options[:Password]
54
+ if _Password
55
+ _parameters['Password'] = _Password
56
+ _pathURL += '&Password=' + _Password
57
+ end
58
+
59
+ _VSwitchId = options[:VSwitchId]
60
+ _PrivateIpAddress = options[:PrivateIpAddress]
61
+ if _VSwitchId
62
+ _parameters['VSwitchId'] = _VSwitchId
63
+ _pathURL += '&VSwitchId=' + _VSwitchId
64
+
65
+ if _PrivateIpAddress
66
+ _parameters['PrivateIpAddress'] = _PrivateIpAddress
67
+ _pathURL += '&PrivateIpAddress=' + _PrivateIpAddress
68
+ end
69
+ else
70
+
71
+ _InternetMaxBandwidthIn = options[:InternetMaxBandwidthIn]
72
+ if _InternetMaxBandwidthIn
73
+ _parameters['InternetMaxBandwidthIn'] = _InternetMaxBandwidthIn
74
+ _pathURL += '&InternetMaxBandwidthIn=' + _InternetMaxBandwidthIn
75
+ end
76
+
77
+ _InternetMaxBandwidthOut = options[:InternetMaxBandwidthOut]
78
+ if _InternetMaxBandwidthOut
79
+ _parameters['InternetMaxBandwidthOut'] = _InternetMaxBandwidthOut
80
+ _pathURL += '&InternetMaxBandwidthOut=' + _InternetMaxBandwidthOut
81
+ end
82
+ end
83
+
84
+ _signature = sign(@aliyun_accesskey_secret, _parameters)
85
+ _pathURL += '&Signature=' + _signature
86
+
87
+ request(
88
+ expects: [200, 203],
89
+ method: 'GET',
90
+ path: _pathURL
91
+ )
92
+ end
93
+ end
94
+
95
+ class Mock
96
+ def create_server(name, image_ref, flavor_ref, options = {})
97
+ response = Excon::Response.new
98
+ response.status = 202
99
+
100
+ server_id = Fog::Mock.random_numbers(6).to_s
101
+ identity = Fog::Identity::OpenStack.new openstack_auth_url: credentials[:openstack_auth_url]
102
+ user = identity.users.find do |u|
103
+ u.name == @openstack_username
104
+ end
105
+
106
+ user_id = if user
107
+ user.id
108
+ else
109
+ response = identity.create_user(@openstack_username,
110
+ 'password',
111
+ "#{@openstack_username}@example.com")
112
+ response.body['user']['id']
113
+ end
114
+
115
+ mock_data = {
116
+ 'addresses' => { 'Private' => [{ 'addr' => Fog::Mock.random_ip }] },
117
+ 'flavor' => { 'id' => flavor_ref, 'links' => [{ 'href' => 'http://nova1:8774/admin/flavors/1', 'rel' => 'bookmark' }] },
118
+ 'id' => server_id,
119
+ 'image' => { 'id' => image_ref, 'links' => [{ 'href' => "http://nova1:8774/admin/images/#{image_ref}", 'rel' => 'bookmark' }] },
120
+ 'links' => [{ 'href' => 'http://nova1:8774/v1.1/admin/servers/5', 'rel' => 'self' }, { 'href' => 'http://nova1:8774/admin/servers/5', 'rel' => 'bookmark' }],
121
+ 'hostId' => '123456789ABCDEF01234567890ABCDEF',
122
+ 'metadata' => options['metadata'] || {},
123
+ 'name' => name || "server_#{rand(999)}",
124
+ 'accessIPv4' => options['accessIPv4'] || '',
125
+ 'accessIPv6' => options['accessIPv6'] || '',
126
+ 'progress' => 0,
127
+ 'status' => 'BUILD',
128
+ 'created' => '2012-09-27T00:04:18Z',
129
+ 'updated' => '2012-09-27T00:04:27Z',
130
+ 'user_id' => user_id,
131
+ 'config_drive' => options['config_drive'] || ''
132
+ }
133
+
134
+ if nics = options['nics']
135
+ nics.each do |_nic|
136
+ mock_data['addresses'].merge!(
137
+ 'Public' => [{ 'addr' => Fog::Mock.random_ip }]
138
+ )
139
+ end
140
+ end
141
+
142
+ response_data = {}
143
+ if options['return_reservation_id'] == 'True'
144
+ response_data = { 'reservation_id' => "r-#{Fog::Mock.random_numbers(6)}" }
145
+ else
146
+ response_data = {
147
+ 'adminPass' => 'password',
148
+ 'id' => server_id,
149
+ 'links' => mock_data['links']
150
+ }
151
+ end
152
+
153
+ if block_devices = options['block_device_mapping_v2']
154
+ block_devices.each { |bd| compute.volumes.get(bd[:uuid]).attach(server_id, bd[:device_name]) }
155
+ elsif block_device = options['block_device_mapping']
156
+ compute.volumes.get(block_device[:volume_id]).attach(server_id, block_device[:device_name])
157
+ end
158
+
159
+ data[:last_modified][:servers][server_id] = Time.now
160
+ data[:servers][server_id] = mock_data
161
+ if options['security_groups']
162
+ groups = Array(options['security_groups']).map do |sg|
163
+ if sg.is_a?(Fog::Compute::OpenStack::SecurityGroup)
164
+ sg.name
165
+ else
166
+ sg
167
+ end
168
+ end
169
+
170
+ data[:server_security_group_map][server_id] = groups
171
+ response_data['security_groups'] = groups
172
+ end
173
+
174
+ data[:last_modified][:servers][server_id] = Time.now
175
+ data[:servers][server_id] = mock_data
176
+ response.body = if options['return_reservation_id'] == 'True'
177
+ response_data
178
+ else
179
+ { 'server' => response_data }
180
+ end
181
+ response
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,46 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_snapshot(diskId, options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/snapshot&createsnapshot]
7
+ action = 'CreateSnapshot'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['DiskId'] = diskId
15
+ pathUrl += '&DiskId='
16
+ pathUrl += diskId
17
+
18
+ name = options[:name]
19
+ desc = options[:description]
20
+
21
+ if name
22
+ parameters['SnapshotName'] = name
23
+ pathUrl += '&SnapshotName='
24
+ pathUrl += name
25
+ end
26
+
27
+ if desc
28
+ parameters['Description'] = desc
29
+ pathUrl += '&Description='
30
+ pathUrl += desc
31
+ end
32
+
33
+ signature = sign(@aliyun_accesskey_secret, parameters)
34
+ pathUrl += '&Signature='
35
+ pathUrl += signature
36
+
37
+ request(
38
+ expects: [200, 203],
39
+ method: 'GET',
40
+ path: pathUrl
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_vpc(cidrBlock, options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vpc&createvpc]
7
+ action = 'CreateVpc'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['CidrBlock'] = cidrBlock
15
+ pathUrl += '&CidrBlock='
16
+ pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
17
+
18
+ name = options[:name]
19
+ desc = options[:description]
20
+
21
+ if name
22
+ parameters['VpcName'] = name
23
+ pathUrl += '&VpcName='
24
+ pathUrl += name
25
+ end
26
+
27
+ if desc
28
+ parameters['Description'] = desc
29
+ pathUrl += '&Description='
30
+ pathUrl += desc
31
+ end
32
+
33
+ signature = sign(@aliyun_accesskey_secret, parameters)
34
+ pathUrl += '&Signature='
35
+ pathUrl += signature
36
+
37
+ request(
38
+ expects: [200, 203],
39
+ method: 'GET',
40
+ path: pathUrl
41
+ )
42
+ end
43
+ end
44
+ end # aliyun
45
+ end # compute
46
+ end # fog
@@ -0,0 +1,58 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_vpn_connection(customergatewayId, vpngatewayId, localsubnet, remotesubnet,options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
7
+ action = 'CreateVpnConnection'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ parameters['CustomerGatewayId'] = customergatewayId
15
+ pathUrl += '&CustomerGatewayId='
16
+ pathUrl += customergatewayId
17
+
18
+ parameters['VpnGatewayId'] = vpngatewayId
19
+ pathUrl += '&VpnGatewayId='
20
+ pathUrl += vpngatewayId
21
+
22
+ parameters['LocalSubnet'] = localsubnet
23
+ pathUrl += '&LocalSubnet='
24
+ pathUrl += localsubnet
25
+
26
+ parameters['RemoteSubnet'] = remotesubnet
27
+ pathUrl += '&RemoteSubnet='
28
+ pathUrl += remotesubnet
29
+
30
+ name = options[:name]
31
+ ipsecconfig = options[:ipsecconfig]
32
+
33
+ if name
34
+ parameters['Name'] = name
35
+ pathUrl += '&Name='
36
+ pathUrl += name
37
+ end
38
+
39
+ if ipsecconfig
40
+ parameters['IpsecConfig'] = ipsecconfig
41
+ pathUrl += '&IpsecConfig='
42
+ pathUrl += ipsecconfig
43
+ end
44
+
45
+ signature = sign(@aliyun_accesskey_secret, parameters)
46
+ pathUrl += '&Signature='
47
+ pathUrl += signature
48
+
49
+ VPCrequest(
50
+ expects: [200, 203],
51
+ method: 'GET',
52
+ path: pathUrl
53
+ )
54
+ end
55
+ end
56
+ end # aliyun
57
+ end # compute
58
+ end # fog
@@ -0,0 +1,48 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_vpn_customergateway(ipaddress, options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
7
+ action = 'CreateCustomerGateway'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutVPCParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
13
+
14
+ parameters['IpAddress'] = ipaddress
15
+ pathUrl += '&IpAddress='
16
+ pathUrl += ipaddress
17
+
18
+
19
+
20
+ name = options[:name]
21
+ desc = options[:description]
22
+
23
+ if name
24
+ parameters['Name'] = name
25
+ pathUrl += '&Name='
26
+ pathUrl += name
27
+ end
28
+
29
+ if desc
30
+ parameters['Description'] = desc
31
+ pathUrl += '&Description='
32
+ pathUrl += desc
33
+ end
34
+
35
+ signature = sign(@aliyun_accesskey_secret, parameters)
36
+ pathUrl += '&Signature='
37
+ pathUrl += signature
38
+
39
+ VPCrequest(
40
+ expects: [200, 203],
41
+ method: 'GET',
42
+ path: pathUrl
43
+ )
44
+ end
45
+ end
46
+ end # aliyun
47
+ end # compute
48
+ end # fog
@@ -0,0 +1,54 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def create_vswitch(vpcId, cidrBlock, options = {})
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
7
+ action = 'CreateVSwitch'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['VpcId'] = vpcId
15
+ pathUrl += '&VpcId='
16
+ pathUrl += vpcId
17
+
18
+ parameters['CidrBlock'] = cidrBlock
19
+ pathUrl += '&CidrBlock='
20
+ pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
21
+
22
+ parameters['ZoneId'] = @aliyun_zone_id
23
+ pathUrl += '&ZoneId='
24
+ pathUrl += @aliyun_zone_id
25
+
26
+ name = options[:name]
27
+ desc = options[:description]
28
+
29
+ if name
30
+ parameters['VSwitchName'] = name
31
+ pathUrl += '&VSwitchName='
32
+ pathUrl += name
33
+ end
34
+
35
+ if desc
36
+ parameters['Description'] = desc
37
+ pathUrl += '&Description='
38
+ pathUrl += desc
39
+ end
40
+
41
+ signature = sign(@aliyun_accesskey_secret, parameters)
42
+ pathUrl += '&Signature='
43
+ pathUrl += signature
44
+
45
+ request(
46
+ expects: [200, 203],
47
+ method: 'GET',
48
+ path: pathUrl
49
+ )
50
+ end
51
+ end
52
+ end # aliyun
53
+ end # compute
54
+ end # fog
@@ -0,0 +1,41 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ # Delete a disk By the given id.
6
+ #
7
+ # ==== Parameters
8
+ # * diskId<~String> - the disk_id
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'RequestId'<~String> - Id of the request
14
+ #
15
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/disk&deletedisk]
16
+ def delete_disk(diskId)
17
+ action = 'DeleteDisk'
18
+ sigNonce = randonStr
19
+ time = Time.new.utc
20
+
21
+ parameters = defalutParameters(action, sigNonce, time)
22
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
23
+
24
+ parameters['DiskId'] = diskId
25
+ pathUrl += '&DiskId='
26
+ pathUrl += diskId
27
+
28
+ signature = sign(@aliyun_accesskey_secret, parameters)
29
+ pathUrl += '&Signature='
30
+ pathUrl += signature
31
+
32
+ request(
33
+ expects: [200, 203],
34
+ method: 'GET',
35
+ path: pathUrl
36
+ )
37
+ end
38
+ end
39
+ end # aliyun
40
+ end # compute
41
+ end # fog
@@ -0,0 +1,31 @@
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&deleteimage]
6
+ def delete_image(imageId)
7
+ action = 'DeleteImage'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ parameters['ImageId'] = imageId
15
+ pathUrl += '&ImageId='
16
+ pathUrl += imageId
17
+
18
+ signature = sign(@aliyun_accesskey_secret, parameters)
19
+ pathUrl += '&Signature='
20
+ pathUrl += signature
21
+
22
+ request(
23
+ expects: [200, 203],
24
+ method: 'GET',
25
+ path: pathUrl
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module Compute
3
+ class Aliyun
4
+ class Real
5
+ def delete_security_group(security_group_id)
6
+ # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&deletesecuritygroup]
7
+ action = 'DeleteSecurityGroup'
8
+ sigNonce = randonStr
9
+ time = Time.new.utc
10
+
11
+ parameters = defalutParameters(action, sigNonce, time)
12
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
13
+
14
+ if security_group_id
15
+ parameters['SecurityGroupId'] = security_group_id
16
+ pathUrl += '&SecurityGroupId='
17
+ pathUrl += security_group_id
18
+ else
19
+ raise ArgumentError, 'Missing required securyti id '
20
+ end
21
+
22
+ signature = sign(@aliyun_accesskey_secret, parameters)
23
+ pathUrl += '&Signature='
24
+ pathUrl += signature
25
+
26
+ request(
27
+ expects: [200, 203],
28
+ method: 'GET',
29
+ path: pathUrl
30
+ )
31
+ end
32
+ end
33
+
34
+ class Mock
35
+ def delete_security_group(security_group_id)
36
+ data[:security_groups].delete security_group_id.to_s
37
+
38
+ response = Excon::Response.new
39
+ response.status = 202
40
+ response.headers = {
41
+ 'Content-Type' => 'text/html; charset=UTF-8',
42
+ 'Content-Length' => '0',
43
+ 'Date' => Date.new
44
+ }
45
+ response.body = {}
46
+ response
47
+ end
48
+ end # mock
49
+ end # aliyun
50
+ end # compute
51
+ 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 delete_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {})
7
+ action = 'RevokeSecurityGroupEgress'
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