<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Got it Duncan.</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 will re-check if I can arrive at any solution without accessing the database.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><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>
<br><div class="gmail_quote">On Sat, Dec 20, 2014 at 7:35 PM, Duncan Thomas <span dir="ltr"><<a href="mailto:duncan.thomas@gmail.com" target="_blank">duncan.thomas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>No, I mean that if drivers are going to access database, then they should do it via a defined interface that limits what they can do to a sane set of operations. I'd still prefer that they didn't need extra access beyond the model update, but I don't know if that is possible.<span class="HOEnZb"><font color="#888888"><br></font></span></p><span class="HOEnZb"><font color="#888888">
<p>Duncan Thomas</p></font></span><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Dec 19, 2014 6:43 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"><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" target="_blank">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" 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" 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>
</div></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><br></div>