Ask Your Question
0

provide way to specify id in models_v2

asked 2012-07-16 01:15:36 -0600

Currently in models_v2.py there is no way to pass in your own id for tables that inherit HasId.

For example:

class HasId(object):
"""id mixin, add to subclasses that have an id."""
id = sa.Column(sa.String(36), primary_key=True, default=utils.str_uuid)

class Network(model_base.BASEV2, HasId, HasTenant):
<...snip>

I suggest modifying db_base_plugin_v2.py so this is possible:

For example:

def create_network(self, context, network): n = network['network']

    tenant_id = self._get_tenant_id_for_create(context, n)
    with context.session.begin():
        network = models_v2.Network(tenant_id=tenant_id,
                                    id = n.get('id') or utils.str_uuid(),
       <..snip>

This modification would not change the interface at all. Does anyone have any strong opinions against this? If not I'll make a bug report and provide the patch.

Thanks,

Aaron

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2012-07-16 01:40:38 -0600

danwent gravatar image

yeah, i think that makes sense, given that certain plugins may be using external ids. It sounds like it won't break things for other people, I think you can just go right ahead.

edit flag offensive delete link more
0

answered 2012-07-16 05:27:23 -0600

Thanks, bug created.

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

Stats

Asked: 2012-07-16 01:15:36 -0600

Seen: 84 times

Last updated: Jul 16 '12