AutoScaling API¶
For details on how to use auto scaling, see /sdk/guides/auto_scaling (NEEDS TO BE DONE).
The AutoScaling Class¶
The AS high-level interface is available through the auto_scaling
member of a Connection
object. The
auto_scaling
member will only be added if the
otcextensions.sdk.register_otc_extensions(conn)
method is called.
Group Operations¶
- class otcextensions.sdk.auto_scaling.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- groups(**query)
Retrieve a generator of groups
- Parameters:
query (dict) – Optional query parameters to be sent to limit the resources being returned. *
name
: group name *status
: group status,INSERVICE
,PAUSED
,ERROR
*scaling_configuration_id
: scaling configuration id *marker
: pagination marker, known asstart_number
*limit
: pagination limit- Returns:
A generator of group (
Group
) instances
- create_group(**attrs)
Create a new group from attributes
- get_group(group)
Get a group
- delete_group(group, ignore_missing=True, force_delete=False)
Delete a group
- Parameters:
group – The value can be the ID of a group or a
Group
instance.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the group does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent group.force_delete (bool) – When set to
True
indicates to forcibly delete an AS group, remove the ECS instances and release them when the AS group is running instances or performing scaling actions.
- find_group(name_or_id, ignore_missing=True)
Find a single group
- Parameters:
name_or_id – The name or ID of a group
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the group does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent group.
- Returns:
None
- resume_group(group)
resume group
- Parameters:
group – The value can be the ID of a group or a
Group
instance.
- pause_group(group)
pause group
- Parameters:
group – The value can be the ID of a group or a
Group
instance.
Config Operations¶
- class otcextensions.sdk.auto_scaling.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- configs(**query)
Retrieve a generator of configs
- Parameters:
query (dict) – Optional query parameters to be sent to limit the resources being returned. *
name
: configuration name *image_id
: image id *marker
: pagination marker *limit
: pagination limit- Returns:
A generator of config (
Config
) instances
- create_config(name, **attrs)
Create a new config from config name and instance-config attributes
- Parameters:
name – auto scaling config name
attrs (dict) – Keyword arguments which will be used to create a
InstanceConfig
, comprised of the properties on the InstanceConfig class.
- Returns:
The results of config creation
- Return type:
- get_config(config)
Get a config
- find_config(name_or_id, ignore_missing=True)
Get a config
- Parameters:
name_or_id – The name or ID of a config
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the config does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent config.
- Returns:
Config instance
- Return type:
- delete_config(config, ignore_missing=True)
Delete a config
- Parameters:
config – The value can be the ID of a config or a
Config
instance.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the config does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent config.
- Returns:
Config been deleted
- Return type:
- batch_delete_configs(configs)
batch delete configs
- Parameters:
configs – The list item value can be the ID of a config or a
Config
instance.
Policy Operations¶
- class otcextensions.sdk.auto_scaling.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- policies(group, **query)
Retrieve a generator of policies
- Parameters:
group – The value can be the ID of a group or a
Group
instance.query (dict) – Optional query parameters to be sent to limit the resources being returned. *
name
: policy name *type
: policy type *scaling_group_id
: scaling group id the policy applied to *marker
: pagination marker *limit
: pagination limit
- Returns:
A generator of policy (
Policy
) instances
- create_policy(**attrs)
Create a new policy from attributes
- update_policy(policy, **attrs)
update policy with attributes
- get_policy(policy)
Get a policy
- delete_policy(policy, ignore_missing=True)
Delete a policy
- Parameters:
policy – The value can be the ID of a policy or a
Policy
instance.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the policy does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent policy.
- Returns:
Policy been deleted
- Return type:
- find_policy(name_or_id, group, ignore_missing=True)
Find a single policy
- Parameters:
name_or_id – The name or ID of a policy
group – ID of a group
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the policy does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent policy.
- Returns:
None
- execute_policy(policy)
execute policy
- Parameters:
policy – The value can be the ID of a policy or a
Policy
instance.
- resume_policy(policy)
resume policy
- Parameters:
policy – The value can be the ID of a policy or a
Policy
instance.
- pause_policy(policy)
pause policy
- Parameters:
policy – The value can be the ID of a policy or a
Policy
instance.
Instance Operations¶
- class otcextensions.sdk.auto_scaling.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- instances(group, **query)
Retrieve a generator of instances
- Parameters:
group – The value can be the ID of a group or a
Group
instance.query (dict) – Optional query parameters to be sent to limit the resources being returned. *
health_status
: instance health status *lifecycle_status
: policy type *scaling_group_id
: scaling group id the policy applied to *marker
: pagination marker *limit
: pagination limit
- Returns:
A generator of instances with type (
Instance
)
- remove_instance(instance, delete_instance=False, ignore_missing=True)
Remove an instance of auto scaling group
- Precondition:
the instance must in
INSERVICE
status- after remove the instance number of auto scaling group should not
be less than min instance number
The own auto scaling group should not in scaling status
- Parameters:
instance – The value can be the ID of a instance or a
Instance
instance.delete_instance (bool) – When set to
True
, instance will be deleted after removed.ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the config does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent config.
- Returns:
None
- batch_instance_action(group, instances, action, delete_instance=False)
Batch add instances for auto scaling group
- Parameters:
group – The group which instances will be added to, The value can be the ID of a group or a
Group
instance.instances – The list item value can be ID of an instance or a
Instance
instanceaction – Action type [
ADD
,REMOVE
,PROTECT
,UNPROTECT
]delete_instance – When set to
True
, instance will be deleted after removed
Actions and Quotas¶
- class otcextensions.sdk.auto_scaling.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- activities(group, **query)
Retrieve a generator of Activity
- Parameters:
group – The value can be the ID of a group or a
Group
instance.query (dict) – Optional query parameters to be sent to limit the resources being returned. *
start_time
: activity start time *end_time
: activity end time *marker
: pagination marker, known asstart_number
*limit
: pagination limit
- Returns:
A generator of group (
Activity
) instances