[openstack-dev] [Neutron LBaaS] Need help with LBaaS drivers

Vijay B os.vbvs at gmail.com
Wed Apr 2 20:27:42 UTC 2014


Hi VijayV, Oleg!

Thanks for the pointers! It turns out I had to put in an __init__.py in the
dummy/ directory, else the driver wouldn't get loaded. Now I see newer
issues, and am trying to fix those. I'll ping back on how that goes and if
I have any questions..

Cheers!
Regards,
Vijay


On Wed, Apr 2, 2014 at 1:34 AM, Oleg Bondarev <obondarev at mirantis.com>wrote:

> Hi Vijay,
>
> Currently you may follow two ways in writing an LBaaS driver:
> 1) write it from scratch (like Radware, Netscaler, Embrane drivers) -
>     in this case your driver should inherit abstract_driver.LoadBalancerAbstractDriver
> and
>     will be running on Neutron service process, LBaaS agent won't be used.
>     So you should restart not q-lbaas but q-svc process in order for new
> driver to be used and it should work with the steps you've described.
>
> 2) leverage
> neutron/services/loadbalancer/drivers/common/agent_drive_base.py framework
> and in fact write only device driver which inheritits
>
> neutron.services.loadbalancer.agent.agent_device_driver.AgentDeviceDriver.
>     This is how HAProxy driver is implemented, please see
> neutron/services/loadbalancer/drivers/haproxy/plugin_driver.py
>     and namespace_driver.py (this is device driver).
>     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)
>     In this case your driver will be running on LBaaS agent and you should
> restart both q-svc and q-lbaas.
>
> Generally, the second approach is preferable as it's better scalable and
> provides you a built-in async mechanism.
>
> Thanks,
> Oleg
>
>
> On Wed, Apr 2, 2014 at 5:44 AM, Vijay B <os.vbvs at gmail.com> wrote:
>
>> Hi,
>>
>>
>> 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:
>>
>>
>> 1) I created a new directory
>> neutron/services/loadbalancer/drivers/dummy/, and in that directory I
>> put in a new file dummy_driver.py, which basically has a class class
>> DummyPluginDriver(abstract_driver.LoadBalancerAbstractDriver):
>>
>> and has empty __init__(), create_vip(), delete_vip() etc functions.
>>
>>
>> 2) 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:
>>
>>
>>
>> service_provider=LOADBALANCER:Dummy:neutron.services.loadbalancer.drivers.dummy.dummy_driver.DummyPluginDriver:default
>>
>>
>>
>> 3) I created a /etc/neutron/services/loadbalancer/dummy/lbaas_agent.ini
>> directory/file
>>
>> I simply copied over the haproxy's lbaas_agent.ini file and changed
>> [haproxy] to [dummy]
>>
>> 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
>>
>>
>>
>> However, I see that the default HAProxyNS driver is still being loaded
>>
>> When I put a breakpoint in loadbalancer/agent/agent_manager.py:86, I see
>> this (relevant text marked in red):
>>
>>
>>
>> 2014-03-31 13:47:16.998 DEBUG neutron.common.utils [-] Reloading cached
>> file /etc/neutron/policy.json from (pid=28405) read_cached_file
>> /opt/stack/neutron/neutron/common/utils.py:53
>>
>> 2014-03-31 13:47:16.998 DEBUG neutron.policy [-] Loading policies from
>> file: /etc/neutron/policy.json from (pid=28405) _set_rules
>> /opt/stack/neutron/neutron/policy.py:89
>>
>> >
>> /opt/stack/neutron/neutron/services/loadbalancer/agent/agent_manager.py(86)_load_drivers()
>>
>> -> self.device_drivers = {}
>>
>> (Pdb) l
>>
>>  81             # pool_id->device_driver_name mapping used to store known
>> instances
>>
>>  82             self.instance_mapping = {}
>>
>>  83
>>
>>  84         def _load_drivers(self):
>>
>>  85             import pdb; pdb.set_trace()
>>
>>  86  ->         self.device_drivers = {}
>>
>>  87             for driver in self.conf.device_driver:
>>
>>  88                 try:
>>
>>  89                     driver_inst = importutils.import_object(
>>
>>  90                         driver,
>>
>>  91                         self.conf,
>>
>> (Pdb) self.conf.device_driver
>>
>>
>> ['neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver']
>>
>> (Pdb)
>>
>>
>> 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?
>>
>>
>> Any help would be much appreciated!
>>
>>
>>
>>  Thanks,
>>
>> Regards,
>>
>> Vijay
>>
>> _______________________________________________
>> 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/20140402/2424aeaa/attachment.html>


More information about the OpenStack-dev mailing list