Release Adam Gray, Akshay Dayal, North Bits

43
python-aliyun Documentation Release Adam Gray, Akshay Dayal, North Bits Aug 08, 2017

Transcript of Release Adam Gray, Akshay Dayal, North Bits

Page 1: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun DocumentationRelease

Adam Gray, Akshay Dayal, North Bits

Aug 08, 2017

Page 2: Release Adam Gray, Akshay Dayal, North Bits
Page 3: Release Adam Gray, Akshay Dayal, North Bits

Contents

1 ali module 3

2 aliyun package 52.1 Subpackages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1.1 aliyun.ecs package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.1.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.1.2 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.1.2 aliyun.slb package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.1.2.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.1.2.2 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.2 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.2.1 aliyun.connection module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2.3 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.3.1 Aliyun API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.3.2 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.3.3 Main Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.3.4 ali command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

3 Indices and tables 33

Python Module Index 35

i

Page 4: Release Adam Gray, Akshay Dayal, North Bits

ii

Page 5: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Contents:

Contents 1

Page 6: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

2 Contents

Page 7: Release Adam Gray, Akshay Dayal, North Bits

CHAPTER 1

ali module

3

Page 8: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

4 Chapter 1. ali module

Page 9: Release Adam Gray, Akshay Dayal, North Bits

CHAPTER 2

aliyun package

Subpackages

aliyun.ecs package

Submodules

aliyun.ecs.connection module

class aliyun.ecs.connection.EcsConnection(region_id, access_key_id=None, se-cret_access_key=None)

Bases: aliyun.connection.Connection

A connection to Aliyun ECS service.

Parameters

• region_id (str) – The id of the region to connect to.

• access_key_id (str) – The access key id.

• secret_access_key (str) – The secret access key.

add_disk(instance_id, size=None, snapshot_id=None, name=None, description=None, device=None,delete_with_instance=None)

Create and attach a non-durable disk to an instance.

This is convenience method, combining create_disk and attach_disk.

A new disk will be allocated for the instance and attached as the next available disk letter to the OS. Thedisk is a plain block device with no partitions nor filesystems.

Either size or snapshot_id must be specified, but not both. If snapshot_id is specified, the size will be takenfrom the snapshot.

If the snapshot referenced was created before 15 July, 2013, the API will throw an error of InvalidSnap-shot.TooOld.

5

Page 10: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Parameters

• instance_id (str) – ID of the instance to add the disk to.

• size (int) – Size of the disk in GB. Must be in the range [5-2048].

• snapshot_id (str) – The snapshot ID to create a disk from. If used, the size will betaken from the snapshot and the given size will be disregarded.

• name (str) – A short name for the disk.

• description (str) – A longer description of the disk.

• device (str) – The full device path for the attached device. E.g. /dev/xvdb. Validvalues: /dev/xvd[b-z].

• delete_with_instance (bool) – Whether to delete the disk when its

Returns the ID to reference the created disk.

Return type disk_id (str)

Raises

• Error – if size and snapshot_id are used.

• Error – InvalidSnapshot.TooOld if referenced snapshot is too old.

add_external_cidr_ip_rule(security_group_id, ip_protocol, port_range, source_cidr_ip, pol-icy=None)

Add a rule for an external CidrIp to a security group.

Parameters

• security_group_id (str) – The id of the security group.

• ip_protocol (str) – TCP, UDP, ICMP, GRE or ALL

• port_range (str) – For tcp/udp range is 1 to 65535. Else -1/-1.

• source_cidr_ip (str) – Source IP address range.

• policy (str) – Accept, Drop or Reject. Default: Accept.

add_group_rule(security_group_id, ip_protocol, port_range, source_group_id, policy=None)Add a rule for one security group to access another security group.

Parameters

• security_group_id (str) – The id of the security group.

• ip_protocol (str) – TCP, UDP, ICMP, GRE or ALL

• port_range (str) – For tcp/udp range is 1 to 65535. Else -1/-1.

• source_group_id (str) – Source security group.

• policy (str) – Accept, Drop or Reject. Default: Accept.

add_internal_cidr_ip_rule(security_group_id, ip_protocol, port_range, source_cidr_ip, pol-icy=None)

Add a rule for an internal CidrIp to a security group.

Parameters

• security_group_id (str) – The id of the security group.

• ip_protocol (str) – TCP, UDP, ICMP, GRE or ALL

• port_range (str) – For tcp/udp range is 1 to 65535. Else -1/-1.

6 Chapter 2. aliyun package

Page 11: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• source_cidr_ip (str) – Source IP address range.

• policy (str) – Accept, Drop or Reject. Default: Accept.

allocate_public_ip(instance_id)Allocate and assign a public IP address to an instance.

Parameters instance_id (str) – instance ID to add a public IP to.

Returns the public IP allocated to the instance.

attach_disk(instance_id, disk_id, device=None, delete_with_instance=None)Attach an existing disk to an existing instance. The disk and instance must already exist. The instancemust be in the Stopped state, or the disk will be attached at next reboot.

The disk will be attached at the next available drive letter (e.g. in linux, /dev/xvdb if only /dev/xvda exists).It will be a raw and un-formatted block device.

Parameters

• instance_id (str) – ID of the instance to add the disk to.

• disk_id (str) – ID of the disk to delete.

• device (str) – The full device path for the attached device. E.g. /dev/xvdb. Validvalues: /dev/xvd[b-z].

• delete_with_instance (bool) – Whether to delete the disk when its associatedinstance is deleted.

create_and_start_instance(image_id, instance_type, initial_security_group_id, ad-ditional_security_group_ids=[], instance_name=None,internet_max_bandwidth_in=None, inter-net_max_bandwidth_out=None, hostname=None,password=None, system_disk_type=None, inter-net_charge_type=None, assign_public_ip=True,block_till_ready=True, data_disks=None, description=None,zone_id=None)

Create and start an instance.

This is a convenience method that does more than just create_instance. You can specify a list of securitygroups (5 total) and the method also starts the instance. It can optionally block for the instance to berunning - by default it does block.

Specifying additional data disks is covered in create_instance().

Parameters

• image_id (str) – Which image id to use.

• instance_type (str) – The type of the instance. To see options use de-scribe_instance_types.

• initial_security_group_id (str) – The security group id on creation.

• additional_security_group_ids (list) – Additional security groups to use.Note: Max size 4.

• instance_name (str) – The name to use for the instance.

• internet_max_bandwidth_in (int) – Max bandwidth in.

• internet_max_bandwidth_out (int) – Max bandwidth out.

• hostname (str) – The hostname to assign.

2.1. Subpackages 7

Page 12: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• password (str) – The root password to assign.

• system_disk_type (str) – cloud, ephemeral or ephemeral_hio. Default: cloud.

• internet_charge_type (str) – PayByBandwidth or PayByTraffic. Default: Pay-ByBandwidth.

• assign_public_ip (bool) – Whether the instance should get assigned a public ipaddress. Default: True.

• block_till_ready (bool) – Whether to block till the instance is running. Default:True.

• data_disks (list) – List of dictionaries defining additional data disk device map-pings. Minimum example: [{‘category’: ‘cloud’, ‘size’: 1024}]

• description (str) – A long description of the instance.

• zone_id (str) – An Availability Zone in the region to put the instance in. E.g. ‘cn-hangzhou-b’

Returns The id of the instance created.

Raises

• Error – if more then 4 additional security group ids specified.

