IcsAS Common Library
IcsAS: Library for Auto Scaling
This is the IcsAS common library. |
-
class opslib.icsas.IcsAS(region, **kwargs)[source]
ICS Library for AutoScale
-
__dict__ = dict_proxy({'__module__': 'opslib.icsas', 'resume_scaling_group': <function resume_scaling_group at 0x4888668>, 'get_group_from_name': <function get_group_from_name at 0x4888398>, '__doc__': '\n ICS Library for AutoScale\n ', 'to_list': <function to_list at 0x4888230>, 'get_launch_config_from_name': <function get_launch_config_from_name at 0x4888410>, 'update_instance_health': <function update_instance_health at 0x4888758>, 'suspend_scaling_group': <function suspend_scaling_group at 0x48885f0>, 'get_instances_from_group_name': <function get_instances_from_group_name at 0x4888320>, 'delete_launch_config_from_name': <function delete_launch_config_from_name at 0x4888500>, '__dict__': <attribute '__dict__' of 'IcsAS' objects>, 'update_launch_config': <function update_launch_config at 0x4888578>, 'create_launch_config': <function create_launch_config at 0x4888488>, '__weakref__': <attribute '__weakref__' of 'IcsAS' objects>, 'terminate_group_instance': <function terminate_group_instance at 0x48886e0>, '__init__': <function __init__ at 0x48881b8>, 'get_group_name_from_instance': <function get_group_name_from_instance at 0x48882a8>})
-
__init__(region, **kwargs)[source]
-
__module__ = 'opslib.icsas'
-
__weakref__
list of weak references to the object (if defined)
-
create_launch_config(launch_config)[source]
Create the Launch Configuration
Parameters: | launch_config (class) – boto launch_config object |
Return type: | string |
Returns: | AWS request Id |
-
delete_launch_config_from_name(name)[source]
Delete the Launch Configuration from its name
Parameters: | name (string) – the name of launch configuration |
Return type: | string |
Returns: | AWS request Id |
-
get_group_from_name(name)[source]
Get the ASG from its name
Parameters: | name (string) – the ASG name |
Return type: | list |
Returns: | a list represents the specific ASG(s) |
-
get_group_name_from_instance(instance_id)[source]
Get the ASG name from the specific instance id
Parameters: | instance_id (string) – EC2 instance id startwith ‘i-xxxxxxx’ |
Return type: | string |
Returns: | name of the ASG, this instance belongs to |
-
get_instances_from_group_name(name)[source]
Get the instance from the specific ASG name
Parameters: | name (string) – the specific ASG name |
Return type: | list |
Returns: | a list contains all the instances |
-
get_launch_config_from_name(name)[source]
Get the Launch Configuration from its name
Parameters: | name (string) – the Launch Configuration name |
Return type: | list |
Returns: | a list represents the specific Launch Configuration(s) |
-
resume_scaling_group(name, scaling_processes=None)[source]
Resumes Auto Scaling processes for an Auto Scaling group.
Parameters: |
- name (string) – the ASG name
- scaling_processes (string or list) –
scaling process names
- Launch
- Terminate
- HealthCheck
- ReplaceUnhealthy
- AZRebalance
- AlarmNotification
- ScheduledActions
- AddToLoadBalancer
|
-
suspend_scaling_group(name, scaling_processes=None)[source]
Suspends Auto Scaling processes for an Auto Scaling group.
Parameters: |
- name (string) – the ASG name
- scaling_processes (string or list) –
scaling process names
- Launch
- Terminate
- HealthCheck
- ReplaceUnhealthy
- AZRebalance
- AlarmNotification
- ScheduledActions
- AddToLoadBalancer
|
-
terminate_group_instance(instance_id, decrement_capacity=True)[source]
Terminates the specified instance. The desired group size can
also be adjusted, if desired.
Parameters: |
- instance_id (str) – The ID of the instance to be terminated.
- decrement_capacity – Whether to decrement the size of the
autoscaling group or not.
|
-
to_list(input)[source]
Validate input, if not list, but string, make it as a list
-
update_instance_health(instance_id, health_status, grace_period=False)[source]
Explicitly set the health status of an instance.
Parameters: |
- instance_id (str) – The identifier of the EC2 instance
- health_status (str) – The health status of the instance.
|
- Healthy: the instance is healthy and should remain in service.
- Unhealthy: the instance is unhealthy. Auto Scaling should terminate and replace it.
Parameters: | grace_period (bool) – If True, this call should respect
the grace period associated with the group. |
-
update_launch_config(name, launch_config)[source]
Update the Launch Configuration for specific ASG
Parameters: |
- name (string) – the name of Auto-Scaling Group
- launch_config (class) – boto launch_config object
|
Return type: | string
|
Returns: | AWS request Id
|
-
class opslib.icsas.RawAS(region)[source]
Raw Library for AutoScale, based on Botocore
-
__dict__ = dict_proxy({'__module__': 'opslib.icsas', 'create_group': <function create_group at 0x4888aa0>, 'kill_group': <function kill_group at 0x4888e60>, 'modify_group': <function modify_group at 0x4888cf8>, 'new_scaling_policy': <function new_scaling_policy at 0x4888ed8>, '__dict__': <attribute '__dict__' of 'RawAS' objects>, 'fetch_all_groups': <function fetch_all_groups at 0x4888848>, '__weakref__': <attribute '__weakref__' of 'RawAS' objects>, '__init__': <function __init__ at 0x48887d0>, 'launch_group': <function launch_group at 0x4888de8>, 'update_group': <function update_group at 0x4888d70>, 'handle_response': <function handle_response at 0x4888938>, 'delete_group': <function delete_group at 0x4888b90>, '__doc__': '\n Raw Library for AutoScale, based on Botocore\n ', 'fetch_launch_config': <function fetch_launch_config at 0x4888a28>, 'delete_scaling_policy': <function delete_scaling_policy at 0x4888f50>, 'delete_launch_config': <function delete_launch_config at 0x4888c08>, 'find_groups': <function find_groups at 0x48888c0>, 'create_launch_config': <function create_launch_config at 0x4888b18>, 'modify_launch_config': <function modify_launch_config at 0x4888c80>, 'fetch_group': <function fetch_group at 0x48889b0>})
-
__init__(region)[source]
Initialize the proper botocore service
-
__module__ = 'opslib.icsas'
-
__weakref__
list of weak references to the object (if defined)
-
create_group(group_config)[source]
Create a new Auto-Scaling Group
Parameters: | group_config (dict) – auto-scaling group configuration |
-
create_launch_config(launch_config)[source]
Create a new Launch Configuration
Parameters: | launch_config (dict) – launch configuration |
-
delete_group(name)[source]
Delete an existing Auto-Scaling Group
Parameters: | name (string) – auto-scaling group name |
-
delete_launch_config(name)[source]
Delete an existing Launch Configuration
Parameters: | name (string) – launch configuration name |
-
delete_scaling_policy(scaling_policy, metric_alarm)[source]
Delete an existing Scaling Policy
Parameters: |
- scaling_policy (dict) – scaling policy configuration
- metric_alarm (dict) – metric alarm configuration
|
-
fetch_all_groups()[source]
Fetch all the Auto-Scaling Groups
Return type: | dict |
Returns: | JSON object for all the Auto-Scaling Groups |
-
fetch_group(name)[source]
Fetch an existing Auto-Scaling Group
Parameters: | name (string) – auto-scaling group name |
-
fetch_launch_config(name)[source]
Fetch an existing Launch Configuration
Parameters: | name (string) – launch configuration name |
-
find_groups(filter={})[source]
Find the names of Auto-Scaling Groups in the filters
Parameters: | filter (dict) – a dictionary to used for resource filtering
The format should be consistent with botocore JSON output |
{
"Tags": [
{
"Key": "Owner",
"Value": "Production"
}
]
}
Return type: | list |
Returns: | a list containing all the names of filtered groups |
-
handle_response(response)[source]
Handle the botocore response
-
kill_group(group_name, force=False, force_cmd='-force')[source]
Delete a new Auto-Scaling Group
Parameters: |
- name (string) – launch configuration name
- force (boolean) – whether to delete the auto-scaling group forcely
|
-
launch_group(group_config, launch_config)[source]
Launch a new Auto-Scaling Group
Parameters: |
- group_config (dict) – auto-scaling group configuration
- launch_config (dict) – launch configuration
|
-
modify_group(group_config)[source]
Modify the Auto-Scaling Group
Parameters: | group_config (dict) – auto-scaling group configuration |
-
modify_launch_config(launch_config, delimiter='_U_')[source]
Modify the Launch Configuration
Parameters: | launch_config (dict) – launch configuration |
-
new_scaling_policy(scaling_policy, metric_alarm)[source]
Create a new Scaling Policy
Parameters: |
- scaling_policy (dict) – scaling policy configuration
- metric_alarm (dict) – metric alarm configuration
|
-
update_group(group_config, launch_config)[source]
Update the Auto-Scaling Group
Parameters: |
- group_config (dict) – auto-scaling group configuration
- launch_config (dict) – launch configuration
|
-
opslib.icsas.get_region(region_name, **kw_params)[source]
Find and return a boto.ec2.autoscale.RegionInfo object
given a region name.
Parameters: | region_name (str) – The name of the region. |
Return type: | boto.ec2.autoscale.RegionInfo |
Returns: | The RegionInfo object for the given region or None if
an invalid region name is provided. |