[openstack-dev] Context class of openstack common project

Andrew Bogott abogott at wikimedia.org
Wed Jul 18 17:24:15 UTC 2012


On 7/18/12 2:38 AM, Mark McLoughlin wrote:
> Hi,
>
> On Wed, 2012-07-18 at 07:24 +0800, 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 see that while the common notifiers code uses this class - and Nova
> uses the common notifiers code - Nova itself doesn't use the class. So,
> I'm not sure how this is supposed to work.

At the moment, it probably doesn't :(

Request context is vital for the plugin framework, which needs the 
context it gets via notifications for various purposes.

The common notifier imports the common context base class only in order 
to call get_context_from_function_and_args, which does isinstance(arg, 
RequestContext) in order to identify the context. Any context which 
doesn't inherit from this class will be overlooked.

So, possible solutions are a) change get_context_from_function_and_args 
to work via duck-typing rather than checking the actual class type, or 
b) insist that project-specific request contexts inherit from the common 
context base class.  I would prefer b, even if the common class is 
essentially empty.

I'm happy to implement either a or b, according to people's preference.  
(Although, in the case of b I'd probably only do it in Nova and leave 
the other projects up to the experts.)

-Andrew




More information about the OpenStack-dev mailing list