Instance

Compute Instances are virtual private servers. Examples of this would be AWS EC2 and Azure Virtual Machines. This class inherits from TopLevelResource and has direct access to the resource’s database object.

Attributes

Description

resource_id

The primary resource identifier that takes the form of a prefix followed by numbers and letters

organization_service_id

The ID of the parent organization service (cloud)

region_name

The region that the instance resides in

instance_id

The provider ID of the instance

instance_type

The type of instance

instance_flavor_resource_id

The resource ID of the type (flavor) this instance runs on

state

The state that the instance is in

name

The name of the instance

availability_zone

The availability zone where this instance runs

launch_time

The time the instance was launched (started)

create_time

The time the instance was created

platform

The platform the system runs on (linux/windows)

root_device_type

Denotes the root device storage type

root_device_name

The name of the root device

image_id

The ID of the image used to create this instance

key_name

The name of the key pair used for this instance

public_ip_address

Returns the public IP address of this instance

private_ip_address

Returns the private IP address of this instance

tenancy

Type of tenancy - dedicated or default

instance_status

Returns the system and instance reachability status

instance_flavor

Returns a flavor object which contains information on the size of the instance

access_lists

Returns a list of associated security groups

network_interfaces

Returns a list of attached network interfaces

volumes

Returns a list of attached volumes

Instance Operations

add_instance_to_app(name)
Add instance to App
delete(user_resource_id=None, force_delete=False, wait_for_result=True)
Delete this resource. If wrapped in a with JobQueue() block, this will queue the deletion job to the wrapped queue, otherwise it calls immediately.
Parameters: force_delete – If set this will work around termination protection (if the cloud supports it). An example of this is AWS.
Returns: bool
get_aggregate_cost()
Retrieve monthly cost and sum the attached volumes in order to factor into total costs.
get_attached_ips()
Retrieve all ip addresses - public and private - associated with this instance.
get_attached_network_interfaces()
Retrieve a list of db object for interfaces which are attached to this instance (if any). DEPRECATED - Used instance.network_interfaces.
get_attached_networks()
Retrieve all networks this instance is attached to.
get_attached_private_ips()
Retrieve private ip addresses which are attached to this instance (if any).
get_attached_public_ips()
Retrieve public ip objects which are attached to this instance (if any).
get_attached_volumes()
Retrieve a list of db object for volumes which are attached to this instance (if any).
get_availability_zone()
Retrieve the name of the availability zone.
get_date_created()
Retrieve the time from the provider that this resource was created. By default this will return the beginning date of epoch if no such create time exists.

static get_db_class()

get_image()
Retrieve the image that the instance uses. If the instance was deleted upstream or if we have not harvested it yet then this could return None.
get_image_id()
Retrieve the image ID of the resource.
get_image_name()
Retrieve the image name that the instance uses. If the instance was deleted upstream or if we have not harvested it yet then this could return None.
get_instance_type()
Retrieve the instance type of the resource.
get_primary_network_interface_id()
Return the network interface attached to eth0 (device index 0).

static get_provider_id_field()

get_resource_dependencies()
Retrieve the dependencies for a particular resources. This is an override of the parent function because we need to reverse the order on our resource lookups.

static get_resource_type()

get_security_groups()
Retrieve security groups which are associated with this instance.
get_supported_actions()
Retrieve all the actions which are supported by this resource.
Restricts actions by resource state.
handle_resource_created(user_resource_id=None, project_resource_id=None)
This should be called when a resource is created/discovered after the basic data is added to the database. This gives an opportunity for post-addition hooks (assignment to projects/groups, alerts, etc.).
handle_resource_destroyed(user_resource_id=None)
This should be called when a resource is destroyed before the basic data is removed from the database. This gives an opportunity for pre-destruction hooks (removal from projects/groups, alerts, etc.).
handle_resource_modified(resource, *args, **kwargs)
This should be called when a resource is modified after the new data has been updated in the DB session. This gives an opportunity for post-modification hooks.

instance

instance_id

is_attached_to_asg()
Return True if instance is attached to Auto Scale Group.

organization_service_id

pause()
Pause this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.

region_name

remove_instance_from_app()
Remove instance from app.
restart()
Restart this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
resume()
Restart this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
shelve()
Stop this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
start()
Start this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
stop()
Stop this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
suspend()
Suspend this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.

top_level_resource = True

unpause()
Unpause this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
unshelve()
Stop this instance. It is wrapped in a with JobQueue() block, this will queue the stop job to the wrapped queue.
uses_simple_networking()
Determine whether this instance supports only instance-based simple networking. i.e. EC2-classic networking or nova-network.