@Test public void addClassifierEmptyClassifier() { OpenflowClassifierProcessor classifierManager = new OpenflowClassifierProcessor(readWriteTransaction, new LogicallyAttachedClassifier(dataGetter), new BareClassifier()); PowerMockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(any(SffName.class))) .thenReturn(null); List<FlowDetails> theFlows = classifierManager.processClassifier(sffClassifier, acl, true); Assert.assertTrue(theFlows.isEmpty()); }
public List<FlowDetails> processClassifier( final SclServiceFunctionForwarder theClassifier, final Acl theAcl, final boolean addClassifierScenario) { addClassifier = addClassifierScenario; Optional<ServiceFunctionForwarder> sff = Optional.of(new SffName(theClassifier.getName())) .map(SfcProviderServiceForwarderAPI::readServiceFunctionForwarder); Optional<String> itfName = classifierHandler.getInterfaceNameFromClassifier(theClassifier); if (!sff.isPresent() || !itfName.isPresent()) { LOG.error("createdServiceFunctionClassifier: " + "Cannot install ACL rules in classifier. SFF exists? {}; Interface exists? {}", sff.isPresent(), itfName.isPresent()); return Collections.emptyList(); } classifierInterface = classifierHandler.usesLogicalInterfaces(sff.get()) ? logicallyAttachedClassifier : bareClassifier.setSff(sff.get()); Optional<String> nodeName = itfName.flatMap(classifierInterface::getNodeName); if(!nodeName.isPresent()) { LOG.error("createdServiceFunctionClassifier: Could not extract the node name from the OVS interface"); return Collections.emptyList(); } if (classifierHandler.usesLogicalInterfaces(sff.get())) { if (addClassifierScenario) { ClassifierGeniusIntegration.performGeniusServiceBinding(tx, itfName.get()); LOG.info("processClassifier - Bound interface {}", itfName.get()); } else { ClassifierGeniusIntegration.performGeniusServiceUnbinding(tx, itfName.get()); LOG.info("processClassifier - Unbound interface {}", itfName.get()); } } return theAcl .getAccessListEntries() .getAce() .stream() .map(theAce -> processAce(nodeName.get(), sff.get(), theClassifier.getName(), theAcl.getAclName(), itfName.get(), theAce)) .reduce(new ArrayList<>(), (dstList, theList) -> Stream.concat(dstList.stream(), theList.stream()).collect(Collectors.toList())); }
OpenflowClassifierProcessor { public List<FlowDetails> processClassifier( final SclServiceFunctionForwarder theClassifier, final Acl theAcl, final boolean addClassifierScenario) { addClassifier = addClassifierScenario; Optional<ServiceFunctionForwarder> sff = Optional.of(new SffName(theClassifier.getName())) .map(SfcProviderServiceForwarderAPI::readServiceFunctionForwarder); Optional<String> itfName = classifierHandler.getInterfaceNameFromClassifier(theClassifier); if (!sff.isPresent() || !itfName.isPresent()) { LOG.error("createdServiceFunctionClassifier: " + "Cannot install ACL rules in classifier. SFF exists? {}; Interface exists? {}", sff.isPresent(), itfName.isPresent()); return Collections.emptyList(); } classifierInterface = classifierHandler.usesLogicalInterfaces(sff.get()) ? logicallyAttachedClassifier : bareClassifier.setSff(sff.get()); Optional<String> nodeName = itfName.flatMap(classifierInterface::getNodeName); if(!nodeName.isPresent()) { LOG.error("createdServiceFunctionClassifier: Could not extract the node name from the OVS interface"); return Collections.emptyList(); } if (classifierHandler.usesLogicalInterfaces(sff.get())) { if (addClassifierScenario) { ClassifierGeniusIntegration.performGeniusServiceBinding(tx, itfName.get()); LOG.info("processClassifier - Bound interface {}", itfName.get()); } else { ClassifierGeniusIntegration.performGeniusServiceUnbinding(tx, itfName.get()); LOG.info("processClassifier - Unbound interface {}", itfName.get()); } } return theAcl .getAccessListEntries() .getAce() .stream() .map(theAce -> processAce(nodeName.get(), sff.get(), theClassifier.getName(), theAcl.getAclName(), itfName.get(), theAce)) .reduce(new ArrayList<>(), (dstList, theList) -> Stream.concat(dstList.stream(), theList.stream()).collect(Collectors.toList())); } }
OpenflowClassifierProcessor { public List<FlowDetails> processClassifier( final SclServiceFunctionForwarder theClassifier, final Acl theAcl, final boolean addClassifierScenario) { addClassifier = addClassifierScenario; Optional<ServiceFunctionForwarder> sff = Optional.of(new SffName(theClassifier.getName())) .map(SfcProviderServiceForwarderAPI::readServiceFunctionForwarder); Optional<String> itfName = classifierHandler.getInterfaceNameFromClassifier(theClassifier); if (!sff.isPresent() || !itfName.isPresent()) { LOG.error("createdServiceFunctionClassifier: " + "Cannot install ACL rules in classifier. SFF exists? {}; Interface exists? {}", sff.isPresent(), itfName.isPresent()); return Collections.emptyList(); } classifierInterface = classifierHandler.usesLogicalInterfaces(sff.get()) ? logicallyAttachedClassifier : bareClassifier.setSff(sff.get()); Optional<String> nodeName = itfName.flatMap(classifierInterface::getNodeName); if(!nodeName.isPresent()) { LOG.error("createdServiceFunctionClassifier: Could not extract the node name from the OVS interface"); return Collections.emptyList(); } if (classifierHandler.usesLogicalInterfaces(sff.get())) { if (addClassifierScenario) { ClassifierGeniusIntegration.performGeniusServiceBinding(tx, itfName.get()); LOG.info("processClassifier - Bound interface {}", itfName.get()); } else { ClassifierGeniusIntegration.performGeniusServiceUnbinding(tx, itfName.get()); LOG.info("processClassifier - Unbound interface {}", itfName.get()); } } return theAcl .getAccessListEntries() .getAce() .stream() .map(theAce -> processAce(nodeName.get(), sff.get(), theClassifier.getName(), theAcl.getAclName(), itfName.get(), theAce)) .reduce(new ArrayList<>(), (dstList, theList) -> Stream.concat(dstList.stream(), theList.stream()).collect(Collectors.toList())); } private  OpenflowClassifierProcessor();  OpenflowClassifierProcessor(WriteTransaction theTx,
                                       LogicallyAttachedClassifier theLogicClassifier,
                                       BareClassifier theBareClassifier); }
