Table Of Contents

Previous topic

Scheduler

Next topic

Common and Misc Libraries

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.

Fake Drivers

Todo

document general info about fakes

When the real thing isn’t available and you have some development to do these fake implementations of various drivers let you get on with your day.

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(read_only=False)

Bases: nova.virt.driver.ComputeDriver

Fake hypervisor driver

FakeDriver.agent_update(instance, url, md5hash)
FakeDriver.attach_volume(connection_info, instance_name, mountpoint)

Attach the disk to the instance at mountpoint using info

FakeDriver.block_stats(instance_name, disk_id)
FakeDriver.compare_cpu(xml)

This method is supported only by libvirt.

FakeDriver.confirm_migration(migration, instance, network_info)
FakeDriver.destroy(instance, network_info, block_device_info=None)
FakeDriver.detach_volume(connection_info, instance_name, mountpoint)

Detach the disk attached to the instance

FakeDriver.ensure_filtering_rules_for_instance(instance_ref, network_info)

This method is supported only by libvirt.

FakeDriver.finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance)
FakeDriver.finish_revert_migration(instance, network_info)
FakeDriver.get_all_bw_usage(instances, start_time, stop_time=None)

Return bandwidth usage info for each interface on each running VM

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

Return fake Host Status of ram, disk, network.

FakeDriver.get_info(instance)
FakeDriver.get_instance_disk_info(instance_name)

This method is supported only by libvirt.

FakeDriver.get_vnc_console(instance)
FakeDriver.get_volume_connector(instance)
FakeDriver.host_maintenance_mode(host, mode)

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

FakeDriver.host_power_action(host, action)

Reboots, shuts down or powers up the host.

FakeDriver.init_host(host)
FakeDriver.inject_file(instance, b64_path, b64_contents)
FakeDriver.interface_stats(instance_name, iface_id)
FakeDriver.list_instances()
FakeDriver.list_instances_detail()
FakeDriver.live_migration(context, instance_ref, dest, post_method, recover_method, block_migration=False)

This method is supported only by libvirt.

FakeDriver.migrate_disk_and_power_off(context, instance, dest, instance_type, network_info)
FakeDriver.pause(instance)
FakeDriver.plug_vifs(instance, network_info)

Plug VIFs into networks.

FakeDriver.poll_rebooting_instances(timeout)
FakeDriver.poll_rescued_instances(timeout)
FakeDriver.power_off(instance)
FakeDriver.power_on(instance)
FakeDriver.pre_live_migration(block_device_info)

This method is supported only by libvirt.

FakeDriver.reboot(instance, network_info, reboot_type)
FakeDriver.refresh_provider_fw_rules()
FakeDriver.refresh_security_group_members(security_group_id)
FakeDriver.refresh_security_group_rules(security_group_id)
FakeDriver.rescue(context, instance, network_info, image_meta)
FakeDriver.resume(instance)
FakeDriver.resume_state_on_host_boot(context, instance, network_info)
FakeDriver.set_admin_password(instance, new_pass)
FakeDriver.set_host_enabled(host, enabled)

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

FakeDriver.snapshot(context, instance, name)
FakeDriver.spawn(context, instance, image_meta, network_info=None, block_device_info=None)
FakeDriver.suspend(instance)
FakeDriver.test_remove_vm(instance_name)

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

FakeDriver.unfilter_instance(instance_ref, network_info)

This method is supported only by libvirt.

FakeDriver.unpause(instance)
FakeDriver.unplug_vifs(instance, network_info)

Unplug VIFs from networks.

FakeDriver.unrescue(instance, network_info)
FakeDriver.update_available_resource(ctxt, host)

Updates compute manager resource info on ComputeNode table.

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

FakeDriver.update_host_status()

Return fake Host Status of ram, disk, network.

class FakeInstance(name, state)

Bases: object

The nova.auth.fakeldap Module

Fake LDAP server for test harness.

This class does very little error checking, and knows nothing about ldap class definitions. It implements the minimum emulation of the python ldap library to work with nova.

class FakeLDAP

Bases: object

Fake LDAP connection.

FakeLDAP.add_s(dn, attr)

Add an object with the specified attributes at dn.

FakeLDAP.delete_s(dn)

Remove the ldap object at specified dn.

FakeLDAP.modify_s(dn, attrs)

Modify the object at dn using the attribute list.

Parameters:
  • dn – a dn
  • attrs

    a list of tuples in the following form:

    ([MOD_ADD | MOD_DELETE | MOD_REPACE], attribute, value)
    
FakeLDAP.modrdn_s(dn, newrdn)
FakeLDAP.search_s(dn, scope, query=None, fields=None)

Search for all matching objects under dn using the query.

