otcextensions.sdk.auto_scaling.v1.instance

The AS Instance Class

The Instance class inherits from Resource.

class otcextensions.sdk.auto_scaling.v1.instance.Instance(_synchronized=False, connection=None, **attrs)

The base resource

Parameters:
  • _synchronized (bool) – This is not intended to be used directly. See new() and existing().

  • connection (openstack.connection.Connection) – Reference to the Connection being used. Defaults to None to allow Resource objects to be used without an active Connection, such as in unit tests. Use of self._connection in Resource code should protect itself with a check for None.

resource_key: ty.Optional[str] = 'scaling_group_instance'

Singular form of key for resource.

resources_key: ty.Optional[str] = 'scaling_group_instances'

Plural form of key for resource.

base_path: str = '/scaling_group_instance'

The base part of the URI for this resource.

allow_list = True

Allow list operation for this resource.

allow_delete = True

Allow delete operation for this resource.

id

Properties AutoScaling instance id

name: ty.Union[Body, URI]

AutoScaling instance name

scaling_group_id

Id of AutoScaling group the instance belongs to

scaling_group_name

Name of AutoScaling group the instance belongs to

scaling_configuration_id

Id of AutoScaling config the instance create with

scaling_configuration_name

Name of AutoScaling config the instance create with

lifecycle_state

AutoScaling instance lifecycle state, valid values include: INSERVICE, PENDING, REMOVING

health_status

AutoScaling instance health state, valid values include: INITIALIZING, NORMAL, ERROR

create_time

AutoScaling instance create time

classmethod find(session, name_or_id, ignore_missing=True, **params)

Find a resource by its name or id.

This method was added in order to be able to get an object of the current class if it exists. This object will be used in some other proxy methods.

Parameters:
  • session (Adapter) – The session to use for making this request.

  • name_or_id – This resource’s identifier, if needed by the request. The default is None.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

  • params (dict) – Any additional parameters to be passed into underlying methods, such as to existing() in order to pass on URI parameters.

Returns:

The Resource object matching the given name or id or None if nothing matches.

Raises:

openstack.exceptions.DuplicateResource if more than one resource is found for this request.

Raises:

openstack.exceptions.ResourceNotFound if nothing is found and ignore_missing is False.

remove(session, 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 owner auto scaling group should not in scaling status.

Parameters:
  • session – openstack session

  • 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 to True, no exception will be set when attempting to delete a nonexistent config.

Returns:

None

batch_action(session, instances, action, delete_instance=False)

batch action on auto-scaling instances

make sure all configs should not been used by auto-scaling group

Parameters:
  • session – openstack session

  • instances – The list item value can be the ID of an instance or a Instance instance

  • action – Action to execute on instances: [ADD, REMOVE, PROTECT, UNPROTECT]

  • delete_instance (bool) – When set to True, instance will be deleted after removed

Returns:

None