Browse Source

Add missing reload method in amphora noop driver

The reload method was also missing in the abstract class.

Task: 40140
Story: 2007847

Change-Id: I2328b3dc4d5b95c8771a305d3d4bb1dee6019117
(cherry picked from commit 89123c0fc117e095c44ed21e360394974d3e15a5)
changes/64/739064/4
Carlos Goncalves 3 months ago
committed by Ann Taraday
parent
commit
1e2aec16c5
3 changed files with 33 additions and 0 deletions
  1. +14
    -0
      octavia/amphorae/drivers/driver_base.py
  2. +11
    -0
      octavia/amphorae/drivers/noop_driver/driver.py
  3. +8
    -0
      octavia/tests/unit/amphorae/drivers/test_noop_amphoraloadbalancer_driver.py

+ 14
- 0
octavia/amphorae/drivers/driver_base.py View File

@@ -64,6 +64,20 @@ class AmphoraLoadBalancerDriver(object, metaclass=abc.ABCMeta):
add more function along with the development.
"""

@abc.abstractmethod
def reload(self, loadbalancer, amphora):
"""Reload the listeners on the amphora.

:param loadbalancer: loadbalancer object to reload listeners
:type loadbalancer: octavia.db.models.LoadBalancer
:param amphora: Amphora to start. If None, reload on all amphora
:type amphora: octavia.db.models.Amphora
:returns: return a value list (listener, vip, status flag--enable)

At this moment, we just build the basic structure for testing, will
add more function along with the development.
"""

@abc.abstractmethod
def delete(self, listener):
"""Delete the listener on the vip.


+ 11
- 0
octavia/amphorae/drivers/noop_driver/driver.py View File

@@ -64,6 +64,13 @@ class NoopManager(object):
(loadbalancer.id, amphora.id)] = (loadbalancer, amphora,
'start')

def reload(self, loadbalancer, amphora=None):
LOG.debug("Amphora %s no-op, reload listeners, lb %s, amp %s",
self.__class__.__name__, loadbalancer.id, amphora)
self.amphoraconfig[
(loadbalancer.id, amphora.id)] = (loadbalancer, amphora,
'reload')

def delete(self, listener):
LOG.debug("Amphora %s no-op, delete listener %s, vip %s",
self.__class__.__name__,
@@ -142,6 +149,10 @@ class NoopAmphoraLoadBalancerDriver(

self.driver.start(loadbalancer, amphora)

def reload(self, loadbalancer, amphora=None):

self.driver.reload(loadbalancer, amphora)

def delete(self, listener):

self.driver.delete(listener)


+ 8
- 0
octavia/tests/unit/amphorae/drivers/test_noop_amphoraloadbalancer_driver.py View File

@@ -95,6 +95,14 @@ class TestNoopAmphoraLoadBalancerDriver(base.TestCase):
self.driver.driver.amphoraconfig[(
self.load_balancer.id, '321')])

def test_reload(self):
mock_amphora = mock.MagicMock()
mock_amphora.id = '321'
self.driver.reload(self.load_balancer, amphora=mock_amphora)
self.assertEqual((self.load_balancer, mock_amphora, 'reload'),
self.driver.driver.amphoraconfig[(
self.load_balancer.id, '321')])

def test_delete(self):
self.driver.delete(self.listener)
self.assertEqual((self.listener, self.vip, 'delete'),


Loading…
Cancel
Save