Management class for VM-related functions (spawn, reboot, etc).
- 
class VMOps(session, virtapi)
 
Bases: object
Management class for VM-related tasks.
- 
agent_enabled(instance)
 
- 
change_instance_metadata(instance, diff)
 
Apply changes to instance metadata to xenstore.
- 
check_can_live_migrate_destination(ctxt, instance_ref, block_migration=False, disk_over_commit=False)
 
Check if it is possible to execute live migration.
| Parameters: | 
- ctxt – security context
 
- instance_ref – nova.db.sqlalchemy.models.Instance object
 
- block_migration – if true, prepare for block migration
if None, calculate it from driver
 
- disk_over_commit – if true, allow disk over commit
 
 
 | 
- 
check_can_live_migrate_source(ctxt, instance_ref, dest_check_data)
 
Check if it’s possible to execute live migration on the source side.
| Parameters: | 
- ctxt – security context
 
- instance_ref – nova.db.sqlalchemy.models.Instance object
 
- dest_check_data – data returned by the check on the
destination, includes block_migration flag
 
 
 | 
- 
confirm_migration(migration, instance, network_info)
 
- 
connect_block_device_volumes(block_device_info)
 
- 
destroy(instance, network_info, block_device_info=None, destroy_disks=True)
 
Destroy VM instance.
This is the method exposed by xenapi_conn.destroy(). The rest of the
destroy_* methods are internal.
- 
finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance, block_device_info=None, power_on=True)
 
- 
finish_revert_migration(context, instance, block_device_info=None, power_on=True)
 
- 
get_all_bw_counters()
 
Return running bandwidth counter for each interface on each
running VM.
- 
get_console_output(instance)
 
Return last few lines of instance console.
- 
get_diagnostics(instance)
 
Return data about VM diagnostics.
- 
get_info(instance, vm_ref=None)
 
Return data about VM instance.
- 
get_instance_diagnostics(instance)
 
Return data about VM diagnostics using the common API.
- 
get_per_instance_usage()
 
Get usage info about each active instance.
- 
get_vnc_console(instance)
 
Return connection info for a vnc console.
- 
inject_file(instance, path, contents)
 
Write a file to the VM instance.
- 
inject_network_info(instance, network_info, vm_ref=None)
 
Generate the network info and make calls to place it into the
xenstore and the xenstore param list.
vm_ref can be passed in because it will sometimes be different than
what vm_utils.lookup(session, instance[‘name’]) will find (ex: rescue)
- 
instance_exists(name_label)
 
- 
list_instance_uuids()
 
Get the list of nova instance uuids for VMs found on the
hypervisor.
- 
list_instances()
 
List VM instances.
- 
live_migrate(context, instance, destination_hostname, post_method, recover_method, block_migration, migrate_data=None)
 
- 
migrate_disk_and_power_off(context, instance, dest, flavor, block_device_info)
 
Copies a VHD from one host machine to another, possibly
resizing filesystem beforehand.
| Parameters: | 
- instance – the instance that owns the VHD in question.
 
- dest – the destination host machine.
 
- flavor – flavor to resize to
 
 
 | 
- 
pause(instance)
 
Pause VM instance.
- 
plug_vifs(instance, network_info)
 
Set up VIF networking on the host.
- 
poll_rebooting_instances(timeout, instances)
 
Look for rebooting instances that can be expired.
- issue a “hard” reboot to any instance that has been stuck in a
reboot state for >= the given timeout
 
- 
post_interrupted_snapshot_cleanup(context, instance)
 
Cleans up any resources left after a failed snapshot.
- 
post_live_migration(context, instance, migrate_data=None)
 
- 
post_live_migration_at_destination(context, instance, network_info, block_migration, block_device_info)
 
- 
power_off(instance)
 
Power off the specified instance.
- 
power_on(instance)
 
Power on the specified instance.
- 
pre_live_migration(context, instance, block_device_info, network_info, disk_info, migrate_data)
 
- 
reboot(instance, reboot_type, bad_volumes_callback=None)
 
Reboot VM instance.
- 
refresh_instance_security_rules(instance)
 
recreates security group rules for specified instance.
- 
refresh_security_group_rules(security_group_id)
 
recreates security group rules for every instance.
- 
rescue(context, instance, network_info, image_meta, rescue_password)
 
Rescue the specified instance.
- shutdown the instance VM.
 
- set ‘bootlock’ to prevent the instance from starting in rescue.
 
- spawn a rescue VM (the vm name-label will be instance-N-rescue).
 
- 
reset_network(instance, rescue=False)
 
Calls resetnetwork method in agent.
- 
restore(instance)
 
Restore the specified instance.
- 
resume(instance)
 
Resume the specified instance.
- 
rollback_live_migration_at_destination(instance, block_device_info)
 
- 
set_admin_password(instance, new_pass)
 
Set the root/admin password on the VM instance.
- 
set_bootable(instance, is_bootable)
 
Set the ability to power on/off an instance.
- 
snapshot(context, instance, image_id, update_task_state)
 
Create snapshot from a running VM instance.
| Parameters: | 
- context – request context
 
- instance – instance to be snapshotted
 
- image_id – id of image to upload to
 
 
 | 
Steps involved in a XenServer snapshot:
- XAPI-Snapshot: Snapshotting the instance using XenAPI. This
creates: Snapshot (Template) VM, Snapshot VBD, Snapshot VDI,
Snapshot VHD
 
- Wait-for-coalesce: The Snapshot VDI and Instance VDI both point to
a ‘base-copy’ VDI.  The base_copy is immutable and may be chained
with other base_copies.  If chained, the base_copies
coalesce together, so, we must wait for this coalescing to occur to
get a stable representation of the data on disk.
 
- Push-to-data-store: Once coalesced, we call
‘image_upload_handler’ to upload the images.
 
- 
soft_delete(instance)
 
Soft delete the specified instance.
- 
spawn(context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None, name_label=None, rescue=False)
 
- 
suspend(instance)
 
Suspend the specified instance.
- 
unfilter_instance(instance_ref, network_info)
 
Removes filters for each VIF of the specified instance.
- 
unpause(instance)
 
Unpause VM instance.
- 
unplug_vifs(instance, network_info, vm_ref)
 
- 
unrescue(instance)
 
Unrescue the specified instance.
- unplug the instance VM’s disk from the rescue VM.
 
- teardown the rescue VM.
 
- release the bootlock to allow the instance VM to start.
 
- 
make_step_decorator(context, instance, update_instance_progress, total_offset=0)
 
Factory to create a decorator that records instance progress as a series
of discrete steps.
Each time the decorator is invoked we bump the total-step-count, so after:
@step
def step1():
    ...
@step
def step2():
    ...
 
 
we have a total-step-count of 2.
Each time the step-function (not the step-decorator!) is invoked, we bump
the current-step-count by 1, so after:
the current-step-count would be 1 giving a progress of 1 / 2 *
100 or 50%.