+++ /dev/null
-/*
- * Copyright © 2018 Red Hat, Inc. and others.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.sfc.classifier.utils;
-
-import static java.util.Collections.emptyList;
-
-import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-public final class SfcUtils {
- private SfcUtils() {
- // Utility class
- }
-
- // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3
- @Nonnull
- public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
- return input != null ? input : emptyList();
- }
-}
+++ /dev/null
-/*
- * Copyright © 2018 Red Hat, Inc. and others.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.sfc.translator;
-
-import static java.util.Collections.emptyList;
-
-import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-public final class SfcTranslatorUtils {
- private SfcTranslatorUtils() {
- // Utility class
- }
-
- // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3
- @Nonnull
- public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
- return input != null ? input : emptyList();
- }
-}
package org.opendaylight.netvirt.sfc.translator.portchain;
-import static org.opendaylight.netvirt.sfc.translator.SfcTranslatorUtils.nullToEmpty;
-
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
*/
@Override
public void update(PortChain origPortChain, PortChain updatePortChain) {
- List<Uuid> oldFcList = new ArrayList<>(nullToEmpty(origPortChain.getFlowClassifiers()));
- oldFcList.removeAll(nullToEmpty(updatePortChain.getFlowClassifiers()));
- if (!oldFcList.isEmpty()) {
- LOG.debug("Removing old list {}", oldFcList);
- processFlowClassifiers(origPortChain, oldFcList, null, false);
+ List<Uuid> oldFcList = origPortChain.getFlowClassifiers();
+ oldFcList = oldFcList != null ? new ArrayList<>(oldFcList) : new ArrayList<>();
+ @Nullable List<Uuid> newFcList = updatePortChain.getFlowClassifiers();
+ if (oldFcList != null && newFcList != null) {
+ oldFcList.removeAll(newFcList);
+ if (!oldFcList.isEmpty()) {
+ LOG.debug("Removing old list {}", oldFcList);
+ processFlowClassifiers(origPortChain, oldFcList, null, false);
+ }
}
processPortChain(updatePortChain);
}
List<ServiceFunction> portChainServiceFunctionList = new ArrayList<>();
//Read chain related port pair group from neutron data store
- for (Uuid ppgUuid : nullToEmpty(newPortChain.getPortPairGroups())) {
- PortPairGroup ppg = neutronMdsalHelper.getNeutronPortPairGroup(ppgUuid);
- if (ppg != null) {
- List<PortPair> portPairList = new ArrayList<>();
- portPairGroupList.add(ppg);
- for (Uuid ppUuid : nullToEmpty(ppg.getPortPairs())) {
- PortPair pp = neutronMdsalHelper.getNeutronPortPair(ppUuid);
- if (pp == null) {
- LOG.error("Port pair {} does not exist in the neutron data store", ppUuid);
- return;
+ @Nullable List<Uuid> newPortPairGroups = newPortChain.getPortPairGroups();
+ if (newPortPairGroups != null) {
+ for (Uuid ppgUuid : newPortPairGroups) {
+ PortPairGroup ppg = neutronMdsalHelper.getNeutronPortPairGroup(ppgUuid);
+ if (ppg != null) {
+ List<PortPair> portPairList = new ArrayList<>();
+ portPairGroupList.add(ppg);
+ @org.eclipse.jdt.annotation.Nullable List<Uuid> ppgPortPairs = ppg.getPortPairs();
+ if (ppgPortPairs != null) {
+ for (Uuid ppUuid : ppgPortPairs) {
+ PortPair pp = neutronMdsalHelper.getNeutronPortPair(ppUuid);
+ if (pp == null) {
+ LOG.error("Port pair {} does not exist in the neutron data store", ppUuid);
+ return;
+ }
+ portPairList.add(pp);
+ }
}
- portPairList.add(pp);
+ groupPortPairsList.put(ppgUuid, portPairList);
}
- groupPortPairsList.put(ppgUuid, portPairList);
}
}
// The RSP will automatically be created from the SFP added above.
// Add ACLs from flow classifiers
- processFlowClassifiers(newPortChain, nullToEmpty(newPortChain.getFlowClassifiers()), sfp.getName().getValue(),
- true);
+ @Nullable List<Uuid> newFlowClassifiers = newPortChain.getFlowClassifiers();
+ processFlowClassifiers(newPortChain, newFlowClassifiers != null ? newFlowClassifiers : Collections.emptyList(),
+ sfp.getName().getValue(), true);
}
private void processFlowClassifiers(PortChain pc, @Nonnull List<Uuid> flowClassifiers, @Nullable String sfpName,