<div dir="ltr">Hi Vijay,<div><br></div><div>Currently you may follow two ways in writing an LBaaS driver: </div><div>1) write it from scratch (like Radware, Netscaler, Embrane drivers) - </div><div> in this case your driver should inherit <span style="color:rgb(35,35,35);font-family:arial,helvetica,sans-serif">abstract_</span><span style="color:rgb(35,35,35);font-family:arial,helvetica,sans-serif">driver.</span><span style="color:rgb(35,35,35);font-family:arial,helvetica,sans-serif">LoadBalancerAbstractDriver and</span> </div>
<div> will be running on Neutron service process, LBaaS agent won't be used. </div><div> So you should restart not <span style="color:rgb(35,35,35);font-family:arial,helvetica,sans-serif">q-lbaas but </span>q-svc process in order for new driver to be used and it should work with the steps you've described.</div>
<div><br></div><div>2) leverage neutron/services/loadbalancer/drivers/common/agent_drive_base.py framework and in fact write only device driver which inheritits</div><div> neutron.services.loadbalancer.agent.agent_device_driver.AgentDeviceDriver. </div>
<div> This is how HAProxy driver is implemented, please see neutron/services/loadbalancer/drivers/haproxy/plugin_driver.py </div><div> and namespace_driver.py (this is device driver).</div><div> Along with updating service_provider in neutron.conf you should also add your device driver to lbaas_agent.ini file (again please check how it is done for haproxy)</div>
<div> In this case your driver will be running on LBaaS agent and you should restart both q-svc and q-lbaas.</div><div><br></div><div>Generally, the second approach is preferable as it's better scalable and provides you a built-in async mechanism.</div>
<div><br></div><div>Thanks,</div><div>Oleg</div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 2, 2014 at 5:44 AM, Vijay B <span dir="ltr"><<a href="mailto:os.vbvs@gmail.com" target="_blank">os.vbvs@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">Hi,</font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px">
<font face="arial, helvetica, sans-serif"><font color="#232323">I'm trying to understand how LBaaS drivers work and so am attempting to write a dummy driver that does nothing for now, but instead of loading my dummy driver, neutron always loads the HAProxy namespace driver. These are the steps I followed:</font></font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">1) I created a new directory neutron/services/loadbalancer/drivers/dummy/, and i</font><span style="font-family:arial,helvetica,sans-serif">n that directory I put in a new file dummy_driver.py, </span><span style="font-family:arial,helvetica,sans-serif">which basically has a class class DummyPluginDriver(abstract_driver.LoadBalancerAbstractDriver):</span></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">and has empty __init__(), create_vip(), delete_vip() etc functions.</font></p><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br>
</font></p><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">2) </font><span style="font-family:arial,helvetica,sans-serif">I'm testing using a devstack setup, so I also edited the /etc/neutron/neutron.conf file, commenting out the default loadbalancer driver entry for HAProxy, and added a line for my dummy driver as follows:</span></p>
<p style="margin:0px;color:rgb(35,35,35)"><span style="font-family:arial,helvetica,sans-serif"><br></span></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">service_provider=LOADBALANCER:Dummy:neutron.services.loadbalancer.drivers.dummy.dummy_driver.DummyPluginDriver:default</font></p><p style="margin:0px;color:rgb(35,35,35)">
<font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">3) I created a /etc/neutron/services/loadbalancer/dummy/lbaas_agent.ini directory/file</font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">I simply copied over the haproxy's lbaas_agent.ini file and changed [haproxy] to [dummy]</font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">and then I restarted the q-lbaas service using cd /opt/stack/neutron && python /usr/local/bin/neutron-lbaas-agent --config-file /etc/neutron/neutron.conf --config-file=/etc/neutron/services/loadbalancer/dummy/lbaas_agent.ini</font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">However, I see that the default HAProxyNS driver is still being loaded</font></p>
<p style="margin:0px"><font face="arial, helvetica, sans-serif"><font color="#232323">When I put a breakpoint in loadbalancer/agent/agent_manager.py:86, I see this (relevant text marked in </font><font color="#ff0000">red</font><font color="#232323">):</font></font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><span style="background-color:rgb(0,230,229)"><br></span></font></p><p style="margin:0px;color:rgb(35,35,35)"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(175,173,36)">
<span style="color:rgb(0,0,0)">2014-03-31 13:47:16.998 </span><span style="color:rgb(52,189,38)">DEBUG neutron.common.utils [</span><span style="color:rgb(52,187,199)">-</span><span style="color:rgb(52,189,38)">] Reloading cached file /etc/neutron/policy.json</span><span style="color:rgb(0,0,0)"> </span>from (pid=28405) read_cached_file /opt/stack/neutron/neutron/common/utils.py:53</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,189,38)"><span style="color:rgb(0,0,0)">2014-03-31 13:47:16.998 </span>DEBUG neutron.policy [<span style="color:rgb(52,187,199)">-</span>] Loading policies from file: /etc/neutron/policy.json<span style="color:rgb(0,0,0)"> </span><span style="color:rgb(175,173,36)">from (pid=28405) _set_rules /opt/stack/neutron/neutron/policy.py:89</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo">> /opt/stack/neutron/neutron/services/loadbalancer/agent/agent_manager.py(86)_load_drivers()</p><p style="margin:0px;font-size:11px;font-family:Menlo">-> self.device_drivers = {}</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">(Pdb) l</p><p style="margin:0px;font-size:11px;font-family:Menlo"> 81 # pool_id->device_driver_name mapping used to store known instances</p><p style="margin:0px;font-size:11px;font-family:Menlo">
82 self.instance_mapping = {}</p><p style="margin:0px;font-size:11px;font-family:Menlo"> 83 </p><p style="margin:0px;font-size:11px;font-family:Menlo"> 84 def _load_drivers(self):</p><p style="margin:0px;font-size:11px;font-family:Menlo">
85 import pdb; pdb.set_trace()</p><p style="margin:0px;font-size:11px;font-family:Menlo"> 86 -> self.device_drivers = {}</p><p style="margin:0px;font-size:11px;font-family:Menlo"> 87 for driver in self.conf.device_driver:</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> 88 try:</p><p style="margin:0px;font-size:11px;font-family:Menlo"> 89 driver_inst = importutils.import_object(</p><p style="margin:0px;font-size:11px;font-family:Menlo">
90 driver,</p><p style="margin:0px;font-size:11px;font-family:Menlo"> 91 self.conf,</p><p style="margin:0px;font-size:11px;font-family:Menlo">(Pdb) self.conf.device_driver</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><font color="#ff0000">['neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver']</font></p><p style="margin:0px;color:rgb(35,35,35)">
</p><p style="margin:0px;font-size:11px;font-family:Menlo">(Pdb) </p><div><br></div>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif">I'm not sure what I'm doing wrong - am I missing something that needs to be done within the dummy driver itself? (in dummy_driver.py?). Should I register some opts or similar? </font></p>
<p style="margin:0px;color:rgb(35,35,35)"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px;color:rgb(35,35,35)"><span style="font-family:arial,helvetica,sans-serif">Any help would be much appreciated!</span></p>
<p style="margin:0px;color:rgb(35,35,35)"><span style="font-family:arial,helvetica,sans-serif"><br></span></p><p style="margin:0px;color:rgb(35,35,35)"><span style="font-family:arial,helvetica,sans-serif"><br></span></p>
<p style="margin:0px;color:rgb(35,35,35)">
<span style="font-family:arial,helvetica,sans-serif">Thanks,</span></p><p style="margin:0px;color:rgb(35,35,35)"><span style="font-family:arial,helvetica,sans-serif">Regards,</span></p><p style="margin:0px;color:rgb(35,35,35)">
<span style="font-family:arial,helvetica,sans-serif">Vijay</span></p></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></div></div>