NG-UI Added the validation for the topology connection. 47/9347/2
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Tue, 7 Jul 2020 10:01:19 +0000 (15:31 +0530)
committerguzman <jmguzman@whitestack.com>
Mon, 13 Jul 2020 14:18:56 +0000 (16:18 +0200)
 * New error validation is added for the VNF Topology connections.

Change-Id: I1b68695718410435cc064bd32ce1da007f6fa6ee
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
src/app/packages/ns-packages/vnf-composer/VNFComposerComponent.ts
src/assets/i18n/de.json
src/assets/i18n/en.json
src/assets/i18n/es.json
src/assets/i18n/pt.json

index 21aad71..bf78d7f 100644 (file)
@@ -706,90 +706,140 @@ export class VNFComposerComponent {
     if (!this.mousedownNode) { return; }
     this.dragLine.classed('hidden', true);
     this.mouseupNode = d;
-    if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'intcp') {
-      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVDUANDINTCP'));
+    if (this.mousedownNode.nodeTypeRef === 'vdu') {
+      this.vduMouseDownNode();
+    } else if (this.mousedownNode.nodeTypeRef === 'cp') {
+      this.cpMouseDownNode();
+    } else if (this.mousedownNode.nodeTypeRef === 'intvl') {
+      this.intVLMouseDownNode();
+    } else if (this.mousedownNode.nodeTypeRef === 'intcp') {
+      this.intCPMouseDownNode();
+    } else {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.INVALIDSELECTION'));
       this.deselectPath();
     }
-    else if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'vdu') {
-      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVDUANDVDU'));
+    this.resetMouseActions();
+    this.currentSelectedNode = null;
+  }
+  /** Establish a connection point between vdu and other nodes @private */
+  private vduMouseDownNode(): void {
+    if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'cp') {
+      this.vduCPConnection(this.mousedownNode.id, this.mouseupNode.id);
+    } else if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'intcp') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVDUANDINTCP'));
       this.deselectPath();
-    }
-    else if (this.mousedownNode.nodeTypeRef === 'intcp' && this.mouseupNode.nodeTypeRef === 'vdu') {
-      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKINTCPANDVDU'));
+    } else if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'vdu') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVDUANDVDU'));
       this.deselectPath();
+    } else if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'intvl') {
+      this.vduIntvlConnection(this.mousedownNode.id, this.mouseupNode.id);
     }
-    else if (this.mousedownNode.nodeTypeRef === 'cp' && this.mouseupNode.nodeTypeRef === 'intvl') {
+  }
+
+  /** Establish a connection point between cp and other nodes @private */
+  private cpMouseDownNode(): void {
+    if (this.mousedownNode.nodeTypeRef === 'cp' && this.mouseupNode.nodeTypeRef === 'vdu') {
+      this.vduCPConnection(this.mouseupNode.id, this.mousedownNode.id);
+    } else if (this.mousedownNode.nodeTypeRef === 'cp' && this.mouseupNode.nodeTypeRef === 'intvl') {
       this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKCPANDVNFVL'));
       this.deselectPath();
+    } else if (this.mousedownNode.nodeTypeRef === 'cp' && this.mouseupNode.nodeTypeRef === 'intcp') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKCPANDINTCP'));
+      this.deselectPath();
+    } else if (this.mousedownNode.nodeTypeRef === 'cp' && this.mouseupNode.nodeTypeRef === 'cp') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKCPANDCP'));
+      this.deselectPath();
     }