• Error – if timeout while waiting for instance to be running.

The data_disks device mapping dictionary describes the same Disk attributes as create_disk():

[{'category': 'ephemeral','size': 200,'name': 'mydiskname','description': 'my disk description','device': '/dev/xvdb'

},{

'category': 'ephemeral','snapshot_id': 'snap-1234','name': 'mydiskname','description': 'my disk description','device': '/dev/xvdb'

}]

The API supports up to 4 additional disks, each up to 1TB, so to get the maximum disk space at instancecreation, this should do the trick:

[{'category': 'cloud', 'size': 1024},{'category': 'cloud', 'size': 1024},{'category': 'cloud', 'size': 1024},{'category': 'cloud', 'size': 1024}

]

create_disk(zone_id, name=None, description=None, size=None, snapshot_id=None)Create a non-durable disk. A new disk will be created and can be managed independently of instance.

Either size or snapshot_id must be specified, but not both. If snapshot_id is specified, the size will be takenfrom the snapshot.

8 Chapter 2. aliyun package

Page 13: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

If the snapshot referenced was created before 15 July, 2013, the API will throw an error of InvalidSnap-shot.TooOld.

Parameters

• zone_id (str) – the Availability Zone to create the disk in. This is required and cannotbe changed. E.g. cn-hangzhou-a.

• name (str) – A short name for the disk.

• description (str) – A longer description of the disk.

• size (int) – Size of the disk in GB. Must be in the range [5-2048].

• snapshot_id (str) – The snapshot ID to create a disk from. If used, the size will betaken from the snapshot and the given size will be disregarded.

Returns The ID to reference the created disk.

Return type (str)

create_image(snapshot_id, image_version=None, description=None, os_name=None)Create an image.

Parameters

• snapshot_id (str) – The id of the snapshot to create the image from.

• image_version (str) – The version of the image.

• description (str) – The description of the image.

• os_name (str) – The os name.

Returns The image id.

create_image_from_instance(instance_id, image_version=None, description=None,os_name=None, timeout_secs=600)

Create an image from an instance.

This is a convenience method that handles creating the snapshot from the system disk and then creates theimage.

Parameters

• instance_id (str) – The id of the instance.

• image_version (str) – The version of the image.

• description (str) – The description.

• os_name (str) – The os name.

• timeout_secs (int) – How long to wait for the snapshot to be created. Default: 600.

Returns The (snapshot id, image id) pair.

Raises Error – if the system disk cannot be found or if the snapshot creation process times out.

create_instance(image_id, instance_type, security_group_id, instance_name=None, in-ternet_max_bandwidth_in=None, internet_max_bandwidth_out=None,hostname=None, password=None, system_disk_type=None, inter-net_charge_type=None, data_disks=None, description=None, zone_id=None)

Create an instance.

Parameters

• image_id (str) – Which image id to use.

2.1. Subpackages 9

Page 14: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• instance_type (str) – The type of the instance. To see options use de-scribe_instance_types.

• security_group_id (str) – The security group id to associate.

• instance_name (str) – The name to use for the instance.

• internet_max_bandwidth_in (int) – Max bandwidth in.

• internet_max_bandwidth_out (int) – Max bandwidth out.

• hostname (str) – The hostname to assign.

• password (str) – The root password to assign.

• system_disk_type (str) – cloud, ephemeral or ephemeral_hio. Default: cloud.

• internet_charge_type (str) – PayByBandwidth or PayByTraffic. Default: Pay-ByBandwidth.

• data_disks (list) – List of *args or **kwargs to DiskMapping

• description (str) – A long description of the instance.

• zone_id (str) – An Availability Zone in the region to put the instance in. E.g. ‘cn-hangzhou-b’

Returns The id of the instance created.

The data_disks argument is passed as *args (if not a dict) or **kwargs (if it is a dict) to create a newmodel.DiskMapping. To create two fully-specified data disks:

[{'category': 'ephemeral','size': 200,'name': 'mydiskname','description': 'my disk description','device': '/dev/xvdb'

},{

'category': 'ephemeral','snapshot_id': 'snap-1234','name': 'mydiskname','description': 'my disk description','device': '/dev/xvdb'

}]

To create two minimally-specified data disks of 2000GB each::

[('cloud', 2000), ('cloud', 2000)]

The API supports up to 4 additional disks, each up to 2000GB, so to get the maximum disk space atinstance creation, this should do the trick:

[{'category': 'cloud', 'size': 2000},{'category': 'cloud', 'size': 2000},{'category': 'cloud', 'size': 2000},{'category': 'cloud', 'size': 2000}

]

create_security_group(description)Create a security group.

10 Chapter 2. aliyun package

Page 15: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Parameters description (str) – The description.

Returns The security group id.

create_snapshot(instance_id, disk_id, snapshot_name=None, timeout_secs=None, descrip-tion=None)

Create a snapshot of a disk.

The instance has to be in the running or stopped state.

Parameters

• instance_id (str) – The id of the instance.

• disk_id (str) – The id of the disk.

• snapshot_name (str) – The name to assign to the snapshot.

• timeout_secs (int) – If you want to block till the snapshot is ready you can specifyhow long to wait for.

• description (str) – A description of the snapshot.

Returns The snapshot id.

Raises Error – if a timeout is given and the snapshot is not ready by then.

delete_disk(disk_id)Delete a disk from an instance.

If the instance state is running, the disk will be removed after reboot. If the instance state is stopped, thedisk will be removed immediately.

Parameters

• instance_id (str) – ID of the instance to delete a disk from.

• disk_id (str) – ID of the disk to delete.

delete_image(image_id)Delete an image.

Parameters image_id (str) – The id of the image.

delete_instance(instance_id)Delete an instance.

Parameters instance_id (str) – The id of the instance.

delete_security_group(security_group_id)Delete a security group.

Parameters security_group_id (str) – The id of the security group.

delete_snapshot(instance_id, snapshot_id)Delete a snapshot.

Parameters

• instance_id (str) – The id of the instance.

• snapshot_id (str) – The id of the snapshot.

describe_auto_snapshot_policy()Describe the Auto-Snapshot policy for both data- and system-disks.

Returns model.AutoSnapshotPolicyResponse.

2.1. Subpackages 11

Page 16: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

describe_disks(zone_id=None, disk_ids=None, instance_id=None, disk_type=None,category=None, status=None, snapshot_id=None, portable=None,delete_with_instance=None, delete_auto_snapshot=None)

List the disks in the region. All arguments are optional to allow restricting the disks retrieved.

Parameters

• zone_id (str) – Availability Zone of the disks.

• disk_ids (list) – List of disk ids to retrieve.

• instance_id (str) – ID of instance retrieved disks are attached to.

• disk_type (str) – “system”, “data”, or “all” (default).

• category (str) – “cloud”, “ephemeral”, or “all” (default).

• status (str) – Restrict to disks only with this status. “In_use”, “Available”, “Attach-ing”, “Detaching”, “Creating”, “ReIniting”, or “All” (default).

• snapshot_id (str) – Snapshot used to create the disk.

• portable (bool) – Whether the disk can be detached and re-attached elsewhere.

• delete_with_instance (bool) – Whether the disk will be deleted with its associ-ated instance.

• delete_auto_snapshot (bool) – Whether the AutoSnapshotPolicy will be deletedwith the Disk.

Returns List of model.Disk objects.

