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
@@ -2,59 +2,45 @@ module Fog
2
2
  module Compute
3
3
  class Aliyun
4
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]
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
7
  action = 'CreateSnapshot'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
-
14
- parameters["DiskId"] = diskId
13
+
14
+ parameters['DiskId'] = diskId
15
15
  pathUrl += '&DiskId='
16
16
  pathUrl += diskId
17
17
 
18
18
  name = options[:name]
19
19
  desc = options[:description]
20
-
20
+
21
21
  if name
22
- parameters["SnapshotName"] = name
22
+ parameters['SnapshotName'] = name
23
23
  pathUrl += '&SnapshotName='
24
24
  pathUrl += name
25
25
  end
26
26
 
27
27
  if desc
28
- parameters["Description"] = desc
28
+ parameters['Description'] = desc
29
29
  pathUrl += '&Description='
30
30
  pathUrl += desc
31
- end
31
+ end
32
32
 
33
33
  signature = sign(@aliyun_accesskey_secret, parameters)
34
34
  pathUrl += '&Signature='
35
35
  pathUrl += signature
36
36
 
37
37
  request(
38
- :expects => [200, 203],
39
- :method => 'GET',
40
- :path => pathUrl
38
+ expects: [200, 203],
39
+ method: 'GET',
40
+ path: pathUrl
41
41
  )
42
42
  end
43
43
  end
44
-
45
- class Mock
46
- def list_images
47
- response = Excon::Response.new
48
- data = list_images_detail.body['images']
49
- images = []
50
- for image in data
51
- images << image.reject { |key, value| !['id', 'name', 'links'].include?(key) }
52
- end
53
- response.status = [200, 203][rand(1)]
54
- response.body = { 'images' => images }
55
- response
56
- end
57
- end
58
44
  end
59
45
  end
60
46
  end
@@ -2,32 +2,32 @@ module Fog
2
2
  module Compute
3
3
  class Aliyun
4
4
  class Real
5
- def create_vpc(cidrBlock, options={})
5
+ def create_vpc(cidrBlock, options = {})
6
6
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vpc&createvpc]
7
7
  action = 'CreateVpc'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
13
 
14
- parameters["CidrBlock"] = cidrBlock
14
+ parameters['CidrBlock'] = cidrBlock
15
15
  pathUrl += '&CidrBlock='
