Ask Your Question

Openstack API mocker or simulator ?

asked 2013-03-24 06:32:00 -0500

dharmesh gravatar image


Is there any tool/project that mocks the openstack API calls ? I want a tool that accepts openstack API and reflects state as an actual openstack deployment will do.

For example, After accepting "vm create" request successfully, the next call to "vm list" should include the new vm details but does not "create/use" any actual resources. Similarly for all other API, with possible exclusion of monitoring calls.

This will easy building tools on top of openstack. Anything that is developed and tested using it should run "as is" on actual deployment. I am curious what are other members using while development and testing ? Let me know if anything is not clear. I am new here.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2013-03-27 10:18:23 -0500

updated 2013-04-11 17:19:38 -0500

Devstack is a great place to start. You can even trick a devstack install into being pretty close to what you want. Here is an example runthrough.

Step 1 - Install devstack

Start with a fresh install of the latest Fedora or Ubuntu release. In my case, I'm using a Fedora 18 virtual machine. It only has one virtual CPU and 2 GB of RAM. Here are the commands I use to run devstack on a fresh VM:

sudo yum update -y
sudo yum install -y git python-netaddr vim-enhanced

git clone

cd devstack/

cat<<EOF | tee localrc

disable_service rabbit
enable_service qpid


Once devstack is up and running, proceed ...

Step 2 - Enable the fake compute driver

Edit /etc/nova/nova.conf to use the fake compute driver. Instead of having nova create real VMs, it will just pretend to.

#compute_driver = libvirt.LibvirtDriver
compute_driver = fake.FakeDriver

After changing this setting, you will need to restart the nova-compute service. Attach to the devstack screen session, screen -x, switch to the n-cpu tab, Ctrl-c to kill the service, hit the up arrow and then run the same command again.

Step 3 - Disable RAM capacity checking

Edit /etc/nova/nova.conf again. This time disable the scheduler's checking of RAM capacity. You don't want the nova-scheduler service denying new VM requests based on how much RAM your host has. It doesn't matter since you're using the fake compute driver.


Now restart the nova-scheduler service using a similar method as was used to restart nova-compute.

Step 4 - Disable quotas

Disable quotas so they don't get in your way. Specifically, we want to set the quotas for the demo tenant.

Switch to the admin user

. ~/devstack/openrc admin

Get the ID for the demo tenant

$ keystone tenant-list
|                id                |        name        | enabled |
| 8ea1cfbd7a07441bbbc8528f0d1feccb |       admin        |   True  |
| 918a3427695b493a92320b0d1f805a6d |      alt_demo      |   True  |
| c77d4e3501f04e3287cfbf769e25814b |        demo        |   True  |
| 88738f98e1b848f9a77aa9927719e3c1 | invisible_to_admin |   True  |
| 604064fc0e3749aaa61401c45d122ccd |      service       |   True  |

Set whatever quotas you want to set ...

$ nova quota-update --instances -1 --cores -1 --ram -1 --fixed-ips -1 --floating-ips -1 c77d4e3501f04e3287cfbf769e25814b

Switch back to the regular demo user

$ . ~/devstack/openrc

Step 5 - Boot a huge instance

Now that we have nova set up with the fake compute driver, as well as removed some other things that would prevent launching instances in this fake environment, we can launch a fake huge VM. Here is an example of where I was able to "launch" a VM with 8 VCPUs and 16 GB of RAM.

$ nova flavor-list
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs |
| 1  | m1.tiny   | 512       | 0    | 0         |      | 1     | 1.0         | True      | {}          |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      | {}          |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      | {}          |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      | {}          |
| 42 | m1.nano   | 64        | 0    | 0         |      | 1     | 1.0         | True      | {}          |
| 5  | m1.xlarge | 16384 ...
edit flag offensive delete link more


@ Russell Thanks for the ans. I am using devstack, but was not aware of the fake drivers. Thanks again for the detailed answer. Exactly what I was looking for.

dharmesh gravatar imagedharmesh ( 2013-03-27 13:53:36 -0500 )edit

answered 2013-03-27 07:15:29 -0500

AFAIK, there's not such a tool out there (public) but I could be wrong. Besides, I don't think it's something straight forward to do and nor it will be reliable. I mean, in order to create such a tool, you'll need to have some kind of persistence among other things in order to make it compliant plus, the tool will have to be aware of some "special cases" handled server-side.

As for now, What I would suggest is to have an real testing environment with OpenStack deployed, which is, AFAIK, what most people do.

There are some other positive aspects about using a real environment:

  1. You're more than sure that what you're doing is compliant with current API version
  2. You can test different cases that may not be "real" in a "fake" tool, i.e: testing race conditions, loads, etc.

Devstack ( is a great tool for development and this is one of those cases where it comes handy, I reckon.

edit flag offensive delete link more


There is a related blueprint (feature roadmap item) over here:

if you're interested in progressing that idea, perhaps you can contribute?

fifieldt gravatar imagefifieldt ( 2013-03-27 08:48:25 -0500 )edit

Failing that, and the excellent suggestion above to have a test environment (which is what I do too), you may be interested in: , which provides sample queries and responses for most API queries.

fifieldt gravatar imagefifieldt ( 2013-03-27 08:48:48 -0500 )edit

@flaper87 Thanks for the suggestions. I agree that real environment would be great, but for my purpose the fake environment will be fine.

dharmesh gravatar imagedharmesh ( 2013-03-27 13:58:05 -0500 )edit

answered 2014-09-04 22:32:12 -0500

asalkeld gravatar image

Also check out Mimic:

There is a summit talk on it too: https://openstacksummitnovember2014pa...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2013-03-24 06:32:00 -0500

Seen: 4,302 times

Last updated: Apr 11 '13