Ask Your Question

Extending nova models

asked 2014-05-21 13:24:20 -0500

radekg gravatar image

Hi everyone,

This is my first question here. I hope I could get an answer for the problem I'm currently facing in the development of a nova API extension. I am trying to add a couple of API endpoints that would serve as an interface to the table storing some data. I was able to create an API endpoint by placing my extension in api/openstack/compute/contrib and modifying the policy.json file. This is now working.

I then added the migration to create a table to nova/db/sqlalchemy/migrate_repo_versions/245_add_custom_table.

After and (I'm using devstack) I can see my table being created. Great.

Next, I proceeded with creating an object definition and created a file in nova/objects. I am basing myself on example ( ( )


calls this ( the important part is

keypair = keypair_obj.KeyPair()
keypair.user_id = user_id = key_name
keypair.fingerprint = fingerprint
keypair.public_key = public_key

KeyPair() is (

this has a method ( and it's calling db_keypair = db.key_pair_create(context, updates) db points to from nova import db

which I believe points to this ( which loads ( there's a function called ( key_pair_create (

IMPL is ( but where is IMPL.key_pair_create?

Is there an easy way to insert a record into the table? Thank you for any pointers.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-05-22 16:48:40 -0500

radekg gravatar image

The way I resolved this is using my own sqlalchemy connection within an object class. It's not perfect but it works. I managed to replicate most of the functionality provided by db api, which I was not able to use in the beginning.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-05-21 13:24:20 -0500

Seen: 88 times

Last updated: May 22 '14