Previous topic

The nova.virt.xenapi.vm_utils Module

Next topic

The nova.virt.xenapi.volume_utils Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.virt.xenapi.vmops Module

Management class for VM-related functions (spawn, reboot, etc).

class SimpleDH

Bases: object

This class wraps all the functionality needed to implement basic Diffie-Hellman-Merkle key exchange in Python. It features intelligent defaults for the prime and base numbers needed for the calculation, while allowing you to supply your own. It requires that the openssl binary be installed on the system on which this is run, as it uses that to handle the encryption and decryption. If openssl is not available, a RuntimeError will be raised.

compute_shared(other)
decrypt(text)
encrypt(text)
generate_private()
get_public()
static mod_exp(num, exp, mod)

Efficient implementation of (num ** exp) % mod

class VMOps(session)

Bases: object

Management class for VM-related tasks

confirm_migration(migration, instance, network_info)
destroy(instance, network_info)

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)
finish_revert_migration(instance)
get_all_bw_usage(start_time, stop_time=None)

Return bandwidth usage info for each interface on each running VM

get_console_output(instance)

Return snapshot of console.

get_diagnostics(instance)

Return data about VM diagnostics.

get_info(instance)

Return data about VM instance.

get_vnc_console(instance)

Return connection info for a vnc console.

inject_file(instance, path, contents)

Write a file to the VM instance.

The path to which it is to be written and the contents of the file need to be supplied; both will be base64-encoded to prevent errors with non-ASCII characters being transmitted. If the agent does not support file injection, or the user has disabled it, a NotImplementedError will be raised.

inject_hostname(instance, vm_ref, hostname)

Inject the hostname of the instance into the xenstore.

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 VMHelper.lookup(session, instance.name) will find (ex: rescue)

list_instances()

List VM instances.

list_instances_detail()

List VM instances, returning InstanceInfo objects.

migrate_disk_and_power_off(context, instance, dest, instance_type)

Copies a VHD from one host machine to another, possibly resizing filesystem before hand.

Parameters:
  • instance – the instance that owns the VHD in question.
  • dest – the destination host machine.
  • disk_type – values are ‘primary’ or ‘cow’.
pause(instance)

Pause VM instance.

plug_vifs(instance, network_info)

Set up VIF networking on the host.

poll_rebooting_instances(timeout)

Look for expirable rebooting instances.

  • issue a “hard” reboot to any instance that has been stuck in a reboot state for >= the given timeout
poll_rescued_instances(timeout)

Look for expirable rescued instances.

  • forcibly exit rescue mode for any instances that have been in rescue mode for >= the provided timeout
power_off(instance)

Power off the specified instance.

power_on(instance)

Power on the specified instance.

reboot(instance, reboot_type)

Reboot VM instance.

refresh_provider_fw_rules()
refresh_security_group_members(security_group_id)

recreates security group rules for every instance

refresh_security_group_rules(security_group_id)

recreates security group rules for every instance

rescue(context, instance, network_info, image_meta)

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, vm_ref=None)

Calls resetnetwork method in agent.

resume(instance)

Resume the specified instance.

set_admin_password(instance, new_pass)

Set the root/admin password on the VM instance.

This is done via an agent running on the VM. Communication between nova and the agent is done via writing xenstore records. Since communication is done over the XenAPI RPC calls, we need to encrypt the password. We’re using a simple Diffie-Hellman class instead of the more advanced one in M2Crypto for compatibility with the agent code.

snapshot(context, instance, image_id)

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:

  1. XAPI-Snapshot: Snapshotting the instance using XenAPI. This creates: Snapshot (Template) VM, Snapshot VBD, Snapshot VDI, Snapshot VHD
  2. 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.
  3. Push-to-glance: Once coalesced, we call a plugin on the XenServer that will bundle the VHDs together and then push the bundle into Glance.
spawn(context, instance, image_meta, network_info)
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)
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.
cmp_version(a, b)

Compare two version strings (eg 0.0.1.10 > 0.0.1.9)

make_step_decorator(context, instance)

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:

step1()

the current-step-count would be 1 giving a progress of 1 / 2 * 100 or 50%.