Properly store VIP data on LB Create

Right now the vip data isn't actually stored back to the DB, it just
looks like it is... So, actually it will create a port and then orphan
it, then create another port with a different IP later.

Change-Id: Ibb7b2bd89155e37fb41a5f62ba2cda6e233a127a
This commit is contained in:
Adam Harwell 2017-08-07 19:01:36 -07:00
parent c87ec394c1
commit c28d212a17
3 changed files with 28 additions and 10 deletions

View File

@ -216,10 +216,13 @@ class LoadBalancersController(base.BaseController):
# create vip port if not exist
vip = self._create_vip_port_if_not_exist(db_lb)
db_lb.vip.ip_address = vip.ip_address
db_lb.vip.port_id = vip.port_id
db_lb.vip.network_id = vip.network_id
db_lb.vip.subnet_id = vip.subnet_id
self.repositories.vip.update(
lock_session, db_lb.id,
ip_address=vip.ip_address,
port_id=vip.port_id,
network_id=vip.network_id,
subnet_id=vip.subnet_id
)
if listeners or pools:
db_pools, db_lists = self._graph_create(

View File

@ -32,9 +32,19 @@ class NoopManager(object):
self.__class__.__name__, loadbalancer)
self.networkconfigconfig[loadbalancer.id] = (
loadbalancer, 'allocate_vip')
return data_models.Vip(ip_address='198.51.100.1',
subnet_id=uuidutils.generate_uuid(),
port_id=uuidutils.generate_uuid(),
subnet_id = uuidutils.generate_uuid()
network_id = uuidutils.generate_uuid()
port_id = uuidutils.generate_uuid()
ip_address = '198.51.100.1'
if loadbalancer.vip:
subnet_id = loadbalancer.vip.subnet_id or subnet_id
network_id = loadbalancer.vip.network_id or network_id
port_id = loadbalancer.vip.port_id or port_id
ip_address = loadbalancer.vip.ip_address or ip_address
return data_models.Vip(ip_address=ip_address,
subnet_id=subnet_id,
network_id=network_id,
port_id=port_id,
load_balancer_id=loadbalancer.id)
def deallocate_vip(self, vip):

View File

@ -1300,6 +1300,8 @@ class TestLoadBalancerGraph(base.BaseAPITest):
'name': 'lb1',
'project_id': self._project_id,
'vip_subnet_id': uuidutils.generate_uuid(),
'vip_port_id': uuidutils.generate_uuid(),
'vip_address': '198.51.100.10',
'listeners': create_listeners,
'pools': create_pools or []
}
@ -1308,9 +1310,12 @@ class TestLoadBalancerGraph(base.BaseAPITest):
'admin_state_up': True,
'provisioning_status': constants.PENDING_CREATE,
'operating_status': constants.OFFLINE,
'vip_address': None,
'vip_network_id': None,
'vip_port_id': None,
# TODO(rm_work): vip_network_id is a weird case, as it will be
# replaced from the port, which in the noop network driver will be
# freshly generated... I don't see a way to actually set it sanely
# for this test without interfering with a ton of stuff, and it is
# expected that this would be overwritten anyway, so 'ANY' is fine?
'vip_network_id': mock.ANY,
'flavor': '',
'provider': 'octavia'
}