describe_images(image_ids=None, owner_alias=None, snapshot_id=None)List images in the region matching params.

Parameters

• image_ids (list) – List of image ids to filter on.

• owner_alias (list) – List of owner alias to filter on. Can be values: system, self,others or marketplace.

• snapshot_id (str) – List images only based off of this snapshot.

Returns class‘.model.Image‘ objects.

Return type List of

describe_instance_disks(instance_id)List the disks associated with an instance. This is now only a helper method which calls describe_diskswith an ID.

Parameters instance_id (str) – The id of the instance.

Returns List of model.Disk.

describe_instance_types()List the instance types available.

Returns List of model.InstanceType.

describe_security_groups()List all the security groups in the region.

Returns List of model.SecurityGroupInfo.

describe_snapshot(snapshot_id)Describe a snapshot.

12 Chapter 2. aliyun package

Page 17: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Parameters snapshot_id (str) – The id of the snapshot.

Returns model.Snapshot.

describe_snapshots(instance_id=None, disk_id=None, snapshot_ids=None)Describe snapshots, filtering by ids or originating disk.

Parameters

• instance_id (str) – Instance ID.

• disk_id (str) – The originating disk ID to get snapshots for.

• snapshot_ids (list) – Filter to up to 10 specific snapshot IDs

Returns A list of model.Snapshot.

detach_disk(instance_id, disk_id)Detach an existing disk from an existing instance.

Parameters

• instance_id (str) – ID of the instance to add the disk to.

• disk_id (str) – ID of the disk to delete.

get_all_clusters()Get a list of ECS clusters in the region.

Returns List of cluster IDs.

get_all_instance_ids(zone_id=None)Get all the instance ids in a region.

Parameters zone_id (str, optional) – The Zone ID to get instance ids from.

Returns The list of instance ids.

get_all_instance_status(zone_id=None)Get the instance statuses.

Parameters zone_id (str, optional) – A specific zone id to get instances from.

Returns The list of model.InstanceStatus.

get_all_region_ids()Get all the region ids.

Returns List of region ids.

get_all_regions()Get all regions.

Returns A list of aliyun.ecs.model.Region

Return type list

get_all_zone_ids()Get all availability zone ids in the region.

Returns List of zone id strings.

get_all_zones()Get all availability zones in the region.

Returns List of model.Zone.

2.1. Subpackages 13

Page 18: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

get_instance(instance_id)Get an instance.

Parameters instance_id (str) – The id of the instance.

Returns model.Instance if found.

Raises Error – if not found.

get_security_group(security_group_id)Get a security group.

Parameters security_group_id (str) – The id of the security group.

Returns The model.SecurityGroup object.

get_security_group_ids()List all the security group ids in the region.

Returns List of security group ids.

join_security_group(instance_id, security_group_id)Add an instance to a security group.

Parameters

• instance_id (str) – The id of the instance.

• security_group_id (str) – The id of the security_group.

leave_security_group(instance_id, security_group_id)Remove an instance from a security group.

Parameters

• instance_id (str) – The id of the instance.

• security_group_id (str) – The id of the security_group.

modify_auto_snapshot_policy(system_disk_policy_enabled, system_disk_policy_time_period,system_disk_policy_retention_days, sys-tem_disk_policy_retention_last_week,data_disk_policy_enabled, data_disk_policy_time_period,data_disk_policy_retention_days,data_disk_policy_retention_last_week)

Modify the account’s auto-snapshot policy.

Parameters

• system_disk_policy_enabled (bool) – Enable/Disable for system disks.

• system_disk_policy_time_period (int) – Time period for system disk autosnapshots.

• system_disk_policy_retention_days (int) – Number of days to retain.

• system_disk_policy_retention_last_week (bool) – Keep/Discard Sun-day’s auto-snapshot.

• data_disk_policy_enabled (bool) – Enable/Disable for data disks.

• data_disk_policy_time_period (int) – Time period for data disk auto snap-shots.

• data_disk_policy_retention_days (int) – Number of days to retain.

14 Chapter 2. aliyun package

Page 19: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• data_disk_policy_retention_last_week (bool) – Keep/Discard Sunday’sauto-snapshot.

modify_disk(disk_id, name=None, description=None, delete_with_instance=None)Modify information about a disk.

Parameters

• disk_id (str) – The Disk to modify/update.

• name (str) – The new disk name.

• description (str) – The new disk description.

• delete_with_instance (str) – Change whether to delete the disk with its associ-ated instance.

modify_instance(instance_id, new_instance_name=None, new_password=None,new_hostname=None, new_security_group_id=None, new_description=None)

Modify certain attributes of an instance.

Only attributes that you want to modify should be specified. If you want to associated multiple securitygroups with an instance use the join_security_group method.

Parameters

• instance_id (str) – The id of the instance.

• new_instance_name (str) – The new instance name.

• new_password (str) – The new root password for the instance. This requires a rebootto take effect.

• new_hostname (str) – The new hostname for the instance.

• new_security_group_id (str) – A single security group id.

• new_description (str) – The new description for the instance.

modify_instance_spec(instance_id, instance_type=None, internet_max_bandwidth_out=None,internet_max_bandwidth_in=None)

NOT PUBLICLY AVAILABLE: Modify instance specification

Modify an existing instance’s instance type or in/out bandwidth limits. This API Action is restricted, soyou may get an error when calling this method.

Parameters

• instance_id (str) – The id fo the instance.

• instance_type (str) – Use describe_instance_types for valid values.

• internet_max_bandwidth_out (int) – Outbound bandwdith limit in Mbps. be-tween 1 and 200, inclusive.

• internet_max_bandwidth_in (int) – Inbound bandwdith limit in Mbps. between1 and 200, inclusive.

reboot_instance(instance_id, force=False)Reboot an instance.

Parameters

• instance_id (str) – The id of the instance.

• force (bool) – Whether to force reboot the instance.

2.1. Subpackages 15

Page 20: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

reinit_disk(disk_id)Re-initialize a disk to it’s original Image.

Parameters disk_id (str) – ID of the Disk to re-initialize.

remove_external_cidr_ip_rule(security_group_id, ip_protocol, port_range, source_cidr_ip,policy=None)

Remove a rule for an external CidrIp from a security group.

Parameters

• security_group_id (str) – The id of the security group.

• ip_protocol (str) – TCP, UDP, ICMP, GRE or ALL

• port_range (str) – For tcp/udp range is 1 to 65535. Else -1/-1.

• source_cidr_ip (str) – Source IP address range.

• policy (str) – Accept, Drop or Reject. Default: Accept.

remove_group_rule(security_group_id, ip_protocol, port_range, source_group_id, policy=None)Remove a rule for a security group to access another security group.

Parameters

• security_group_id (str) – The id of the security group.

• ip_protocol (str) – TCP, UDP, ICMP, GRE or ALL

• port_range (str) – For tcp/udp range is 1 to 65535. Else -1/-1.

• source_group_id (str) – Source security group.

• policy (str) – Accept, Drop or Reject. Default: Accept.

remove_internal_cidr_ip_rule(security_group_id, ip_protocol, port_range, source_cidr_ip,policy=None)

Remove a rule for an internal CidrIp from a security group.

Parameters

• security_group_id (str) – The id of the security group.

• ip_protocol (str) – TCP, UDP, ICMP, GRE or ALL

• port_range (str) – For tcp/udp range is 1 to 65535. Else -1/-1.

• source_cidr_ip (str) – Source IP address range.

