Merge "NSX|V3: ensure that DB binding is updated if there is an IP change"
This commit is contained in:
commit
fbaf707df7
@ -162,6 +162,17 @@ def delete_neutron_nsx_service_binding(session, network_id, service_type):
|
||||
network_id=network_id, nsx_service_type=service_type).delete()
|
||||
|
||||
|
||||
def update_nsx_dhcp_bindings(session, port_id, org_ip, new_ip):
|
||||
try:
|
||||
with session.begin(subtransactions=True):
|
||||
binding = (session.query(nsx_models.NeutronNsxDhcpBinding).
|
||||
filter_by(port_id=port_id, ip_address=org_ip).one())
|
||||
binding.ip_address = new_ip
|
||||
except exc.NoResultFound:
|
||||
LOG.debug("Binding not found for port %s", port_id)
|
||||
return
|
||||
|
||||
|
||||
def get_nsx_dhcp_bindings(session, port_id):
|
||||
return [binding for binding in session.query(
|
||||
nsx_models.NeutronNsxDhcpBinding).filter_by(port_id=port_id)]
|
||||
|
@ -1973,6 +1973,11 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
context, binding, new_port['mac_address'],
|
||||
ips_to_add[i][1], old_port['network_id'],
|
||||
dhcp_opts=dhcp_opts)
|
||||
# Update DB IP
|
||||
nsx_db.update_nsx_dhcp_bindings(context.session,
|
||||
old_port['id'],
|
||||
ip,
|
||||
ips_to_add[i][1])
|
||||
else:
|
||||
for (subnet_id, ip) in ips_to_delete:
|
||||
binding = self._find_dhcp_binding(subnet_id, ip,
|
||||
|
Loading…
x
Reference in New Issue
Block a user