From: Michal Cmarada Date: Mon, 11 Sep 2017 06:45:55 +0000 (+0200) Subject: fix registerEndpoint in port delete for base Eps X-Git-Tag: release/oxygen~34 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ae60758bca67741ae701aac00def648f6de9fe65;p=groupbasedpolicy.git fix registerEndpoint in port delete for base Eps when neutron router interface is deleted, contextId should be changed back to NetworkId. this patch fixes NetworkId for parents in L2 endpoint. Change-Id: I799fd4fb6c9a79b68514e7c139cc09b6c2e279fa Signed-off-by: Michal Cmarada --- diff --git a/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/EndpointRegistrator.java b/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/EndpointRegistrator.java index 0a95f3fc1..551a84357 100644 --- a/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/EndpointRegistrator.java +++ b/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/EndpointRegistrator.java @@ -61,7 +61,7 @@ public class EndpointRegistrator { try { RpcResult rpcResult = baseEpService.registerEndpoint(regBaseEpInput).get(); if (!rpcResult.isSuccessful()) { - LOG.warn("Illegal state - registerEndpoint was not successful. Input of RPC: {}", regBaseEpInput); + LOG.warn("Illegal state - register Base Endpoint was not successful. Input of RPC: {}", regBaseEpInput); return false; } return true; @@ -97,7 +97,7 @@ public class EndpointRegistrator { try { RpcResult rpcResult = epService.registerEndpoint(regEndpointInput).get(); if (!rpcResult.isSuccessful()) { - LOG.warn("Illegal state - registerEndpoint was not successful. Input of RPC: {}", regEndpointInput); + LOG.warn("Illegal state - register Endpoint was not successful. Input of RPC: {}", regEndpointInput); return false; } return true; diff --git a/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronPortAware.java b/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronPortAware.java index 7901f8f1d..951d59385 100644 --- a/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronPortAware.java +++ b/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/mapping/NeutronPortAware.java @@ -377,8 +377,7 @@ public class NeutronPortAware implements NeutronAware { createBasicMacAddrEpInputBuilder(portInSameSubnet, networkContainment, endpointGroupIds); AddressEndpointRegBuilder l3BaseEp = createBasicL3AddrEpInputBuilder(portInSameSubnet, networkContainment, endpointGroupIds, neutron); - ContextId resolvedCtxId = l3BaseEp.getContextId(); - ContextId networkCtxId = new ContextId(portInSameSubnet.getNetworkId().getValue()); + setParentChildRelationshipForEndpoints(l3BaseEp, l2BaseEp); AddressEndpointUnregBuilder addrEpUnreg = new AddressEndpointUnregBuilder().setAddress(l3BaseEp.getAddress()) @@ -395,6 +394,7 @@ public class NeutronPortAware implements NeutronAware { } else { l3BaseEp.setContextId(new ContextId(networkId.getValue())); } + setParentChildRelationshipForEndpoints(l3BaseEp, l2BaseEp); RegisterEndpointInput regBaseEpInput = new RegisterEndpointInputBuilder() .setAddressEndpointReg(ImmutableList.of(l2BaseEp.build(), l3BaseEp.build())).build(); epRegistrator.registerEndpoint(regBaseEpInput); diff --git a/renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/util/GbpNetconfTransaction.java b/renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/util/GbpNetconfTransaction.java index 42aaab400..c6c461833 100644 --- a/renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/util/GbpNetconfTransaction.java +++ b/renderers/vpp/src/main/java/org/opendaylight/groupbasedpolicy/renderer/vpp/util/GbpNetconfTransaction.java @@ -53,7 +53,8 @@ public class GbpNetconfTransaction { public static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier vppIid, @Nonnull final InstanceIdentifier iid, @Nonnull final T data, byte retryCounter) { VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().lock(); - boolean result = write(VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(), iid, data, retryCounter); + boolean result = + write(VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(), iid, data, retryCounter); VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().unlock(); return result; } @@ -76,9 +77,10 @@ public class GbpNetconfTransaction { * @return true if transaction is successful, false otherwise */ public static boolean netconfSyncedMerge(@Nonnull final InstanceIdentifier vppIid, - @Nonnull final InstanceIdentifier iid, @Nonnull final T data, byte retryCounter) { + @Nonnull final InstanceIdentifier iid, @Nonnull final T data, byte retryCounter) { VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().lock(); - boolean result = merge(VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(), iid, data, retryCounter); + boolean result = + merge(VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(), iid, data, retryCounter); VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().unlock(); return result; } @@ -90,8 +92,8 @@ public class GbpNetconfTransaction { * @param retryCounter retry counter, will repeat the operation for specified amount of times if transaction fails * @return true if transaction is successful, false otherwise */ - public static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier vppIid, @Nonnull final ConfigCommand command, - byte retryCounter) { + public static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier vppIid, + @Nonnull final ConfigCommand command, byte retryCounter) { VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().lock(); boolean result = write(VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(), command, retryCounter); VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().unlock(); @@ -105,8 +107,8 @@ public class GbpNetconfTransaction { * @param retryCounter retry counter, will repeat the operation for specified amount of times if transaction fails * @return true if transaction is successful, false otherwise */ - public static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier vppIid, @Nonnull final RoutingCommand command, - byte retryCounter) { + public static boolean netconfSyncedWrite(@Nonnull final InstanceIdentifier vppIid, + @Nonnull final RoutingCommand command, byte retryCounter) { VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().lock(); boolean result = write(VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey(), command, retryCounter); VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getValue().unlock(); @@ -271,13 +273,10 @@ public class GbpNetconfTransaction { Preconditions.checkArgument(!data.isEmpty()); final ReadWriteTransaction rwTx = mountpoint.newReadWriteTransaction(); try { - data.forEach((k, v) -> { - rwTx.put(LogicalDatastoreType.CONFIGURATION, k, v, true); - }); + data.forEach((k, v) -> rwTx.put(LogicalDatastoreType.CONFIGURATION, k, v, true)); final CheckedFuture futureTask = rwTx.submit(); futureTask.get(); - LOG.trace("Netconf WRITE transaction done for {}", - data.keySet().stream().map(iid -> iid.getPathArguments())); + LOG.trace("Netconf WRITE transaction done for {}", data); return true; } catch (Exception e) { // Retry @@ -334,7 +333,8 @@ public class GbpNetconfTransaction { * @param retryCounter number of attempts * @return true if transaction is successful, false otherwise */ - private static boolean deleteIfExists(final InstanceIdentifier vppIid, final AbstractInterfaceCommand command, byte retryCounter) { + private static boolean deleteIfExists(final InstanceIdentifier vppIid, final AbstractInterfaceCommand command, + byte retryCounter) { Preconditions.checkNotNull(vppIid); InstanceIdentifier iid = VppIidFactory.getInterfaceIID(command.getInterfaceBuilder().getKey()); return deleteIfExists(vppIid, iid, retryCounter); @@ -383,7 +383,8 @@ public class GbpNetconfTransaction { final Set> iids, byte retryCounter) { LOG.trace("Netconf DELETE transaction started. Data will be read at first. RetryCounter: {}", retryCounter); Preconditions.checkNotNull(vppIid); - final ReadWriteTransaction rwTx = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey().newReadWriteTransaction(); + final ReadWriteTransaction rwTx = + VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey().newReadWriteTransaction(); Set> alreadyRemoved = new HashSet<>(); for (InstanceIdentifier iid : iids) { short microReadRetries = 3; @@ -402,9 +403,7 @@ public class GbpNetconfTransaction { } } } - alreadyRemoved.forEach(t -> { - iids.remove(t); - }); + alreadyRemoved.forEach(t -> iids.remove(t)); try { final CheckedFuture futureTask = rwTx.submit(); futureTask.get();