Class: Fog::Compute::Aliyun::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/aliyun/compute.rb,
lib/fog/aliyun/requests/compute/list_vpcs.rb,
lib/fog/aliyun/requests/compute/create_vpc.rb,
lib/fog/aliyun/requests/compute/delete_vpc.rb,
lib/fog/aliyun/requests/compute/list_disks.rb,
lib/fog/aliyun/requests/compute/list_zones.rb,
lib/fog/aliyun/requests/compute/modify_vpc.rb,
lib/fog/aliyun/requests/compute/attach_disk.rb,
lib/fog/aliyun/requests/compute/create_disk.rb,
lib/fog/aliyun/requests/compute/delete_disk.rb,
lib/fog/aliyun/requests/compute/detach_disk.rb,
lib/fog/aliyun/requests/compute/list_images.rb,
lib/fog/aliyun/requests/compute/stop_server.rb,
lib/fog/aliyun/requests/compute/create_image.rb,
lib/fog/aliyun/requests/compute/delete_image.rb,
lib/fog/aliyun/requests/compute/list_servers.rb,
lib/fog/aliyun/requests/compute/start_server.rb,
lib/fog/aliyun/requests/compute/create_server.rb,
lib/fog/aliyun/requests/compute/delete_server.rb,
lib/fog/aliyun/requests/compute/list_vrouters.rb,
lib/fog/aliyun/requests/compute/list_vswitchs.rb,
lib/fog/aliyun/requests/compute/reboot_server.rb,
lib/fog/aliyun/requests/compute/create_vswitch.rb,
lib/fog/aliyun/requests/compute/delete_vswitch.rb,
lib/fog/aliyun/requests/compute/list_snapshots.rb,
lib/fog/aliyun/requests/compute/modify_vswitch.rb,
lib/fog/aliyun/requests/compute/create_snapshot.rb,
lib/fog/aliyun/requests/compute/delete_snapshot.rb,
lib/fog/aliyun/requests/compute/list_route_tables.rb,
lib/fog/aliyun/requests/compute/list_server_types.rb,
lib/fog/aliyun/requests/compute/list_vpn_gateways.rb,
lib/fog/aliyun/requests/compute/list_eip_addresses.rb,
lib/fog/aliyun/requests/compute/join_security_group.rb,
lib/fog/aliyun/requests/compute/release_eip_address.rb,
lib/fog/aliyun/requests/compute/allocate_eip_address.rb,
lib/fog/aliyun/requests/compute/leave_security_group.rb,
lib/fog/aliyun/requests/compute/list_security_groups.rb,
lib/fog/aliyun/requests/compute/list_vpn_connections.rb,
lib/fog/aliyun/requests/compute/associate_eip_address.rb,
lib/fog/aliyun/requests/compute/create_security_group.rb,
lib/fog/aliyun/requests/compute/create_vpn_connection.rb,
lib/fog/aliyun/requests/compute/delete_security_group.rb,
lib/fog/aliyun/requests/compute/delete_vpn_connection.rb,
lib/fog/aliyun/requests/compute/unassociate_eip_address.rb,
lib/fog/aliyun/requests/compute/list_security_group_rules.rb,
lib/fog/aliyun/requests/compute/list_vpn_customergateways.rb,
lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb,
lib/fog/aliyun/requests/compute/create_vpn_customergateway.rb,
lib/fog/aliyun/requests/compute/delete_vpn_customergateway.rb,
lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb,
lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb,
lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb,
lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb,
lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb,
lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb,
lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb,
lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.

Raises:

  • (ArgumentError)


264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/fog/aliyun/compute.rb', line 264

def initialize(options = {})
  # initialize the parameters
  @aliyun_url = options[:aliyun_url]
  @aliyun_accesskey_id = options[:aliyun_accesskey_id]
  @aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
  @aliyun_region_id = options[:aliyun_region_id]
  @aliyun_zone_id = options[:aliyun_zone_id]

  # check for the parameters
  missing_credentials = []
  missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
  missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
  missing_credentials << :aliyun_region_id unless @aliyun_region_id
  missing_credentials << :aliyun_url unless @aliyun_url
  raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?

  @connection_options = options[:connection_options] || {}

  uri = URI.parse(@aliyun_url)
  @host = uri.host
  @path = uri.path
  @port = uri.port
  @scheme = uri.scheme

  vpcuri = URI.parse('https://vpc.aliyuncs.com')
  @vpchost = vpcuri.host
  @vpcpath = vpcuri.path
  @vpcport = vpcuri.port
  @vpcscheme = vpcuri.scheme

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
  @VPCconnection = Fog::Core::Connection.new("#{@vpcscheme}://#{@vpchost}:#{@vpcport}", @persistent, @connection_options)
end

Instance Attribute Details

#aliyun_accesskey_idObject (readonly)

Initialize connection to ECS

Notes

options parameter must include values for :aliyun_url, :aliyun_accesskey_id, :aliyun_secret_access_key, :aliyun_region_id and :aliyun_zone_id in order to create a connection. if you haven’t set these values in the configuration file.

Examples

