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, vif)
attach_volume(context, connection_info, instance, mountpoint, disk_bus=None, device_type=None, encryption=None)

Attach the disk to the instance at mountpoint using info.

block_stats(instance, disk_id)
capabilities = {'supports_recreate': True, 'has_imagecache': True, 'supports_migrate_to_same_host': True}
check_can_live_migrate_destination(context, instance, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False)
check_can_live_migrate_destination_cleanup(context, dest_check_data)
check_can_live_migrate_source(context, instance, dest_check_data, block_device_info=None)
cleanup(context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None, destroy_vifs=True)
confirm_migration(migration, instance, network_info)
destroy(context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None)
detach_interface(instance, vif)
detach_volume(connection_info, instance, mountpoint, encryption=None)

Detach the disk attached to the instance.

ensure_filtering_rules_for_instance(instance, network_info)
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, network_info, block_device_info=None, power_on=True)
get_all_bw_counters(instances)

Return bandwidth usage counters for each interface on each running VM.

get_all_volume_usage(context, compute_host_bdms)

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

get_available_nodes(refresh=False)
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(context, instance)
get_console_pool_info(console_type)
get_diagnostics(instance)
get_host_cpu_stats()
get_host_ip_addr()
get_info(instance)
get_instance_diagnostics(instance)
get_instance_disk_info(instance, block_device_info=None)
get_mks_console(context, instance)
get_rdp_console(context, instance)
get_serial_console(context, instance)
get_spice_console(context, instance)
get_vnc_console(context, 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(action)

Reboots, shuts down or powers up the host.

init_host(host)
inject_file(instance, b64_path, b64_contents)
instance_on_disk(instance)
list_instance_uuids()
list_instances()
live_migration(context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None)
live_migration_abort(instance)
live_migration_force_complete(instance)
local_gb = 600000

Fake hypervisor driver.

memory_mb = 800000
migrate_disk_and_power_off(context, instance, dest, flavor, network_info, block_device_info=None, timeout=0, retry_interval=0)
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, timeout=0, retry_interval=0)
power_on(context, instance, network_info, block_device_info=None)
pre_live_migration(context, instance, block_device_info, network_info, disk_info, migrate_data=None)
quiesce(context, instance, image_meta)
reboot(context, instance, network_info, reboot_type, block_device_info=None, bad_volumes_callback=None)
refresh_instance_security_rules(instance)
refresh_security_group_rules(security_group_id)
rescue(context, instance, network_info, image_meta, rescue_password)
restore(instance)
resume(context, 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(enabled)

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

snapshot(context, instance, image_id, update_task_state)
soft_delete(instance)
spawn(context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None)
suspend(context, instance)
swap_volume(old_connection_info, new_connection_info, instance, mountpoint, resize_to)

Replace the disk attached to the instance.

trigger_crash_dump(instance)
unfilter_instance(instance, network_info)
unpause(instance)
unplug_vifs(instance, network_info)

Unplug VIFs from networks.

unquiesce(context, instance, image_meta)
unrescue(instance, network_info)
vcpus = 1000
class FakeInstance(name, state, uuid)

Bases: object

class FakeVirtAPI

Bases: nova.virt.virtapi.VirtAPI

wait_for_instance_event(*args, **kwds)
class Resources(vcpus=8, memory_mb=8000, local_gb=500)

Bases: object

claim(vcpus=0, mem=0, disk=0)
dump()
local_gb = 0
local_gb_used = 0
memory_mb = 0
memory_mb_used = 0
release(vcpus=0, mem=0, disk=0)
vcpus = 0
vcpus_used = 0
class SmallFakeDriver(virtapi, read_only=False)

Bases: nova.virt.fake.FakeDriver

local_gb = 1028
memory_mb = 8192
vcpus = 1
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

To restore the change, call restore_nodes()

Previous topic

The nova.virt.event Module

Next topic

The nova.virt.firewall Module

Project Source

This Page