libcloud.compute.drivers.ecs module
Node driver for Aliyun.
- class libcloud.compute.drivers.ecs.DiskCategory[source]
Bases:
object
Enum defined disk types supported by Aliyun system and data disks.
- CLOUD = 'cloud'
- CLOUD_EFFICIENCY = 'cloud_efficiency'
- CLOUD_SSD = 'cloud_ssd'
- EPHEMERAL_SSD = 'ephemeral_ssd'
- class libcloud.compute.drivers.ecs.ECSDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, region=None, **kwargs)[source]
Bases:
NodeDriver
Aliyun ECS node driver.
Used for Aliyun ECS service.
TODO: Get guest OS root password Adjust internet bandwidth settings Manage security groups and rules
- Parameters:
key (
str
) – API key or username to be used (required)secret (
str
) – Secret password to be used (required)secure (
bool
) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.host (
str
) – Override hostname used for connections.port (
int
) – Override port used for connections.api_version (
str
) – Optional API version. Only used by drivers which support multiple API versions.region (
str
) – Optional driver region. Only used by drivers which support multiple regions.
- Return type:
None
- NODE_STATE_MAPPING = {'Running': NodeState.RUNNING, 'Starting': NodeState.PENDING, 'Stopped': NodeState.STOPPED, 'Stopping': NodeState.PENDING}
- SNAPSHOT_STATE_MAPPING = {'accomplished': VolumeSnapshotState.AVAILABLE, 'failed': VolumeSnapshotState.ERROR, 'progressing': VolumeSnapshotState.CREATING}
- VOLUME_STATE_MAPPING = {'Attaching': StorageVolumeState.ATTACHING, 'Available': StorageVolumeState.AVAILABLE, 'Creating': StorageVolumeState.CREATING, 'Detaching': StorageVolumeState.INUSE, 'In_use': StorageVolumeState.INUSE, 'ReIniting': StorageVolumeState.CREATING}
- attach_volume(node, volume, device=None, ex_delete_with_instance=None)[source]
Attaches volume to node.
@inherits
NodeDriver.attach_volume
- Parameters:
device (
str
between /dev/xvdb to xvdz, if empty, allocated by the system) – device path allocated for this attached volumeex_delete_with_instance (
bool
) – if to delete this volume when the instance is deleted.
- connectionCls
alias of
ECSConnection
- copy_image(source_region, node_image, name, description=None, ex_destination_region_id=None, ex_client_token=None)[source]
Copies an image from a source region to the destination region. If not provide a destination region, default to the current region.
@inherits
NodeDriver.copy_image
- Parameters:
ex_destination_region_id (
str
) – id of the destination regionex_client_token (
str
) – a token generated by client to identify each request.
- create_image(node, name, description=None, ex_snapshot_id=None, ex_image_version=None, ex_client_token=None)[source]
Creates an image from a system disk snapshot.
@inherits
NodeDriver.create_image
- Parameters:
ex_snapshot_id (
str
) – the id of the snapshot to create the image. (required)ex_image_version (
str
) – the version number of the imageex_client_token (
str
) – a token generated by client to identify each request.
- create_node(name, size, image, auth=None, ex_security_group_id=None, ex_description=None, ex_internet_charge_type=None, ex_internet_max_bandwidth_out=None, ex_internet_max_bandwidth_in=None, ex_hostname=None, ex_io_optimized=None, ex_system_disk=None, ex_data_disks=None, ex_vswitch_id=None, ex_private_ip_address=None, ex_client_token=None, **kwargs)[source]
@inherits:
NodeDriver.create_node
- Parameters:
name (
str
) – The name for this new node (required)image (NodeImage) – The image to use when creating this node (required)
size (NodeSize) – The size of the node to create (required)
auth (
NodeAuthSSHKey
orNodeAuthPassword
) – Initial authentication information for the node (optional)ex_security_group_id (
str
) – The id of the security group the new created node is attached to. (required)ex_description (
str
) – A description string for this node (optional)ex_internet_charge_type (a
str
of ‘PayByTraffic’ or ‘PayByBandwidth’) – The internet charge type (optional)ex_internet_max_bandwidth_out (a
int
in range [0, 100] aint
in range [1, 100] for ‘PayByTraffic’ internet charge type) – The max output bandwidth, in Mbps (optional) Required for ‘PayByTraffic’ internet charge typeex_internet_max_bandwidth_in (a
int
in range [1, 200] default to 200 in server side) – The max input bandwidth, in Mbps (optional)ex_hostname (
str
) – The hostname for the node (optional)ex_io_optimized (
boll
) – Whether the node is IO optimized (optional)ex_system_disk (
dict
) – The system disk for the node (optional)ex_data_disks (a list of dict) – The data disks for the node (optional)
ex_vswitch_id (
str
) – The id of vswitch for a VPC type node (optional)ex_private_ip_address (
str
) – The IP address in private network (optional)ex_client_token – A token generated by client to keep requests idempotency (optional)
- create_public_ip(instance_id)[source]
Create public ip.
- Parameters:
instance_id (
str
) – instance id for allocating public ip.
:return public ip :rtype
str
- create_volume(size, name, location=None, snapshot=None, ex_zone_id=None, ex_description=None, ex_disk_category=None, ex_client_token=None)[source]
Create a new volume.
@inherites
NodeDriver.create_volume
- Parameters:
ex_zone_id (
str
) – the availability zone id (required)ex_description (
unicode
) – volume descriptionex_disk_category (
str
) – disk category for data diskex_client_token (
str
) – a token generated by client to identify each request.
- create_volume_snapshot(volume, name=None, ex_description=None, ex_client_token=None)[source]
Creates a snapshot of the storage volume.
@inherits
NodeDriver.create_volume_snapshot
- Parameters:
ex_description (
unicode
) – description of the snapshot.ex_client_token (
str
) – a token generated by client to identify each request.
- delete_image(node_image)[source]
Deletes a node image from a provider.
- Parameters:
node_image (
NodeImage
) – Node image object.- Returns:
True
if delete_image was successful,False
otherwise.- Return type:
bool
- destroy_node(node)[source]
Destroy a node.
Depending upon the provider, this may destroy all data associated with the node, including backups.
- Parameters:
node (
Node
) – The node to be destroyed- Returns:
True if the destroy was successful, False otherwise.
- Return type:
bool
- destroy_volume(volume)[source]
Destroys a storage volume.
- Parameters:
volume (
StorageVolume
) – Volume to be destroyed- Return type:
bool
- destroy_volume_snapshot(snapshot)[source]
Destroys a snapshot.
- Parameters:
snapshot (
VolumeSnapshot
) – The snapshot to delete- Return type:
- detach_volume(volume, ex_instance_id=None)[source]
Detaches a volume from a node.
@inherits
NodeDriver.detach_volume
- Parameters:
ex_instance_id (
str
) – the id of the instance from which the volume is detached.
- disk_categories
alias of
DiskCategory
- ex_create_security_group(description=None, client_token=None)[source]
Create a new security group.
- Parameters:
description (
unicode
) – security group descriptionclient_token (
str
) – a token generated by client to identify each request.
- ex_delete_security_group_by_id(group_id=None)[source]
Delete a new security group.
- Parameters:
group_id (
str
) – security group id
- ex_join_security_group(node, group_id=None)[source]
Join a node into security group.
- Parameters:
node (
Node
) – The node to join security groupgroup_id (
str
) – security group id.
- Returns:
join operation result.
- Return type:
bool
- ex_leave_security_group(node, group_id=None)[source]
Leave a node from security group.
- Parameters:
node (
Node
) – The node to leave security groupgroup_id (
str
) – security group id.
- Returns:
leave operation result.
- Return type:
bool
- ex_list_security_group_attributes(group_id=None, nic_type='internet')[source]
List security group attributes in the current region.
- Parameters:
group_id (
str
) – security group id.nic_type (
str
) – internet|intranet.
- Returns:
a list of defined security group Attributes
- Return type:
list
ofECSSecurityGroupAttribute
- ex_list_security_groups(ex_filters=None)[source]
List security groups in the current region.
- Parameters:
ex_filters (
dict
) – security group attributes to filter results.- Returns:
a list of defined security groups
- Return type:
list
ofECSSecurityGroup
- ex_list_zones(region_id=None)[source]
List availability zones in the given region or the current region.
- Parameters:
region_id (
str
) – the id of the region to query zones from- Returns:
list of zones
- Return type:
list
ofECSZone
- ex_modify_security_group_by_id(group_id=None, name=None, description=None)[source]
Modify a new security group. :keyword group_id: id of the security group :type group_id:
str
:keyword name: new name of the security group :type name:unicode
:keyword description: new description of the security group :type description:unicode
- features: Dict[str, List[str]] = {'create_node': ['password']}
- List of available features for a driver.
libcloud.compute.base.NodeDriver.create_node()
ssh_key: Supports
NodeAuthSSHKey
as an authentication method for nodes.password: Supports
NodeAuthPassword
as an authentication method for nodes.generates_password: Returns a password attribute on the Node object returned from creation.
- get_image(image_id, ex_region_id=None)[source]
Returns a single node image from a provider.
- Parameters:
image_id (
str
) – Node to run the task on.
:rtype
NodeImage
: :return: NodeImage instance on success.
- internet_charge_types
alias of
InternetChargeType
- list_images(location=None, ex_image_ids=None, ex_filters=None)[source]
List images on a provider.
@inherits
NodeDriver.list_images
- Parameters:
ex_image_ids (
list
ofstr
) – a list of image ids to filter the images to be returned.ex_filters (
dict
) – image attribute and value pairs to filter images. Only the image which matches all the pairs will be returned. If the filter attribute need a json array value, uselist
object, the driver will convert it.
- list_locations()[source]
List data centers for a provider
- Returns:
list of node location objects
- Return type:
list
ofNodeLocation
- list_nodes(ex_node_ids=None, ex_filters=None)[source]
List all nodes.
@inherits:
NodeDriver.create_node
- Parameters:
ex_node_ids (
list
ofstr
) – a list of node’s ids used to filter nodes. Only the nodes which’s id in this list will be returned.ex_filters (
dict
) – node attribute and value pairs to filter nodes. Only the nodes which matches all the pairs will be returned. If the filter attribute need a json array value, uselist
object, the driver will convert it.
- list_sizes(location=None)[source]
List sizes on a provider
- Parameters:
location (
NodeLocation
) – The location at which to list sizes- Returns:
list of node size objects
- Return type:
list
ofNodeSize
- list_volume_snapshots(volume, ex_snapshot_ids=[], ex_filters=None)[source]
List snapshots for a storage volume.
@inherites
NodeDriver.list_volume_snapshots
- Parameters:
ex_snapshot_ids (
list
ofstr
) – a list of snapshot ids to filter the snapshots returned.ex_filters (
dict
) – snapshot attribute and value pairs to filter snapshots. Only the snapshot which matches all the pairs will be returned. If the filter attribute need a json array value, uselist
object, the driver will convert it.
- list_volumes(ex_volume_ids=None, ex_filters=None)[source]
List all volumes.
@inherits:
NodeDriver.list_volumes
- Parameters:
ex_volume_ids (
list
ofstr
) – a list of volume’s ids used to filter volumes. Only the volumes which’s id in this list will be returned.ex_filters (
dict
) – volume attribute and value pairs to filter volumes. Only the volumes which matches all will be returned. If the filter attribute need a json array value, uselist
object, the driver will convert it.
- namespace = None
- path = '/'
- reboot_node(node, ex_force_stop=False)[source]
Reboot the given node
@inherits
NodeDriver.reboot_node
- Parameters:
ex_force_stop (
bool
) – ifTrue
, stop node force (maybe lose data) otherwise, stop node normally, default toFalse
- start_node(node)[source]
Start node to running state.
- Parameters:
node (
Node
) – theNode
object to start- Returns:
starting operation result.
- Return type:
bool
- class libcloud.compute.drivers.ecs.ECSSecurityGroup(id, name, description=None, driver=None, vpc_id=None, creation_time=None)[source]
Bases:
object
Security group used to control nodes internet and intranet accessibility.