-    else if (this.mousedownNode.nodeTypeRef === 'intvl' && this.mouseupNode.nodeTypeRef === 'cp') {
+  }
+
+  /** Establish a connection piont between intvl and other nodes @private */
+  private intVLMouseDownNode(): void {
+    if (this.mousedownNode.nodeTypeRef === 'intvl' && this.mouseupNode.nodeTypeRef === 'cp') {
       this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVNFVLANDCP'));
       this.deselectPath();
-    }
-    else if (this.mousedownNode.nodeTypeRef === 'intcp' && this.mouseupNode.nodeTypeRef === 'cp') {
-      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKINTCPANDCP'));
+    } else if (this.mousedownNode.nodeTypeRef === 'intvl' && this.mouseupNode.nodeTypeRef === 'vdu') {
+      this.vduIntvlConnection(this.mouseupNode.id, this.mousedownNode.id);
+    } else if (this.mousedownNode.nodeTypeRef === 'intvl' && this.mouseupNode.nodeTypeRef === 'intvl') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVNFVLANDVNFVL'));
+      this.deselectPath();
+    } else if (this.mousedownNode.nodeTypeRef === 'intvl' && this.mouseupNode.nodeTypeRef === 'intcp') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKVNFVLANDONTCP'));
       this.deselectPath();
     }
-    else if (this.mousedownNode.nodeTypeRef === 'cp' && this.mouseupNode.nodeTypeRef === 'intcp') {
-      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKCPANDINTCP'));
+  }
+
+  /** Establish a connection point between intcp and other nodes @private */
+  private intCPMouseDownNode(): void {
+    if (this.mousedownNode.nodeTypeRef === 'intcp' && this.mouseupNode.nodeTypeRef === 'vdu') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKINTCPANDVDU'));
       this.deselectPath();
-    } else if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'cp') {
-      this.vnfdPackageDetails.vdu.forEach((vduDetails: VDU) => {
-        if (vduDetails.id === this.mousedownNode.id) {
-          if (vduDetails.interface === undefined) { vduDetails.interface = []; }
-          vduDetails.interface.push({
-            'external-connection-point-ref': this.mouseupNode.id, 'mgmt-interface': true,
-            name: 'eth_' + this.sharedService.randomString(),
-            'virtual-interface': { type: 'VIRTIO' },
-            type: 'EXTERNAL'
-          });
-          if (vduDetails['internal-connection-point'] === undefined) {
-            vduDetails['internal-connection-point'] = [];
-          }
-          if (vduDetails['monitoring-param'] === undefined) {
-            vduDetails['monitoring-param'] = [];
-          }
-          if (vduDetails['vm-flavor'] === undefined) {
-            vduDetails['vm-flavor'] = {};
-          }
-        }
-      });
-      this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
+    } else if (this.mousedownNode.nodeTypeRef === 'intcp' && this.mouseupNode.nodeTypeRef === 'cp') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKINTCPANDCP'));
       this.deselectPath();
-    } else if (this.mousedownNode.nodeTypeRef === 'vdu' && this.mouseupNode.nodeTypeRef === 'intvl') {
-      const setIntCP: string = 'intcp_' + this.sharedService.randomString();
-      this.vnfdPackageDetails['internal-vld'].forEach((vldInternal: InternalVLD) => {
-        if (vldInternal.id === this.mouseupNode.id) {
-          if (vldInternal['internal-connection-point'] === undefined) { vldInternal['internal-connection-point'] = []; }
-          vldInternal['internal-connection-point'].push({ 'id-ref': setIntCP });
-        }
-      });
-      this.vnfdPackageDetails.vdu.forEach((vduDetails: VDU) => {
-        if (vduDetails.id === this.mousedownNode.id) {
-          if (vduDetails.interface === undefined) {
-            vduDetails.interface = [];
-          }
-          vduDetails.interface.push({
-            'internal-connection-point-ref': setIntCP, name: 'int_' + setIntCP, type: 'INTERNAL', 'virtual-interface': { type: 'VIRTIO' }
-          });
-          if (vduDetails['internal-connection-point'] === undefined) {
-            vduDetails['internal-connection-point'] = [];
-          }
-          vduDetails['internal-connection-point'].push({
-            id: setIntCP, name: setIntCP, 'short-name': setIntCP, type: 'VPORT'
-          });
-        }
-      });
-      this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
+    } else if (this.mousedownNode.nodeTypeRef === 'intcp' && this.mouseupNode.nodeTypeRef === 'intvl') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKINTCPANDVNFVL'));
       this.deselectPath();