Args: dn – dn to search under scope – only SCOPE_BASE and SCOPE_SUBTREE are supported query – query to filter objects by fields – fields to return. Returns all fields if not specified

FakeLDAP.simple_bind_s(dn, password)

This method is ignored, but provided for compatibility.

FakeLDAP.unbind_s()

This method is ignored, but provided for compatibility.

exception NO_SUCH_OBJECT

Bases: exceptions.Exception

Duplicate exception class from real LDAP module.

exception OBJECT_CLASS_VIOLATION

Bases: exceptions.Exception

Duplicate exception class from real LDAP module.

exception SERVER_DOWN

Bases: exceptions.Exception

Duplicate exception class from real LDAP module.

class Store

Bases: object

classmethod Store.instance()
initialize(_uri)

Opens a fake connection with an LDAP server.

The nova.testing.fake.rabbit Module

The nova.volume.driver.FakeAOEDriver Class

The nova.tests.service_unittest.FakeManager Class

The nova.tests.api.openstack.fakes Module

class Context

Bases: object

class FakeAuthDatabase

Bases: object

static FakeAuthDatabase.auth_token_create(context, token)
static FakeAuthDatabase.auth_token_destroy(context, token_id)
static FakeAuthDatabase.auth_token_get(context, token_hash)
FakeAuthDatabase.data = {}
class FakeAuthManager

Bases: object

FakeAuthManager.add_user(user)
FakeAuthManager.auth_data = []
classmethod FakeAuthManager.clear_fakes()
FakeAuthManager.create_project(name, manager_user, description=None, member_users=None)
FakeAuthManager.create_user(name, access=None, secret=None, admin=False)
FakeAuthManager.delete_project(pid)
FakeAuthManager.delete_user(uid)
FakeAuthManager.get_project(pid)
FakeAuthManager.get_projects(user_id=None)
FakeAuthManager.get_user(uid)
FakeAuthManager.get_user_from_access_key(key)
FakeAuthManager.get_users()
FakeAuthManager.is_admin(user_id)
FakeAuthManager.is_project_member(user_id, project)
FakeAuthManager.modify_project(project, manager_user=None, description=None)
FakeAuthManager.modify_user(user_id, access=None, secret=None, admin=None)
FakeAuthManager.projects = {}
classmethod FakeAuthManager.reset_fake_data()
class FakeRateLimiter(application)

Bases: object

class FakeRequestContext(*args, **kwargs)

Bases: nova.context.RequestContext

class FakeRouter(ext_mgr=None)

Bases: nova.wsgi.Router

class FakeToken(**kwargs)

Bases: object

FakeToken.id_count = 0
class HTTPRequest(*args, **kwargs)

Bases: nova.api.openstack.wsgi.Request

classmethod HTTPRequest.blank(*args, **kwargs)
class TestRouter(controller)

Bases: nova.wsgi.Router

create_info_cache(nw_cache)
fake_auth_init(self, application)
fake_instance_get(**kwargs)
fake_instance_get_all_by_filters(num_servers=5, **kwargs)
get_fake_uuid(token=0)
stub_instance(id, user_id=None, project_id=None, host=None, vm_state=None, task_state=None, reservation_id='', uuid='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', image_ref='10', flavor_id='1', name=None, key_name='', access_ipv4=None, access_ipv6=None, progress=0, auto_disk_config=False, display_name=None, include_fake_metadata=True, power_state=None, nw_cache=None, metadata=None, security_groups=None)
class stub_out_compute_api_backup(stubs)

Bases: object

stub_out_compute_api_backup.backup(context, instance, name, backup_type, rotation, extra_properties=None)
stub_out_compute_api_snapshot(stubs)
stub_out_glance(stubs)
stub_out_glance_add_image(stubs, sent_to_glance)

We return the metadata sent to glance by modifying the sent_to_glance dict in place.

stub_out_instance_quota(stubs, allowed)
stub_out_key_pair_funcs(stubs, have_key_pair=True)
stub_out_networking(stubs)
stub_out_nw_api(stubs, cls=None, private=None, publics=None)
stub_out_nw_api_get_floating_ips_by_fixed_address(stubs, func=None)
stub_out_nw_api_get_instance_nw_info(stubs, num_networks=1, func=None)
stub_out_rate_limiting(stubs)
stub_volume(id, **kwargs)
stub_volume_create(self, context, size, name, description, snapshot, **param)
stub_volume_delete(self, context, *args, **param)
stub_volume_get(self, context, volume_id)
stub_volume_get_all(self, context, search_opts=None)
stub_volume_get_notfound(self, context, volume_id)
stub_volume_update(self, context, *args, **param)
wsgi_app(inner_app_v2=None, fake_auth_context=None, use_no_auth=False, ext_mgr=None)