16
- pathUrl += URI.encode(cidrBlock,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
16
+ pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
17
17
 
18
18
  name = options[:name]
19
19
  desc = options[:description]
20
20
 
21
21
  if name
22
- parameters["VpcName"] = name
22
+ parameters['VpcName'] = name
23
23
  pathUrl += '&VpcName='
24
- pathUrl += name
24
+ pathUrl += name
25
25
  end
26
26
 
27
27
  if desc
28
- parameters["Description"] = desc
28
+ parameters['Description'] = desc
29
29
  pathUrl += '&Description='
30
- pathUrl += desc
30
+ pathUrl += desc
31
31
  end
32
32
 
33
33
  signature = sign(@aliyun_accesskey_secret, parameters)
@@ -35,39 +35,12 @@ module Fog
35
35
  pathUrl += signature
36
36
 
37
37
  request(
38
- :expects => [200, 203],
39
- :method => 'GET',
40
- :path => pathUrl
38
+ expects: [200, 203],
39
+ method: 'GET',
40
+ path: pathUrl
41
41
  )
42
42
  end
43
43
  end
44
-
45
- class Mock
46
- def create_security_group(name, description)
47
- Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
48
- tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
49
- security_group_id = Fog::Mock.random_numbers(2).to_i + 1
50
- self.data[:security_groups][security_group_id.to_s] = {
51
- 'tenant_id' => tenant_id,
52
- 'rules' => [],
53
- 'id' => security_group_id,
54
- 'name' => name,
55
- 'description' => description
56
- }
57
-
58
- response = Excon::Response.new
59
- response.status = 200
60
- response.headers = {
61
- 'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
62
- 'Content-Type' => 'application/json',
63
- 'Content-Length' => Fog::Mock.random_numbers(3).to_s,
64
- 'Date' => Date.new}
65
- response.body = {
66
- 'security_group' => self.data[:security_groups][security_group_id.to_s]
67
- }
68
- response
69
- end
70
- end # mock
71
44
  end # aliyun
72
45
  end # compute
73
46
  end # fog
@@ -2,24 +2,24 @@ module Fog
2
2
  module Compute
3
3
  class Aliyun
4
4
  class Real
5
- def create_vswitch(vpcId, cidrBlock, options={})
5
+ def create_vswitch(vpcId, cidrBlock, options = {})
6
6
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
7
7
  action = 'CreateVSwitch'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
13
 
14
- parameters["VpcId"] = vpcId
14
+ parameters['VpcId'] = vpcId
15
15
  pathUrl += '&VpcId='
16
16
  pathUrl += vpcId
17
17
 
18
- parameters["CidrBlock"] = cidrBlock
18
+ parameters['CidrBlock'] = cidrBlock
19
19
  pathUrl += '&CidrBlock='
20
- pathUrl += URI.encode(cidrBlock,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
20
+ pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
21
21
 
22
- parameters["ZoneId"] = @aliyun_zone_id
22
+ parameters['ZoneId'] = @aliyun_zone_id
23
23
  pathUrl += '&ZoneId='
24
24
  pathUrl += @aliyun_zone_id
25
25
 
@@ -27,15 +27,15 @@ module Fog
27
27
  desc = options[:description]
28
28
 
29
29
  if name
30
- parameters["VSwitchName"] = name
30
+ parameters['VSwitchName'] = name
31
31
  pathUrl += '&VSwitchName='
32
- pathUrl += name
32
+ pathUrl += name
33
33
  end
34
34
 
35
35
  if desc
36
- parameters["Description"] = desc
36
+ parameters['Description'] = desc
37
37
  pathUrl += '&Description='
38
- pathUrl += desc
38
+ pathUrl += desc
39
39
  end
40
40
 
41
41
  signature = sign(@aliyun_accesskey_secret, parameters)
@@ -43,39 +43,12 @@ module Fog
43
43
  pathUrl += signature
44
44
 
45
45
  request(
46
- :expects => [200, 203],
47
- :method => 'GET',
48
- :path => pathUrl
46
+ expects: [200, 203],
47
+ method: 'GET',
48
+ path: pathUrl
49
49
  )
50
50
  end
51
51
  end
52
-
53
- class Mock
54
- def create_security_group(name, description)
55
- Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
56
- tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
57
- security_group_id = Fog::Mock.random_numbers(2).to_i + 1
58
- self.data[:security_groups][security_group_id.to_s] = {
59
- 'tenant_id' => tenant_id,
60
- 'rules' => [],
61
- 'id' => security_group_id,
62
- 'name' => name,
63
- 'description' => description
64
- }
65
-
66
- response = Excon::Response.new
67
- response.status = 200
68
- response.headers = {
69
- 'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
70
- 'Content-Type' => 'application/json',
71
- 'Content-Length' => Fog::Mock.random_numbers(3).to_s,
72
- 'Date' => Date.new}
73
- response.body = {
74
- 'security_group' => self.data[:security_groups][security_group_id.to_s]
75
- }
76
- response
77
- end
78
- end # mock
79
52
  end # aliyun
80
53
  end # compute
81
54
  end # fog
@@ -6,7 +6,7 @@ module Fog
6
6
  #
7
7
  # ==== Parameters
8
8
  # * diskId<~String> - the disk_id
9
- #
9
+ #
10
10
  # ==== Returns
11
11
  # * response<~Excon::Response>:
12
12
  # * body<~Hash>:
@@ -15,54 +15,27 @@ module Fog
15
15
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/disk&deletedisk]
16
16
  def delete_disk(diskId)
17
17
  action = 'DeleteDisk'
18
- sigNonce = randonStr()
18
+ sigNonce = randonStr
19
19
  time = Time.new.utc
20
20
 
21
21
  parameters = defalutParameters(action, sigNonce, time)
22
22
  pathUrl = defaultAliyunUri(action, sigNonce, time)
23
-
24
- parameters["DiskId"] = diskId
23
+
24
+ parameters['DiskId'] = diskId
25
25
  pathUrl += '&DiskId='
26
- pathUrl += diskId
26
+ pathUrl += diskId
27
27
 
28
28
  signature = sign(@aliyun_accesskey_secret, parameters)
29
29
  pathUrl += '&Signature='
30
30
  pathUrl += signature
31
31
 
32
32
  request(
33
- :expects => [200, 203],
34
- :method => 'GET',
35
- :path => pathUrl
33
+ expects: [200, 203],
34
+ method: 'GET',
35
+ path: pathUrl
36
36
  )
37
37
  end
38
38
  end
39
-
40
- class Mock
41
- def create_security_group(name, description)
42
- Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
43
- tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
44
- security_group_id = Fog::Mock.random_numbers(2).to_i + 1
45
- self.data[:security_groups][security_group_id.to_s] = {
46
- 'tenant_id' => tenant_id,
47
- 'rules' => [],
48
- 'id' => security_group_id,
49
- 'name' => name,
50
- 'description' => description
51
- }
52
-
53
- response = Excon::Response.new
54
- response.status = 200
55
- response.headers = {
56
- 'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
57
- 'Content-Type' => 'application/json',
58
- 'Content-Length' => Fog::Mock.random_numbers(3).to_s,
59
- 'Date' => Date.new}
60
- response.body = {
61
- 'security_group' => self.data[:security_groups][security_group_id.to_s]
62
- }
63
- response
64
- end
65
- end # mock
66
39
  end # aliyun
67
40
  end # compute
68
41
  end # fog
@@ -5,54 +5,27 @@ module Fog
5
5
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/image&deleteimage]
6
6
  def delete_image(imageId)