• policy (str) – Accept, Drop or Reject. Default: Accept.

replace_system_disk(instance_id, image_id)Replace an Instance’s system disk to the given Image.

Parameters

• instance_id (str) – ID of the Instance to replace.

• image_id (str) – ID of the Image to use for the new system disk.

Returns ID of the new disk.

reset_disk(disk_id, snapshot_id)Reset a disk to its snapshot.

Parameters

• disk_id (str) – Disk ID to reset.

16 Chapter 2. aliyun package

Page 21: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• snapshot_id (str) – ID of snapshot to reset the disk to.

start_instance(instance_id)Start an instance.

Parameters instance_id (str) – The id of the instance.

stop_instance(instance_id, force=False)Stop an instance.

Parameters

• instance_id (str) – The id of the instance.

• force (bool) – Whether to force stop the instance.

exception aliyun.ecs.connection.ErrorBases: exceptions.Exception

Base exception class for this module.

aliyun.ecs.model module

class aliyun.ecs.model.AutoSnapshotExecutionStatus(system_disk_execution_status,data_disk_execution_status)

Bases: object

class aliyun.ecs.model.AutoSnapshotPolicy(system_disk_enabled, system_disk_time_period,system_disk_retention_days, sys-tem_disk_retention_last_week, data_disk_enabled,data_disk_time_period, data_disk_retention_days,data_disk_retention_last_week)

Bases: object

class aliyun.ecs.model.AutoSnapshotPolicyStatus(status, policy)Bases: object

class aliyun.ecs.model.Disk(disk_id, disk_type, disk_category, disk_size, attached_time=None,creation_time=None, delete_auto_snapshot=None,delete_with_instance=None, description=None, detached_time=None,device=None, image_id=None, instance_id=None, opera-tion_locks=None, portable=None, product_code=None, snap-shot_id=None, status=None, zone_id=None)

Bases: object

class aliyun.ecs.model.DiskMapping(category, size=None, snapshot_id=None, name=None, de-scription=None, device=None)

Bases: object

api_dict(ordinal=1)Serialize for insertion into API request parameters.

Parameters ordinal (int) – The number of the data disk to serialize as.

Returns

A dictionary of URL GET query parameters to create the disk. E.g.:

{'DataDisk.1.Category': 'cloud','DataDisk.1.Size': 2000

}

2.1. Subpackages 17

Page 22: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Return type dict

exception aliyun.ecs.model.DiskMappingErrorBases: exceptions.Exception

class aliyun.ecs.model.Image(image_id, image_version, name, description, size, architecture,owner_alias, os_name)

Bases: object

class aliyun.ecs.model.Instance(instance_id, name, image_id, region_id, instance_type, host-name, status, security_group_ids, public_ip_addresses,internal_ip_addresses, internet_charge_type, inter-net_max_bandwidth_in, internet_max_bandwidth_out, cre-ation_time, description, cluster_id, operation_locks, zone_id)

Bases: object

An Aliyun ECS instance.

class aliyun.ecs.model.InstanceStatus(instance_id, status)Bases: object

class aliyun.ecs.model.InstanceType(instance_type_id, cpu_core_count, memory_size)Bases: object

class aliyun.ecs.model.Region(region_id, local_name)Bases: object

class aliyun.ecs.model.SecurityGroup(region_id, security_group_id, description, permissions)Bases: object

class aliyun.ecs.model.SecurityGroupInfo(security_group_id, description)Bases: object

class aliyun.ecs.model.SecurityGroupPermission(ip_protocol, port_range, source_cidr_ip,source_group_id, policy, nic_type)

Bases: object

class aliyun.ecs.model.Snapshot(snapshot_id, snapshot_name, progress, creation_time, descrip-tion=None, source_disk_id=None, source_disk_type=None,source_disk_size=None)

Bases: object

class aliyun.ecs.model.Zone(zone_id, local_name, available_resource_creation=None, avail-able_disk_types=None)

Bases: object

disk_supported(disk_type)Convenience method to say whether a disk type is supported.

Parameters disk_type (str) – either ‘cloud’ or ‘ephemeral’.

Returns boolean

resource_creation_supported(resource_type)Convenience method to say whether a resource can be created.

Parameters resource_type (str) – either ‘Instance’ or ‘Disk’

Returns Boolean. True if the resource creation is supported.

Module contents

18 Chapter 2. aliyun package

Page 23: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Aliyun ECS

To interact with the ECS API, use aliyun.ecs.connection.EcsConnection.

import aliyun.ecs.connectionconn = aliyun.ecs.connection.EcsConnection('cn-hangzhou')my_instance_ids = conn.get_all_instance_ids()for instance_id in my_instance_ids:

print "Instance ID: ", instance_idinstance = conn.get_instance(instance_id)print "Instance object: ", instance

The many methods in aliyun.ecs.connection.EcsConnection are split into two categories:

1. Direct API implementation

2. Helper and wrapper functionality

The following ECS API actions are nearly fully supported:

• DescribeRegions

• DescribeInstanceStatus

• DescribeInstanceAttribute

• StartInstance

• StopInstance

• RebootInstance

• DeleteInstance

• ModifyInstanceAttribute

• CreateInstance

• AllocatePublicIpAddress

• DescribeInstanceTypes

• JoinSecurityGroup

• LeaveSecurityGroup

• DescribeSecurityGroups

• CreateSecurityGroup

• DescribeSecurityGroupAttribute

• DeleteSecurityGroup

• AuthorizeSecurityGroup

• RevokeSecurityGroup

• DescribeInstanceDisks

• DeleteSnapshot

• DescribeSnapshotAttribute

• DescribeSnapshots

• CreateSnapshot

2.1. Subpackages 19

Page 24: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• DescribeImages

• DeleteImage

• CreateImage

Additional helper functionality is provided by:

• aliyun.ecs.connection.EcsConnection.get_all_region_ids()

• aliyun.ecs.connection.EcsConnection.get_all_instance_ids()

• aliyun.ecs.connection.EcsConnection.create_and_start_instance()

• aliyun.ecs.connection.EcsConnection.get_security_group_ids()

• aliyun.ecs.connection.EcsConnection.add_group_rule()

• aliyun.ecs.connection.EcsConnection.add_internal_cidr_ip_rule()

• aliyun.ecs.connection.EcsConnection.add_external_cidr_ip_rule()

• aliyun.ecs.connection.EcsConnection.remove_group_rule()

• aliyun.ecs.connection.EcsConnection.remove_internal_cidr_ip_rule()

• aliyun.ecs.connection.EcsConnection.remove_external_cidr_ip_rule()

The API’s models are reflected in aliyun.ecs.model and are generally not intended for direct use.

aliyun.slb package

Submodules

aliyun.slb.connection module

exception aliyun.slb.connection.ErrorBases: exceptions.Exception

Base Exception class for this module.

class aliyun.slb.connection.SlbConnection(region_id, access_key_id=None, se-cret_access_key=None)

Bases: aliyun.connection.Connection

A connection to Aliyun SLB service.

add_backend_server_ids(load_balancer_id, backend_server_ids)

Helper wrapper to add backend server IDs specified to the SLB specified.

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId to retrieve.

• backend_server_ids (list of str) – the backend server ids to add

add_backend_servers(load_balancer_id, backend_servers)Add backend servers to a load balancer

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId to retrieve.

• backend_servers (list of BackendServer) – the backend servers to add

