[openstack-dev] Context class of openstack common project

Russell Bryant rbryant at redhat.com
Wed Jul 18 01:21:19 UTC 2012


On 07/17/2012 07:24 PM, Yong Sheng Gong wrote:
> Hi,
> We ( quantum) are using notifier and rpc code of openstack common
> project, but found these common codes need a common Context class.
> I think the common Context class is from glance project, which is using
> user, and tenant instead of user_id and tenant_id in nova.
> Quantum's Context class is from nova originally.
> 
> I think for all others to use the Common code, we have to redesign the
> common Context so that it is easy to be a base class.
> 1.  Don't have fields, such as user, and tenant. Instead we can have
> methods.

The rpc code doesn't make any assumptions about what fields that context
has.  I believe the only requirement is that it has a to_dict() method.

It also looks like the notifiers don't use the context at all, except to
pass it through to rpc.  I'm not even sure the context is necessary or
useful for notifications.

I guess we could have a base class, but the only thing that I can find
that the common code cares about is that there is a to_dict() method.
Did you come across something else?

> 2.  Don't use module methods since it is no way to be redefined.
> Consider factory or define it in configuration.


-- 
Russell Bryant





More information about the OpenStack-dev mailing list