fog-aliyun 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +309 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/fog-aliyun.gemspec +30 -0
  13. data/lib/fog/aliyun.rb +19 -0
  14. data/lib/fog/aliyun/compute.rb +346 -0
  15. data/lib/fog/aliyun/models/compute/vpc.rb +69 -0
  16. data/lib/fog/aliyun/models/compute/vpcs.rb +89 -0
  17. data/lib/fog/aliyun/models/compute/vswitch.rb +70 -0
  18. data/lib/fog/aliyun/models/compute/vswitches.rb +87 -0
  19. data/lib/fog/aliyun/models/storage/directories.rb +45 -0
  20. data/lib/fog/aliyun/models/storage/directory.rb +48 -0
  21. data/lib/fog/aliyun/models/storage/file.rb +197 -0
  22. data/lib/fog/aliyun/models/storage/files.rb +178 -0
  23. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +79 -0
  24. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +63 -0
  25. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +66 -0
  26. data/lib/fog/aliyun/requests/compute/attach_disk.rb +82 -0
  27. data/lib/fog/aliyun/requests/compute/create_disk.rb +135 -0
  28. data/lib/fog/aliyun/requests/compute/create_image.rb +79 -0
  29. data/lib/fog/aliyun/requests/compute/create_security_group.rb +77 -0
  30. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +86 -0
  31. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +86 -0
  32. data/lib/fog/aliyun/requests/compute/create_server.rb +188 -0
  33. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +60 -0
  34. data/lib/fog/aliyun/requests/compute/create_vpc.rb +73 -0
  35. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +81 -0
  36. data/lib/fog/aliyun/requests/compute/delete_disk.rb +58 -0
  37. data/lib/fog/aliyun/requests/compute/delete_image.rb +58 -0
  38. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +51 -0
  39. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +85 -0
  40. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +86 -0
  41. data/lib/fog/aliyun/requests/compute/delete_server.rb +48 -0
  42. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +45 -0
  43. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +52 -0
  44. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +51 -0
  45. data/lib/fog/aliyun/requests/compute/detach_disk.rb +51 -0
  46. data/lib/fog/aliyun/requests/compute/join_security_group.rb +41 -0
  47. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +41 -0
  48. data/lib/fog/aliyun/requests/compute/list_disks.rb +75 -0
  49. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +81 -0
  50. data/lib/fog/aliyun/requests/compute/list_images.rb +85 -0
  51. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +74 -0
  52. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +81 -0
  53. data/lib/fog/aliyun/requests/compute/list_server_types.rb +77 -0
  54. data/lib/fog/aliyun/requests/compute/list_servers.rb +74 -0
  55. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +86 -0
  56. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +64 -0
  57. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +67 -0
  58. data/lib/fog/aliyun/requests/compute/list_zones.rb +44 -0
  59. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +73 -0
  60. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +73 -0
  61. data/lib/fog/aliyun/requests/compute/reboot_server.rb +44 -0
  62. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +53 -0
  63. data/lib/fog/aliyun/requests/compute/start_server.rb +42 -0
  64. data/lib/fog/aliyun/requests/compute/stop_server.rb +42 -0
  65. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +56 -0
  66. data/lib/fog/aliyun/requests/storage/copy_object.rb +42 -0
  67. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -0
  68. data/lib/fog/aliyun/requests/storage/delete_container.rb +38 -0
  69. data/lib/fog/aliyun/requests/storage/delete_object.rb +53 -0
  70. data/lib/fog/aliyun/requests/storage/get_bucket.rb +148 -0
  71. data/lib/fog/aliyun/requests/storage/get_container.rb +72 -0
  72. data/lib/fog/aliyun/requests/storage/get_containers.rb +76 -0
  73. data/lib/fog/aliyun/requests/storage/get_object.rb +45 -0
  74. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +43 -0
  75. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +43 -0
  76. data/lib/fog/aliyun/requests/storage/head_object.rb +34 -0
  77. data/lib/fog/aliyun/requests/storage/list_buckets.rb +47 -0
  78. data/lib/fog/aliyun/requests/storage/list_objects.rb +104 -0
  79. data/lib/fog/aliyun/requests/storage/put_bucket.rb +23 -0
  80. data/lib/fog/aliyun/requests/storage/put_container.rb +35 -0
  81. data/lib/fog/aliyun/requests/storage/put_object.rb +199 -0
  82. data/lib/fog/aliyun/storage.rb +214 -0
  83. data/lib/fog/aliyun/version.rb +5 -0
  84. data/lib/fog/bin/aliyun.rb +31 -0
  85. metadata +227 -0