OpenflowClassifierProcessor { public List<FlowDetails> processClassifier( final SclServiceFunctionForwarder theClassifier, final Acl theAcl, final boolean addClassifierScenario) { addClassifier = addClassifierScenario; Optional<ServiceFunctionForwarder> sff = Optional.of(new SffName(theClassifier.getName())) .map(SfcProviderServiceForwarderAPI::readServiceFunctionForwarder); Optional<String> itfName = classifierHandler.getInterfaceNameFromClassifier(theClassifier); if (!sff.isPresent() || !itfName.isPresent()) { LOG.error("createdServiceFunctionClassifier: " + "Cannot install ACL rules in classifier. SFF exists? {}; Interface exists? {}", sff.isPresent(), itfName.isPresent()); return Collections.emptyList(); } classifierInterface = classifierHandler.usesLogicalInterfaces(sff.get()) ? logicallyAttachedClassifier : bareClassifier.setSff(sff.get()); Optional<String> nodeName = itfName.flatMap(classifierInterface::getNodeName); if(!nodeName.isPresent()) { LOG.error("createdServiceFunctionClassifier: Could not extract the node name from the OVS interface"); return Collections.emptyList(); } if (classifierHandler.usesLogicalInterfaces(sff.get())) { if (addClassifierScenario) { ClassifierGeniusIntegration.performGeniusServiceBinding(tx, itfName.get()); LOG.info("processClassifier - Bound interface {}", itfName.get()); } else { ClassifierGeniusIntegration.performGeniusServiceUnbinding(tx, itfName.get()); LOG.info("processClassifier - Unbound interface {}", itfName.get()); } } return theAcl .getAccessListEntries() .getAce() .stream() .map(theAce -> processAce(nodeName.get(), sff.get(), theClassifier.getName(), theAcl.getAclName(), itfName.get(), theAce)) .reduce(new ArrayList<>(), (dstList, theList) -> Stream.concat(dstList.stream(), theList.stream()).collect(Collectors.toList())); } private  OpenflowClassifierProcessor();  OpenflowClassifierProcessor(WriteTransaction theTx,
                                       LogicallyAttachedClassifier theLogicClassifier,
                                       BareClassifier theBareClassifier); List<FlowDetails> processClassifierList(Acl theAcl,
                                                   boolean addClassifier,
                                                   List<SclServiceFunctionForwarder> classifierList); List<FlowDetails> processClassifier(
            final SclServiceFunctionForwarder theClassifier,
            final Acl theAcl,
            final boolean addClassifierScenario); @Subscribe void refreshTransaction(WriteTransaction theTx); }
