From 24e93461d0ef52d776e670b91735f9599d11154d Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Thu, 26 Sep 2019 19:30:18 +0300 Subject: [PATCH] Octavia driver: agent implementation The driver is loaded, then terminated whenever a request is issued. This behavior causes termination of the Octavia listener which is responsible to the processing of the driver status updates and statistics processing. The following change implements an agent which will execute the listener. Change-Id: I566aaa65df4ba7455577a539aa9eebb6cc36a099 --- doc/source/devstack.rst | 8 +++++ setup.cfg | 2 ++ .../services/lbaas/octavia/octavia_driver.py | 35 +++++++++++-------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/doc/source/devstack.rst b/doc/source/devstack.rst index 7681325563..5e53d7aa90 100644 --- a/doc/source/devstack.rst +++ b/doc/source/devstack.rst @@ -155,6 +155,9 @@ Add octavia and python-octaviaclient repos as external repositories and configur [controller_worker] network_driver = allowed_address_pairs_driver + [driver_agent] + enabled_provider_agents=vmwareagent + NSX-T ----- @@ -279,6 +282,8 @@ Add octavia and python-octaviaclient repos as external repositories and configur [controller_worker] network_driver = allowed_address_pairs_driver + [driver_agent] + enabled_provider_agents=vmwareagent NSX-P ----- @@ -360,6 +365,9 @@ Add octavia and python-octaviaclient repos as external repositories and configur [controller_worker] network_driver = allowed_address_pairs_driver + [driver_agent] + enabled_provider_agents=vmwareagent + Trunk Driver ~~~~~~~~~~~~ diff --git a/setup.cfg b/setup.cfg index 1b6e0c713b..517a5b97d5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -95,6 +95,8 @@ vmware_nsx.neutron.nsxv3.housekeeper.jobs = mismatch_logical_port = vmware_nsx.plugins.nsx_v3.housekeeper.mismatch_logical_port:MismatchLogicalportJob octavia.api.drivers = vmwareedge = vmware_nsx.services.lbaas.octavia.octavia_driver:NSXOctaviaDriver +octavia.driver_agent.provider_agents = + vmwareagent = vmware_nsx.services.lbaas.octavia.octavia_driver:vmware_nsx_provider_agent [build_sphinx] source-dir = doc/source build-dir = doc/build diff --git a/vmware_nsx/services/lbaas/octavia/octavia_driver.py b/vmware_nsx/services/lbaas/octavia/octavia_driver.py index a7d2937910..e0dfe200e6 100644 --- a/vmware_nsx/services/lbaas/octavia/octavia_driver.py +++ b/vmware_nsx/services/lbaas/octavia/octavia_driver.py @@ -15,6 +15,7 @@ import copy import socket +import time from oslo_config import cfg from oslo_log import helpers as log_helpers @@ -75,7 +76,6 @@ class NSXOctaviaDriver(driver_base.ProviderDriver): def __init__(self): super(NSXOctaviaDriver, self).__init__() self._init_rpc_messaging() - self._init_rpc_listener() self._init_cert_manager() self.repositories = repositories.Repositories() @@ -88,20 +88,6 @@ class NSXOctaviaDriver(driver_base.ProviderDriver): version='1.0') self.client = messaging.RPCClient(transport, target) - @log_helpers.log_method_call - def _init_rpc_listener(self): - # Initialize RPC listener - topic = d_const.DRIVER_TO_OCTAVIA_TOPIC - server = socket.gethostname() - target = messaging.Target(topic=topic, server=server, - exchange="common", fanout=False) - endpoints = [NSXOctaviaDriverEndpoint()] - access_policy = dispatcher.DefaultRPCAccessPolicy - - self.octavia_server = get_rpc_server(target, endpoints, - access_policy) - self.octavia_server.start() - @log_helpers.log_method_call def _init_cert_manager(self): self.cert_manager = stevedore_driver.DriverManager( @@ -589,3 +575,22 @@ class NSXOctaviaDriverEndpoint(driver_lib.DriverLibrary): except exceptions.UpdateStatisticsError as e: LOG.error("Failed to update Octavia listener statistics. " "Stats %s, Error %s", statistics, e.fault_string) + + +@log_helpers.log_method_call +def vmware_nsx_provider_agent(exit_event): + # Initialize RPC listener + topic = d_const.DRIVER_TO_OCTAVIA_TOPIC + server = socket.gethostname() + target = messaging.Target(topic=topic, server=server, + exchange="common", fanout=False) + endpoints = [NSXOctaviaDriverEndpoint()] + access_policy = dispatcher.DefaultRPCAccessPolicy + get_transport() + octavia_server = get_rpc_server(target, endpoints, access_policy) + octavia_server.start() + + LOG.info('VMware NSX Octavia provider agent has started.') + while not exit_event.is_set(): + time.sleep(1) + LOG.info('VMware NSX Octavia provider agent is exiting.')