<p dir="ltr">Thanks Duncan. <br>
Do you mean hepler methods in the specific driver class?</p>
<div class="gmail_quote">On 19 Dec 2014 14:51, "Duncan Thomas" <<a href="mailto:duncan.thomas@gmail.com">duncan.thomas@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>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.</p>
<p>Duncan Thomas</p>
<div class="gmail_quote">On Dec 18, 2014 11:41 PM, "Amit Das" <<a href="mailto:amit.das@cloudbyte.com" target="_blank">amit.das@cloudbyte.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">Hi Stackers,<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">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.</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">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.</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">In short, it has been advised not to use "<i>context.get_admin_context()</i>".</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><a href="https://review.openstack.org/#/c/102511/15/cinder/volume/drivers/cloudbyte/cloudbyte.py" target="_blank">https://review.openstack.org/#/c/102511/15/cinder/volume/drivers/cloudbyte/cloudbyte.py</a><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">However, i get errors trying to use the default context as shown below:</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default"><div class="gmail_default"><font face="trebuchet ms, sans-serif"><i>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</i></font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"><i>2014-12-19 12:18:17.880 TRACE oslo.messaging.rpc.dispatcher return context.is_admin</i></font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"><i>2014-12-19 12:18:17.880 TRACE oslo.messaging.rpc.dispatcher AttributeError: 'module' object has no attribute 'is_admin'</i></font></div></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">So what is the proper way to run these DB operations from within a driver ?</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div><div><div dir="ltr"><div><font style="background-color:rgb(255,255,255)" color="#000000" face="trebuchet ms, sans-serif">Regards,</font></div><font style="background-color:rgb(255,255,255)" color="#000000" face="trebuchet ms, sans-serif">Amit</font><div><a href="http://www.cloudbyte.com/" target="_blank"><font style="background-color:rgb(255,255,255)" color="#0000ff" face="trebuchet ms, sans-serif"><i>CloudByte Inc.</i></font></a></div></div></div></div>
</div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div>