sdb = Fog::Compute.new(:provider=>'aliyun',
 :aliyun_accesskey_id => your_:aliyun_accesskey_id,
 :aliyun_secret_access_key => your_aliyun_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

Returns

  • ECS object with connection to aliyun.



258
259
260
# File 'lib/fog/aliyun/compute.rb', line 258

def aliyun_accesskey_id
  @aliyun_accesskey_id
end

#aliyun_accesskey_secretObject (readonly)

Returns the value of attribute aliyun_accesskey_secret.



259
260
261
# File 'lib/fog/aliyun/compute.rb', line 259

def aliyun_accesskey_secret
  @aliyun_accesskey_secret
end

#aliyun_region_idObject (readonly)

Returns the value of attribute aliyun_region_id.



260
261
262
# File 'lib/fog/aliyun/compute.rb', line 260

def aliyun_region_id
  @aliyun_region_id
end

#aliyun_urlObject (readonly)

Returns the value of attribute aliyun_url.



261
262
263
# File 'lib/fog/aliyun/compute.rb', line 261

def aliyun_url
  @aliyun_url
end

#aliyun_zone_idObject (readonly)

Returns the value of attribute aliyun_zone_id.



262
263
264
# File 'lib/fog/aliyun/compute.rb', line 262

def aliyun_zone_id
  @aliyun_zone_id
end

Instance Method Details

#allocate_eip_address(options = {}) ⇒ Object

Allocate an eip IP address.

Notes

The new eip Ip address would be avalable The allocated eip Ip address can only associate to the instance of the vpc in the same region Now the eip can support ICMP,TCP,UDP

Parameters

  • server_id<~String> - id of the instance

  • allocationId<~String> - id of the EIP

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘EipAddress’<~String> - the allocated eip address

      • ‘AllocationId’<~String> - the instance id on the public ip

      • ‘RequestId’<~String> - Id of the request

Aliyun API Reference



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/aliyun/requests/compute/allocate_eip_address.rb', line 24

def allocate_eip_address(options = {})
  _action = 'AllocateEipAddress'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  # optional parameters
  _Bandwidth = options[:bandwidth]
  if _Bandwidth
    _parameters['Bandwidth'] = _Bandwidth
    _pathURL += '&Bandwidth=' + _Bandwidth
  end

  _InternetChargeType = options[:internet_charge_type]
  _InternetChargeType ||= 'PayByTraffic'
  _parameters['InternetChargeType'] = _InternetChargeType
  _pathURL += '&InternetChargeType=' + _InternetChargeType

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#allocate_public_ip_address(server_id) ⇒ Object

Allocate an avalable public IP address to the given instance.

Parameters

  • server_id<~String> - id of the instance

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘IpAddress’<~String> - The allocated ip address

      • ‘RequestId’<~String> - Id of the request

Aliyun API Reference



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb', line 18

def allocate_public_ip_address(server_id)
  _action = 'AllocatePublicIpAddress'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#associate_eip_address(server_id, allocationId, options = {}) ⇒ Object

Associate an avalable eip IP address to the given instance.

Parameters

  • server_id<~String> - id of the instance

  • allocationId<~String> - id of the EIP

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

Aliyun API Reference



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/aliyun/requests/compute/associate_eip_address.rb', line 18

def associate_eip_address(server_id, allocationId, options = {})
  _action = 'AssociateEipAddress'
  _sigNonce = randonStr
  _time = Time.new.utc

  type = options['instance_type']

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _parameters['AllocationId'] = allocationId
  _pathURL += '&AllocationId=' + allocationId

  if type
    _parameters['InstanceType'] = type
    _pathURL += 'InstanceType=' + type
  end

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#attach_disk(instanceId, diskId, options = {}) ⇒ Object

Mount a disk.

Parameters

  • instanceId<~String> - id of the instance

  • diskId<~String> - id of the disk

  • options<~hash>

    * :deleteWithInstance - if 'true',the disk will be relese with the instance.else, won't
    * :device - if nil, the system will default allocate from /dev/xvdb to /dev/xvdz. default nil
    

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

Aliyun API Reference



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/aliyun/requests/compute/attach_disk.rb', line 21

def attach_disk(instanceId, diskId, options = {})
  action = 'AttachDisk'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['InstanceId'] = instanceId
  pathUrl += '&InstanceId='
  pathUrl += instanceId

  parameters['DiskId'] = diskId
  pathUrl += '&DiskId='
  pathUrl += diskId

  deleteWithInstance = options[:deleteWithInstance]
  device = options[:device]

  deleteWithInstance ||= 'true'

  parameters['DeleteWithInstance'] = deleteWithInstance
  pathUrl += '&DeleteWithInstance='
  pathUrl += deleteWithInstance

  if device
    parameters['Device'] = device
    pathUrl += '&Device='
    pathUrl += URI.encode(device, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_disk(size, options = {}) ⇒ Object

Create a disk with assigned size.

Parameters

  • size<~String> - the size of the disk (GB).–cloud:5~2000GB,cloud_efficiency: 20~2048GB,cloud_ssd:20~1024GB

  • options<~hash>

    * :name - The name of the disk,default nil. If not nil, it must start with english or chinise character.
         The length should be within [2,128]. It can contain digits,'.','_' or '-'.It shouldn't start with 'http://' or 'https://'
    * :description - The name of the disk,default nil. If not nil, the length should be within [2,255].It shouldn't start with 'http://' or 'https://'
    * :category - Default 'cloud'. can be set to 'cloud','cloud_efficiency' or 'cloud_ssd'
    

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

      • ‘DiskId’<~String> - Id of the created disk

Aliyun API Reference



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fog/aliyun/requests/compute/create_disk.rb', line 23

def create_disk(size, options = {})
  action = 'CreateDisk'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['ZoneId'] = @aliyun_zone_id
  pathUrl += '&ZoneId='
  pathUrl += @aliyun_zone_id

  parameters['Size'] = size
  pathUrl += '&Size='
  pathUrl += size

  name = options[:name]
  desc = options[:description]
  category = options[:category]

  if name
    parameters['DiskName'] = name
    pathUrl += '&DiskName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  if category
    parameters['DiskCategory'] = category
    pathUrl += 'DiskCategory'
    pathUrl += category
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  ).merge(options)
end

#create_disk_by_snapshot(snapshotId, options = {}) ⇒ Object

Create a disk By the snapshot with given snapshot_id.

Parameters

  • snapshotId<~String> - the snapshot_id

  • options<~hash>

    * :name - The name of the disk,default nil. If not nil, it must start with english or chinise character.
         The length should be within [2,128]. It can contain digits,'.','_' or '-'.It shouldn't start with 'http://' or 'https://'
    * :description - The name of the disk,default nil. If not nil, the length should be within [2,255].It shouldn't start with 'http://' or 'https://'
    * :category - Default 'cloud'. can be set to 'cloud','cloud_efficiency' or 'cloud_ssd'
    

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

      • ‘DiskId’<~String> - Id of the created disk

Aliyun API Reference



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/fog/aliyun/requests/compute/create_disk.rb', line 88

def create_disk_by_snapshot(snapshotId, options = {})
  action = 'CreateDisk'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['ZoneId'] = @aliyun_zone_id
  pathUrl += '&ZoneId='
  pathUrl += @aliyun_zone_id

  parameters['SnapshotId'] = snapshotId
  pathUrl += '&SnapshotId='
  pathUrl += snapshotId

  name = options[:name]
  desc = options[:description]
  category = options[:category]

  if name
    parameters['DiskName'] = name
    pathUrl += '&DiskName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  if category
    parameters['DiskCategory'] = category
    pathUrl += 'DiskCategory'
    pathUrl += category
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_image(snapshotId, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/aliyun/requests/compute/create_image.rb', line 8

def create_image(snapshotId, options = {})
  action = 'CreateImage'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SnapshotId'] = snapshotId
  pathUrl += '&SnapshotId='
  pathUrl += snapshotId

  name = options[:name]
  if name
    parameters['ImageName'] = name
    pathUrl += '&ImageName='
    pathUrl += name
  end

  desc = options[:description]
  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  version = options[:version]
  if version
    parameters['ImageVersion'] = version
    pathUrl += '&ImageVersion='
    pathUrl += version
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_security_group(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/aliyun/requests/compute/create_security_group.rb', line 8

def create_security_group(options = {})
  action = 'CreateSecurityGroup'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  name = options[:name]
  desc = options[:description]
  vpcid = options[:vpcId]

  if name
    parameters['SecurityGroupName'] = name
    pathUrl += '&SecurityGroupName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  if vpcid
    parameters['VpcId'] = vpcid
    pathUrl += '&VpcId='
    pathUrl += vpcid
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb', line 8

def create_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {})
  action = 'AuthorizeSecurityGroupEgress'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['DestCidrIp'] = destCidrIp
  pathUrl += '&DestCidrIp='
  pathUrl += URI.encode(destCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  nicType ||= 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb', line 8

def create_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option = {})
  action = 'AuthorizeSecurityGroupEgress'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['DestGroupId'] = dest_group_id
  pathUrl += '&DestGroupId='
  pathUrl += dest_group_id

  nicType = 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  destGOAccount = option[:destGroupOwnerAccount]
  if sourceGOAccount
    parameters['DestGroupOwnerAccount'] = destGOAccount
    pathUrl += '&DestGroupOwnerAccount='
    pathUrl += destGOAccount
  end

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, option = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb', line 8

def create_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, option = {})
  action = 'AuthorizeSecurityGroup'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['SourceCidrIp'] = sourceCidrIp
  pathUrl += '&SourceCidrIp='
  pathUrl += URI.encode(sourceCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  nicType ||= 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb', line 8

def create_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option = {})
  action = 'AuthorizeSecurityGroup'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['SourceGroupId'] = source_securitygroup_id
  pathUrl += '&SourceGroupId='
  pathUrl += source_securitygroup_id

  nicType = 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  sourceGOAccount = option[:sourceGroupOwnerAccount]
  if sourceGOAccount
    parameters['SourceGroupOwnerAccount'] = sourceGOAccount
    pathUrl += '&SourceGroupOwnerAccount='
    pathUrl += sourceGOAccount
  end

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_server(imageId, securityGroupId, instanceType, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fog/aliyun/requests/compute/create_server.rb', line 8

def create_server(imageId, securityGroupId, instanceType, options = {})
  _action = 'CreateInstance'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['ImageId'] = imageId
  _pathURL += '&ImageId=' + imageId

  _parameters['InstanceType'] = instanceType
  _pathURL += '&InstanceType=' + instanceType

  _parameters['SecurityGroupId'] = securityGroupId
  _pathURL += '&SecurityGroupId=' + securityGroupId

  _ZoneId = options[:ZoneId]
  if _ZoneId
    _parameters['ZoneId'] = _ZoneId
    _pathURL += '&ZoneId=' + _ZoneId
  end

  _InstanceName = options[:InstanceName]
  if _InstanceName
    _parameters['InstanceName'] = _InstanceName
    _pathURL += '&InstanceName=' + _InstanceName
  end

  _Description = options[:Description]
  if _Description
    _parameters['Description'] = _Description
    _pathURL += '&Description=' + _Description
  end

  _InternetChargeType = options[:InternetChargeType]
  if _InternetChargeType
    _parameters['InternetChargeType'] = _InternetChargeType
    _pathURL += '&InternetChargeType=' + _InternetChargeType
  end

  _HostName = options[:HostName]
  if _HostName
    _parameters['HostName'] = _HostName
    _pathURL += '&HostName=' + _HostName
  end

  _Password = options[:Password]
  if _Password
    _parameters['Password'] = _Password
    _pathURL += '&Password=' + _Password
  end

  _VSwitchId = options[:VSwitchId]
  _PrivateIpAddress = options[:PrivateIpAddress]
  if _VSwitchId
    _parameters['VSwitchId'] = _VSwitchId
    _pathURL += '&VSwitchId=' + _VSwitchId

    if _PrivateIpAddress
      _parameters['PrivateIpAddress'] = _PrivateIpAddress
      _pathURL += '&PrivateIpAddress=' + _PrivateIpAddress
    end
  end

  _InternetMaxBandwidthIn = options[:InternetMaxBandwidthIn]
  if _InternetMaxBandwidthIn
    _parameters['InternetMaxBandwidthIn'] = _InternetMaxBandwidthIn
    _pathURL += '&InternetMaxBandwidthIn=' + _InternetMaxBandwidthIn
  end

  _InternetMaxBandwidthOut = options[:InternetMaxBandwidthOut]
  if _InternetMaxBandwidthOut
    _parameters['InternetMaxBandwidthOut'] = _InternetMaxBandwidthOut
    _pathURL += '&InternetMaxBandwidthOut=' + _InternetMaxBandwidthOut
  end

  _KeyPairName = options[:KeyPairName]
  if _KeyPairName
    _parameters['KeyPairName'] = _KeyPairName
    _pathURL += '&KeyPairName=' + _KeyPairName
  end

  _UserData = options[:UserData]
  if _UserData
    _parameters['UserData'] = _UserData
    _pathURL += '&UserData=' + _UserData
  end

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: _pathURL
  )
end

#create_snapshot(diskId, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/aliyun/requests/compute/create_snapshot.rb', line 7

def create_snapshot(diskId, options = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/snapshot&createsnapshot]
  action = 'CreateSnapshot'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['DiskId'] = diskId
  pathUrl += '&DiskId='
  pathUrl += diskId

  name = options[:name]
  desc = options[:description]

  if name
    parameters['SnapshotName'] = name
    pathUrl += '&SnapshotName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_vpc(cidrBlock, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/aliyun/requests/compute/create_vpc.rb', line 7

def create_vpc(cidrBlock, options = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vpc&createvpc]
  action = 'CreateVpc'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['CidrBlock'] = cidrBlock
  pathUrl += '&CidrBlock='
  pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  name = options[:name]
  desc = options[:description]

  if name
    parameters['VpcName'] = name
    pathUrl += '&VpcName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_vpn_connection(customergatewayId, vpngatewayId, localsubnet, remotesubnet, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/aliyun/requests/compute/create_vpn_connection.rb', line 7

def create_vpn_connection(customergatewayId, vpngatewayId, localsubnet, remotesubnet, options = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
  action = 'CreateVpnConnection'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  parameters['CustomerGatewayId'] = customergatewayId
  pathUrl += '&CustomerGatewayId='
  pathUrl += customergatewayId

  parameters['VpnGatewayId'] = vpngatewayId
  pathUrl += '&VpnGatewayId='
  pathUrl += vpngatewayId

  parameters['LocalSubnet'] = localsubnet
  pathUrl += '&LocalSubnet='
  pathUrl += localsubnet

  parameters['RemoteSubnet'] = remotesubnet
  pathUrl += '&RemoteSubnet='
  pathUrl += remotesubnet

  name = options[:name]
  ipsecconfig = options[:ipsecconfig]

  if name
    parameters['Name'] = name
    pathUrl += '&Name='
    pathUrl += name
  end

  if ipsecconfig
    parameters['IpsecConfig'] = ipsecconfig
    pathUrl += '&IpsecConfig='
    pathUrl += ipsecconfig
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_vpn_customergateway(ipaddress, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/aliyun/requests/compute/create_vpn_customergateway.rb', line 7

def create_vpn_customergateway(ipaddress, options = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
  action = 'CreateCustomerGateway'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  parameters['IpAddress'] = ipaddress
  pathUrl += '&IpAddress='
  pathUrl += ipaddress

  name = options[:name]
  desc = options[:description]

  if name
    parameters['Name'] = name
    pathUrl += '&Name='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#create_vswitch(vpcId, cidrBlock, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/aliyun/requests/compute/create_vswitch.rb', line 7

def create_vswitch(vpcId, cidrBlock, options = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&createvswitch]
  action = 'CreateVSwitch'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['VpcId'] = vpcId
  pathUrl += '&VpcId='
  pathUrl += vpcId

  parameters['CidrBlock'] = cidrBlock
  pathUrl += '&CidrBlock='
  pathUrl += URI.encode(cidrBlock, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  parameters['ZoneId'] = @aliyun_zone_id
  pathUrl += '&ZoneId='
  pathUrl += @aliyun_zone_id

  name = options[:name]
  desc = options[:description]

  if name
    parameters['VSwitchName'] = name
    pathUrl += '&VSwitchName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#defalutVPCParameters(action, sigNonce, time) ⇒ Object



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/fog/aliyun/compute.rb', line 402

def defalutVPCParameters(action, sigNonce, time)
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
  para = {
    'Format' => 'JSON',
    'Version' => '2016-04-28',
    'Action' => action,
    'AccessKeyId' => @aliyun_accesskey_id,
    'SignatureVersion' => '1.0',
    'SignatureMethod' => 'HMAC-SHA1',
    'SignatureNonce' => sigNonce,
    'RegionId' => @aliyun_region_id,
    'Timestamp' => parTimeFormat
  }
  para
end

#defaultAliyunQueryParameters(action, sigNonce, time) ⇒ Object



357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/fog/aliyun/compute.rb', line 357

def defaultAliyunQueryParameters(action, sigNonce, time)
  {
    Format: 'JSON',
    AccessKeyId: @aliyun_accesskey_id,
    Action: action,
    SignatureMethod: 'HMAC-SHA1',
    RegionId: @aliyun_region_id,
    SignatureNonce: sigNonce,
    SignatureVersion: '1.0',
    Version: '2014-05-26',
    Timestamp: time.strftime('%Y-%m-%dT%H:%M:%SZ')
  }
end

#defaultAliyunUri(action, sigNonce, time) ⇒ Object

operation compute– default URL



351
352
353
354
355
# File 'lib/fog/aliyun/compute.rb', line 351

def defaultAliyunUri(action, sigNonce, time)
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
  urlTimeFormat = URI.encode(parTimeFormat, ':')
  '?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2014-05-26&Timestamp=' + urlTimeFormat
end

#defaultAliyunVPCUri(action, sigNonce, time) ⇒ Object



371
372
373
374
375
# File 'lib/fog/aliyun/compute.rb', line 371

def defaultAliyunVPCUri(action, sigNonce, time)
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
  urlTimeFormat = URI.encode(parTimeFormat, ':')
  '?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2016-04-28&Timestamp=' + urlTimeFormat
end

#defaultParameters(action, sigNonce, time) ⇒ Object

operation compute–collection of default parameters



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/fog/aliyun/compute.rb', line 386

def defaultParameters(action, sigNonce, time)
  parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
  para = {
    'Format' => 'JSON',
    'Version' => '2014-05-26',
    'Action' => action,
    'AccessKeyId' => @aliyun_accesskey_id,
    'SignatureVersion' => '1.0',
    'SignatureMethod' => 'HMAC-SHA1',
    'SignatureNonce' => sigNonce,
    'RegionId' => @aliyun_region_id,
    'Timestamp' => parTimeFormat
  }
  para
end

#delete_disk(diskId) ⇒ Object

Delete a disk By the given id.

Parameters

  • diskId<~String> - the disk_id

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

Aliyun API Reference



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/aliyun/requests/compute/delete_disk.rb', line 18

def delete_disk(diskId)
  action = 'DeleteDisk'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['DiskId'] = diskId
  pathUrl += '&DiskId='
  pathUrl += diskId

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_image(imageId) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aliyun/requests/compute/delete_image.rb', line 8

def delete_image(imageId)
  action = 'DeleteImage'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['ImageId'] = imageId
  pathUrl += '&ImageId='
  pathUrl += imageId

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_security_group(security_group_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/delete_security_group.rb', line 7

def delete_security_group(security_group_id)
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&deletesecuritygroup]
  action = 'DeleteSecurityGroup'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  if security_group_id
    parameters['SecurityGroupId'] = security_group_id
    pathUrl += '&SecurityGroupId='
    pathUrl += security_group_id
  else
    raise ArgumentError, 'Missing required securyti id '
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb', line 8

def delete_security_group_egress_ip_rule(securitygroup_id, destCidrIp, nicType, option = {})
  action = 'RevokeSecurityGroupEgress'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['DestCidrIp'] = destCidrIp
  pathUrl += '&DestCidrIp='
  pathUrl += URI.encode(destCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  nicType ||= 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb', line 8

def delete_security_group_egress_sg_rule(securitygroup_id, dest_group_id, option = {})
  action = 'RevokeSecurityGroupEgress'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['DestGroupId'] = dest_group_id
  pathUrl += '&DestGroupId='
  pathUrl += dest_group_id

  nicType = 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  destGOAccount = option[:destGroupOwnerAccount]
  if sourceGOAccount
    parameters['DestGroupOwnerAccount'] = destGOAccount
    pathUrl += '&DestGroupOwnerAccount='
    pathUrl += destGOAccount
  end

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, option = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb', line 7

def delete_security_group_ip_rule(securitygroup_id, sourceCidrIp, nicType, option = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&revokesecuritygroup]
  action = 'RevokeSecurityGroup'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['SourceCidrIp'] = sourceCidrIp
  pathUrl += '&SourceCidrIp='
  pathUrl += URI.encode(sourceCidrIp, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  nicType ||= 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb', line 7

def delete_security_group_sg_rule(securitygroup_id, source_securitygroup_id, option = {})
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/securitygroup&revokesecuritygroup]
  action = 'RevokeSecurityGroup'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securitygroup_id
  pathUrl += '&SecurityGroupId='
  pathUrl += securitygroup_id

  parameters['SourceGroupId'] = source_securitygroup_id
  pathUrl += '&SourceGroupId='
  pathUrl += source_securitygroup_id

  nicType = 'intranet'
  parameters['NicType'] = nicType
  pathUrl += '&NicType='
  pathUrl += nicType

  portRange = option[:portRange]
  portRange ||= '-1/-1'
  parameters['PortRange'] = portRange
  pathUrl += '&PortRange='
  pathUrl += URI.encode(portRange, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')

  protocol = option[:protocol]
  protocol ||= 'all'
  parameters['IpProtocol'] = protocol
  pathUrl += '&IpProtocol='
  pathUrl += protocol

  sourceGOAccount = option[:sourceGroupOwnerAccount]
  if sourceGOAccount
    parameters['SourceGroupOwnerAccount'] = sourceGOAccount
    pathUrl += '&SourceGroupOwnerAccount='
    pathUrl += sourceGOAccount
  end

  policy = option[:policy]
  policy ||= 'accept'
  parameters['Policy'] = policy
  pathUrl += '&Policy='
  pathUrl += policy

  priority = option[:priority]
  priority ||= '1'
  parameters['Priority'] = priority
  pathUrl += '&Priority='
  pathUrl += priority

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_server(server_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/aliyun/requests/compute/delete_server.rb', line 7

def delete_server(server_id)
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&deleteinstance]
  _action = 'DeleteInstance'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#delete_snapshot(snapshotId) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aliyun/requests/compute/delete_snapshot.rb', line 7

def delete_snapshot(snapshotId)
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/snapshot&deletesnapshot]
  action = 'DeleteSnapshot'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SnapshotId'] = snapshotId
  pathUrl += '&SnapshotId='
  pathUrl += snapshotId

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_vpc(vpc_id) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/delete_vpc.rb', line 8

def delete_vpc(vpc_id)
  action = 'DeleteVpc'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  if vpc_id
    parameters['VpcId'] = vpc_id
    pathUrl += '&VpcId='
    pathUrl += vpc_id
  else
    raise ArgumentError, 'Missing required vpc_id'
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_vpn_connection(vpn_connectionid) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/delete_vpn_connection.rb', line 7

def delete_vpn_connection(vpn_connectionid)
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&deletevswitch]
  action = 'DeleteVpnConnection'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  if vpn_connectionid
    parameters['VpnConnectionId'] = vpn_connectionid
    pathUrl += '&VpnConnectionId='
    pathUrl += vpn_connectionid
  else
    raise ArgumentError, 'Missing required vpn_connectionid'
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_vpn_customergateway(vpn_customergatewayid) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/delete_vpn_customergateway.rb', line 7

def delete_vpn_customergateway(vpn_customergatewayid)
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&deletevswitch]
  action = 'DeleteCustomerGateway'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  if vpn_customergatewayid
    parameters['CustomerGatewayId'] = vpn_customergatewayid
    pathUrl += '&CustomerGatewayId='
    pathUrl += vpn_customergatewayid
  else
    raise ArgumentError, 'Missing required vpn_customergatewayid'
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#delete_vswitch(vswitch_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/delete_vswitch.rb', line 7

def delete_vswitch(vswitch_id)
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&deletevswitch]
  action = 'DeleteVSwitch'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  if vswitch_id
    parameters['VSwitchId'] = vswitch_id
    pathUrl += '&VSwitchId='
    pathUrl += vswitch_id
  else
    raise ArgumentError, 'Missing required vswitch_id'
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#detach_disk(instanceId, diskId, _options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/aliyun/requests/compute/detach_disk.rb', line 8

def detach_disk(instanceId, diskId, _options = {})
  action = 'DetachDisk'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['InstanceId'] = instanceId
  pathUrl += '&InstanceId='
  pathUrl += instanceId

  parameters['DiskId'] = diskId
  pathUrl += '&DiskId='
  pathUrl += diskId

  device = _options[:device]
  if device
    parameters['Device'] = device
    pathUrl += '&Device='
    pathUrl += URI.encode(device, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  end
  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#get_instance_type(cpuCount, memorySize) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/aliyun/requests/compute/list_server_types.rb', line 26

def get_instance_type(cpuCount, memorySize)
  _action = 'DescribeInstanceTypes'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  response = request(
    expects: [200, 203],
    method: 'GET',
    path: _pathURL
  )

  _InstanceTypeId = nil
  _InstanceTypeList = response.body['InstanceTypes']['InstanceType']
  _InstanceTypeList.each do |instance_type|
    next unless (instance_type['CpuCoreCount'] == cpuCount) && (instance_type['MemorySize'] == memorySize)
    _InstanceTypeId = instance_type['InstanceTypeId']
    puts '_instanceTypeId: ' + _InstanceTypeId
    break
  end
  _InstanceTypeId
end

#join_security_group(server_id, group_id) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/aliyun/requests/compute/join_security_group.rb', line 8

def join_security_group(server_id, group_id)
  _action = 'JoinSecurityGroup'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _parameters['SecurityGroupId'] = group_id
  _pathURL += '&SecurityGroupId=' + group_id

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#leave_security_group(server_id, group_id) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/aliyun/requests/compute/leave_security_group.rb', line 8

def leave_security_group(server_id, group_id)
  _action = 'LeaveSecurityGroup'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _parameters['SecurityGroupId'] = group_id
  _pathURL += '&SecurityGroupId=' + group_id

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#list_disks(options = {}) ⇒ Object

Describe disks.

Parameters

  • options<~hash>

    * :diskIds - arry of diskId, the length of arry should less than or equal to 100.
    * :instanceId - id of the instance
    * :diskType - Default 'all'.Can be set to all | system | data
    * :category - Default 'all'. Can be set to all | cloud | cloud_efficiency | cloud_ssd | ephemeral | ephemeral_ssd
    * :state - status of the disk. Default 'All'. Can be set to In_use | Available | Attaching | Detaching | Creating | ReIniting | All
    * :snapshotId - id of snapshot which used to create disk.
    * :name - name of disk
    * :portable - If ture, can exist dependently,which means it can be mount or umont in available zones.
          Else, it must be created or destroyed with a instance.
          The value for ocal disks and system disks on the cloud and cloud disks paid by month must be false.
    * :delWithIns - If ture, the disk will be released when the instance is released.
    * :delAutoSna - If ture, the auto created snapshot will be destroyed when the disk is destroyed
    * :enAutoSna - Whether the disk apply the auto snapshot strategy.
    * :diskChargeType - Prepaid | Postpaid
    

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

      • ‘Disks’<~Hash> - list of Disk,and the parameter of disk refer to the Volume model

Aliyun API Reference



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/fog/aliyun/requests/compute/list_disks.rb', line 32

def list_disks(options = {})
  action = 'DescribeDisks'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  instanceId = options[:instanceId]
  diskIds = options[:diskIds]
  diskType = options[:diskType]
  category = options[:category]
  state = options[:state]
  snapshotId = options[:snapshotId]
  name = options[:name]
  portable = options[:portable]
  delWithIns = options[:deleteWithInstance]
  delAutoSna = options[:deleteAutoSnapshot]
  enAutoSna = options[:enableAutoSnapshot]
  diskChargeType = options[:diskChargeType]

  if diskChargeType
    parameters['DiskChargeType'] = diskChargeType
    pathUrl += '&DiskChargeType='
    pathUrl += diskChargeType
  end

  if enAutoSna
    parameters['EnableAutoSnapshot'] = enAutoSna
    pathUrl += '&EnableAutoSnapshot='
    pathUrl += enAutoSna
  end

  if delAutoSna
    parameters['DeleteAutoSnapshot'] = delAutoSna
    pathUrl += '&DeleteAutoSnapshot='
    pathUrl += delAutoSna
  end

  if delWithIns
    parameters['DeleteWithInstance'] = delWithIns
    pathUrl += '&DeleteWithInstance='
    pathUrl += delWithIns
  end

  if portable
    parameters['Portable'] = portable
    pathUrl += '&Portable='
    pathUrl += portable
  end

  if name
    parameters['DiskName'] = name
    pathUrl += '&DiskName='
    pathUrl += name
  end

  if snapshotId
    parameters['SnapshotId'] = snapshotId
    pathUrl += '&SnapshotId='
    pathUrl += snapshotId
  end

  if state
    parameters['Status'] = state
    pathUrl += '&Status='
    pathUrl += state
  end

  if category
    parameters['DiskType'] = diskType
    pathUrl += '&DiskType='
    pathUrl += diskType
  end

  if category
    parameters['Category'] = category
    pathUrl += '&Category='
    pathUrl += category
  end

  if instanceId
    parameters['InstanceId'] = instanceId
    pathUrl += '&InstanceId='
    pathUrl += instanceId
  end

  if diskIds
    parameters['DiskIds'] = Fog::JSON.encode(diskIds)
    pathUrl += '&DiskIds='
    pathUrl += Fog::JSON.encode(diskIds)
  end

  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize = options[:pageSize]
  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_eip_addresses(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/aliyun/requests/compute/list_eip_addresses.rb', line 8

def list_eip_addresses(options = {})
  _action = 'DescribeEipAddresses'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _Status = options[:state]
  if _Status
    _parameters['Status'] = _Status
    _pathURL += '&Status=' + _Status
  end

  _EipAddress = options[:ip_address]
  if _EipAddress
    _parameters['EipAddress'] = _EipAddress
    _pathURL += '&EipAddress=' + _EipAddress
  end

  _AllocationId = options[:allocation_id]
  if _AllocationId
    _parameters['AllocationId'] = _AllocationId
    _pathURL += '&AllocationId=' + _AllocationId
  end

  _PageNumber = options[:page_number]
  if _PageNumber
    _parameters['PageNumber'] = _PageNumber
    _pathURL += '&PageNumber=' + _PageNumber
  end

  _PageSize = options[:page_size]
  _PageSize ||= '50'
  _parameters['PageSize'] = _PageSize
  _pathURL += '&PageSize=' + _PageSize

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#list_images(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fog/aliyun/requests/compute/list_images.rb', line 8

def list_images(options = {})
  action = 'DescribeImages'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  pageNumber = options[:pageNumber]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize = options[:pageSize]
  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  imageId = options[:imageId]
  if imageId
    parameters['ImageId'] = imageId
    pathUrl += '&ImageId='
    pathUrl += imageId
  end

  imageName = options[:imageName]
  if imageName
    parameters['ImageName'] = imageName
    pathUrl += '&ImageName='
    pathUrl += imageName
  end

  snapshotId = options[:snapshotId]
  if snapshotId
    parameters['SnapshotId'] = snapshotId
    pathUrl += '&SnapshotId='
    pathUrl += snapshotId
  end

  ownerAlias = options[:ownerAlias]
  if ownerAlias
    parameters['ImageOwnerAlias'] = ownerAlias
    pathUrl += '&ImageOwnerAlias='
    pathUrl += ownerAlias
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_route_tables(vrouterid, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/aliyun/requests/compute/list_route_tables.rb', line 8

def list_route_tables(vrouterid, options = {})
  action = 'DescribeRouteTables'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['VRouterId'] = vrouterid
  pathUrl += '&VRouterId='
  pathUrl += vrouterid

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  routeTableId = options[:routeTableId]
  if routeTableId
    parameters['RouteTableId'] = routeTableId
    pathUrl += '&RouteTableId='
    pathUrl += routeTableId
  end
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_security_group_rules(securityGroupId, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/aliyun/requests/compute/list_security_group_rules.rb', line 8

def list_security_group_rules(securityGroupId, options = {})
  action = 'DescribeSecurityGroupAttribute'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['SecurityGroupId'] = securityGroupId
  pathUrl += '&SecurityGroupId='
  pathUrl += securityGroupId

  nicType = options[:nicType]
  if nicType
    parameters['NicType'] = nicType
    pathUrl += '&NicType='
    pathUrl += nicType
  end
  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  if pageSize
    parameters['PageSize'] = pageSize
    pathUrl += '&PageSize='
    pathUrl += pageSize
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_security_groups(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/aliyun/requests/compute/list_security_groups.rb', line 8

def list_security_groups(options = {})
  action = 'DescribeSecurityGroups'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  vpcId = options[:vpcId]

  if vpcId
    parameters['VpcId'] = vpcId
    pathUrl += '&VpcId='
    pathUrl += vpcId
  end

  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize = options[:pageSize]
  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200],
    method: 'GET',
    path: pathUrl
  )
end

#list_server_typesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/aliyun/requests/compute/list_server_types.rb', line 8

def list_server_types
  _action = 'DescribeInstanceTypes'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: _pathURL
  )
end

#list_servers(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/aliyun/requests/compute/list_servers.rb', line 8

def list_servers(options = {})
  _action = 'DescribeInstances'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _query_parameters = defaultAliyunQueryParameters(_action, _sigNonce, _time)

  _InstanceId = options[:instanceId]
  _VpcId = options[:vpcId]
  _SecurityGroupId = options[:securityGroupId]
  _PageNumber = options[:pageNumber]
  _PageSize = options[:pageSize]

  unless _InstanceId.nil?
    _InstanceStr = "[\"#{_InstanceId}\"]"
    _parameters['InstanceIds'] = _InstanceStr
    _query_parameters[:InstanceIds] = _InstanceStr
  end

  unless _VpcId.nil?
    _parameters['VpcId'] = _VpcId
    _query_parameters[:VpcId] = _VpcId
  end

  unless _SecurityGroupId.nil?
    _parameters['SecurityGroupId'] = _SecurityGroupId
    _query_parameters[:SecurityGroupId] = _SecurityGroupId
  end

  unless _PageNumber.nil?
    _parameters['PageNumber'] = _PageNumber
    _query_parameters[:PageNumber] = _PageNumber
  end

  _PageSize ||= '50'
  _parameters['PageSize'] = _PageSize
  _query_parameters[:PageSize] = _PageSize

  _signature = sign_without_encoding(@aliyun_accesskey_secret, _parameters)
  _query_parameters[:Signature] = _signature

  request(
    expects: [200, 203],
    method: 'GET',
    query: _query_parameters
  )
end

#list_snapshots(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/fog/aliyun/requests/compute/list_snapshots.rb', line 8

def list_snapshots(options = {})
  action = 'DescribeSnapshots'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  instanceId = options[:instanceId]
  diskId = options[:diskId]
  snapshotId = options[:snapshotIds]
  sourceDiskType = options[:sourceDiskType]
  name = options[:snapshotName]
  state = options[:state]
  type = options[:snapshotType]
  usage = options[:usage]

  if usage
    parameters['Usage'] = usage
    pathUrl += '&Usage='
    pathUrl += usage
  end

  if type
    parameters['SnapshotType'] = type
    pathUrl += '&SnapshotType='
    pathUrl += type
  end

  if state
    parameters['Status'] = state
    pathUrl += '&Status='
    pathUrl += state
  end

  if name
    parameters['SnapshotName'] = name
    pathUrl += '&SnapshotName='
    pathUrl += name
  end

  if instanceId
    parameters['InstanceId'] = instanceId
    pathUrl += '&InstanceId='
    pathUrl += instanceId
  end

  if diskId
    parameters['DiskId'] = diskId
    pathUrl += '&DiskId='
    pathUrl += diskId
  end

  if snapshotId
    parameters['SnapshotIds'] = Fog::JSON.encode(snapshotId)
    pathUrl += '&SnapshotIds='
    pathUrl += Fog::JSON.encode(snapshotId)
  end

  if sourceDiskType
    parameters['SourceDiskType'] = sourceDiskType
    pathUrl += '&SourceDiskType='
    pathUrl += sourceDiskType
  end

  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_vpcs(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aliyun/requests/compute/list_vpcs.rb', line 8

def list_vpcs(options = {})
  action = 'DescribeVpcs'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  _VpcId = options[:vpcId]
  if _VpcId
    parameters['VpcId'] = _VpcId
    pathUrl += '&VpcId='
    pathUrl += _VpcId
  end

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_vpn_connections(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aliyun/requests/compute/list_vpn_connections.rb', line 8

def list_vpn_connections(options = {})
  action = 'DescribeVpnConnections'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  _VpnGatewayId = options[:vpngatewayId]
  if _VpnGatewayId
    parameters['VpnGatewayId'] = _VpnGatewayId
    pathUrl += '&VpnGatewayId='
    pathUrl += _VpnGatewayId
  end

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_vpn_customergateways(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/aliyun/requests/compute/list_vpn_customergateways.rb', line 8

def list_vpn_customergateways(options = {})
  action = 'DescribeCustomerGateways'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_vpn_gateways(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aliyun/requests/compute/list_vpn_gateways.rb', line 8

def list_vpn_gateways(options = {})
  action = 'DescribeVpnGateways'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defalutVPCParameters(action, sigNonce, time)
  pathUrl = defaultAliyunVPCUri(action, sigNonce, time)

  _VpcId = options[:vpcId]
  if _VpcId
    parameters['VpcId'] = _VpcId
    pathUrl += '&VpcId='
    pathUrl += _VpcId
  end

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  VPCrequest(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_vrouters(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aliyun/requests/compute/list_vrouters.rb', line 8

def list_vrouters(options = {})
  action = 'DescribeVrouters'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  _VRouterId = options[:vRouterId]
  if _VRouterId
    parameters['VRouterId'] = _VRouterId
    pathUrl += '&VRouterId='
    pathUrl += _VRouterId
  end

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_vswitchs(vpcid, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/aliyun/requests/compute/list_vswitchs.rb', line 8

def list_vswitchs(vpcid, options = {})
  action = 'DescribeVSwitches'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['VpcId'] = vpcid
  pathUrl += '&VpcId='
  pathUrl += vpcid

  pageNumber = options[:pageNumber]
  pageSize = options[:pageSize]
  vswitchId = options[:vSwitchId]
  if vswitchId
    parameters['VSwitchId'] = vswitchId
    pathUrl += '&VSwitchId='
    pathUrl += vswitchId
  end
  if pageNumber
    parameters['PageNumber'] = pageNumber
    pathUrl += '&PageNumber='
    pathUrl += pageNumber
  end

  pageSize ||= '50'
  parameters['PageSize'] = pageSize
  pathUrl += '&PageSize='
  pathUrl += pageSize

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#list_zonesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/aliyun/requests/compute/list_zones.rb', line 8

def list_zones
  action = 'DescribeZones'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#modify_switch(vSwitchId, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/aliyun/requests/compute/modify_vswitch.rb', line 8

def modify_switch(vSwitchId, options = {})
  action = 'ModifyVSwitchAttribute'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['VSwitchId'] = vSwitchId
  pathUrl += '&VSwitchId='
  pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  name = options[:name]
  desc = options[:description]

  if name
    parameters['VSwitchName'] = name
    pathUrl += '&VSwitchName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#modify_vpc(vpcId, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/aliyun/requests/compute/modify_vpc.rb', line 8

def modify_vpc(vpcId, options = {})
  action = 'ModifyVpcAttribute'
  sigNonce = randonStr
  time = Time.new.utc

  parameters = defaultParameters(action, sigNonce, time)
  pathUrl = defaultAliyunUri(action, sigNonce, time)

  parameters['VpcId'] = vpcId
  pathUrl += '&VpcId='
  pathUrl += URI.encode(vpcId, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  name = options[:name]
  desc = options[:description]

  if name
    parameters['VpcName'] = name
    pathUrl += '&VpcName='
    pathUrl += name
  end

  if desc
    parameters['Description'] = desc
    pathUrl += '&Description='
    pathUrl += desc
  end

  signature = sign(@aliyun_accesskey_secret, parameters)
  pathUrl += '&Signature='
  pathUrl += signature

  request(
    expects: [200, 203],
    method: 'GET',
    path: pathUrl
  )
end

#randonStrObject

generate random num



378
379
380
381
382
383
# File 'lib/fog/aliyun/compute.rb', line 378

def randonStr
  numStr = rand(100_000).to_s
  timeStr = Time.now.to_f.to_s
  ranStr = timeStr + '-' + numStr
  ranStr
end

#reboot_server(server_id, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/reboot_server.rb', line 8

def reboot_server(server_id, options = {})
  _action = 'RebootInstance'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _ForceStop = options[:aliyun_ForceStop]
  if _ForceStop
    _parameters['ForceStop'] = _ForceStop
    _pathURL += '&ForceStop=' + _ForceStop
  end

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#release_eip_address(allocationId) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/aliyun/requests/compute/release_eip_address.rb', line 8

def release_eip_address(allocationId)
  _action = 'ReleaseEipAddress'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['AllocationId'] = allocationId
  _pathURL += '&AllocationId=' + allocationId

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#reloadObject



299
300
301
302
# File 'lib/fog/aliyun/compute.rb', line 299

def reload
  @connection.reset
  @VPCconnection.reset
end

#request(params) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/fog/aliyun/compute.rb', line 304

def request(params)
  begin
    response = @connection.request(params.merge(headers: {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json',
      'X-Auth-Token' => @auth_token
    }.merge!(params[:headers] || {}),
                                                path: "#{@path}/#{params[:path]}",
                                                query: params[:query]))
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
          when Excon::Errors::NotFound
            Fog::Compute::Aliyun::NotFound.slurp(error)
          else
            error
          end
  end

  response.body = Fog::JSON.decode(response.body) if !response.body.empty? && response.get_header('Content-Type') == 'application/json'

  response
end

#sign(accessKeySecret, parameters) ⇒ Object

compute signature This method should be considered deprecated and replaced with sign_without_encoding, which is better for using querystring hashes and not building querystrings with string concatination.



421
422
423
424
# File 'lib/fog/aliyun/compute.rb', line 421

def sign(accessKeySecret, parameters)
  signature = sign_without_encoding(accessKeySecret, parameters)
  URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
end

#sign_without_encoding(accessKeySecret, parameters) ⇒ Object



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/fog/aliyun/compute.rb', line 426

def sign_without_encoding(accessKeySecret, parameters)
  sortedParameters = parameters.sort
  canonicalizedQueryString = ''
  sortedParameters.each do |k, v|
    canonicalizedQueryString += '&' + URI.encode(k, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ') + '=' + URI.encode(v, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  end

  canonicalizedQueryString[0] = ''
  stringToSign = 'GET&%2F&' + URI.encode(canonicalizedQueryString, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
  key = accessKeySecret + '&'

  digVer = OpenSSL::Digest.new('sha1')
  digest = OpenSSL::HMAC.digest(digVer, key, stringToSign)
  signature = Base64.encode64(digest)
  signature[-1] = ''
  signature
end

#start_server(server_id) ⇒ Object

Start the server.

Parameters

  • server_id <~String> - The ID of the server to be started.

Returns

  • success <~Boolean>

Aliyun API Reference



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/start_server.rb', line 14

def start_server(server_id)
  _action = 'StartInstance'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#stop_server(server_id) ⇒ Object

Stop the server.

Parameters

  • server_id <~String> - The ID of the server to be stopped.

Returns

  • success <~Boolean>

Aliyun API Reference



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aliyun/requests/compute/stop_server.rb', line 14

def stop_server(server_id)
  _action = 'StopInstance'
  _sigNonce = randonStr
  _time = Time.new.utc

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#unassociate_eip_address(server_id, allocationId, options = {}) ⇒ Object

Disassociate an avalable eip IP address to the given instance.

Parameters

  • server_id<~String> - id of the instance

  • allocationId<~String> - id of the EIP

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘RequestId’<~String> - Id of the request

Aliyun API Reference



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/aliyun/requests/compute/unassociate_eip_address.rb', line 18

def unassociate_eip_address(server_id, allocationId, options = {})
  _action = 'UnassociateEipAddress'
  _sigNonce = randonStr
  _time = Time.new.utc

  type = options['instance_type']

  _parameters = defaultParameters(_action, _sigNonce, _time)
  _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

  _parameters['InstanceId'] = server_id
  _pathURL += '&InstanceId=' + server_id

  _parameters['AllocationId'] = allocationId
  _pathURL += '&AllocationId=' + allocationId

  if type
    _parameters['InstanceType'] = type
    _pathURL += 'InstanceType=' + type
  end

  _signature = sign(@aliyun_accesskey_secret, _parameters)
  _pathURL += '&Signature=' + _signature

  request(
    expects: [200, 204],
    method: 'GET',
    path: _pathURL
  )
end

#VPCrequest(params) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/fog/aliyun/compute.rb', line 327

def VPCrequest(params)
  begin
    response = @VPCconnection.request(params.merge(headers: {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json',
      'X-Auth-Token' => @auth_token
    }.merge!(params[:headers] || {}),
                                                   path: "#{@path}/#{params[:path]}",
                                                   query: params[:query]))
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
          when Excon::Errors::NotFound
            Fog::Compute::Aliyun::NotFound.slurp(error)
          else
            error
          end
  end

  response.body = Fog::JSON.decode(response.body) if !response.body.empty? && response.get_header('Content-Type') == 'application/json'

  response
end