Add code to fix the problem that support existed loadbalancer policy

For the previous question that support existed loadbalancer policy,I
found some bugs which it would report error if I post params without
health or add member failed.

To fix these bugs, I add some code to check the param about health and
control to delete loadbalancer if existed loadbalancer not new creating.

Change-Id: I64a711673866a8e6455dbf0d86910326507e9f3d
Closes-Bug: 1715070
This commit is contained in:
TingtingYu 2017-09-16 10:30:55 +08:00
parent 1e9d7f41bc
commit adfbcb9499
1 changed files with 4 additions and 3 deletions

View File

@ -350,8 +350,8 @@ class LoadBalancingPolicy(base.Policy):
data['loadbalancer'] = self.lb
data['pool'] = self.pool_spec.get(self.POOL_ID, None)
data['vip_address'] = self.vip_spec.get(self.VIP_ADDRESS, None)
if self.hm_spec.get(self.HM_ID, None):
data['healthmonitor'] = self.hm_spec.get(self.HM_ID, None)
if self.hm_spec and self.hm_spec.get(self.HM_ID, None):
data['healthmonitor'] = self.hm_spec.get(self.HM_ID)
else:
res, data = lb_driver.lb_create(self.vip_spec, self.pool_spec,
self.hm_spec)
@ -369,7 +369,8 @@ class LoadBalancingPolicy(base.Policy):
# were created and return the failure reason.
# TODO(anyone): May need to "roll-back" changes caused by any
# successful member_add() calls.
lb_driver.lb_delete(**data)
if not self.lb:
lb_driver.lb_delete(**data)
return False, 'Failed in adding node into lb pool'
node.data.update({'lb_member': member_id})