20 Chapter 2. aliyun package

Page 25: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

create_http_listener(load_balancer_id, listener_port, backend_server_port, band-width, sticky_session, health_check, healthy_threshold=3, un-healthy_threshold=3, scheduler=None, connect_timeout=None, in-terval=None, x_forwarded_for=None, sticky_session_type=None,cookie_timeout=None, cookie=None, domain=None, uri=None)

Create an HTTP SLB Listener

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• listener_port (int) – Port for the SLB to listen on

• backend_server_port (int) – Port to send traffic to on the back-end

• bandwidth (int) – The peak burst speed of the network. Optional values: - 1|1 -1000Mbps For the paybybandwidth intances, the peak burst speed of all Listeners shouldnot exceed the Bandwidth value in SLB instance creation, and the Bandwidth value mustnot be set to - 1. For paybytraffic instances, this value can be set to - 1, meaning there isno restriction on bandwidth peak speed.

• sticky_session (str) – on or off

• healthy_threshold (int) – Number of successful healthchecks before consideringthe listener healthy. Default 3.

• unhealthy_threshold (int) – Number of failed healthchecks before consideringthe listener unhealthy. Default 3.

• health_check (str) – ‘on’ and ‘off’ (default)

HTTPListener arguments:

scheduler (str): wrr or wlc. Round Robin (default) or Least Connections.

connect_timeout (int): number of seconds to timeout and fail a health check

interval (int): number of seconds between health checks x_forwarded_for (bool): wether or not toappend ips to

x-fordwarded-for http header

sticky_session_type (str): ‘insert’ to have the SLB add a cookie to requests ‘server’ to have the SLBlook for a server-injected cookie sticky_session must be ‘on’

cookie_timeout (int [0-86400]): Lifetime of cookie in seconds. Max 1 day. sticky_session must be‘on’

cookie (str): The Cookie key to use as sticky_session indicator. sticky_session_type must be ‘server’

domain (str): the Host header to use for the health check uri (str): URL path for healthcheck. E.g./health

create_load_balancer(region_id, address_type=None, internet_charge_type=None, band-width=None, load_balancer_name=None)

Create a load balancer. This does not configure listeners nor backend servers.

Parameters

• region_id (str) – An id from get_all_region_ids()

• addres_type (str) – IP the SLB on the public network (‘internet’, default) or theprivate network (‘intranet’)

2.1. Subpackages 21

Page 26: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• internet_charge_type (str) – ‘paybytraffic’ (default) vs ‘paybybandwidth’

• bandwidth (int) – peak burst speed of ‘paybybandwidth’ type slbs. Listener must beset first before this will take effect. default: 1 (unit Mbps)

• load_balancer_name (str) – Name of the SLB. 80 char max. Optional.

Returns load_balancer_id of the created LB. Address and Name are not given.

create_tcp_listener(load_balancer_id, listener_port, backend_server_port,healthy_threshold=3, unhealthy_threshold=3, listener_status=None,scheduler=None, health_check=None, connect_timeout=None, inter-val=None, connect_port=None, persistence_timeout=None)

Create a TCP SLB Listener

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• listener_port (int) – Port for the SLB to listen on

• backend_server_port (int) – Port to send traffic to on the back-end

• healthy_threshold (int) – Number of successful healthchecks before consideringthe listener healthy. Default 3.

• unhealthy_threshold (int) – Number of failed healthchecks before consideringthe listener unhealthy. Default 3.

• arguments (TCPListener) –

• listener_status (str) – ‘active’ (default) or ‘stopped’.

• scheduler (str) – wrr or wlc. Round Robin (default) or Least Connections.

• health_check (bool) – True for ‘on’ and False for ‘off’ (default)

• connect_timeout (int) – number of seconds to timeout and fail a health check

• interval (int) – number of seconds between health checks

• connect_port (int) – defaults to backend_server_port

• persistence_timeout (int) – number of seconds to hold TCP connection open

delete_listener(load_balancer_id, listener_port)Delete the SLB Listner on specified port

Parameters

• load_balancer_id (str) – SLB ID

• listener_port (int) – SLB Listener port. Between 1 and 65535.

delete_load_balancer(load_balancer_id)Delete a LoadBalancer by ID

Parameters load_balancer_id (str) – Aliyun SLB LoadBalancerId to delete.

deregister_backend_server_ids(server_ids)Helper wrapper to get load balancers with the server id in them and remove the server from each loadbalancer.

Parameters server_id (List of str) – List of Aliyun ECS Instance IDs

Returns List of SLB IDs that were modified.

deregister_backend_servers(backend_servers)

22 Chapter 2. aliyun package

Page 27: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

get_all_load_balancer_ids()Get all the load balancer IDs in the region.

get_all_load_balancer_status(instance_id=None)Get all LoadBalancerStatus in the region.

Parameters instance_id (str, optional) – Restrict results to LBs with this instance.

Returns List of LoadBalancerStatus.

get_all_region_ids()

get_all_regions()Get all regions.

Return: list[slb.Region]

get_backend_server_ids(load_balancer_id, listener_port=None)

get_backend_servers(load_balancer_id, listener_port=None)Get backend servers for a given load balancer and its listener port.

If listener_port is not specified, all listeners are listed separately.

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId to retrieve.

• listener_port (int, optional) – the port to get backend server statuses for

Returns List of ListenerStatus

get_http_listener(load_balancer_id, listener_port)Get the HTTP Listener from an SLB ID and port

Parameters

• load_balancer_id (str) – SLB ID

• listener_port (int) – SLB Listener port. Between 1 and 65535.

Returns HTTPListener

get_load_balancer(load_balancer_id)Get a LoadBalancer by ID.

Parameters load_balancer_id (str) – Aliyun SLB LoadBalancerId to retrieve.

Returns LoadBalancer with given ID.

get_tcp_listener(load_balancer_id, listener_port)Get the TCP Listener from an SLB ID and port

Parameters

• load_balancer_id (str) – SLB ID

• listener_port (int) – SLB Listener port. Between 1 and 65535.

Returns TCPListener

remove_backend_server_ids(load_balancer_id, backend_server_ids)

Helper wrapper to remove backend server IDs specified from the SLB specified.

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId to retrieve.

2.1. Subpackages 23

Page 28: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• backend_server_ids (list of str) – the backend server ids to remove

remove_backend_servers(load_balancer_id, backend_servers)

Remove backend servers from a load balancer Note: the SLB API ignores Weight when RemovingBackend Servers. So you’re probably better off using remove_backend_server_id anyway.

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId to retrieve.

• backend_servers (list of BackendServer) – the backend servers to remove

set_listener_status(load_balancer_id, listener_port, status)Set the status of an SLB Listener. Turn them on or off.

Parameters

• load_balancer_id (str) – SLB ID

• listener_port (int) – SLB Listener port. Between 1 and 65535.

• status (str) – ‘inactive’ for off and ‘active’ for on.

set_load_balancer_name(load_balancer_id, name)Set the Name of an SLB

Parameters

• load_balancer_id (str) – SLB ID

• name (str) – Alias for the SLB. Up to 64 characters.

set_load_balancer_status(load_balancer_id, status)Set the Status of an SLB

Parameters

• load_balancer_id (str) – SLB ID

• status (str) – One of ‘inactive’ or ‘active’

start_load_balancer_listener(load_balancer_id, listener_port)Start a listener

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId

• listener_port (int) – The listener port to activate

