X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2Ftasks%2FDeviceRenderingTask.java;h=a997336c67c58707e67ba5f746181d611ed4cc6c;hb=73478a3a5354a2a557520fec6314532bf0ad6a29;hp=37fa8e096790656ef593f29a410f045ece336cef;hpb=7ea354677f9b8ee0b160a7b636c51bb0bedfcd7b;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java index 37fa8e096..a997336c6 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/tasks/DeviceRenderingTask.java @@ -7,15 +7,15 @@ */ package org.opendaylight.transportpce.renderer.provisiondevice.tasks; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; - import org.opendaylight.transportpce.renderer.ServicePathInputData; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderingResult; import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutput; -import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200128.olm.renderer.input.Nodes; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.ServicePathOutput; +import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.optical.renderer.nodes.Nodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,15 +36,31 @@ public class DeviceRenderingTask implements Callable { @Override public DeviceRenderingResult call() throws Exception { - ServicePathOutput output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(), - this.direction); - if (!output.isSuccess()) { - LOG.warn("Device rendering not successfully finished."); - return DeviceRenderingResult.failed("Operation Failed"); + ServicePathOutput output; + switch (this.servicePathInputData.getServicePathInput().getOperation()) { + case Create: + output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(), + this.direction); + if (!output.getSuccess()) { + LOG.error("Device rendering setup service path failed."); + return DeviceRenderingResult.failed("Operation Failed"); + } + List olmList = this.servicePathInputData.getNodeLists().getOlmNodeList(); + LOG.info("Device rendering setup service path finished successfully."); + return DeviceRenderingResult.ok(olmList, new ArrayList<>(output.nonnullNodeInterface().values()), + new ArrayList<>(output.nonnullLinkTp())); + case Delete: + output = this.deviceRenderer.deleteServicePath(this.servicePathInputData.getServicePathInput()); + if (!output.getSuccess()) { + LOG.error("Device rendering delete service path failed."); + return DeviceRenderingResult.failed("Operation Failed"); + } + LOG.info("Device rendering delete service path finished successfully."); + return DeviceRenderingResult.ok(null, new ArrayList<>(output.nonnullNodeInterface().values()), + new ArrayList<>(output.nonnullLinkTp())); + default: + return DeviceRenderingResult.failed("Device rendering failed - unknwon operation"); } - List olmList = this.servicePathInputData.getNodeLists().getOlmList(); - LOG.info("Device rendering finished successfully."); - return DeviceRenderingResult.ok(olmList, output.getNodeInterface()); } }