The nova.virt.fake Module

A fake (in-memory) hypervisor+api.

Allows nova testing w/o a hypervisor. This module also documents the semantics of real hypervisor connections.

class FakeDriver(virtapi, read_only=False)

Bases: nova.virt.driver.ComputeDriver

attach_interface(instance, image_meta, network_info)
attach_volume(connection_info, instance, mountpoint)

Attach the disk to the instance at mountpoint using info.

block_stats(instance_name, disk_id)
capabilities = {'supports_recreate': True, 'has_imagecache': True}

Fake hypervisor driver.

check_can_live_migrate_destination(ctxt, instance_ref, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False)
check_can_live_migrate_destination_cleanup(ctxt, dest_check_data)
check_can_live_migrate_source(ctxt, instance_ref, dest_check_data)
confirm_migration(migration, instance, network_info)
destroy(instance, network_info, block_device_info=None, destroy_disks=True)
detach_interface(instance, network_info)
detach_volume(connection_info, instance, mountpoint)

Detach the disk attached to the instance.

ensure_filtering_rules_for_instance(instance_ref, network_info)

This method is supported only by libvirt.

finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance, block_device_info=None)
finish_revert_migration(instance, network_info, block_device_info=None)
get_all_bw_counters(instances)

Return bandwidth usage counters for each interface on each running VM

get_all_volume_usage(context, instances, start_time, stop_time=None)

Return usage info for volumes attached to vms on a given host

get_available_nodes()
get_available_resource(nodename)

Updates compute manager resource info on ComputeNode table.

Since we don’t have a real hypervisor, pretend we have lots of disk and ram.

get_console_output(instance)
get_console_pool_info(console_type)
get_diagnostics(instance_name)
get_disk_available_least()
static get_host_ip_addr()
get_host_stats(refresh=False)

Return fake Host Status of ram, disk, network.

get_info(instance)
get_instance_disk_info(instance_name)
get_spice_console(instance)
get_vnc_console(instance)
get_volume_connector(instance)
host_maintenance_mode(host, mode)

Start/Stop host maintenance window. On start, it triggers guest VMs evacuation.

host_power_action(host, action)

Reboots, shuts down or powers up the host.

init_host(host)
inject_file(instance, b64_path, b64_contents)
instance_on_disk(instance)
interface_stats(instance_name, iface_id)
legacy_nwinfo()
list_instance_uuids()
list_instances()
live_migration(context, instance_ref, dest, post_method, recover_method, block_migration=False, migrate_data=None)
migrate_disk_and_power_off(context, instance, dest, instance_type, network_info, block_device_info=None)
pause(instance)
plug_vifs(instance, network_info)

Plug VIFs into networks.

poll_rebooting_instances(timeout, instances)
post_live_migration_at_destination(context, instance, network_info, block_migration=False, block_device_info=None)
power_off(instance)
power_on(context, instance, network_info, block_device_info)
pre_live_migration(context, instance_ref, block_device_info, network_info, migrate_data=None)
reboot(context, instance, network_info, reboot_type, block_device_info=None, bad_volumes_callback=None)
refresh_instance_security_rules(instance)
refresh_provider_fw_rules()
refresh_security_group_members(security_group_id)
refresh_security_group_rules(security_group_id)
rescue(context, instance, network_info, image_meta, rescue_password)
restore(instance)
resume(instance, network_info, block_device_info=None)
resume_state_on_host_boot(context, instance, network_info, block_device_info=None)
set_admin_password(instance, new_pass)
set_host_enabled(host, enabled)

Sets the specified host’s ability to accept new instances.

snapshot(context, instance, name, update_task_state)
soft_delete(instance)
spawn(context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None)
suspend(instance)
test_remove_vm(instance_name)

Removes the named VM, as if it crashed. For testing.

unfilter_instance(instance_ref, network_info)

This method is supported only by libvirt.

unpause(instance)
unplug_vifs(instance, network_info)

Unplug VIFs from networks.

unrescue(instance, network_info)
class FakeInstance(name, state)

Bases: object

class FakeVirtAPI

Bases: nova.virt.virtapi.VirtAPI

agent_build_get_by_triple(context, hypervisor, os, architecture)
aggregate_get_by_host(context, host, key=None)
aggregate_metadata_add(context, aggregate, metadata, set_delete=False)
aggregate_metadata_delete(context, aggregate, key)
instance_get_all_by_host(context, host)
instance_get_by_uuid(context, instance_uuid)
instance_type_get(context, instance_type_id)
instance_update(context, instance_uuid, updates)
provider_fw_rule_get_all(context)
security_group_get_by_instance(context, instance)
security_group_rule_get_by_security_group(context, security_group)
restore_nodes()

Resets FakeDriver’s node list modified by set_nodes().

Usually called from tearDown().

set_nodes(nodes)

Sets FakeDriver’s node.list.

It has effect on the following methods:
get_available_nodes() get_available_resource get_host_stats()

To restore the change, call restore_nodes()

Previous topic

The nova.virt.event Module

Next topic

The nova.virt.firewall Module

This Page