Remove extraneous fields from Cloud LoadBalancer access list

This fixes a bug where the load balancer creation fails with this
error:

resource CREATE failed: BadRequest: resources.loadbalancer: Must
supply a unique access list item to update the current list. (HTTP
400)

Closes-Bug: 1541953
Change-Id: I5183b305a7bf2cef16e5e01e88fdb3f24aeb4be5
This commit is contained in:
Jason Dunsmore 2016-02-03 16:55:10 -06:00
parent 8ef79f95b7
commit 3ae796a0bc
2 changed files with 6 additions and 1 deletions

View File

@ -789,6 +789,7 @@ class CloudLoadBalancer(resource.Resource):
return False
def _access_list_needs_update(self, old, new):
old = [{key: al[key] for key in self._ACCESS_LIST_KEYS} for al in old]
old = set([frozenset(s.items()) for s in old])
new = set([frozenset(s.items()) for s in new])
return old != new

View File

@ -680,6 +680,10 @@ class LoadBalancerTest(common.HeatTestCase):
'type': 'ALLOW'},
{'address': '172.165.3.43',
'type': 'DENY'}]
api_access_list = [{"address": '192.168.1.1/0', 'id': 1234,
'type': 'ALLOW'},
{'address': '172.165.3.43', 'id': 3422,
'type': 'DENY'}]
template = self._set_template(self.lb_template,
accessList=access_list)
@ -688,7 +692,7 @@ class LoadBalancerTest(common.HeatTestCase):
self.expected_body)
self.m.StubOutWithMock(fake_lb, 'get_access_list')
fake_lb.get_access_list().AndReturn([])
fake_lb.get_access_list().AndReturn(access_list)
fake_lb.get_access_list().AndReturn(api_access_list)
self.m.StubOutWithMock(fake_lb, 'add_access_list')
fake_lb.add_access_list(access_list)