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,150 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# Describe disks.
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * options<~hash>
|
9
|
+
# * :diskIds - arry of diskId, the length of arry should less than or equal to 100.
|
10
|
+
# * :instanceId - id of the instance
|
11
|
+
# * :diskType - Default 'all'.Can be set to all | system | data
|
12
|
+
# * :category - Default 'all'. Can be set to all | cloud | cloud_efficiency | cloud_ssd | ephemeral | ephemeral_ssd
|
13
|
+
# * :state - status of the disk. Default 'All'. Can be set to In_use | Available | Attaching | Detaching | Creating | ReIniting | All
|
14
|
+
# * :snapshotId - id of snapshot which used to create disk.
|
15
|
+
# * :name - name of disk
|
16
|
+
# * :portable - If ture, can exist dependently,which means it can be mount or umont in available zones.
|
17
|
+
# Else, it must be created or destroyed with a instance.
|
18
|
+
# The value for ocal disks and system disks on the cloud and cloud disks paid by month must be false.
|
19
|
+
# * :delWithIns - If ture, the disk will be released when the instance is released.
|
20
|
+
# * :delAutoSna - If ture, the auto created snapshot will be destroyed when the disk is destroyed
|
21
|
+
# * :enAutoSna - Whether the disk apply the auto snapshot strategy.
|
22
|
+
# * :diskChargeType - Prepaid | Postpaid
|
23
|
+
# ==== Returns
|
24
|
+
# * response<~Excon::Response>:
|
25
|
+
# * body<~Hash>:
|
26
|
+
# * 'RequestId'<~String> - Id of the request
|
27
|
+
# * 'Disks'<~Hash> - list of Disk,and the parameter of disk refer to the Volume model
|
28
|
+
#
|
29
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/disk&describedisks]
|
30
|
+
def list_disks(options = {})
|
31
|
+
action = 'DescribeDisks'
|
32
|
+
sigNonce = randonStr
|
33
|
+
time = Time.new.utc
|
34
|
+
|
35
|
+
parameters = defalutParameters(action, sigNonce, time)
|
36
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
37
|
+
|
38
|
+
pageNumber = options[:pageNumber]
|
39
|
+
pageSize = options[:pageSize]
|
40
|
+
instanceId = options[:instanceId]
|
41
|
+
diskIds = options[:diskIds]
|
42
|
+
diskType = options[:diskType]
|
43
|
+
category = options[:category]
|
44
|
+
state = options[:state]
|
45
|
+
snapshotId = options[:snapshotId]
|
46
|
+
name = options[:name]
|
47
|
+
portable = options[:portable]
|
48
|
+
delWithIns = options[:deleteWithInstance]
|
49
|
+
delAutoSna = options[:deleteAutoSnapshot]
|
50
|
+
enAutoSna = options[:enableAutoSnapshot]
|
51
|
+
diskChargeType = options[:diskChargeType]
|
52
|
+
|
53
|
+
if diskChargeType
|
54
|
+
parameters['DiskChargeType'] = diskChargeType
|
55
|
+
pathUrl += '&DiskChargeType='
|
56
|
+
pathUrl += diskChargeType
|
57
|
+
end
|
58
|
+
|
59
|
+
if enAutoSna
|
60
|
+
parameters['EnableAutoSnapshot'] = enAutoSna
|
61
|
+
pathUrl += '&EnableAutoSnapshot='
|
62
|
+
pathUrl += enAutoSna
|
63
|
+
end
|
64
|
+
|
65
|
+
if delAutoSna
|
66
|
+
parameters['DeleteAutoSnapshot'] = delAutoSna
|
67
|
+
pathUrl += '&DeleteAutoSnapshot='
|
68
|
+
pathUrl += delAutoSna
|
69
|
+
end
|
70
|
+
|
71
|
+
if delWithIns
|
72
|
+
parameters['DeleteWithInstance'] = delWithIns
|
73
|
+
pathUrl += '&DeleteWithInstance='
|
74
|
+
pathUrl += delWithIns
|
75
|
+
end
|
76
|
+
|
77
|
+
if portable
|
78
|
+
parameters['Portable'] = portable
|
79
|
+
pathUrl += '&Portable='
|
80
|
+
pathUrl += portable
|
81
|
+
end
|
82
|
+
|
83
|
+
if name
|
84
|
+
parameters['DiskName'] = name
|
85
|
+
pathUrl += '&DiskName='
|
86
|
+
pathUrl += name
|
87
|
+
end
|
88
|
+
|
89
|
+
if snapshotId
|
90
|
+
parameters['SnapshotId'] = snapshotId
|
91
|
+
pathUrl += '&SnapshotId='
|
92
|
+
pathUrl += snapshotId
|
93
|
+
end
|
94
|
+
|
95
|
+
if state
|
96
|
+
parameters['Status'] = state
|
97
|
+
pathUrl += '&Status='
|
98
|
+
pathUrl += state
|
99
|
+
end
|
100
|
+
|
101
|
+
if category
|
102
|
+
parameters['DiskType'] = diskType
|
103
|
+
pathUrl += '&DiskType='
|
104
|
+
pathUrl += diskType
|
105
|
+
end
|
106
|
+
|
107
|
+
if category
|
108
|
+
parameters['Category'] = category
|
109
|
+
pathUrl += '&Category='
|
110
|
+
pathUrl += category
|
111
|
+
end
|
112
|
+
|
113
|
+
if instanceId
|
114
|
+
parameters['InstanceId'] = instanceId
|
115
|
+
pathUrl += '&InstanceId='
|
116
|
+
pathUrl += instanceId
|
117
|
+
end
|
118
|
+
|
119
|
+
if diskIds
|
120
|
+
parameters['DiskIds'] = Fog::JSON.encode(diskIds)
|
121
|
+
pathUrl += '&DiskIds='
|
122
|
+
pathUrl += Fog::JSON.encode(diskIds)
|
123
|
+
end
|
124
|
+
|
125
|
+
if pageNumber
|
126
|
+
parameters['PageNumber'] = pageNumber
|
127
|
+
pathUrl += '&PageNumber='
|
128
|
+
pathUrl += pageNumber
|
129
|
+
end
|
130
|
+
|
131
|
+
pageSize = options[:pageSize]
|
132
|
+
pageSize = '50' unless pageSize
|
133
|
+
parameters['PageSize'] = pageSize
|
134
|
+
pathUrl += '&PageSize='
|
135
|
+
pathUrl += pageSize
|
136
|
+
|
137
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
138
|
+
pathUrl += '&Signature='
|
139
|
+
pathUrl += signature
|
140
|
+
|
141
|
+
request(
|
142
|
+
expects: [200, 203],
|
143
|
+
method: 'GET',
|
144
|
+
path: pathUrl
|
145
|
+
)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,55 @@
|
|
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&describeeipaddress]
|
6
|
+
def list_eip_addresses(options = {})
|
7
|
+
_action = 'DescribeEipAddresses'
|
8
|
+
_sigNonce = randonStr
|
9
|
+
_time = Time.new.utc
|
10
|
+
|
11
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
14
|
+
_Status = options[:state]
|
15
|
+
if _Status
|
16
|
+
_parameters['Status'] = _Status
|
17
|
+
_pathURL += '&Status=' + _Status
|
18
|
+
end
|
19
|
+
|
20
|
+
_EipAddress = options[:ip_address]
|
21
|
+
if _EipAddress
|
22
|
+
_parameters['EipAddress'] = _EipAddress
|
23
|
+
_pathURL += '&EipAddress=' + _EipAddress
|
24
|
+
end
|
25
|
+
|
26
|
+
_AllocationId = options[:allocation_id]
|
27
|
+
if _AllocationId
|
28
|
+
_parameters['AllocationId'] = _AllocationId
|
29
|
+
_pathURL += '&AllocationId=' + _AllocationId
|
30
|
+
end
|
31
|
+
|
32
|
+
_PageNumber = options[:page_number]
|
33
|
+
if _PageNumber
|
34
|
+
_parameters['PageNumber'] = _PageNumber
|
35
|
+
_pathURL += '&PageNumber=' + _PageNumber
|
36
|
+
end
|
37
|
+
|
38
|
+
_PageSize = options[:page_size]
|
39
|
+
_PageSize = '50' unless _PageSize
|
40
|
+
_parameters['PageSize'] = _PageSize
|
41
|
+
_pathURL += '&PageSize=' + _PageSize
|
42
|
+
|
43
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
44
|
+
_pathURL += '&Signature=' + _signature
|
45
|
+
|
46
|
+
request(
|
47
|
+
expects: [200, 204],
|
48
|
+
method: 'GET',
|
49
|
+
path: _pathURL
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end # aliyun
|
54
|
+
end # compute
|
55
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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/image&describeimages]
|
6
|
+
def list_images(options = {})
|
7
|
+
action = 'DescribeImages'
|
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
|
+
if pageNumber
|
16
|
+
parameters['PageNumber'] = pageNumber
|
17
|
+
pathUrl += '&PageNumber='
|
18
|
+
pathUrl += pageNumber
|
19
|
+
end
|
20
|
+
|
21
|
+
pageSize = options[:pageSize]
|
22
|
+
pageSize = '50' unless pageSize
|
23
|
+
parameters['PageSize'] = pageSize
|
24
|
+
pathUrl += '&PageSize='
|
25
|
+
pathUrl += pageSize
|
26
|
+
|
27
|
+
imageId = options[:imageId]
|
28
|
+
if imageId
|
29
|
+
parameters['ImageId'] = imageId
|
30
|
+
pathUrl += '&ImageId='
|
31
|
+
pathUrl += imageId
|
32
|
+
end
|
33
|
+
|
34
|
+
imageName = options[:imageName]
|
35
|
+
if imageName
|
36
|
+
parameters['ImageName'] = imageName
|
37
|
+
pathUrl += '&ImageName='
|
38
|
+
pathUrl += imageName
|
39
|
+
end
|
40
|
+
|
41
|
+
snapshotId = options[:snapshotId]
|
42
|
+
if snapshotId
|
43
|
+
parameters['SnapshotId'] = snapshotId
|
44
|
+
pathUrl += '&SnapshotId='
|
45
|
+
pathUrl += snapshotId
|
46
|
+
end
|
47
|
+
|
48
|
+
ownerAlias = options[:ownerAlias]
|
49
|
+
if ownerAlias
|
50
|
+
parameters['ImageOwnerAlias'] = ownerAlias
|
51
|
+
pathUrl += '&ImageOwnerAlias='
|
52
|
+
pathUrl += ownerAlias
|
53
|
+
end
|
54
|
+
|
55
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
56
|
+
pathUrl += '&Signature='
|
57
|
+
pathUrl += signature
|
58
|
+
|
59
|
+
request(
|
60
|
+
expects: [200, 203],
|
61
|
+
method: 'GET',
|
62
|
+
path: pathUrl
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Mock
|
68
|
+
def list_images(_options = {})
|
69
|
+
response = Excon::Response.new
|
70
|
+
data = list_images_detail.body['images']
|
71
|
+
images = []
|
72
|
+
for image in data
|
73
|
+
images << image.reject { |key, _value| !%w(id name links).include?(key) }
|
74
|
+
end
|
75
|
+
response.status = [200, 203][rand(1)]
|
76
|
+
response.body = { 'images' => images }
|
77
|
+
response
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
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/vswitch&describevswitches]
|
6
|
+
def list_route_tables(vrouterid, options = {})
|
7
|
+
action = 'DescribeRouteTables'
|
8
|
+
sigNonce = randonStr
|
9
|
+
time = Time.new.utc
|
10
|
+
|
11
|
+
parameters = defalutParameters(action, sigNonce, time)
|
12
|
+
pathUrl = defaultAliyunUri(action, sigNonce, time)
|
13
|
+
|
14
|
+
parameters['VRouterId'] = vrouterid
|
15
|
+
pathUrl += '&VRouterId='
|
16
|
+
pathUrl += vrouterid
|
17
|
+
|
18
|
+
pageNumber = options[:pageNumber]
|
19
|
+
pageSize = options[:pageSize]
|
20
|
+
routeTableId = options[:routeTableId]
|
21
|
+
if routeTableId
|
22
|
+
parameters['RouteTableId'] = routeTableId
|
23
|
+
pathUrl += '&RouteTableId='
|
24
|
+
pathUrl += routeTableId
|
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
|
+
|
49
|
+
class Mock
|
50
|
+
def list_route_tables(_vrouterid, _options = {})
|
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| !%w(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,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/securitygroup&describesecuritygroupattribute]
|
6
|
+
def list_security_group_rules(securityGroupId, options = {})
|
7
|
+
action = 'DescribeSecurityGroupAttribute'
|
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'] = securityGroupId
|
15
|
+
pathUrl += '&SecurityGroupId='
|
16
|
+
pathUrl += securityGroupId
|
17
|
+
|
18
|
+
nicType = options[:nicType]
|
19
|
+
if nicType
|
20
|
+
parameters['NicType'] = nicType
|
21
|
+
pathUrl += '&NicType='
|
22
|
+
pathUrl += nicType
|
23
|
+
end
|
24
|
+
pageNumber = options[:pageNumber]
|
25
|
+
pageSize = options[:pageSize]
|
26
|
+
if pageNumber
|
27
|
+
parameters['PageNumber'] = pageNumber
|
28
|
+
pathUrl += '&PageNumber='
|
29
|
+
pathUrl += pageNumber
|
30
|
+
end
|
31
|
+
|
32
|
+
if pageSize
|
33
|
+
parameters['PageSize'] = pageSize
|
34
|
+
pathUrl += '&PageSize='
|
35
|
+
pathUrl += pageSize
|
36
|
+
end
|
37
|
+
|
38
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
39
|
+
pathUrl += '&Signature='
|
40
|
+
pathUrl += signature
|
41
|
+
|
42
|
+
request(
|
43
|
+
expects: [200, 203],
|
44
|
+
method: 'GET',
|
45
|
+
path: pathUrl
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Mock
|
51
|
+
def get_security_group(security_group_id)
|
52
|
+
security_group = data[:security_groups][security_group_id.to_s]
|
53
|
+
response = Excon::Response.new
|
54
|
+
if security_group
|
55
|
+
response.status = 200
|
56
|
+
response.headers = {
|
57
|
+
'X-Compute-Request-Id' => 'req-63a90344-7c4d-42e2-936c-fd748bced1b3',
|
58
|
+
'Content-Type' => 'application/json',
|
59
|
+
'Content-Length' => '167',
|
60
|
+
'Date' => Date.new
|
61
|
+
}
|
62
|
+
response.body = {
|
63
|
+
'security_group' => security_group
|
64
|
+
}
|
65
|
+
else
|
66
|
+
raise Fog::Compute::OpenStack::NotFound, "Security group #{security_group_id} does not exist"
|
67
|
+
end
|
68
|
+
response
|
69
|
+
end
|
70
|
+
end # mock
|
71
|
+
end # aliyun
|
72
|
+
end # compute
|
73
|
+
end # fog
|
@@ -0,0 +1,78 @@
|
|
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
|
+
action = 'DescribeSecurityGroups'
|
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
|
+
vpcId = options[:vpcId]
|
17
|
+
|
18
|
+
if vpcId
|
19
|
+
parameters['VpcId'] = vpcId
|
20
|
+
pathUrl += '&VpcId='
|
21
|
+
pathUrl += vpcId
|
22
|
+
end
|
23
|
+
|
24
|
+
if pageNumber
|
25
|
+
parameters['PageNumber'] = pageNumber
|
26
|
+
pathUrl += '&PageNumber='
|
27
|
+
pathUrl += pageNumber
|
28
|
+
end
|
29
|
+
|
30
|
+
pageSize = options[:pageSize]
|
31
|
+
pageSize = '50' unless pageSize
|
32
|
+
parameters['PageSize'] = pageSize
|
33
|
+
pathUrl += '&PageSize='
|
34
|
+
pathUrl += pageSize
|
35
|
+
|
36
|
+
signature = sign(@aliyun_accesskey_secret, parameters)
|
37
|
+
pathUrl += '&Signature='
|
38
|
+
pathUrl += signature
|
39
|
+
|
40
|
+
request(
|
41
|
+
expects: [200],
|
42
|
+
method: 'GET',
|
43
|
+
path: pathUrl
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Mock
|
49
|
+
def list_security_groups(server_id = nil)
|
50
|
+
security_groups = data[:security_groups].values
|
51
|
+
|
52
|
+
groups = if server_id
|
53
|
+
server_group_names =
|
54
|
+
Array(data[:server_security_group_map][server_id])
|
55
|
+
|
56
|
+
server_group_names.map do |name|
|
57
|
+
security_groups.find do |sg|
|
58
|
+
sg['name'] == name
|
59
|
+
end
|
60
|
+
end.compact
|
61
|
+
else
|
62
|
+
security_groups
|
63
|
+
end
|
64
|
+
|
65
|
+
Excon::Response.new(
|
66
|
+
body: { 'security_groups' => groups },
|
67
|
+
headers: {
|
68
|
+
'X-Compute-Request-Id' => "req-#{Fog::Mock.random_base64(36)}",
|
69
|
+
'Content-Type' => 'application/json',
|
70
|
+
'Date' => Date.new
|
71
|
+
},
|
72
|
+
status: 200
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end # mock
|
76
|
+
end # aliyun
|
77
|
+
end # compute
|
78
|
+
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
|
+
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
|
+
next unless (instanceType['CpuCoreCount'] == cpuCount) && (instanceType['MemorySize'] == memorySize)
|
52
|
+
_InstanceTypeId = instanceType['InstanceTypeId']
|
53
|
+
puts '_instanceTypeId: ' + _InstanceTypeId
|
54
|
+
break
|
55
|
+
# 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,71 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Aliyun
|
4
|
+
class Real
|
5
|
+
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&describeinstances]
|
6
|
+
def list_servers(options = {})
|
7
|
+
_action = 'DescribeInstances'
|
8
|
+
_sigNonce = randonStr
|
9
|
+
_time = Time.new.utc
|
10
|
+
|
11
|
+
_parameters = defalutParameters(_action, _sigNonce, _time)
|
12
|
+
_pathURL = defaultAliyunUri(_action, _sigNonce, _time)
|
13
|
+
|
14
|
+
_InstanceId = options[:instanceId]
|
15
|
+
_VpcId = options[:vpcId]
|
16
|
+
_SecurityGroupId = options[:securityGroupId]
|
17
|
+
_PageNumber = options[:pageNumber]
|
18
|
+
_PageSize = options[:pageSize]
|
19
|
+
|
20
|
+
unless _InstanceId.nil?
|
21
|
+
_InstanceStr = "[\"#{_InstanceId}\"]"
|
22
|
+
_parameters['InstanceIds'] = _InstanceStr
|
23
|
+
_pathURL += '&InstanceIds=' + _InstanceStr
|
24
|
+
end
|
25
|
+
|
26
|
+
unless _VpcId.nil?
|
27
|
+
_parameters['VpcId'] = _VpcId
|
28
|
+
_pathURL += '&VpcId=' + _VpcId
|
29
|
+
end
|
30
|
+
|
31
|
+
unless _SecurityGroupId.nil?
|
32
|
+
_parameters['SecurityGroupId'] = _SecurityGroupId
|
33
|
+
_pathURL += '&SecurityGroupId=' + _SecurityGroupId
|
34
|
+
end
|
35
|
+
|
36
|
+
unless _PageNumber.nil?
|
37
|
+
_parameters['PageNumber'] = _PageNumber
|
38
|
+
_pathURL += '&PageNumber=' + _PageNumber
|
39
|
+
end
|
40
|
+
|
41
|
+
_PageSize = '50' unless _PageSize
|
42
|
+
_parameters['PageSize'] = _PageSize
|
43
|
+
_pathURL += '&PageSize=' + _PageSize
|
44
|
+
|
45
|
+
_signature = sign(@aliyun_accesskey_secret, _parameters)
|
46
|
+
_pathURL += '&Signature=' + _signature
|
47
|
+
|
48
|
+
request(
|
49
|
+
expects: [200, 203],
|
50
|
+
method: 'GET',
|
51
|
+
path: _pathURL
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Mock
|
57
|
+
def list_servers(_options = {})
|
58
|
+
response = Excon::Response.new
|
59
|
+
data = list_servers_detail.body['servers']
|
60
|
+
servers = []
|
61
|
+
for server in data
|
62
|
+
servers << server.reject { |key, _value| !%w(id name links).include?(key) }
|
63
|
+
end
|
64
|
+
response.status = [200, 203][rand(1)]
|
65
|
+
response.body = { 'servers' => servers }
|
66
|
+
response
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|