stop_load_balancer_listener(load_balancer_id, listener_port)Stop a listener

Parameters

• load_balancer_id (str) – Aliyun SLB LoadBalancerId

• listener_port (int) – The listener port to activate

update_http_listener(load_balancer_id, listener_port, healthy_threshold=None, un-healthy_threshold=None, scheduler=None, health_check=None,health_check_timeout=None, interval=None, x_forwarded_for=None,sticky_session=None, sticky_session_type=None, cookie_timeout=None,cookie=None, domain=None, uri=None)

Update an existing HTTP SLB Listener

24 Chapter 2. aliyun package

Page 29: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• listener_port (int) – Port for the SLB to listen on

• healthy_threshold (int) – Number of successful healthchecks before consideringthe listener healthy. Default 3.

• unhealthy_threshold (int) – Number of failed healthchecks before consideringthe listener unhealthy. Default 3.

• scheduler (str) – wrr or wlc. Round Robin (default) or Least Connections.

• health_check (bool) – True for ‘on’ and False for ‘off’ (default)

• health_check_timeout (int) – number of seconds to timeout and fail a healthcheck

• interval (int) – number of seconds between health checks

• x_forwarded_for (bool) – wether or not to append ips to x-fordwarded-for httpheader

• sticky_session (bool) – use slb sticky sessions. default false.

• sticky_session_type (str) – ‘insert’ to have the SLB add a cookie to requests‘server’ to have the SLB look for a server-injected cookie sticky_session must be ‘on’

• cookie_timeout (int [0-86400]) – Lifetime of cookie in seconds. Max 1 day.sticky_session must be ‘on’

• cookie (str) – The Cookie key to use as sticky_session indicator. sticky_session_typemust be ‘server’

• domain (str) – the Host header to use for the health check

• uri (str) – URL path for healthcheck. E.g. /health

update_tcp_listener(load_balancer_id, listener_port, healthy_threshold=None, un-healthy_threshold=None, scheduler=None, health_check=None,connect_timeout=None, interval=None, connect_port=None, persis-tence_timeout=None)

Update an existing TCP SLB Listener

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• listener_port (int) – Port for the SLB to listen on

• healthy_threshold (int) – Number of successful healthchecks before consideringthe listener healthy. Default 3.

• unhealthy_threshold (int) – Number of failed healthchecks before consideringthe listener unhealthy. Default 3.

• scheduler (str) – wrr or wlc. Round Robin (default) or Least Connections.

• health_check (bool) – True for ‘on’ and False for ‘off’ (default)

• connect_timeout (int) – number of seconds to timeout and fail a health check

• interval (int) – number of seconds between health checks

• connect_port (int) – defaults to backend_server_port

• persistence_timeout (int) – number of seconds to hold TCP connection open

2.1. Subpackages 25

Page 30: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

aliyun.slb.model module

class aliyun.slb.model.BackendServer(instance_id, weight)Bases: object

BackendServer describing ECS instances attached to an SLB

Parameters

• instance_id (str) – ECS InstanceId (also SLB ServerId) attached

• weight (int) – SLB weight. Between 1 and 1000. Default 100.

Properties: status (str): (read-only) SLB ServerHealthStatus either ‘normal’ or ‘abnormal’

class aliyun.slb.model.BackendServerStatus(server_id, status)Bases: object

class aliyun.slb.model.HTTPListener(load_balancer_id, listener_port, backend_server_port,listener_status=’active’, scheduler=’wrr’,health_check=False, connect_timeout=5, inter-val=2, x_forwarded_for=False, sticky_session=False,sticky_session_type=None, cookie_timeout=None,cookie=None, domain=None, uri=’‘)

Bases: aliyun.slb.model.Listener

HTTP Load Balancer Listener

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• listener_port (int, required) – port the Load Balancer listens on

• backend_server_port (int, required) – port number to connect to servers

• listener_status (str) – ‘active’ (default) or ‘stopped’

• scheduler (str) – wrr or wlc. Round Robin (default) or Least Connections.

• health_check (bool) – True for ‘on’ and False for ‘off’ (default)

• connect_timeout (int) – number of seconds to timeout and fail a health check

• interval (int) – number of seconds between health checks

• x_forwarded_for (bool) – Wether or not to append IPs to X-Fordwarded-For HTTPheader

• sticky_session (bool) – Use SLB Sticky Sessions. Default False.

• sticky_session_type (str) – ‘insert’ to have the SLB add a cookie to requests‘server’ to have the SLB look for a server-injected cookie sticky_session must be ‘on’

• cookie_timeout (int [0-86400]) – Lifetime of cookie in seconds. Max 1 day.sticky_session must be True.

• cookie (str) – The Cookie key to use as sticky_session indicator. sticky_session_typemust be ‘server’

• domain (str) – the Host header to use for the health check

• uri (str) – URL path for healthcheck. E.g. /health

26 Chapter 2. aliyun package

Page 31: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

class aliyun.slb.model.Listener(load_balancer_id, listener_port, backend_server_port, lis-tener_status=None, scheduler=’wrr’, health_check=False,connect_timeout=5, interval=2)

Bases: object

(Abstract by use) base class for LoadBalancerListeners

Parameters

• load_balancer_id (int, required) – ID of the SLB instance

• listener_port (int, required) – port the Load Balancer listens on

• backend_server_port (int, required) – port number to connect to servers

• listener_status (str) – ‘active’ (default) or ‘stopped’.

• scheduler (str) – wrr or wlc. Round Robin (default) or Least Connections.

• health_check (bool) – True for ‘on’ and False for ‘off’ (default)

• healthy_threshold (int) – number of health check successes to become healthy

• unhealthy_threshold (int) – number of health check failures to become unhealthy

• connect_timeout (int) – number of seconds to timeout and fail a health check

• interval (int) – number of seconds between health checks

class aliyun.slb.model.ListenerStatus(listener_port, backend_servers=None)Bases: object

Status for listener port and backend server list pairings.

Parameters

• listener_port (int) – Number between 1 and 65535.

• backend_servers (list of BackendServerStatus) –

class aliyun.slb.model.LoadBalancer(load_balancer_id, region_id, load_balancer_name,load_balancer_status, address, address_type, listener_ports,backend_servers=None)

Bases: object

An Aliyun Server Load Balancer (SLB) instance. Modeled after the DescribeLoadBalancerAttribute SLB API.

Parameters

• load_balancer_id (str) – unique identifier of the SLB.

• region_id (str) – region id for the SLB.

• load_balancer_name (str) – description of the SLB.

• load_balancer_status (str) – status of the SLB. ‘inactive’ or ‘active’

• address (str) – IP address of the SLB.

• address_type (str) – internet vs intranet

• listener_ports (list int) – Ports which have listeners

• backend_servers (list of BackendServer, optional) – BackendServersto put into the load balancer

2.1. Subpackages 27

Page 32: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

class aliyun.slb.model.LoadBalancerStatus(load_balancer_id, load_balancer_name, status)Bases: object

Simple status of SLB

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• load_balancer_name (str) – name of the SLB.

• status (str) – SLB status.

class aliyun.slb.model.Region(region_id)Bases: object

class aliyun.slb.model.TCPListener(load_balancer_id, listener_port, backend_server_port, lis-tener_status=’active’, scheduler=’wrr’, health_check=False,connect_timeout=5, interval=2, connect_port=None, persis-tence_timeout=0)

