watcher.common.nova_helper module

watcher.common.nova_helper module

service None

Bases: object

NovaHelper.abort_live_migrate(instance_id, source, destination, retry=240)[source]
NovaHelper.confirm_resize(instance, previous_status, retry=60)[source]
NovaHelper.create_image_from_instance(instance_id, image_name, metadata={'reason': 'instance_migrate'})[source]

This method creates a new image from a given instance.

It waits for this image to be in ‘active’ state before returning. It returns the unique UUID of the created image if successful, None otherwise.

Parameters:
  • instance_id – the uniqueid of the instance to backup as an image.
  • image_name – the name of the image to create.
  • metadata – a dictionary containing the list of key-value pairs to associate to the image as metadata.
NovaHelper.create_instance(node_id, inst_name='test', image_id=None, flavor_name='m1.tiny', sec_group_list=['default'], network_names_list=['demo-net'], keypair_name='mykeys', create_new_floating_ip=True, block_device_mapping_v2=None)[source]

This method creates a new instance

It also creates, if requested, a new floating IP and associates it with the new instance It returns the unique id of the created instance.

NovaHelper.delete_instance(instance_id)[source]

This method deletes a given instance.

Parameters:instance_id – the unique id of the instance to delete.
NovaHelper.disable_service_nova_compute(hostname, reason=None)[source]
NovaHelper.enable_service_nova_compute(hostname)[source]
NovaHelper.find_instance(instance_id)[source]
NovaHelper.get_aggregate_detail(aggregate_id)[source]
NovaHelper.get_aggregate_list()[source]
NovaHelper.get_availability_zone_list()[source]
NovaHelper.get_compute_node_by_hostname(node_hostname)[source]

Get compute node by hostname

NovaHelper.get_compute_node_by_id(node_id)[source]

Get compute node by ID (not UUID)

NovaHelper.get_compute_node_by_name(node_name, servers=False)[source]
NovaHelper.get_compute_node_list()[source]
NovaHelper.get_flavor_list()[source]
NovaHelper.get_hostname(instance)[source]
NovaHelper.get_instance_by_name(instance_name)[source]
NovaHelper.get_instance_by_uuid(instance_uuid)[source]
NovaHelper.get_instance_list(filters=None, limit=-1)[source]

List servers for all tenants with details.

This always gets servers with the all_tenants=True filter.

Parameters:
  • filters – dict of additional filters (optional).
  • limit – Maximum number of servers to return (optional). If limit == -1, all servers will be returned, note that limit == -1 will have a performance penalty. For details, please see: https://bugs.launchpad.net/watcher/+bug/1834679
Returns:

list of novaclient Server objects

NovaHelper.get_instances_by_node(host)[source]
NovaHelper.get_network_id_from_name(net_name='private')[source]

This method returns the unique id of the provided network name

NovaHelper.get_running_migration(instance_id)[source]
NovaHelper.get_security_group_id_from_name(group_name='default')[source]

This method returns the security group of the provided group name

NovaHelper.get_service(service_id)[source]
NovaHelper.get_service_list()[source]
NovaHelper.live_migrate_instance(instance_id, dest_hostname, retry=120)[source]

This method does a live migration of a given instance

This method uses the Nova built-in live_migrate() action to do a live migration of a given instance.

It returns True if the migration was successful, False otherwise.

Parameters:
  • instance_id – the unique id of the instance to migrate.
  • dest_hostname – the name of the destination compute node, if destination_node is None, nova scheduler choose the destination host
NovaHelper.resize_instance(instance_id, flavor, retry=120)[source]

This method resizes given instance with specified flavor.

This method uses the Nova built-in resize() action to do a resize of a given instance.

It returns True if the resize was successful, False otherwise.

Parameters:
  • instance_id – the unique id of the instance to resize.
  • flavor – the name or ID of the flavor to resize to.
NovaHelper.stop_instance(instance_id)[source]

This method stops a given instance.

Parameters:instance_id – the unique id of the instance to stop.
NovaHelper.swap_volume(old_volume, new_volume, retry=120, retry_interval=10)[source]

Swap old_volume for new_volume

NovaHelper.wait_for_instance_state(server, state, retry, sleep)[source]

Waits for server to be in a specific state

The state can be one of the following : active, stopped

Parameters:
  • server – server object.
  • state – for which state we are waiting for
  • retry – how many times to retry
  • sleep – seconds to sleep between the retries
NovaHelper.wait_for_instance_status(instance, status_list, retry, sleep)[source]

Waits for instance to be in a specific status

The status can be one of the following : BUILD, ACTIVE, ERROR, VERIFY_RESIZE, SHUTOFF

Parameters:
  • instance – instance object.
  • status_list – tuple containing the list of status we are waiting for
  • retry – how many times to retry
  • sleep – seconds to sleep between the retries
NovaHelper.wait_for_volume_status(volume, status, timeout=60, poll_interval=1)[source]

Wait until volume reaches given status.

Parameters:
  • volume – volume resource
  • status – expected status of volume
  • timeout – timeout in seconds
  • poll_interval – poll interval in seconds
NovaHelper.watcher_non_live_migrate_instance(instance_id, dest_hostname, retry=120)[source]

This method migrates a given instance

This method uses the Nova built-in migrate() action to do a migration of a given instance. For migrating a given dest_hostname, Nova API version must be 2.56 or higher.

It returns True if the migration was successful, False otherwise.

Parameters:
  • instance_id – the unique id of the instance to migrate.
  • dest_hostname – the name of the destination compute node, if destination_node is None, nova scheduler choose the destination host
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.