This is the IcsEc2 common library. |
ICS Library for EC2
Add tags to the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|
Bind EIP address to the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | bool |
Returns: | success or raise IcsEc2Exception |
Clean up snapshots by specific tags and duration
Parameters: | tags (dict) – snapshot tags like |
---|
{
"Name": "XXX"
}
Parameters: | duration (int) – seconds |
---|---|
Return type: | list |
Returns: | list of cleaned snapshot ids |
Remove tags of the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|
Delete snapshots by snapshot_id
Parameters: | snapshot_id (string) – snapshot Id like ‘snap-xxxxxx’ |
---|---|
Return type: | boolean |
Returns: | true, false, exception |
Fetch the Image Id by specific tags
Parameters: | tags (dict) – AMI tags like {‘Name’: ‘XXX’} |
---|---|
Return type: | string |
Returns: | Image Id |
Find the Snapshot Id by specific tags
Parameters: | tags (dict) – snapshot tags like {‘Name’: ‘XXX’} |
---|---|
Return type: | string |
Returns: | Snapshot Id |
Find AMI by specific tags
Parameters: | tags (dict) – AMI tags like {‘Name’: ‘XXX’} |
---|---|
Return type: | list |
Returns: | list of boto image objects |
Find a snapshot by specific tags
Parameters: | tags (dict) – snapshot tags like {‘Name’: ‘XXX’} |
---|---|
Return type: | list |
Returns: | list of boto snapshot objects |
Convert {“Name”: “XXX”} to {“tag:Name”: “XXX”}
Free EIP address to the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | bool |
Returns: | success or raise IcsEc2Exception |
Get all Availability Zones under this region
Return type: | list |
---|---|
Returns: | list of availability zones in this region |
Get the name of Availability Zone by its Subnet Id
Parameters: | subnet_id (string) – subnet id |
---|---|
Return type: | string |
Returns: | availability zone name |
Get EIP objects via the list of EIP addresses
Parameters: | eip_list (list) – the list of EIP addresses |
---|---|
Return type: | class |
Returns: | EIP objects in boto |
Get EIP objects via the instance id
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | class |
Returns: | EIP objects in boto |
Get the attribute value of an instance.
Parameters: | |
---|---|
Variables: |
|
Get the event of the specified instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | tuple |
Returns: | a tuple contains (instance_status, system_status) |
Get tags of the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | dict |
Returns: | a dictionary containing the tags of this instance |
Get the private IPv4 address of the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | string |
Returns: | a string containing the private IPv4 address |
Get the private dns address of the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | string |
Returns: | a string containing the private IPv4 address |
Get the public IPv4 address of the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | string |
Returns: | a string containing the public IPv4 address |
Get the public dns address of the instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | string |
Returns: | a string containing the public dns address |
Get security group id
Parameters: | |
---|---|
Return type: | string |
Returns: | security group id |
Get Security Group Name (if Ec2) / Id (if Vpc)
Parameters: | |
---|---|
Return type: | string |
Returns: | security group id |
Get boto Volume Objects by instance Id
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | list |
Returns: | list of boto volume objects |
Get the index of Availability Zone for Cassandra
Parameters: | index (int) – the index of cassandra instance |
---|---|
Return type: | string |
Returns: | zone index like “1” |
Get the name of Availability Zone for Cassandra
Parameters: | index (int) – the index of cassandra instance |
---|---|
Return type: | string |
Returns: | zone name like “us-west-2a” |
Get the suffix of Availability Zone for Cassandra
Parameters: | index (int) – the index of cassandra instance |
---|---|
Return type: | string |
Returns: | zone suffix like “a-1” |
check the availability of the specified EIP address: free or not
Parameters: | eip (string) – one EIP address |
---|---|
Return type: | tuple |
Returns: | (True/False, EIP object/None) |
check the health of the specified instance
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
---|---|
Return type: | boolean |
Returns: | True/False |
Get the number of all Availability Zones under this region
Return type: | int |
---|---|
Returns: | number of availability zones in this region |