Bases: aliyun.slb.model.Listener

TCP Load Balancer Listener

Parameters

• load_balancer_id (str) – LoadBalancerId unique identifier of the SLB.

• listener_port (int, required) – port the Load Balancer listens on

• backend_server_port (int, required) – port number to connect to servers

• listener_status (str) – ‘active’ (default) or ‘stopped’.

• scheduler (str) – wrr or wlc. Round Robin (default) or Least Connections.

• health_check (bool) – True for ‘on’ and False for ‘off’ (default)

• connect_timeout (int) – number of seconds to timeout and fail a health check

• interval (int) – number of seconds between health checks

• connect_port (int) – defaults to backend_server_port

• persistence_timeout (int) – number of seconds to hold TCP connection open

Module contents

Aliyun SLB

To interact with the SLB API, use aliyun.slb.connection.SlbConnection.

import aliyun.slb.connectionconn = aliyun.slb.connection.SlbConnection('cn-hangzhou')conn.deregister_backend_server_ids(['bad_id'])

Generally, the API Action parameters are implemented in methods named very similar to their associated Action. Some additional helper functionality wraps some calls. The helper methods are:

• aliyun.slb.connection.SlbConnection.get_all_region_ids()

• aliyun.slb.connection.SlbConnection.get_all_load_balancer_ids()

• aliyun.slb.connection.SlbConnection.get_backend_server_ids()

28 Chapter 2. aliyun package

Page 33: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

• aliyun.slb.connection.SlbConnection.remove_backend_server_ids()

• aliyun.slb.connection.SlbConnection.add_backend_server_ids()

• aliyun.slb.connection.SlbConnection.deregister_backend_server_ids()

• aliyun.slb.connection.SlbConnection.deregister_backend_servers()

Submodules

aliyun.connection module

class aliyun.connection.Connection(region_id, service, access_key_id=None, se-cret_access_key=None)

Bases: object

get(params, paginated=False, encoding=None)Make a get request to the API.

Parameters

• params (dict) – The parameters to the request. Keys and values should be string types.

• paginated (bool) – Should the results be paginated.

• encoding (str) – Encoding of the parameters. By default reads stdin encoding, orfailing that default encoding, or failing that utf8.

Returns Parsed result.

class aliyun.connection.Credentials(access_key_id, secret_access_key)Bases: tuple

access_key_idAlias for field number 0

secret_access_keyAlias for field number 1

exception aliyun.connection.ErrorBases: exceptions.Exception

Base exception class for this module.

aliyun.connection.find_credentials()Tries to get the aliyun credentials from the following in priority:

•environment variables

•config file

The environment variables to use are:

•ALI_ACCESS_KEY_ID

•ALI_SECRET_ACCESS_KEY

If both of these are not found, it then looks for config files at:

$HOME/.aliyun.cfg/etc/aliyun.cfg

The format of the file must be:

2.2. Submodules 29

Page 34: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

[default]access_key_id=ACCESS_KEYsecret_access_key=SECRET_KEY

Module contents

Aliyun API

The Aliyun API is well-documented at dev.aliyun.com. Each service’s API is very similar: There are regions, actions,and each action has many parameters. It is an OAuth2 API, so you need to have an ID and a secret. You can get thesefrom the Aliyun management console.

Authentication

You will need security credentials for your Aliyun account. You can view and create them in the Aliyun managementconsole. This library will look for credentials in the following places:

1. Environment variables ALI_ACCESS_KEY_ID and ALI_SECRET_ACCESS_KEY

2. An ini-style configuration file at ~/.aliyun.cfg with contents like:

[default]access_key_id=xxxxxxxxxxxxxsecret_access_key=xxxxxxxxxxxxxxxxxxxxxxx

3. A system-wide version of that file at /etc/aliyun.cfg with similar contents.

We recommend using environment variables whenever possible.

Main Interfaces

The main components of python-aliyun are ECS and SLB. Other Aliyun products will be added as API supportdevelops. Within each Aliyun product, we tried to implement every API Action variation available. We used a boto-style design where most API interaction is done with a connection object which marshalls Python objects and APIrepresentations.

ECS:

You can create a new ECS connection and interact with ECS like this:

import aliyun.ecs.connectionconn = aliyun.ecs.connection.EcsConnection('cn-hangzhou')print conn.get_all_instance_ids()

See more at aliyun.ecs

SLB:

Similarly for SLB, get the connection object like this:

import aliyun.slb.connectionconn = aliyun.slb.connection.SlbConnection('cn-hangzhou')print conn.get_all_load_balancer_ids()

See more at aliyun.slb

30 Chapter 2. aliyun package

Page 35: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

ali command

The ali commandline tool is mostly used for debugging the Aliyun API interactions. It accepts arbitrary Key=Valuepairs and passes them on to the API after wrapping them.

ali --region cn-hangzhou ecs Action=DescribeRegionsali --region cn-hangzhou slb Action=DescribeLoadBalancers

2.3. Module contents 31

Page 36: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

32 Chapter 2. aliyun package

Page 37: Release Adam Gray, Akshay Dayal, North Bits

CHAPTER 3

Indices and tables

• genindex

• modindex

• search

33

Page 38: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

34 Chapter 3. Indices and tables

Page 39: Release Adam Gray, Akshay Dayal, North Bits

Python Module Index

aaliyun, 30aliyun.connection, 29aliyun.ecs, 18aliyun.ecs.connection, 5aliyun.ecs.model, 17aliyun.slb, 28aliyun.slb.connection, 20aliyun.slb.model, 26

35

Page 40: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

36 Python Module Index

Page 41: Release Adam Gray, Akshay Dayal, North Bits

Index

Aaccess_key_id (aliyun.connection.Credentials attribute),

29add_backend_server_ids()

(aliyun.slb.connection.SlbConnection method),20

add_backend_servers() (aliyun.slb.connection.SlbConnectionmethod), 20

add_disk() (aliyun.ecs.connection.EcsConnectionmethod), 5

add_external_cidr_ip_rule()(aliyun.ecs.connection.EcsConnectionmethod), 6

add_group_rule() (aliyun.ecs.connection.EcsConnectionmethod), 6

add_internal_cidr_ip_rule()(aliyun.ecs.connection.EcsConnectionmethod), 6

aliyun (module), 30aliyun.connection (module), 29aliyun.ecs (module), 18aliyun.ecs.connection (module), 5aliyun.ecs.model (module), 17aliyun.slb (module), 28aliyun.slb.connection (module), 20aliyun.slb.model (module), 26allocate_public_ip() (aliyun.ecs.connection.EcsConnection

method), 7api_dict() (aliyun.ecs.model.DiskMapping method), 17attach_disk() (aliyun.ecs.connection.EcsConnection

method), 7AutoSnapshotExecutionStatus (class in

aliyun.ecs.model), 17AutoSnapshotPolicy (class in aliyun.ecs.model), 17AutoSnapshotPolicyStatus (class in aliyun.ecs.model), 17

BBackendServer (class in aliyun.slb.model), 26BackendServerStatus (class in aliyun.slb.model), 26

CConnection (class in aliyun.connection), 29create_and_start_instance()

(aliyun.ecs.connection.EcsConnectionmethod), 7

create_disk() (aliyun.ecs.connection.EcsConnectionmethod), 8

create_http_listener() (aliyun.slb.connection.SlbConnectionmethod), 20

create_image() (aliyun.ecs.connection.EcsConnectionmethod), 9