7
7
  action = 'DeleteImage'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
13
 
14
- parameters["ImageId"] = imageId
14
+ parameters['ImageId'] = imageId
15
15
  pathUrl += '&ImageId='
16
- pathUrl += imageId
16
+ pathUrl += imageId
17
17
 
18
18
  signature = sign(@aliyun_accesskey_secret, parameters)
19
19
  pathUrl += '&Signature='
20
20
  pathUrl += signature
21
21
 
22
22
  request(
23
- :expects => [200, 203],
24
- :method => 'GET',
25
- :path => pathUrl
23
+ expects: [200, 203],
24
+ method: 'GET',
25
+ path: pathUrl
26
26
  )
27
27
  end
28
28
  end
29
-
30
- class Mock
31
- def create_image(server_id, name, metadata={})
32
- response = Excon::Response.new
33
- response.status = 202
34
-
35
- img_id=Fog::Mock.random_numbers(6).to_s
36
-
37
- data = {
38
- 'id' => img_id,
39
- 'server' => {"id"=>"3", "links"=>[{"href"=>"http://nova1:8774/admin/servers/#{server_id}", "rel"=>"bookmark"}]},
40
- 'links' => [{"href"=>"http://nova1:8774/v1.1/admin/images/#{img_id}", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/images/#{img_id}", "rel"=>"bookmark"}],
41
- 'metadata' => metadata || {},
42
- 'name' => name || "server_#{rand(999)}",
43
- 'progress' => 0,
44
- 'status' => 'SAVING',
45
- 'minDisk' => 0,
46
- 'minRam' => 0,
47
- 'updated' => "",
48
- 'created' => ""
49
- }
50
- self.data[:last_modified][:images][data['id']] = Time.now
51
- self.data[:images][data['id']] = data
52
- response.body = { 'image' => data }
53
- response
54
- end
55
- end
56
29
  end
57
30
  end
58
31
  end
@@ -5,42 +5,42 @@ module Fog
5
5
  def delete_security_group(security_group_id)
6
6
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&deletesecuritygroup]
7
7
  action = 'DeleteSecurityGroup'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
13
 
14
14
  if security_group_id
15
- parameters["SecurityGroupId"] = security_group_id
15
+ parameters['SecurityGroupId'] = security_group_id
16
16
  pathUrl += '&SecurityGroupId='
17
- pathUrl += security_group_id
17
+ pathUrl += security_group_id
18
18
  else
19
- raise ArgumentError, "Missing required securyti id "
19
+ raise ArgumentError, 'Missing required securyti id '
20
20
  end
21
21
 
22
22
  signature = sign(@aliyun_accesskey_secret, parameters)
23
23
  pathUrl += '&Signature='
24
24
  pathUrl += signature
25
-
25
+
26
26
  request(
27
- :expects => [200, 203],
28
- :method => 'GET',
29
- :path => pathUrl
27
+ expects: [200, 203],
28
+ method: 'GET',
29
+ path: pathUrl
30
30
  )
31
31
  end
32
32
  end
33
33
 
34
34
  class Mock
35
35
  def delete_security_group(security_group_id)
36
- self.data[:security_groups].delete security_group_id.to_s
36
+ data[:security_groups].delete security_group_id.to_s
37
37
 
38
38
  response = Excon::Response.new
39
39
  response.status = 202
40
40
  response.headers = {
41
- "Content-Type" => "text/html; charset=UTF-8",
42
- "Content-Length" => "0",
43
- "Date" => Date.new
41
+ 'Content-Type' => 'text/html; charset=UTF-8',
42
+ 'Content-Length' => '0',
43
+ 'Date' => Date.new
44
44
  }
45
45
  response.body = {}
46
46
  response
@@ -48,4 +48,4 @@ module Fog
48
48
  end # mock
49
49
  end # aliyun
50
50
  end # compute
51
- end #fog
51
+ end # fog
@@ -3,58 +3,47 @@ module Fog
3
3
  class Aliyun
4
4
  class Real
5
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
-
6
+ def delete_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {})
8
7
  action = 'RevokeSecurityGroupEgress'
