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.
A fake (in-memory) hypervisor+api.
Allows nova testing w/o a hypervisor. This module also documents the
semantics of real hypervisor connections.
-
class FakeConnection
Bases: nova.virt.driver.ComputeDriver
Fake hypervisor driver
-
FakeConnection.agent_update(instance, url, md5hash)
-
FakeConnection.attach_volume(connection_info, instance_name, mountpoint)
Attach the disk to the instance at mountpoint using info
-
FakeConnection.block_stats(instance_name, disk_id)
-
FakeConnection.compare_cpu(xml)
This method is supported only by libvirt.
-
FakeConnection.confirm_migration(migration, instance, network_info)
-
FakeConnection.destroy(instance, network_info, block_device_info=None)
-
FakeConnection.detach_volume(connection_info, instance_name, mountpoint)
Detach the disk attached to the instance
-
FakeConnection.ensure_filtering_rules_for_instance(instance_ref, network_info)
This method is supported only by libvirt.
-
FakeConnection.finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance)
-
FakeConnection.finish_revert_migration(instance, network_info)
-
FakeConnection.get_all_bw_usage(start_time, stop_time=None)
Return bandwidth usage info for each interface on each
running VM
-
FakeConnection.get_console_output(instance)
-
FakeConnection.get_console_pool_info(console_type)
-
FakeConnection.get_diagnostics(instance_name)
-
FakeConnection.get_disk_available_least()
-
static FakeConnection.get_host_ip_addr()
-
FakeConnection.get_host_stats(refresh=False)
Return fake Host Status of ram, disk, network.
-
FakeConnection.get_info(instance)
-
FakeConnection.get_instance_disk_info(instance_name)
This method is supported only by libvirt.
-
FakeConnection.get_vnc_console(instance)
-
FakeConnection.get_volume_connector(instance)
-
FakeConnection.host_maintenance_mode(host, mode)
Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation.
-
FakeConnection.host_power_action(host, action)
Reboots, shuts down or powers up the host.
-
FakeConnection.init_host(host)
-
FakeConnection.inject_file(instance, b64_path, b64_contents)
-
classmethod FakeConnection.instance()
-
FakeConnection.interface_stats(instance_name, iface_id)
-
FakeConnection.list_disks(instance_name)
-
FakeConnection.list_instances()
-
FakeConnection.list_instances_detail()
-
FakeConnection.list_interfaces(instance_name)
-
FakeConnection.live_migration(context, instance_ref, dest, post_method, recover_method, block_migration=False)
This method is supported only by libvirt.
-
FakeConnection.migrate_disk_and_power_off(context, instance, dest, instance_type, network_info)
-
FakeConnection.pause(instance)
-
FakeConnection.plug_vifs(instance, network_info)
Plug VIFs into networks.
-
FakeConnection.poll_rebooting_instances(timeout)
-
FakeConnection.poll_rescued_instances(timeout)
-
FakeConnection.poll_unconfirmed_resizes(resize_confirm_window)
-
FakeConnection.pre_live_migration(block_device_info)
This method is supported only by libvirt.
-
FakeConnection.reboot(instance, network_info, reboot_type, block_device_info=None)
-
FakeConnection.refresh_provider_fw_rules()
-
FakeConnection.refresh_security_group_members(security_group_id)
-
FakeConnection.refresh_security_group_rules(security_group_id)
-
FakeConnection.rescue(context, instance, network_info, image_meta)
-
FakeConnection.resize(instance, flavor)
-
FakeConnection.resume(instance)
-
FakeConnection.resume_state_on_host_boot(context, instance, network_info, block_device_info=None)
-
FakeConnection.set_admin_password(instance, new_pass)
-
FakeConnection.set_host_enabled(host, enabled)
Sets the specified host’s ability to accept new instances.
-
FakeConnection.snapshot(context, instance, name)
-
FakeConnection.spawn(context, instance, image_meta, network_info=None, block_device_info=None)
-
FakeConnection.suspend(instance)
-
FakeConnection.test_remove_vm(instance_name)
Removes the named VM, as if it crashed. For testing
-
FakeConnection.unfilter_instance(instance_ref, network_info)
This method is supported only by libvirt.
-
FakeConnection.unpause(instance)
-
FakeConnection.unplug_vifs(instance, network_info)
Unplug VIFs from networks.
-
FakeConnection.unrescue(instance, network_info)
-
FakeConnection.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.
-
FakeConnection.update_host_status()
Return fake Host Status of ram, disk, network.
-
class FakeInstance(name, state)
Bases: object
-
get_connection(_read_only)
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.
-
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.
Based a bit on the carrot.backends.queue backend... but a lot better.
-
class Backend(connection, **kwargs)
Bases: carrot.backends.base.BaseBackend
-
Backend.cancel(consumer_tag)
-
Backend.consume(limit=None)
-
Backend.declare_consumer(queue, callback, consumer_tag, *args, **kwargs)
-
Backend.exchange_declare(exchange, type, *args, **kwargs)
-
Backend.get(queue, no_ack=False)
-
Backend.prepare_message(message_data, delivery_mode, content_type, content_encoding, **kwargs)
Prepare message for sending.
-
Backend.publish(message, exchange, routing_key, **kwargs)
-
Backend.queue_bind(queue, exchange, routing_key, **kwargs)
-
Backend.queue_declare(queue, **kwargs)
-
class Exchange(name, exchange_type)
Bases: object
-
Exchange.bind(callback, routing_key)
-
Exchange.publish(message, routing_key=None)
-
class Message(backend, **kwargs)
Bases: carrot.backends.base.BaseMessage
-
class Queue(name)
Bases: object
-
Queue.pop()
-
Queue.push(message, routing_key=None)
-
Queue.size()
-
reset_all()
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(environ, charset=(No Default), unicode_errors=(No Default), decode_param_names=(No Default), **kw)
Bases: webob.request.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)
-
stub_out_auth(stubs)
-
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_image_service(stubs)
-
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=True, fake_auth_context=None, use_no_auth=False, ext_mgr=None)