From ca5445b3c56bb648b8bdcfef6b18a8d9ba2e0ef9 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 14 Nov 2012 12:36:20 -0500 Subject: [PATCH] Remove CREATE action from worker msg protocol. Fixes bug #1078774 CREATE is now replaced by UPDATE, which did the same thing anyway. Change-Id: Ic446a349e053c7787209bdc227bd93b02d67dd12 --- bin/client.py | 2 +- libra/worker/controller.py | 15 +++------------ tests/test_worker_controller.py | 12 ++++++------ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/bin/client.py b/bin/client.py index e7e73614..55d7337c 100755 --- a/bin/client.py +++ b/bin/client.py @@ -43,7 +43,7 @@ def main(): client = JSONGearmanClient(['localhost:4730']) data = """ { - "hpcs_action": "create", + "hpcs_action": "update", "loadbalancers": [ { "name": "a-new-loadbalancer", diff --git a/libra/worker/controller.py b/libra/worker/controller.py index 57bcd18c..3fa6cdfa 100644 --- a/libra/worker/controller.py +++ b/libra/worker/controller.py @@ -47,9 +47,7 @@ class LBaaSController(object): self.logger.info("Requested action: %s" % action) try: - if action == 'CREATE': - return self._action_create() - elif action == 'UPDATE': + if action == 'UPDATE': return self._action_update() elif action == 'SUSPEND': return self._action_suspend() @@ -68,9 +66,9 @@ class LBaaSController(object): self.msg[self.RESPONSE_FIELD] = self.RESPONSE_FAILURE return self.msg - def _action_create(self): + def _action_update(self): """ - Create a Load Balancer. + Create/Update a Load Balancer. This is the only method (so far) that actually parses the contents of the JSON message (other than the ACTION_FIELD field). Modifying @@ -201,13 +199,6 @@ class LBaaSController(object): return self.msg - def _action_update(self): - """ Update a Load Balancer. """ - # NOTE(shrews): We would need to know the current configuration of - # the load balancer to do an update. Note sure this is really feasible, - # so for now we just do the same as CREATE. - return self._action_create() - def _action_suspend(self): """ Suspend a Load Balancer. """ try: diff --git a/tests/test_worker_controller.py b/tests/test_worker_controller.py index 41d40553..5fc8c6a0 100644 --- a/tests/test_worker_controller.py +++ b/tests/test_worker_controller.py @@ -27,7 +27,7 @@ class TestWorkerController(unittest.TestCase): def testCreate(self): msg = { - c.ACTION_FIELD: 'CREATE', + c.ACTION_FIELD: 'UPDATE', 'loadbalancers': [ { 'protocol': 'http', @@ -47,7 +47,7 @@ class TestWorkerController(unittest.TestCase): def testUpdate(self): msg = { - c.ACTION_FIELD: 'CREATE', + c.ACTION_FIELD: 'UPDATE', 'loadbalancers': [ { 'protocol': 'http', @@ -94,7 +94,7 @@ class TestWorkerController(unittest.TestCase): def testCreateMissingLBs(self): msg = { - c.ACTION_FIELD: 'CREATE' + c.ACTION_FIELD: 'UPDATE' } controller = c(self.logger, self.driver, msg) response = controller.run() @@ -102,7 +102,7 @@ class TestWorkerController(unittest.TestCase): def testCreateMissingNodes(self): msg = { - c.ACTION_FIELD: 'CREATE', + c.ACTION_FIELD: 'UPDATE', 'loadbalancers': [ { 'protocol': 'http' } ] } controller = c(self.logger, self.driver, msg) @@ -111,7 +111,7 @@ class TestWorkerController(unittest.TestCase): def testCreateMissingProto(self): msg = { - c.ACTION_FIELD: 'CREATE', + c.ACTION_FIELD: 'UPDATE', 'loadbalancers': [ { 'nodes': [ @@ -129,7 +129,7 @@ class TestWorkerController(unittest.TestCase): def testBadAlgorithm(self): msg = { - c.ACTION_FIELD: 'CREATE', + c.ACTION_FIELD: 'UPDATE', 'loadbalancers': [ { 'protocol': 'http',