in footmark/ess/connection.py [0:0]
def describe_instances(self, scaling_group_id=None, scaling_configuration_id=None, instance_ids=None,
health_status=None, lifecycle_state=None, creation_type=None, pagenumber=None, pagesize=50):
"""
Queries the list of ECS instances in a scaling group.
You can query by scaling group ID, scaling configuration ID, health status, lifecycle status, and creation type.
:type str
:param scaling_group_id: ID of a scaling group.
:type str
:param scaling_configuration_id: ID of a scaling configuration
:type list
:param instance_ids: ID of the ECS instance to be attached to the scaling group after it is enabled.
At most 20 IDs can be entered.
:type str
:param health_status: Health status of an ECS instance in the scaling group. Options: Healthy and Unhealthy.
:type str
:param lifecycle_state: Lifecycle status of an ECS instance in the scaling group. Options:
- InService: the ECS instance has been added to the scaling group and runs properly.
- Pending: the ECS instance is being attached to the scaling group with relevant configurations not completed.
- Removing: the ECS instance is being removed from the scaling group.
:type str
:param creation_type: ECS instance creation type. Options:
- AutoCreated: the ECS instance is automatically created by the Auto Scaling service in the scaling group.
- Attached: the ECS instance is created outside the Auto Scaling service and manually attached to the scaling group.
:type int
:param pagenumber: Page number of the scaling group list. The initial value and default value are both 1.
:type int
:param pagesize: When querying by page, this parameter indicates the number of lines per page. Maximum value: 50; default value: 10.
:rtype: list
:return: A list of :class:`footmark.ess.instance`
"""
instances = []
params = {}
if scaling_group_id:
self.build_list_params(params, scaling_group_id, 'ScalingGroupId')
if scaling_configuration_id:
self.build_list_params(params, scaling_configuration_id, 'ScalingConfigurationId')
if instance_ids:
for i in range(len(instance_ids)):
if i < 20 and instance_ids[i]:
self.build_list_params(params, instance_ids[i], 'InstanceId' + bytes(i + 1))
if health_status:
self.build_list_params(params, health_status, 'HealthStatus')
if lifecycle_state:
self.build_list_params(params, lifecycle_state, 'LifecycleState')
if creation_type:
self.build_list_params(params, creation_type, 'CreationType')
self.build_list_params(params, pagesize, 'PageSize')
pNum = pagenumber
if not pNum:
pNum = 1
while True:
self.build_list_params(params, pNum, 'PageNumber')
cfg_list = self.get_list('DescribeScalingInstances', params, ['ScalingInstances', ScalingInstance])
for cfg in cfg_list:
instances.append(cfg)
if pagenumber or len(cfg_list) < pagesize:
break
pNum += 1
return instances