import org.opendaylight.netvirt.openstack.sfc.translator.flowclassifier.FlowClassifierTranslator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInput;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathOutput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.DeleteRenderedPathInput;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePathService;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
* OpenDaylight Neutron Port Chain yang models data change listener
*/
public class NeutronPortChainListener extends DelegatingDataTreeListener<PortChain> {
-
private static final Logger LOG = LoggerFactory.getLogger(NeutronPortChainListener.class);
private static final InstanceIdentifier<PortChain> portChainIid =
private final SfcMdsalHelper sfcMdsalHelper;
private final NeutronMdsalHelper neutronMdsalHelper;
private final OvsdbMdsalHelper ovsdbMdsalHelper;
- private final RenderedServicePathService rspService;
+ private RenderedServicePathService rspService;
public NeutronPortChainListener(DataBroker db, RenderedServicePathService rspService) {
super(db,new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, portChainIid));
*/
@Override
public void remove(InstanceIdentifier<PortChain> path, PortChain deletedPortChain) {
- sfcMdsalHelper.removeServiceFunctionChain(PortChainTranslator.getSFCKey(deletedPortChain));
+ if(this.rspService != null) {
+ DeleteRenderedPathInput deleteRenderedPathInput =
+ PortChainTranslator.buildDeleteRenderedServicePathInput(PortChainTranslator
+ .getSFPKey(deletedPortChain));
+ if (deleteRenderedPathInput != null ) {
+ this.rspService.deleteRenderedPath(deleteRenderedPathInput);
+ }
+ }
+ sfcMdsalHelper.deleteServiceFunctionPath(PortChainTranslator.getSFPKey(deletedPortChain));
+ sfcMdsalHelper.deleteServiceFunctionChain(PortChainTranslator.getSFCKey(deletedPortChain));
}
/**
@Override
public void add(final InstanceIdentifier<PortChain> path, final PortChain newPortChain) {
processPortChain(newPortChain);
- eventProcessor.submit(new Runnable() {
- @Override
- public void run() {
- processPortChain(newPortChain);
- }
- });
+ eventProcessor.submit(() -> processPortChain(newPortChain));
}
private void processPortChain(PortChain newPortChain) {
if (this.rspService != null) {
// Build Create Rendered Service Path input
- CreateRenderedPathInput rpInput = PortChainTranslator.buildRenderedServicePathInput(sfp);
+ CreateRenderedPathInput rpInput = PortChainTranslator.buildCreateRenderedServicePathInput(sfp);
//Call Create Rendered Service Path RPC call
if (rpInput != null) {
LOG.info("Call RPC for creating RSP :{}", rpInput);
Future<RpcResult<CreateRenderedPathOutput>> result = this.rspService.createRenderedPath(rpInput);
try {
- result.get();
- processFlowClassifiers(newPortChain, newPortChain.getFlowClassifiers(), rpInput.getName());
+ if (result.get() != null) {
+ CreateRenderedPathOutput output = result.get().getResult();
+ LOG.debug("RSP name received from SFC : {}", output.getName());
+ processFlowClassifiers(newPortChain, newPortChain.getFlowClassifiers(), output.getName());
+ } else {
+ LOG.error("RSP creation failed : {}", rpInput);
+ }
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error occurred during creating Rendered Service Path using RPC call", e);
}