Adapt renderer to manage 100GE service on Switch
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / tasks / OtnDeviceRenderingTask.java
index 34365fb7b13c8f49e5330800244b1b259065dd65..59296db118e5bbc4168991f5352bce0f5c05270d 100644 (file)
@@ -22,37 +22,37 @@ public class OtnDeviceRenderingTask implements Callable<OtnDeviceRenderingResult
 
     private final OtnDeviceRendererService otnDeviceRenderer;
     private final OtnServicePathInput otnServicePathInput;
+    private final String serviceType;
 
     public OtnDeviceRenderingTask(OtnDeviceRendererService otnDeviceRendererService,
-            OtnServicePathInput otnServicePathInput) {
+            OtnServicePathInput otnServicePathInput, String serviceType) {
         this.otnDeviceRenderer = otnDeviceRendererService;
         this.otnServicePathInput = otnServicePathInput;
+        this.serviceType = serviceType;
     }
 
     @Override
     public OtnDeviceRenderingResult call() throws Exception {
         OtnServicePathOutput output;
+        String operation;
         switch (this.otnServicePathInput.getOperation()) {
             case Create:
-                output = this.otnDeviceRenderer.setupOtnServicePath(this.otnServicePathInput);
-                if (!output.getSuccess()) {
-                    LOG.error("Device rendering setup otn service path failed.");
-                    return OtnDeviceRenderingResult.failed("Operation Failed");
-                }
-                LOG.info("Device rendering setup otn service path finished successfully.");
-                return OtnDeviceRenderingResult.ok(new ArrayList<>(output.nonnullNodeInterface().values()),
-                    new ArrayList<>(output.nonnullLinkTp()));
+                operation = "setup";
+                output = this.otnDeviceRenderer.setupOtnServicePath(this.otnServicePathInput, this.serviceType);
+                break;
             case Delete:
-                output = this.otnDeviceRenderer.deleteOtnServicePath(this.otnServicePathInput);
-                if (!output.getSuccess()) {
-                    LOG.error("Device rendering delete otn service path failed.");
-                    return OtnDeviceRenderingResult.failed("Operation Failed");
-                }
-                LOG.info("Device rendering delete otn service path finished successfully.");
-                return OtnDeviceRenderingResult.ok(new ArrayList<>(output.nonnullNodeInterface().values()),
-                    new ArrayList<>(output.nonnullLinkTp()));
+                operation = "delete";
+                output = this.otnDeviceRenderer.deleteOtnServicePath(this.otnServicePathInput, this.serviceType);
+                break;
             default:
-                return OtnDeviceRenderingResult.failed("Device rendering failed - unknwon operation");
+                return OtnDeviceRenderingResult.failed("Device rendering failed - unknown operation");
         }
+        if (!output.getSuccess()) {
+            LOG.error("Device rendering {} otn service path failed.", operation);
+            return OtnDeviceRenderingResult.failed("Operation Failed");
+        }
+        LOG.info("Device rendering {} otn service path finished successfully.", operation);
+        return OtnDeviceRenderingResult.ok(new ArrayList<>(output.nonnullNodeInterface().values()),
+            new ArrayList<>(output.nonnullLinkTp()));
     }
 }