From: Barath Kumar R Date: Tue, 4 May 2021 11:46:14 +0000 (+0530) Subject: BUG 1383 Cannot compose VNFD from UI: 'mgmt_cp missing' when adding VDU X-Git-Tag: release-v10.0-start~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F29%2F10729%2F1;p=osm%2FNG-UI.git BUG 1383 Cannot compose VNFD from UI: 'mgmt_cp missing' when adding VDU * Before adding CP need to VDU * While adding CP add mgmt-cp Change-Id: I4219faea328ab46285f8e049d5dc1a7565cdea42 Signed-off-by: Barath Kumar R --- diff --git a/src/app/packages/ns-packages/vnf-composer/VNFComposerComponent.ts b/src/app/packages/ns-packages/vnf-composer/VNFComposerComponent.ts index 081874a..7c3c247 100644 --- a/src/app/packages/ns-packages/vnf-composer/VNFComposerComponent.ts +++ b/src/app/packages/ns-packages/vnf-composer/VNFComposerComponent.ts @@ -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'] = {}; } } }); diff --git a/src/app/utilities/compose-packages/ComposePackages.ts b/src/app/utilities/compose-packages/ComposePackages.ts index be70655..c621215 100644 --- a/src/app/utilities/compose-packages/ComposePackages.ts +++ b/src/app/utilities/compose-packages/ComposePackages.ts @@ -239,6 +239,6 @@ export class ComposePackages implements OnInit { } }; } - return jsyaml.dump(packageYaml); + return jsyaml.dump(packageYaml, { sortKeys: true }); } } diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 79cf07f..8e24408 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -307,7 +307,8 @@ "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", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 164d465..11cbc54 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -307,7 +307,8 @@ "VDU": "VDU", "INTVL": "IntVL", "INTCP": "IntCP", - "DATAEMPTY": "Please change something" + "DATAEMPTY": "Please change something", + "ADDCPBEFOREVDU": "Add CP before adding VDU" }, "PROJECT": { "NEWPROJECT": "New Project", diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json index 9592c8d..a74a931 100644 --- a/src/assets/i18n/es.json +++ b/src/assets/i18n/es.json @@ -307,7 +307,8 @@ "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", diff --git a/src/assets/i18n/pt.json b/src/assets/i18n/pt.json index 67db90a..d4ebbfc 100644 --- a/src/assets/i18n/pt.json +++ b/src/assets/i18n/pt.json @@ -307,7 +307,8 @@ "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",