BUG 1383 Cannot compose VNFD from UI: 'mgmt_cp missing' when adding VDU 40/10740/1
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Tue, 4 May 2021 11:46:14 +0000 (17:16 +0530)
committerBarath Kumar R <barath.r@tataelxsi.co.in>
Wed, 5 May 2021 04:22:36 +0000 (09:52 +0530)
 * Before adding CP need to VDU
 * While adding CP add mgmt-cp

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

index 081874a..7c3c247 100644 (file)
@@ -266,7 +266,7 @@ export class VNFComposerComponent {
     if (vnfdPackageDetails['ext-cpd'] !== undefined) {
       vnfdPackageDetails['ext-cpd'].forEach((cp: EXTCPD): void => {
         this.nodes.push({
-          id: cp['int-cpd'] !== undefined ? cp['int-cpd'].cpd : cp.id,
+          id: cp['int-cpd'].cpd !== undefined ? cp['int-cpd'].cpd : cp.id,
           name: cp.id,
           reflexive: false,
           type: 'cp'
@@ -643,32 +643,38 @@ export class VNFComposerComponent {
   /** Drop VDU Composer Data @private */
   private vduDropCompose(): void {
     const randomID: string = this.sharedService.randomString();
-    if (this.vnfdPackageDetails.vdu === undefined) {
-      this.vnfdPackageDetails.vdu = [];
+    if (this.vnfdPackageDetails['mgmt-cp'] === undefined) {
+      this.notifierService.notify('error', this.translateService.instant('PAGE.TOPOLOGY.ADDCPBEFOREVDU'));
+    } else {
+      if (this.vnfdPackageDetails.vdu === undefined) {
+        this.vnfdPackageDetails.vdu = [];
+      }
+      this.vnfdPackageDetails.vdu.push({
+        id: 'vdu_' + randomID,
+        name: 'vdu_' + randomID,
+        description: '',
+        'sw-image-desc': 'ubuntu',
+        'int-cpd': [],
+        'monitoring-parameter': [],
+        'virtual-compute-desc': '',
+        'virtual-storage-desc': []
+      });
+      this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
     }
-    this.vnfdPackageDetails.vdu.push({
-      id: 'vdu_' + randomID,
-      name: 'vdu_' + randomID,
-      description: '',
-      'sw-image-desc': 'ubuntu',
-      'int-cpd': [],
-      'monitoring-parameter': [],
-      'virtual-compute-desc': '',
-      'virtual-storage-desc': []
-    });
-    this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
   }
   /** Drop CP Composer Data @private */
   private cpDropCompose(): void {
     const randomID: string = this.sharedService.randomString();
     if (this.vnfdPackageDetails['ext-cpd'] === undefined) {
       this.vnfdPackageDetails['ext-cpd'] = [];
-      this.vnfdPackageDetails['mgmt-cp'] = 'cp_' + randomID;
     }
     this.vnfdPackageDetails['ext-cpd'].push({
       id: 'cp_' + randomID,
       'int-cpd': {}
     });
+    if (this.vnfdPackageDetails['mgmt-cp'] === undefined) {
+      this.vnfdPackageDetails['mgmt-cp'] = 'cp_' + randomID;
+    }
     this.addNodes(environment.VNFPACKAGES_URL, this.identifier, this.vnfdPackageDetails);
   }
   /** Drop IntVL Composer Data @private */
@@ -812,25 +818,23 @@ export class VNFComposerComponent {
                 if (vdu['int-cpd'] === undefined) {
                   vdu['int-cpd'] = [];
                 }
-                if (extcpd['int-cpd'] === undefined) {
-                  vdu['int-cpd'].push({
-                    id: vduExternalID,
-                    'virtual-network-interface-requirement': [
-                      {
-                        name: vduExternalID,
-                        position: 1,
-                        'virtual-interface': { type: 'PARAVIRT' }
-                      }
-                    ]
-                  });
-                  this.vnfdPackageDetails['ext-cpd'][index] = {
-                    id: extcpd.id,
-                    'int-cpd': {
-                      cpd: vduExternalID,
-                      'vdu-id': vduID
+                vdu['int-cpd'].push({
+                  id: vduExternalID,
+                  'virtual-network-interface-requirement': [
+                    {
+                      name: vduExternalID,
+                      position: 1,
+                      'virtual-interface': { type: 'PARAVIRT' }
                     }
-                  };
-                }
+                  ]
+                });
+                this.vnfdPackageDetails['ext-cpd'][index] = {
+                  id: extcpd.id,
+                  'int-cpd': {
+                    cpd: vduExternalID,
+                    'vdu-id': vduID
+                  }
+                };
               }
             });
           }
@@ -1018,7 +1022,7 @@ export class VNFComposerComponent {
             this.vnfdPackageDetails['ext-cpd'].forEach((extCPD: EXTCPD): void => {
               if (extCPD['int-cpd'] !== undefined) {
                 if (extCPD['int-cpd'].cpd === CPDID) {
-                  delete extCPD['int-cpd'];
+                  extCPD['int-cpd'] = {};
                 }
               }
             });
index be70655..c621215 100644 (file)
@@ -239,6 +239,6 @@ export class ComposePackages implements OnInit {
         }
       };
     }
-    return jsyaml.dump(packageYaml);
+    return jsyaml.dump(packageYaml, { sortKeys: true });
   }
 }
index ba63664..47d7a98 100644 (file)
             "VDU": "VDU",
             "INTVL": "IntVL",
             "INTCP": "IntCP",
-            "DATAEMPTY": "Bitte ändere etwas"
+            "DATAEMPTY": "Bitte ändere etwas",
+            "ADDCPBEFOREVDU": "Fügen Sie CP hinzu, bevor Sie VDU hinzufügen"
         },
         "PROJECT": {
             "NEWPROJECT": "Nieuw project",
index 239192a..9046e5b 100644 (file)
             "VDU": "VDU",
             "INTVL": "IntVL",
             "INTCP": "IntCP",
-            "DATAEMPTY": "Please change something"
+            "DATAEMPTY": "Please change something",
+            "ADDCPBEFOREVDU": "Add CP before adding VDU"
         },
         "PROJECT": {
             "NEWPROJECT": "New Project",
index 40dd3d1..7b17d28 100644 (file)
             "VDU": "VDU",
             "INTVL": "IntVL",
             "INTCP": "IntCP",
-            "DATAEMPTY": "Por favor, cambia algo"
+            "DATAEMPTY": "Por favor, cambia algo",
+            "ADDCPBEFOREVDU": "Agregue CP antes de agregar VDU"
         },
         "PROJECT": {
             "NEWPROJECT": "Nuevo proyecto",
index e97c200..ce9071d 100644 (file)
             "VDU": "VDU",
             "INTVL": "IntVL",
             "INTCP": "IntCP",
-            "DATAEMPTY": "Por favor mude algo"
+            "DATAEMPTY": "Por favor mude algo",
+            "ADDCPBEFOREVDU": "Adicione CP antes de adicionar VDU"
         },
         "PROJECT": {
             "NEWPROJECT": "Novo projeto",