- String oldFixedIPAddress = Strings.nullToEmpty(original.getFixedIPAddress());
- String oldPortUUID = Strings.nullToEmpty(original.getPortUUID());
- String newFixedIPAddress = Strings.nullToEmpty(delta.getFixedIPAddress());
- String newPortUUID = Strings.nullToEmpty(delta.getPortUUID());
- if (oldFixedIPAddress.equals(newFixedIPAddress) && oldPortUUID.equals(newPortUUID)) {
- // interesting fields were not changed
- return StatusCode.OK;
- }
-
- if ((!oldFixedIPAddress.isEmpty() && newFixedIPAddress.isEmpty())
- || (!oldPortUUID.isEmpty() && newPortUUID.isEmpty())) {
- DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL,
- IidFactory.internalPortByFloatingIpPortIid(floatingIpPortId), rwTx);
- DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL,
- IidFactory.floatingIpPortByInternalPortIid(new UniqueId(oldPortUUID)), rwTx);
- // TODO unregister EP representing floating ip port
- } else if (!newFixedIPAddress.isEmpty() && !newPortUUID.isEmpty()) {
- // workaround for https://bugs.opendaylight.org/show_bug.cgi?id=3368
- // otherwise we will create port representing floating IP in NeutronPortAware
- Integer errorCode = registerFloatingIpPort(original.getTenantUUID(), floatingIpPortId.getValue(), rwTx);
- if (errorCode != null) {
- rwTx.cancel();
- return errorCode;
- }
-
- UniqueId internalPortId = new UniqueId(newPortUUID);
- InternalPortByFloatingIpPort internalPortByFloatingIpPort = new InternalPortByFloatingIpPortBuilder().setFloatingIpPortId(
- floatingIpPortId)
- .setFloatingIpPortIpAddress(Utils.createIpAddress(original.getFloatingIPAddress()))
- .setInternalPortId(internalPortId)
- .setInternalPortIpAddress(Utils.createIpAddress(newFixedIPAddress))
- .build();
- rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.internalPortByFloatingIpPortIid(floatingIpPortId),
- internalPortByFloatingIpPort, true);
- rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.floatingIpPortByInternalPortIid(internalPortId),
- new FloatingIpPortByInternalPortBuilder(internalPortByFloatingIpPort).build(), true);
- }