create_image_from_instance()(aliyun.ecs.connection.EcsConnectionmethod), 9

create_instance() (aliyun.ecs.connection.EcsConnectionmethod), 9

create_load_balancer() (aliyun.slb.connection.SlbConnectionmethod), 21

create_security_group() (aliyun.ecs.connection.EcsConnectionmethod), 10

create_snapshot() (aliyun.ecs.connection.EcsConnectionmethod), 11

create_tcp_listener() (aliyun.slb.connection.SlbConnectionmethod), 22

Credentials (class in aliyun.connection), 29

Ddelete_disk() (aliyun.ecs.connection.EcsConnection

method), 11delete_image() (aliyun.ecs.connection.EcsConnection

method), 11delete_instance() (aliyun.ecs.connection.EcsConnection

method), 11delete_listener() (aliyun.slb.connection.SlbConnection

method), 22delete_load_balancer() (aliyun.slb.connection.SlbConnection

method), 22delete_security_group() (aliyun.ecs.connection.EcsConnection

method), 11

37

Page 42: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

delete_snapshot() (aliyun.ecs.connection.EcsConnectionmethod), 11

deregister_backend_server_ids()(aliyun.slb.connection.SlbConnection method),22

deregister_backend_servers()(aliyun.slb.connection.SlbConnection method),22

describe_auto_snapshot_policy()(aliyun.ecs.connection.EcsConnectionmethod), 11

describe_disks() (aliyun.ecs.connection.EcsConnectionmethod), 11

describe_images() (aliyun.ecs.connection.EcsConnectionmethod), 12

describe_instance_disks()(aliyun.ecs.connection.EcsConnectionmethod), 12

describe_instance_types()(aliyun.ecs.connection.EcsConnectionmethod), 12

describe_security_groups()(aliyun.ecs.connection.EcsConnectionmethod), 12

describe_snapshot() (aliyun.ecs.connection.EcsConnectionmethod), 12

describe_snapshots() (aliyun.ecs.connection.EcsConnectionmethod), 13

detach_disk() (aliyun.ecs.connection.EcsConnectionmethod), 13

Disk (class in aliyun.ecs.model), 17disk_supported() (aliyun.ecs.model.Zone method), 18DiskMapping (class in aliyun.ecs.model), 17DiskMappingError, 18

EEcsConnection (class in aliyun.ecs.connection), 5Error, 17, 20, 29

Ffind_credentials() (in module aliyun.connection), 29

Gget() (aliyun.connection.Connection method), 29get_all_clusters() (aliyun.ecs.connection.EcsConnection

method), 13get_all_instance_ids() (aliyun.ecs.connection.EcsConnection

method), 13get_all_instance_status() (aliyun.ecs.connection.EcsConnection

method), 13get_all_load_balancer_ids()

(aliyun.slb.connection.SlbConnection method),22

get_all_load_balancer_status()(aliyun.slb.connection.SlbConnection method),23

get_all_region_ids() (aliyun.ecs.connection.EcsConnectionmethod), 13

get_all_region_ids() (aliyun.slb.connection.SlbConnectionmethod), 23

get_all_regions() (aliyun.ecs.connection.EcsConnectionmethod), 13

get_all_regions() (aliyun.slb.connection.SlbConnectionmethod), 23

get_all_zone_ids() (aliyun.ecs.connection.EcsConnectionmethod), 13

get_all_zones() (aliyun.ecs.connection.EcsConnectionmethod), 13

get_backend_server_ids()(aliyun.slb.connection.SlbConnection method),23

get_backend_servers() (aliyun.slb.connection.SlbConnectionmethod), 23

get_http_listener() (aliyun.slb.connection.SlbConnectionmethod), 23

get_instance() (aliyun.ecs.connection.EcsConnectionmethod), 13

get_load_balancer() (aliyun.slb.connection.SlbConnectionmethod), 23

get_security_group() (aliyun.ecs.connection.EcsConnectionmethod), 14

get_security_group_ids()(aliyun.ecs.connection.EcsConnectionmethod), 14

get_tcp_listener() (aliyun.slb.connection.SlbConnectionmethod), 23

HHTTPListener (class in aliyun.slb.model), 26

IImage (class in aliyun.ecs.model), 18Instance (class in aliyun.ecs.model), 18InstanceStatus (class in aliyun.ecs.model), 18InstanceType (class in aliyun.ecs.model), 18

Jjoin_security_group() (aliyun.ecs.connection.EcsConnection

method), 14

Lleave_security_group() (aliyun.ecs.connection.EcsConnection

method), 14Listener (class in aliyun.slb.model), 26ListenerStatus (class in aliyun.slb.model), 27LoadBalancer (class in aliyun.slb.model), 27

38 Index

Page 43: Release Adam Gray, Akshay Dayal, North Bits

python-aliyun Documentation, Release

LoadBalancerStatus (class in aliyun.slb.model), 27

Mmodify_auto_snapshot_policy()

(aliyun.ecs.connection.EcsConnectionmethod), 14

modify_disk() (aliyun.ecs.connection.EcsConnectionmethod), 15

modify_instance() (aliyun.ecs.connection.EcsConnectionmethod), 15

modify_instance_spec() (aliyun.ecs.connection.EcsConnectionmethod), 15

Rreboot_instance() (aliyun.ecs.connection.EcsConnection

method), 15Region (class in aliyun.ecs.model), 18Region (class in aliyun.slb.model), 28reinit_disk() (aliyun.ecs.connection.EcsConnection

method), 15remove_backend_server_ids()

(aliyun.slb.connection.SlbConnection method),23

remove_backend_servers()(aliyun.slb.connection.SlbConnection method),24

remove_external_cidr_ip_rule()(aliyun.ecs.connection.EcsConnectionmethod), 16

remove_group_rule() (aliyun.ecs.connection.EcsConnectionmethod), 16

remove_internal_cidr_ip_rule()(aliyun.ecs.connection.EcsConnectionmethod), 16

replace_system_disk() (aliyun.ecs.connection.EcsConnectionmethod), 16

reset_disk() (aliyun.ecs.connection.EcsConnectionmethod), 16

resource_creation_supported() (aliyun.ecs.model.Zonemethod), 18

Ssecret_access_key (aliyun.connection.Credentials at-

tribute), 29SecurityGroup (class in aliyun.ecs.model), 18SecurityGroupInfo (class in aliyun.ecs.model), 18SecurityGroupPermission (class in aliyun.ecs.model), 18set_listener_status() (aliyun.slb.connection.SlbConnection

method), 24set_load_balancer_name()

(aliyun.slb.connection.SlbConnection method),24

set_load_balancer_status()(aliyun.slb.connection.SlbConnection method),24

SlbConnection (class in aliyun.slb.connection), 20Snapshot (class in aliyun.ecs.model), 18start_instance() (aliyun.ecs.connection.EcsConnection

method), 17start_load_balancer_listener()

(aliyun.slb.connection.SlbConnection method),24

stop_instance() (aliyun.ecs.connection.EcsConnectionmethod), 17

stop_load_balancer_listener()(aliyun.slb.connection.SlbConnection method),24

TTCPListener (class in aliyun.slb.model), 28

Uupdate_http_listener() (aliyun.slb.connection.SlbConnection

method), 24update_tcp_listener() (aliyun.slb.connection.SlbConnection

method), 25

ZZone (class in aliyun.ecs.model), 18

Index 39