[openstack-dev] [cinder] [driver] DB operations

Amit Das amit.das at cloudbyte.com
Sat Dec 20 02:37:13 UTC 2014


Thanks Duncan.
Do you mean hepler methods in the specific driver class?
On 19 Dec 2014 14:51, "Duncan Thomas" <duncan.thomas at gmail.com> wrote:

> So our general advice has historical been 'drivers should not be accessing
> the db directly'. I haven't had chance to look at your driver code yet,
> I've been on vacation, but my suggestion is that if you absolutely must
> store something in the admin metadata rather than somewhere that is covered
> by the model update (generally provider location and provider auth) then
> writing some helper methods that wrap the context bump and db call would be
> better than accessing it directly from the driver.
>
> Duncan Thomas
> On Dec 18, 2014 11:41 PM, "Amit Das" <amit.das at cloudbyte.com> wrote:
>
>> Hi Stackers,
>>
>> I have been developing a Cinder driver for CloudByte storage and have
>> come across some scenarios where the driver needs to do create, read &
>> update operations on cinder database (volume_admin_metadata table). This is
>> required to establish a mapping between OpenStack IDs with the backend
>> storage IDs.
>>
>> Now, I have got some review comments w.r.t the usage of DB related
>> operations esp. w.r.t raising the context to admin.
>>
>> In short, it has been advised not to use "*context.get_admin_context()*".
>>
>>
>> https://review.openstack.org/#/c/102511/15/cinder/volume/drivers/cloudbyte/cloudbyte.py
>>
>> However, i get errors trying to use the default context as shown below:
>>
>> *2014-12-19 12:18:17.880 TRACE oslo.messaging.rpc.dispatcher   File
>> "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 103, in
>> is_admin_context*
>> *2014-12-19 12:18:17.880 TRACE oslo.messaging.rpc.dispatcher     return
>> context.is_admin*
>> *2014-12-19 12:18:17.880 TRACE oslo.messaging.rpc.dispatcher
>> AttributeError: 'module' object has no attribute 'is_admin'*
>>
>> So what is the proper way to run these DB operations from within a driver
>> ?
>>
>>
>> Regards,
>> Amit
>> *CloudByte Inc.* <http://www.cloudbyte.com/>
>>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141220/44c58303/attachment.html>


More information about the OpenStack-dev mailing list