@@ -0,0 +1,81 @@
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&describesecuritygroup]
6
+ def list_security_groups(options={})
7
+
8
+ action = 'DescribeSecurityGroups'
9
+ sigNonce = randonStr()
10
+ time = Time.new.utc
11
+
12
+ parameters = defalutParameters(action, sigNonce, time)
13
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
14
+
15
+ pageNumber = options[:pageNumber]
16
+ pageSize = options[:pageSize]
17
+ vpcId = options[:vpcid]
18
+
19
+ if vpcId
20
+ parameters["VpcId"] = vpcId
21
+ pathUrl += '&VpcId='
22
+ pathUrl += vpcId
23
+ end
24
+
25
+ if pageNumber
26
+ parameters["PageNumber"] = pageNumber
27
+ pathUrl += '&PageNumber='
28
+ pathUrl += pageNumber
29
+ end
30
+
31
+ pageSize = options[:pageSize]
32
+ unless pageSize
33
+ pageSize = '50'
34
+ end
35
+ parameters["PageSize"] = pageSize
36
+ pathUrl += '&PageSize='
37
+ pathUrl += pageSize
38
+
39
+ signature = sign(@aliyun_accesskey_secret, parameters)
40
+ pathUrl += '&Signature='
41
+ pathUrl += signature
42
+
43
+ request(
44
+ :expects => [200],
45
+ :method => 'GET',
46
+ :path => pathUrl
47
+ )
48
+ end
49
+ end
50
+
51
+ class Mock
52
+ def list_security_groups(server_id = nil)
53
+ security_groups = self.data[:security_groups].values
54
+
55
+ groups = if server_id then
56
+ server_group_names =
57
+ Array(self.data[:server_security_group_map][server_id])
58
+
59
+ server_group_names.map do |name|
60
+ security_groups.find do |sg|
61
+ sg['name'] == name
62
+ end
63
+ end.compact
64
+ else
65
+ security_groups
66
+ end
67
+
68
+ Excon::Response.new(
69
+ :body => { 'security_groups' => groups },
70
+ :headers => {
71
+ "X-Compute-Request-Id" => "req-#{Fog::Mock.random_base64(36)}",
72
+ "Content-Type" => "application/json",
73
+ "Date" => Date.new
74
+ },
75
+ :status => 200
76
+ )
77
+ end
78
+ end # mock
79
+ end # aliyun
80
+ end # compute
81
+ end # fog
@@ -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.3.1.DGkmH7#/pub/ecs/open-api/other&describeinstancetypes]
6
+ def list_server_types
7
+ _action = 'DescribeInstanceTypes'
8
+ _sigNonce = randonStr()
9
+ _time = Time.new.utc
10
+
11
+ _parameters = defalutParameters(_action, _sigNonce, _time)
12
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
13
+
14
+ _signature = sign(@aliyun_accesskey_secret, _parameters)
15
+ _pathURL += '&Signature='+_signature
16
+
17
+ response = request(
18
+ :expects => [200, 203],
19
+ :method => 'GET',
20
+ :path => _pathURL
21
+ )
22
+
23
+ #_InstanceType = Hash.new
24
+ #_InstanceTypeList = Fog::JSON.decode(response.body)["InstanceTypes"]["InstanceType"]
25
+ #_InstanceTypeList.each do |instanceType|
26
+ # _InstanceType[[instanceType["CpuCoreCount"], instanceType["MemorySize"]]] = instanceType["InstanceTypeId"]
27
+ #end
28
+ #_InstanceType
29
+ end #end list_server_types
30
+
31
+ def get_instance_type(cpuCount, memorySize)
32
+ _action = 'DescribeInstanceTypes'
33
+ _sigNonce = randonStr()
34
+ _time = Time.new.utc
35
+
36
+ _parameters = defalutParameters(_action, _sigNonce, _time)
37
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
38
+
39
+ _signature = sign(@aliyun_accesskey_secret, _parameters)
40
+ _pathURL += '&Signature='+_signature
41
+
42
+ response = request(
43
+ :expects => [200, 203],
44
+ :method => 'GET',
45
+ :path => _pathURL
46
+ )
47
+
48
+ _InstanceTypeId = nil
49
+ _InstanceTypeList = Fog::JSON.decode(response.body)["InstanceTypes"]["InstanceType"]
50
+ _InstanceTypeList.each do |instanceType|
51
+ if ((instanceType["CpuCoreCount"] == cpuCount) && (instanceType["MemorySize"] == memorySize))
52
+ _InstanceTypeId = instanceType["InstanceTypeId"]
53
+ puts "_instanceTypeId: "+_InstanceTypeId
54
+ break
55
+ end #end if
56
+ end #end each
57
+ _InstanceTypeId
58
+ end #end get_instance_type
59
+ end #end class Real
60
+
61
+ # class Mock
62
+ # def list_servers(options = {})
63
+ # response = Excon::Response.new
64
+ # data = list_servers_detail.body['servers']
65
+ # servers = []
66
+ # for server in data
67
+ # servers << server.reject { |key, value| !['id', 'name', 'links'].include?(key) }
68
+ # end
69
+ # response.status = [200, 203][rand(1)]
70
+ # response.body = { 'servers' => servers }
71
+ # response
72
+ # end
73
+ # end
74
+ end #end class Aliyun
75
+ end #end module Compute
76
+ #end module Fog
77
+ end
@@ -0,0 +1,74 @@
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&describeinstances]
6
+ def list_servers(options={})
7
+
8
+ _action = 'DescribeInstances'
9
+ _sigNonce = randonStr()
10
+ _time = Time.new.utc
11
+
12
+ _parameters = defalutParameters(_action, _sigNonce, _time)
13
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
14
+
15
+ _InstanceId = options[:aliyun_InstanceId]
16
+ _VpcId = options[:aliyun_VpcId]
17
+ _SecurityGroupId = options[:aliyun_SecurityGroupId]
18
+ _PageNumber = options[:aliyun_PageNumber]
19
+ _PageSize = options[:aliyun_PageSize]
20
+
21
+ if _InstanceId != nil
22
+ _InstanceStr = "[\"#{_InstanceId}\"]"
23
+ _parameters['InstanceIds'] = _InstanceStr
24
+ _pathURL += '&InstanceIds='+_InstanceStr
25
+ end
26
+
27
+ if _VpcId != nil
28
+ _parameters['VpcId'] = _VpcId
29
+ _pathURL += '&VpcId='+_VpcId
30
+ end
31
+
32
+ if _SecurityGroupId != nil
33
+ _parameters['SecurityGroupId']=_SecurityGroupId
34
+ _pathURL += '&SecurityGroupId='+_SecurityGroupId
35
+ end
36
+
37
+ if _PageNumber != nil
38
+ _parameters['PageNumber']=_PageNumber
39
+ _pathURL += '&PageNumber='+_PageNumber
40
+ end
41
+
42
+ unless _PageSize
43
+ _PageSize = '50'
44
+ end
45
+ _parameters['PageSize']=_PageSize
46
+ _pathURL += '&PageSize='+_PageSize
47
+
48
+ _signature = sign(@aliyun_accesskey_secret, _parameters)
49
+ _pathURL += '&Signature='+_signature
50
+
51
+ request(
52
+ :expects => [200, 203],
53
+ :method => 'GET',
54
+ :path => _pathURL
55
+ )
56
+ end
57
+ end
58
+
59
+ class Mock
60
+ def list_servers(options = {})
61
+ response = Excon::Response.new
62
+ data = list_servers_detail.body['servers']
63
+ servers = []
64
+ for server in data
65
+ servers << server.reject { |key, value| !['id', 'name', 'links'].include?(key) }
66
+ end
67
+ response.status = [200, 203][rand(1)]
68
+ response.body = { 'servers' => servers }
69
+ response
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,86 @@
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/snapshot&describesnapshots]
6
+ def list_snapshoots(options={})
7
+
8
+ action = 'DescribeSnapshots'
9
+ sigNonce = randonStr()
10
+ time = Time.new.utc
11
+
12
+ parameters = defalutParameters(action, sigNonce, time)
13
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
14
+
15
+ pageNumber = options[:pageNumber]
16
+ pageSize = options[:pageSize]
17
+ instanceId = options[:instanceId]
18
+ diskId = options[:diskId]
19
+ snapshotId = options[:snapshotIds]
20
+ sourceDiskType = options[:sourceDiskType]
21
+
22
+ if instanceId
23
+ parameters["InstanceId"] = instanceId
24
+ pathUrl += '&InstanceId='
25
+ pathUrl += instanceId
26
+ end
27
+
28
+ if diskId
29
+ parameters["DiskId"] = diskId
30
+ pathUrl += '&DiskId='
31
+ pathUrl += diskId
32
+ end
33
+
34
+ if snapshotId
35
+ parameters["SnapshotIds"] = Fog::JSON.encode(snapshotId)
36
+ pathUrl += '&SnapshotIds='
37
+ pathUrl += Fog::JSON.encode(snapshotId)
38
+ end
39
+
40
+ if sourceDiskType
41
+ parameters["SourceDiskType"] = sourceDiskType
42
+ pathUrl += '&SourceDiskType='
43
+ pathUrl += sourceDiskType
44
+ end
45
+
46
+ if pageNumber
47
+ parameters["PageNumber"] = pageNumber
48
+ pathUrl += '&PageNumber='
49
+ pathUrl += pageNumber
50
+ end
51
+
52
+ unless pageSize
53
+ pageSize = '50'
54
+ end
55
+ parameters["PageSize"] = pageSize
56
+ pathUrl += '&PageSize='
57
+ pathUrl += pageSize
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
+ )
68
+ end
69
+ end
70
+
71
+ class Mock
72
+ def list_images
73
+ response = Excon::Response.new
74
+ data = list_images_detail.body['images']
75
+ images = []
76
+ for image in data
77
+ images << image.reject { |key, value| !['id', 'name', 'links'].include?(key) }
78
+ end
79
+ response.status = [200, 203][rand(1)]
80
+ response.body = { 'images' => images }
81
+ response
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,64 @@
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/vpc&describevpcs]
6
+ def list_vpcs(options={})
7
+
8
+ action = 'DescribeVpcs'
9
+ sigNonce = randonStr()
10
+ time = Time.new.utc
11
+
12
+ parameters = defalutParameters(action, sigNonce, time)
13
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
14
+
15
+ _VpcId = options[:vpcId]
16
+ if _VpcId
17
+ parameters["VpcId"] = _VpcId
18
+ pathUrl += '&VpcId='
19
+ pathUrl += _VpcId
20
+ end
21
+
22
+ pageNumber = options[:pageNumber]
23
+ pageSize = options[:pageSize]
24
+ if pageNumber
25
+ parameters["PageNumber"] = pageNumber
26
+ pathUrl += '&PageNumber='
27
+ pathUrl += pageNumber
28
+ end
29
+
30
+ unless pageSize
31
+ pageSize = '50'
32
+ end
33
+ parameters["PageSize"] = pageSize
34
+ pathUrl += '&PageSize='
35
+ pathUrl += pageSize
36
+
37
+ signature = sign(@aliyun_accesskey_secret, parameters)
38
+ pathUrl += '&Signature='
39
+ pathUrl += signature
40
+
41
+ request(
42
+ :expects => [200, 203],
43
+ :method => 'GET',
44
+ :path => pathUrl
45
+ )
46
+ end
47
+ end
48
+
49
+ class Mock
50
+ def list_images
51
+ response = Excon::Response.new
52
+ data = list_images_detail.body['images']
53
+ images = []
54
+ for image in data
55
+ images << image.reject { |key, value| !['id', 'name', 'links'].include?(key) }
56
+ end
57
+ response.status = [200, 203][rand(1)]
58
+ response.body = { 'images' => images }
59
+ response
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,67 @@
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/vswitch&describevswitches]
6
+ def list_vswitchs(vpcid, options={})
7
+
8
+ action = 'DescribeVSwitches'
9
+ sigNonce = randonStr()
10
+ time = Time.new.utc
11
+
12
+ parameters = defalutParameters(action, sigNonce, time)
13
+ pathUrl = defaultAliyunUri(action, sigNonce, time)
14
+
15
+ parameters["VpcId"] = vpcid
16
+ pathUrl += '&VpcId='
17
+ pathUrl += vpcid
18
+
19
+ pageNumber = options[:pageNumber]
20
+ pageSize = options[:pageSize]
21
+ vswitchId = options[:vSwitchId]
22
+ if vswitchId
23
+ parameters["VSwitchId"] = vswitchId
24
+ pathUrl +='&VSwitchId='
25
+ pathUrl += vswitchId
26
+ end
27
+ if pageNumber
28
+ parameters["PageNumber"] = pageNumber
29
+ pathUrl += '&PageNumber='
30
+ pathUrl += pageNumber
31
+ end
32
+
33
+ unless pageSize
34
+ pageSize = '50'
35
+ end
36
+ parameters["PageSize"] = pageSize
37
+ pathUrl += '&PageSize='
38
+ pathUrl += pageSize
39
+
40
+ signature = sign(@aliyun_accesskey_secret, parameters)
41
+ pathUrl += '&Signature='
42
+ pathUrl += signature
43
+
44
+ request(
45
+ :expects => [200, 203],
46
+ :method => 'GET',
47
+ :path => pathUrl
48
+ )
49
+ end
50
+ end
51
+
52
+ class Mock
53
+ def list_images
54
+ response = Excon::Response.new
55
+ data = list_images_detail.body['images']
56
+ images = []
57
+ for image in data
58
+ images << image.reject { |key, value| !['id', 'name', 'links'].include?(key) }
59
+ end
60
+ response.status = [200, 203][rand(1)]
61
+ response.body = { 'images' => images }
62
+ response
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end