fog-xiaozhu 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +149 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +312 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fog-aliyun.gemspec +33 -0
- data/lib/fog/aliyun/compute.rb +424 -0
- data/lib/fog/aliyun/models/compute/eip_address.rb +57 -0
- data/lib/fog/aliyun/models/compute/eip_addresses.rb +28 -0
- data/lib/fog/aliyun/models/compute/image.rb +66 -0
- data/lib/fog/aliyun/models/compute/images.rb +25 -0
- data/lib/fog/aliyun/models/compute/route_entry.rb +26 -0
- data/lib/fog/aliyun/models/compute/route_entrys.rb +41 -0
- data/lib/fog/aliyun/models/compute/route_table.rb +30 -0
- data/lib/fog/aliyun/models/compute/route_tables.rb +27 -0
- data/lib/fog/aliyun/models/compute/security_group.rb +81 -0
- data/lib/fog/aliyun/models/compute/security_group_rule.rb +47 -0
- data/lib/fog/aliyun/models/compute/security_group_rules.rb +23 -0
- data/lib/fog/aliyun/models/compute/security_groups.rb +32 -0
- data/lib/fog/aliyun/models/compute/server.rb +70 -0
- data/lib/fog/aliyun/models/compute/servers.rb +42 -0
- data/lib/fog/aliyun/models/compute/snapshot.rb +52 -0
- data/lib/fog/aliyun/models/compute/snapshots.rb +38 -0
- data/lib/fog/aliyun/models/compute/volume.rb +101 -0
- data/lib/fog/aliyun/models/compute/volumes.rb +135 -0
- data/lib/fog/aliyun/models/compute/vpc.rb +77 -0
- data/lib/fog/aliyun/models/compute/vpcs.rb +80 -0
- data/lib/fog/aliyun/models/compute/vrouter.rb +35 -0
- data/lib/fog/aliyun/models/compute/vrouters.rb +61 -0
- data/lib/fog/aliyun/models/compute/vswitch.rb +70 -0
- data/lib/fog/aliyun/models/compute/vswitches.rb +80 -0
- data/lib/fog/aliyun/models/storage/directories.rb +39 -0
- data/lib/fog/aliyun/models/storage/directory.rb +48 -0
- data/lib/fog/aliyun/models/storage/file.rb +192 -0
- data/lib/fog/aliyun/models/storage/files.rb +193 -0
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +54 -0
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +39 -0
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +49 -0
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +79 -0
- data/lib/fog/aliyun/requests/compute/create_disk.rb +137 -0
- data/lib/fog/aliyun/requests/compute/create_image.rb +79 -0
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +77 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/create_server.rb +186 -0
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +46 -0
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +46 -0
- data/lib/fog/aliyun/requests/compute/create_vpn_connection.rb +58 -0
- data/lib/fog/aliyun/requests/compute/create_vpn_customergateway.rb +48 -0
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +54 -0
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +41 -0
- data/lib/fog/aliyun/requests/compute/delete_image.rb +31 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +51 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/delete_server.rb +48 -0
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +31 -0
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +35 -0
- data/lib/fog/aliyun/requests/compute/delete_vpn_connection.rb +35 -0
- data/lib/fog/aliyun/requests/compute/delete_vpn_customergateway.rb +35 -0
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +35 -0
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +41 -0
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +40 -0
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +40 -0
- data/lib/fog/aliyun/requests/compute/list_disks.rb +150 -0
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +55 -0
- data/lib/fog/aliyun/requests/compute/list_images.rb +82 -0
- data/lib/fog/aliyun/requests/compute/list_route_tables.rb +64 -0
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +73 -0
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +78 -0
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +77 -0
- data/lib/fog/aliyun/requests/compute/list_servers.rb +71 -0
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +97 -0
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +47 -0
- data/lib/fog/aliyun/requests/compute/list_vpn_connections.rb +49 -0
- data/lib/fog/aliyun/requests/compute/list_vpn_customergateways.rb +43 -0
- data/lib/fog/aliyun/requests/compute/list_vpn_gateways.rb +49 -0
- data/lib/fog/aliyun/requests/compute/list_vrouters.rb +61 -0
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +50 -0
- data/lib/fog/aliyun/requests/compute/list_zones.rb +44 -0
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +73 -0
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +45 -0
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +43 -0
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +29 -0
- data/lib/fog/aliyun/requests/compute/start_server.rb +41 -0
- data/lib/fog/aliyun/requests/compute/stop_server.rb +41 -0
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +49 -0
- data/lib/fog/aliyun/requests/storage/copy_object.rb +39 -0
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -0
- data/lib/fog/aliyun/requests/storage/delete_container.rb +35 -0
- data/lib/fog/aliyun/requests/storage/delete_object.rb +51 -0
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -0
- data/lib/fog/aliyun/requests/storage/get_container.rb +60 -0
- data/lib/fog/aliyun/requests/storage/get_containers.rb +64 -0
- data/lib/fog/aliyun/requests/storage/get_object.rb +45 -0
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +43 -0
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +43 -0
- data/lib/fog/aliyun/requests/storage/head_object.rb +34 -0
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -0
- data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -0
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -0
- data/lib/fog/aliyun/requests/storage/put_container.rb +35 -0
- data/lib/fog/aliyun/requests/storage/put_object.rb +189 -0
- data/lib/fog/aliyun/storage.rb +233 -0
- data/lib/fog/aliyun/version.rb +5 -0
- data/lib/fog/aliyun.rb +19 -0
- data/lib/fog/bin/aliyun.rb +31 -0
- metadata +311 -0
@@ -0,0 +1,97 @@
|
|
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_snapshots(options = {})
|
7
|
+
action = 'DescribeSnapshots'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
pageNumber = options[:pageNumber]
|
15
|
+
pageSize = options[:pageSize]
|
16
|
+
instanceId = options[:instanceId]
|
17
|
+
diskId = options[:diskId]
|
18
|
+
snapshotId = options[:snapshotIds]
|
19
|
+
sourceDiskType = options[:sourceDiskType]
|
20
|
+
name = options[:snapshotName]
|
21
|
+
state = options[:state]
|
22
|
+
type = options[:snapshotType]
|
23
|
+
usage = options[:usage]
|
24
|
+
|
25
|
+
if usage
|
26
|
+
parameters['Usage'] = usage
|
27
|
+
pathUrl += '&Usage='
|
28
|
+
pathUrl += usage
|
29
|
+
end
|
30
|
+
|
31
|
+
if type
|
32
|
+
parameters['SnapshotType'] = type
|
33
|
+
pathUrl += '&SnapshotType='
|
34
|
+
pathUrl += type
|
35
|
+
end
|
36
|
+
|
37
|
+
if state
|
38
|
+
parameters['Status'] = state
|
39
|
+
pathUrl += '&Status='
|
40
|
+
pathUrl += state
|
41
|
+
end
|
42
|
+
|
43
|
+
if name
|
44
|
+
parameters['SnapshotName'] = name
|
45
|
+
pathUrl += '&SnapshotName='
|
46
|
+
pathUrl += name
|
47
|
+
end
|
48
|
+
|
49
|
+
if instanceId
|
50
|
+
parameters['InstanceId'] = instanceId
|
51
|
+
pathUrl += '&InstanceId='
|
52
|
+
pathUrl += instanceId
|
53
|
+
end
|
54
|
+
|
55
|
+
if diskId
|
56
|
+
parameters['DiskId'] = diskId
|
57
|
+
pathUrl += '&DiskId='
|
58
|
+
pathUrl += diskId
|
59
|
+
end
|
60
|
+
|
61
|
+
if snapshotId
|
62
|
+
parameters['SnapshotIds'] = Fog::JSON.encode(snapshotId)
|
63
|
+
pathUrl += '&SnapshotIds='
|
64
|
+
pathUrl += Fog::JSON.encode(snapshotId)
|
65
|
+
end
|
66
|
+
|
67
|
+
if sourceDiskType
|
68
|
+
parameters['SourceDiskType'] = sourceDiskType
|
69
|
+
pathUrl += '&SourceDiskType='
|
70
|
+
pathUrl += sourceDiskType
|
71
|
+
end
|
72
|
+
|
73
|
+
if pageNumber
|
74
|
+
parameters['PageNumber'] = pageNumber
|
75
|
+
pathUrl += '&PageNumber='
|
76
|
+
pathUrl += pageNumber
|
77
|
+
end
|
78
|
+
|
79
|
+
pageSize = '50' unless pageSize
|
80
|
+
parameters['PageSize'] = pageSize
|
81
|
+
pathUrl += '&PageSize='
|
82
|
+
pathUrl += pageSize
|
83
|
+
|
84
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
85
|
+
pathUrl += '&Signature='
|
86
|
+
pathUrl += signature
|
87
|
+
|
88
|
+
request(
|
89
|
+
expects: [200, 203],
|
90
|
+
method: 'GET',
|
91
|
+
path: pathUrl
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
action = 'DescribeVpcs'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
_VpcId = options[:vpcId]
|
15
|
+
if _VpcId
|
16
|
+
parameters['VpcId'] = _VpcId
|
17
|
+
pathUrl += '&VpcId='
|
18
|
+
pathUrl += _VpcId
|
19
|
+
end
|
20
|
+
|
21
|
+
pageNumber = options[:pageNumber]
|
22
|
+
pageSize = options[:pageSize]
|
23
|
+
if pageNumber
|
24
|
+
parameters['PageNumber'] = pageNumber
|
25
|
+
pathUrl += '&PageNumber='
|
26
|
+
pathUrl += pageNumber
|
27
|
+
end
|
28
|
+
|
29
|
+
pageSize = '50' unless pageSize
|
30
|
+
parameters['PageSize'] = pageSize
|
31
|
+
pathUrl += '&PageSize='
|
32
|
+
pathUrl += pageSize
|
33
|
+
|
34
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
35
|
+
pathUrl += '&Signature='
|
36
|
+
pathUrl += signature
|
37
|
+
|
38
|
+
request(
|
39
|
+
expects: [200, 203],
|
40
|
+
method: 'GET',
|
41
|
+
path: pathUrl
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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_vpn_connections(options = {})
|
7
|
+
action = 'DescribeVpnConnections'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutVPCParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
_VpnGatewayId = options[:vpngatewayId]
|
15
|
+
if _VpnGatewayId
|
16
|
+
parameters['VpnGatewayId'] = _VpnGatewayId
|
17
|
+
pathUrl += '&VpnGatewayId='
|
18
|
+
pathUrl += _VpnGatewayId
|
19
|
+
end
|
20
|
+
|
21
|
+
pageNumber = options[:pageNumber]
|
22
|
+
pageSize = options[:pageSize]
|
23
|
+
if pageNumber
|
24
|
+
parameters['PageNumber'] = pageNumber
|
25
|
+
pathUrl += '&PageNumber='
|
26
|
+
pathUrl += pageNumber
|
27
|
+
end
|
28
|
+
|
29
|
+
pageSize = '50' unless pageSize
|
30
|
+
parameters['PageSize'] = pageSize
|
31
|
+
pathUrl += '&PageSize='
|
32
|
+
pathUrl += pageSize
|
33
|
+
|
34
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
35
|
+
pathUrl += '&Signature='
|
36
|
+
pathUrl += signature
|
37
|
+
|
38
|
+
VPCrequest(
|
39
|
+
expects: [200, 203],
|
40
|
+
method: 'GET',
|
41
|
+
path: pathUrl
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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_vpn_customergateways(options = {})
|
7
|
+
action = 'DescribeCustomerGateways'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutVPCParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
|
15
|
+
pageNumber = options[:pageNumber]
|
16
|
+
pageSize = options[:pageSize]
|
17
|
+
if pageNumber
|
18
|
+
parameters['PageNumber'] = pageNumber
|
19
|
+
pathUrl += '&PageNumber='
|
20
|
+
pathUrl += pageNumber
|
21
|
+
end
|
22
|
+
|
23
|
+
pageSize = '50' unless pageSize
|
24
|
+
parameters['PageSize'] = pageSize
|
25
|
+
pathUrl += '&PageSize='
|
26
|
+
pathUrl += pageSize
|
27
|
+
|
28
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
29
|
+
pathUrl += '&Signature='
|
30
|
+
pathUrl += signature
|
31
|
+
|
32
|
+
VPCrequest(
|
33
|
+
expects: [200, 203],
|
34
|
+
method: 'GET',
|
35
|
+
path: pathUrl
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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_vpn_gateways(options = {})
|
7
|
+
action = 'DescribeVpnGateways'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutVPCParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunVPCUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
_VpcId = options[:vpcId]
|
15
|
+
if _VpcId
|
16
|
+
parameters['VpcId'] = _VpcId
|
17
|
+
pathUrl += '&VpcId='
|
18
|
+
pathUrl += _VpcId
|
19
|
+
end
|
20
|
+
|
21
|
+
pageNumber = options[:pageNumber]
|
22
|
+
pageSize = options[:pageSize]
|
23
|
+
if pageNumber
|
24
|
+
parameters['PageNumber'] = pageNumber
|
25
|
+
pathUrl += '&PageNumber='
|
26
|
+
pathUrl += pageNumber
|
27
|
+
end
|
28
|
+
|
29
|
+
pageSize = '50' unless pageSize
|
30
|
+
parameters['PageSize'] = pageSize
|
31
|
+
pathUrl += '&PageSize='
|
32
|
+
pathUrl += pageSize
|
33
|
+
|
34
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
35
|
+
pathUrl += '&Signature='
|
36
|
+
pathUrl += signature
|
37
|
+
|
38
|
+
VPCrequest(
|
39
|
+
expects: [200, 203],
|
40
|
+
method: 'GET',
|
41
|
+
path: pathUrl
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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_vrouters(options = {})
|
7
|
+
action = 'DescribeVrouters'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
_VRouterId = options[:vRouterId]
|
15
|
+
if _VRouterId
|
16
|
+
parameters['VRouterId'] = _VRouterId
|
17
|
+
pathUrl += '&VRouterId='
|
18
|
+
pathUrl += _VRouterId
|
19
|
+
end
|
20
|
+
|
21
|
+
pageNumber = options[:pageNumber]
|
22
|
+
pageSize = options[:pageSize]
|
23
|
+
if pageNumber
|
24
|
+
parameters['PageNumber'] = pageNumber
|
25
|
+
pathUrl += '&PageNumber='
|
26
|
+
pathUrl += pageNumber
|
27
|
+
end
|
28
|
+
|
29
|
+
pageSize = '50' unless pageSize
|
30
|
+
parameters['PageSize'] = pageSize
|
31
|
+
pathUrl += '&PageSize='
|
32
|
+
pathUrl += pageSize
|
33
|
+
|
34
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
35
|
+
pathUrl += '&Signature='
|
36
|
+
pathUrl += signature
|
37
|
+
|
38
|
+
request(
|
39
|
+
expects: [200, 203],
|
40
|
+
method: 'GET',
|
41
|
+
path: pathUrl
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Mock
|
47
|
+
def list_vrouters
|
48
|
+
response = Excon::Response.new
|
49
|
+
data = list_images_detail.body['VRouters']
|
50
|
+
images = []
|
51
|
+
for image in data
|
52
|
+
images << image.reject { |key, _value| !%w(id name links).include?(key) }
|
53
|
+
end
|
54
|
+
response.status = [200, 203][rand(1)]
|
55
|
+
response.body = { 'VRouter' => images }
|
56
|
+
response
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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
|
+
action = 'DescribeVSwitches'
|
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
|
+
pageNumber = options[:pageNumber]
|
19
|
+
pageSize = options[:pageSize]
|
20
|
+
vswitchId = options[:vSwitchId]
|
21
|
+
if vswitchId
|
22
|
+
parameters['VSwitchId'] = vswitchId
|
23
|
+
pathUrl += '&VSwitchId='
|
24
|
+
pathUrl += vswitchId
|
25
|
+
end
|
26
|
+
if pageNumber
|
27
|
+
parameters['PageNumber'] = pageNumber
|
28
|
+
pathUrl += '&PageNumber='
|
29
|
+
pathUrl += pageNumber
|
30
|
+
end
|
31
|
+
|
32
|
+
pageSize = '50' unless pageSize
|
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
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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/region&describezones]
|
6
|
+
def list_zones
|
7
|
+
action = 'DescribeZones'
|
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='
|
16
|
+
pathUrl += signature
|
17
|
+
|
18
|
+
request(
|
19
|
+
expects: [200, 203],
|
20
|
+
method: 'GET',
|
21
|
+
path: pathUrl
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
def list_zones(*_args)
|
28
|
+
Excon::Response.new(
|
29
|
+
body: { 'availabilityZoneInfo' => [
|
30
|
+
{
|
31
|
+
'zoneState' => {
|
32
|
+
'available' => true
|
33
|
+
},
|
34
|
+
'hosts' => nil,
|
35
|
+
'zoneName' => 'nova'
|
36
|
+
}
|
37
|
+
] },
|
38
|
+
status: 200
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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&modifyvpcattribute]
|
6
|
+
def modify_vpc(vpcId, options = {})
|
7
|
+
action = 'ModifyVpcAttribute'
|
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 += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
17
|
+
name = options[:name]
|
18
|
+
desc = options[:description]
|
19
|
+
|
20
|
+
if name
|
21
|
+
parameters['VpcName'] = name
|
22
|
+
pathUrl += '&VpcName='
|
23
|
+
pathUrl += name
|
24
|
+
end
|
25
|
+
|
26
|
+
if desc
|
27
|
+
parameters['Description'] = desc
|
28
|
+
pathUrl += '&Description='
|
29
|
+
pathUrl += desc
|
30
|
+
end
|
31
|
+
|
32
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
33
|
+
pathUrl += '&Signature='
|
34
|
+
pathUrl += signature
|
35
|
+
|
36
|
+
request(
|
37
|
+
expects: [200, 203],
|
38
|
+
method: 'GET',
|
39
|
+
path: pathUrl
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class Mock
|
45
|
+
def modify_vpc(_vpcId, _options = {})
|
46
|
+
Fog::Identity::OpenStack.new(openstack_auth_url: credentials[:openstack_auth_url])
|
47
|
+
tenant_id = Fog::Identity::OpenStack::V2::Mock.data[current_tenant][:tenants].keys.first
|
48
|
+
security_group_id = Fog::Mock.random_numbers(2).to_i + 1
|
49
|
+
data[:security_groups][security_group_id.to_s] = {
|
50
|
+
'tenant_id' => tenant_id,
|
51
|
+
'rules' => [],
|
52
|
+
'id' => security_group_id,
|
53
|
+
'name' => name,
|
54
|
+
'description' => description
|
55
|
+
}
|
56
|
+
|
57
|
+
response = Excon::Response.new
|
58
|
+
response.status = 200
|
59
|
+
response.headers = {
|
60
|
+
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
|
61
|
+
'Content-Type' => 'application/json',
|
62
|
+
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
63
|
+
'Date' => Date.new
|
64
|
+
}
|
65
|
+
response.body = {
|
66
|
+
'security_group' => data[:security_groups][security_group_id.to_s]
|
67
|
+
}
|
68
|
+
response
|
69
|
+
end
|
70
|
+
end # mock
|
71
|
+
end # aliyun
|
72
|
+
end # compute
|
73
|
+
end # fog
|
@@ -0,0 +1,45 @@
|
|
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&modifyvswitchattribute]
|
6
|
+
def modify_switch(vSwitchId, options = {})
|
7
|
+
action = 'ModifyVSwitchAttribute'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
parameters['VSwitchId'] = vSwitchId
|
15
|
+
pathUrl += '&VSwitchId='
|
16
|
+
pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
|
17
|
+
name = options[:name]
|
18
|
+
desc = options[:description]
|
19
|
+
|
20
|
+
if name
|
21
|
+
parameters['VSwitchName'] = name
|
22
|
+
pathUrl += '&VSwitchName='
|
23
|
+
pathUrl += name
|
24
|
+
end
|
25
|
+
|
26
|
+
if desc
|
27
|
+
parameters['Description'] = desc
|
28
|
+
pathUrl += '&Description='
|
29
|
+
pathUrl += desc
|
30
|
+
end
|
31
|
+
|
32
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
33
|
+
pathUrl += '&Signature='
|
34
|
+
pathUrl += signature
|
35
|
+
|
36
|
+
request(
|
37
|
+
expects: [200, 203],
|
38
|
+
method: 'GET',
|
39
|
+
path: pathUrl
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end # aliyun
|
44
|
+
end # compute
|
45
|
+
end # fog
|
@@ -0,0 +1,43 @@
|
|
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&rebootinstance]
|
6
|
+
def reboot_server(server_id, options = {})
|
7
|
+
_action = 'RebootInstance'
|
8
|
+
_sigNonce = randonStr
|
9
|
+
_time = Time.new.utc
|
10
|
+
|
11
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
14
|
+
_parameters['InstanceId'] = server_id
|
15
|
+
_pathURL += '&InstanceId=' + server_id
|
16
|
+
|
17
|
+
_ForceStop = options[:aliyun_ForceStop]
|
18
|
+
if _ForceStop
|
19
|
+
_parameters['ForceStop'] = _ForceStop
|
20
|
+
_pathURL += '&ForceStop=' + _ForceStop
|
21
|
+
end
|
22
|
+
|
23
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
24
|
+
_pathURL += '&Signature=' + _signature
|
25
|
+
|
26
|
+
request(
|
27
|
+
expects: [200, 204],
|
28
|
+
method: 'GET',
|
29
|
+
path: _pathURL
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def reboot_server(_server_id, _type = 'SOFT')
|
36
|
+
response = Excon::Response.new
|
37
|
+
response.status = 202
|
38
|
+
response
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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/network&releaseeipaddress]
|
6
|
+
def release_eip_address(allocationId)
|
7
|
+
_action = 'ReleaseEipAddress'
|
8
|
+
_sigNonce = randonStr
|
9
|
+
_time = Time.new.utc
|
10
|
+
|
11
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
14
|
+
_parameters['AllocationId'] = allocationId
|
15
|
+
_pathURL += '&AllocationId=' + allocationId
|
16
|
+
|
17
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
18
|
+
_pathURL += '&Signature=' + _signature
|
19
|
+
|
20
|
+
request(
|
21
|
+
expects: [200, 204],
|
22
|
+
method: 'GET',
|
23
|
+
path: _pathURL
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end # aliyun
|
28
|
+
end # compute
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# Start the server.
|
6
|
+
#
|
7
|
+
# === Parameters
|
8
|
+
# * server_id <~String> - The ID of the server to be started.
|
9
|
+
# === Returns
|
10
|
+
# * success <~Boolean>
|
11
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&staetinstance]
|
12
|
+
def start_server(server_id)
|
13
|
+
_action = 'StartInstance'
|
14
|
+
_sigNonce = randonStr
|
15
|
+
_time = Time.new.utc
|
16
|
+
|
17
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
18
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
19
|
+
|
20
|
+
_parameters['InstanceId'] = server_id
|
21
|
+
_pathURL += '&InstanceId=' + server_id
|
22
|
+
|
23
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
24
|
+
_pathURL += '&Signature=' + _signature
|
25
|
+
|
26
|
+
request(
|
27
|
+
expects: [200, 204],
|
28
|
+
method: 'GET',
|
29
|
+
path: _pathURL
|
30
|
+
)
|
31
|
+
end # def start_server
|
32
|
+
end # class Real
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def start_server(_server_id)
|
36
|
+
true
|
37
|
+
end # def start_server
|
38
|
+
end # class Mock
|
39
|
+
end # class aliyun
|
40
|
+
end # module Compute
|
41
|
+
end # module Fog
|