OpenflowClassifierProcessor { public List<FlowDetails> processClassifier( final SclServiceFunctionForwarder theClassifier, final Acl theAcl, final boolean addClassifierScenario) { addClassifier = addClassifierScenario; Optional<ServiceFunctionForwarder> sff = Optional.of(new SffName(theClassifier.getName())) .map(SfcProviderServiceForwarderAPI::readServiceFunctionForwarder); Optional<String> itfName = classifierHandler.getInterfaceNameFromClassifier(theClassifier); if (!sff.isPresent() || !itfName.isPresent()) { LOG.error("createdServiceFunctionClassifier: " + "Cannot install ACL rules in classifier. SFF exists? {}; Interface exists? {}", sff.isPresent(), itfName.isPresent()); return Collections.emptyList(); } classifierInterface = classifierHandler.usesLogicalInterfaces(sff.get()) ? logicallyAttachedClassifier : bareClassifier.setSff(sff.get()); Optional<String> nodeName = itfName.flatMap(classifierInterface::getNodeName); if(!nodeName.isPresent()) { LOG.error("createdServiceFunctionClassifier: Could not extract the node name from the OVS interface"); return Collections.emptyList(); } if (classifierHandler.usesLogicalInterfaces(sff.get())) { if (addClassifierScenario) { ClassifierGeniusIntegration.performGeniusServiceBinding(tx, itfName.get()); LOG.info("processClassifier - Bound interface {}", itfName.get()); } else { ClassifierGeniusIntegration.performGeniusServiceUnbinding(tx, itfName.get()); LOG.info("processClassifier - Unbound interface {}", itfName.get()); } } return theAcl .getAccessListEntries() .getAce() .stream() .map(theAce -> processAce(nodeName.get(), sff.get(), theClassifier.getName(), theAcl.getAclName(), itfName.get(), theAce)) .reduce(new ArrayList<>(), (dstList, theList) -> Stream.concat(dstList.stream(), theList.stream()).collect(Collectors.toList())); } private  OpenflowClassifierProcessor();  OpenflowClassifierProcessor(WriteTransaction theTx,
                                       LogicallyAttachedClassifier theLogicClassifier,
                                       BareClassifier theBareClassifier); List<FlowDetails> processClassifierList(Acl theAcl,
                                                   boolean addClassifier,
                                                   List<SclServiceFunctionForwarder> classifierList); List<FlowDetails> processClassifier(
            final SclServiceFunctionForwarder theClassifier,
            final Acl theAcl,
            final boolean addClassifierScenario); @Subscribe void refreshTransaction(WriteTransaction theTx);  }