Merge "Properly store VIP data on LB Create"

This commit is contained in:
Jenkins 2017-08-10 09:15:49 +00:00 committed by Gerrit Code Review
commit 738f3f78a6
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 # create vip port if not exist
vip = self._create_vip_port_if_not_exist(db_lb) vip = self._create_vip_port_if_not_exist(db_lb)
db_lb.vip.ip_address = vip.ip_address self.repositories.vip.update(
db_lb.vip.port_id = vip.port_id lock_session, db_lb.id,
db_lb.vip.network_id = vip.network_id ip_address=vip.ip_address,
db_lb.vip.subnet_id = vip.subnet_id port_id=vip.port_id,
network_id=vip.network_id,
subnet_id=vip.subnet_id
)
if listeners or pools: if listeners or pools:
db_pools, db_lists = self._graph_create( db_pools, db_lists = self._graph_create(

View File

@ -32,9 +32,19 @@ class NoopManager(object):
self.__class__.__name__, loadbalancer) self.__class__.__name__, loadbalancer)
self.networkconfigconfig[loadbalancer.id] = ( self.networkconfigconfig[loadbalancer.id] = (
loadbalancer, 'allocate_vip') loadbalancer, 'allocate_vip')
return data_models.Vip(ip_address='198.51.100.1', subnet_id = uuidutils.generate_uuid()
subnet_id=uuidutils.generate_uuid(), network_id = uuidutils.generate_uuid()
port_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) load_balancer_id=loadbalancer.id)
def deallocate_vip(self, vip): def deallocate_vip(self, vip):

View File

@ -1300,6 +1300,8 @@ class TestLoadBalancerGraph(base.BaseAPITest):
'name': 'lb1', 'name': 'lb1',
'project_id': self._project_id, 'project_id': self._project_id,
'vip_subnet_id': uuidutils.generate_uuid(), 'vip_subnet_id': uuidutils.generate_uuid(),
'vip_port_id': uuidutils.generate_uuid(),
'vip_address': '198.51.100.10',
'listeners': create_listeners, 'listeners': create_listeners,
'pools': create_pools or [] 'pools': create_pools or []
} }
@ -1308,9 +1310,12 @@ class TestLoadBalancerGraph(base.BaseAPITest):
'admin_state_up': True, 'admin_state_up': True,
'provisioning_status': constants.PENDING_CREATE, 'provisioning_status': constants.PENDING_CREATE,
'operating_status': constants.OFFLINE, 'operating_status': constants.OFFLINE,
'vip_address': None, # TODO(rm_work): vip_network_id is a weird case, as it will be
'vip_network_id': None, # replaced from the port, which in the noop network driver will be
'vip_port_id': None, # 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': '', 'flavor': '',
'provider': 'octavia' 'provider': 'octavia'
} }