9
- sigNonce = randonStr()
8
+ sigNonce = randonStr
10
9
  time = Time.new.utc
11
10
 
12
11
  parameters = defalutParameters(action, sigNonce, time)
13
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
14
-
15
- parameters["SecurityGroupId"] = securitygroup_id
13
+
14
+ parameters['SecurityGroupId'] = securitygroup_id
16
15
  pathUrl += '&SecurityGroupId='
17
16
  pathUrl += securitygroup_id
18
17
 
19
- parameters["DestCidrIp"] = destCidrIp
18
+ parameters['DestCidrIp'] = destCidrIp
20
19
  pathUrl += '&DestCidrIp='
21
- pathUrl += URI.encode(destCidrIp,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
22
- unless nicType
23
- nicType='intranet'
24
- end
25
- parameters["NicType"] = nicType
20
+ pathUrl += URI.encode(destCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
21
+ nicType = 'intranet' unless nicType
22
+ parameters['NicType'] = nicType
26
23
  pathUrl += '&NicType='
27
24
  pathUrl += nicType
28
-
25
+
29
26
  portRange = option[:portRange]
30
- unless portRange
31
- portRange = '-1/-1'
32
- end
33
- parameters["PortRange"] = portRange
27
+ portRange = '-1/-1' unless portRange
28
+ parameters['PortRange'] = portRange
34
29
  pathUrl += '&PortRange='
35
- pathUrl += URI.encode(portRange,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
36
-
30
+ pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
31
+
37
32
  protocol = option[:protocol]
38
- unless protocol
39
- protocol = 'all'
40
- end
41
- parameters["IpProtocol"] = protocol
33
+ protocol = 'all' unless protocol
34
+ parameters['IpProtocol'] = protocol
42
35
  pathUrl += '&IpProtocol='
43
36
  pathUrl += protocol
44
37
 
45
38
  policy = option[:policy]
46
- unless policy
47
- policy = 'accept'
48
- end
49
- parameters["Policy"] = policy
39
+ policy = 'accept' unless policy
40
+ parameters['Policy'] = policy
50
41
  pathUrl += '&Policy='
51
42
  pathUrl += policy
52
43
 
53
44
  priority = option[:priority]
54
- unless priority
55
- priority = '1'
56
- end
57
- parameters["Priority"] = priority
45
+ priority = '1' unless priority
46
+ parameters['Priority'] = priority
58
47
  pathUrl += '&Priority='
59
48
  pathUrl += priority
60
49
 
@@ -63,42 +52,12 @@ module Fog
63
52
  pathUrl += signature
64
53
 
65
54
  request(
66
- :expects => [200, 203],
67
- :method => 'GET',
68
- :path => pathUrl
55
+ expects: [200, 203],
56
+ method: 'GET',
57
+ path: pathUrl
69
58
  )
70
59
  end
71
60
  end
72
-
73
- class Mock
74
- def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)
75
- parent_group_id = parent_group_id.to_i
76
- response = Excon::Response.new
77
- response.status = 200
78
- response.headers = {
79
- 'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
80
- 'Content-Type' => 'application/json',
81
- 'Content-Length' => Fog::Mock.random_numbers(3).to_s,
82
- 'Date' => Date.new
83
- }
84
- rule = {
85
- 'id' => Fog::Mock.random_numbers(2).to_i,
86
- 'from_port' => from_port,
87
- 'group' => group_id || {},
88
- 'ip_protocol' => ip_protocol,
89
- 'to_port' => to_port,
90
- 'parent_group_id' => parent_group_id,
91
- 'ip_range' => {
92
- 'cidr' => cidr
93
- }
94
- }
95
- self.data[:security_groups][parent_group_id.to_s]['rules'].push(rule)
96
- response.body = {
97
- 'security_group_rule' => rule
98
- }
99
- response
100
- end
101
- end # mock
102
61
  end # aliyun
103
62
  end # compute
104
63
  end # fog