-    }
-    else {
-      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.INVALIDSELECTION'));
+    } else if (this.mousedownNode.nodeTypeRef === 'intcp' && this.mouseupNode.nodeTypeRef === 'intcp') {
+      this.notifierService.notify('warning', this.translateService.instant('PAGE.VNFPACKAGE.VNFCOMPOSE.CANNOTLINKINTCPANDINTCP'));
       this.deselectPath();
     }
-    this.resetMouseActions();
-    this.currentSelectedNode = null;
   }
+
+  /** Establish a connection between VDU & CP vice versa @private */
+  private vduCPConnection(nodeA: string, nodeB: string): void {
+    this.vnfdPackageDetails.vdu.forEach((vduDetails: VDU) => {
+      if (vduDetails.id === nodeA) {
+        if (vduDetails.interface === undefined) { vduDetails.interface = []; }
+        vduDetails.interface.push({
+          'external-connection-point-ref': nodeB, 'mgmt-interface': true,
+          name: 'eth_' + this.sharedService.randomString(),
+          'virtual-interface': { type: 'VIRTIO' },
+          type: 'EXTERNAL'
+        });
+        if (vduDetails['internal-connection-point'] === undefined) {
+          vduDetails['internal-connection-point'] = [];
+        }
+        if (vduDetails['monitoring-param'] === undefined) {
+          vduDetails['monitoring-param'] = [];
+        }
+        if (vduDetails['vm-flavor'] === undefined) {
+          vduDetails['vm-flavor'] = {};
+        }
+      }
+    });
+    this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
+    this.deselectPath();
+  }
+
+  /** Establish a connection between vdu & intvl and vice versa @private */
+  private vduIntvlConnection(nodeA: string, nodeB: string): void {
+    const setIntCP: string = 'intcp_' + this.sharedService.randomString();
+    this.vnfdPackageDetails['internal-vld'].forEach((vldInternal: InternalVLD) => {
+      if (vldInternal.id === nodeB) {
+        if (vldInternal['internal-connection-point'] === undefined) { vldInternal['internal-connection-point'] = []; }
+        vldInternal['internal-connection-point'].push({ 'id-ref': setIntCP });
+      }
+    });
+    this.vnfdPackageDetails.vdu.forEach((vduDetails: VDU) => {
+      if (vduDetails.id === nodeA) {
+        if (vduDetails.interface === undefined) {
+          vduDetails.interface = [];
+        }
+        vduDetails.interface.push({
+          'internal-connection-point-ref': setIntCP, name: 'int_' + setIntCP, type: 'INTERNAL', 'virtual-interface': { type: 'VIRTIO' }
+        });
+        if (vduDetails['internal-connection-point'] === undefined) {
+          vduDetails['internal-connection-point'] = [];
+        }
+        vduDetails['internal-connection-point'].push({
+          id: setIntCP, name: setIntCP, 'short-name': setIntCP, type: 'VPORT'
+        });
+      }
+    });
+    this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
+    this.deselectPath();
+  }
+
   /** Events handles when mousemove it will capture the selected node data @private */
   private mousemove(): void {
     if (!this.mousedownNode) { return; }
index 992d48a..cc22546 100644 (file)
                 "CANNOTLINKVNFVLANDCP": "Sie können vnf_vl nicht mit cp verknüpfen",
                 "CANNOTLINKINTCPANDCP": "Sie können intcp nicht mit cp verknüpfen",
                 "CANNOTLINKCPANDINTCP": "Sie können cp nicht mit int_cp verknüpfen",
-                "CANNOTLINKVDUANDVDU": "Sie können ein vdu nicht mit einem vdu verknüpfen"
+                "CANNOTLINKVDUANDVDU": "Sie können ein vdu nicht mit einem vdu verknüpfen",
+                "CANNOTLINKCPANDCP": "Sie können ein CP nicht mit einem CP verknüpfen",
+                "CANNOTLINKVNFVLANDVNFVL": "Sie können vnf_vl nicht mit vnf_vl verknüpfen",
+                "CANNOTLINKVNFVLANDONTCP": "Sie können vnf_vl nicht mit int_cp verknüpfen",
+                "CANNOTLINKINTCPANDVNFVL": "Sie können intcp nicht mit vnf_vl verknüpfen",
+                "CANNOTLINKINTCPANDINTCP": "Sie können intcp nicht mit intcp verknüpfen"
             }
         },
         "NETSLICE": {
index 44d452a..4bcf7a8 100644 (file)
                 "CANNOTLINKVNFVLANDCP": "You cant link vnf_vl with cp",
                 "CANNOTLINKINTCPANDCP": "You cant link intcp with cp",
                 "CANNOTLINKCPANDINTCP": "You cant link cp with int_cp",
-                "CANNOTLINKVDUANDVDU": "You can't link a vdu with a vdu"
+                "CANNOTLINKVDUANDVDU": "You can't link a vdu with a vdu",
+                "CANNOTLINKCPANDCP": "You can't link a cp with a cp",
+                "CANNOTLINKVNFVLANDVNFVL": "You cant link vnf_vl with vnf_vl",
+                "CANNOTLINKVNFVLANDONTCP": "You cant link vnf_vl with int_cp",
+                "CANNOTLINKINTCPANDVNFVL": "You cant link intcp with vnf_vl",
+                "CANNOTLINKINTCPANDINTCP": "You cant link intcp with intcp"
             }
         },
         "NETSLICE": {
index 6b8fc76..f80d529 100644 (file)
                 "CANNOTLINKVNFVLANDCP": "No puedes vincular vnf_vl con cp",
                 "CANNOTLINKINTCPANDCP": "No puedes vincular intcp con cp",
                 "CANNOTLINKCPANDINTCP": "No puedes vincular cp con int_cp",
-                "CANNOTLINKVDUANDVDU": "No puedes vincular un vdu con un vdu"
+                "CANNOTLINKVDUANDVDU": "No puedes vincular un vdu con un vdu",
+                "CANNOTLINKCPANDCP": "No puedes vincular una cp con una cp",
+                "CANNOTLINKVNFVLANDVNFVL": "No puede vincular vnf_vl con vnf_vl",
+                "CANNOTLINKVNFVLANDONTCP": "No puede vincular vnf_vl con int_cp",
+                "CANNOTLINKINTCPANDVNFVL": "No puedes vincular intcp con vnf_vl",
+                "CANNOTLINKINTCPANDINTCP": "No puede vincular intcp con intcp"
             }
         },
         "NETSLICE": {
index ded0191..b2e995f 100644 (file)
                 "CANNOTLINKVNFVLANDCP": "Você não pode vincular vnf_vl ao cp",
                 "CANNOTLINKINTCPANDCP": "Você não pode vincular o intcp ao cp",
                 "CANNOTLINKCPANDINTCP": "Você não pode vincular o cp ao int_cp",
-                "CANNOTLINKVDUANDVDU": "Você não pode vincular um vdu a um vdu"
+                "CANNOTLINKVDUANDVDU": "Você não pode vincular um vdu a um vdu",
+                "CANNOTLINKCPANDCP": "Você não pode vincular um cp a um cp",
+                "CANNOTLINKVNFVLANDVNFVL": "Você não pode vincular vnf_vl a vnf_vl",
+                "CANNOTLINKVNFVLANDONTCP": "Você não pode vincular vnf_vl com int_cp",
+                "CANNOTLINKINTCPANDVNFVL": "Você não pode vincular intcp a vnf_vl",
+                "CANNOTLINKINTCPANDINTCP": "Você não pode vincular intcp a intcp"
             }
         },
         "NETSLICE": {