2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 ===================================================================
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
20 ============LICENSE_END============================================
23 import * as XLSX from 'xlsx';
24 import * as _ from 'underscore';
26 import { ActivatedRoute, Router } from '@angular/router';
27 import { Component, OnInit, ViewChild } from '@angular/core';
28 import { Observable } from 'rxjs/Observable';
29 import { BuildDesignComponent } from '../build-artifacts.component';
30 import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
31 import { Location } from '@angular/common';
32 import { MappingEditorService } from '../../..//shared/services/mapping-editor.service';
33 import { NgProgress } from 'ngx-progressbar';
34 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
35 import { NotificationService } from '../../../shared/services/notification.service';
36 import { NotificationsService } from 'angular2-notifications';
37 import { ParamShareService } from '../../..//shared/services/paramShare.service';
38 import { environment } from '../../../../environments/environment';
39 import { saveAs } from 'file-saver';
40 import { Jsonp } from '@angular/http';
41 import { ReferenceDataFormUtil } from './reference-dataform.util';
42 import { UtilityService } from '../../../shared/services/utilityService/utility.service';
43 import { APIService } from "../../../shared/services/cdt.apicall";
45 // Common Confirm Modal
46 import { DialogService } from 'ng2-bootstrap-modal';
47 import { ConfirmComponent } from "../../../shared/confirmModal/confirm.component";
51 type AOA = Array<Array<any>>;
54 selector: 'reference-dataform',
55 templateUrl: './reference-dataform.component.html',
56 styleUrls: ['./reference-dataform.component.css'],
57 providers: [ReferenceDataFormUtil]
59 export class ReferenceDataformComponent implements OnInit {
60 public classNm= "ReferenceDataformComp";
61 public showUploadStatus: boolean = false;
62 public fileUploaded: boolean = false;
63 public uploadedData: any;
64 public statusMsg: string;
65 public uploadStatus: boolean = false;
66 public isCollapsedContent: boolean = true;
67 public vnfcCollLength: number = 0;
68 public vfncCollection = [];
70 public actionType: any;
71 numberTest: RegExp = /^[^.a-z]+$/;
72 public numberOfVmTest: boolean = true;
73 public tempAllData = [];
74 disableGrpNotationValue: boolean;
75 public noRefData = false;
76 public disableRetrieve = false;
77 public getRefStatus = false;
78 public uploadStatusError: boolean;
79 public showUploadErrorStatus: boolean;
80 public noData: string;
82 public appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
83 public downloadData = {
85 template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
86 pd: { pdData: '', pdFileName: '' }
92 oldVnfcIdentifier: any
93 public uploadFileName: any;
94 public addVmClickedFlag: boolean = false;
95 public getExcelUploadStatus: boolean = false;
96 public uploadedDataArray: any;
97 public actionFlag = false;
100 nonConfigureAction: any;
104 public actionLevels = [
107 oldtemplateIdentifier: any
109 identifierDrpValues: any = [];
110 //settings for the notifications.
113 showProgressBar: true,
118 //initializing this object to contain all the parameters to be captured later
119 public referenceDataObject = {
121 'action-level': 'vnf',
122 scope: { 'vnf-type': '', 'vnfc-type-list': [] },
125 'device-protocol': '',
130 public refernceScopeObj = { sourceType: '', from: '', to: '' };
131 public actions = ['', // using comma as prefix hereafter for easy reordering
138 , 'DistributeTraffic'
139 , 'DistributeTrafficCheck'
143 , 'LicenseManagement'
168 , 'OpenStack Actions'
169 ]; //.. manual ordering
170 public groupAnotationValue = ['', 'Pair'];
171 public groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
172 public deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'REST', 'CLI', 'RESTCONF'];
173 public deviceTemplates = ['', 'Y', 'N'];
174 public sourceTypeColl = ['', 'vnfType', 'vnfcType'];
175 public ipAddressBoolean = ['', 'Y', 'N'];
176 public Sample: any = {
177 'vnfc-instance': '1',
178 'vnfc-function-code': '',
179 'ipaddress-v4-oam-vip': '',
180 'group-notation-type': '',
181 'group-notation-value': ''
183 hideModal: boolean = false;
185 public uploadTypes = [{
186 value: 'Reference Data',
187 display: 'Sample Json Param File'
190 value: 'Mapping Data',
191 display: 'Sample Json Param File'
194 public selectedUploadType: string = this.uploadTypes[0].value;
195 public vnfcTypeData: string = '';
196 public title: string;
197 public allowAction: boolean = true;
198 public actionExist: boolean = false;
199 public disableVnftype: boolean = false;
200 public otherActions: boolean = false;
201 public actionHealthCheck: boolean = false;
202 public actionChanged: boolean = false;
203 public initialAction: string = '';
204 public noCacheData: boolean;
205 public updateParams: any;
206 public vnfParams: any;
207 public firstArrayElement = [];
208 public remUploadedDataArray = [];
209 isConfigScaleOut = false
210 isConfigScaleIn = false
211 isConfigOrConfigModify = false
212 displayVnfc = 'false';
214 isVnfcTypeList: boolean = true;
215 public referencDataTab = [
218 name: 'Reference Data',
223 name: 'Reference Data',
227 url: 'templates/myTemplates',
229 name: 'Parameter Definition',
230 url: 'parameterDefinitions/create'
236 public actionList = require('../../../../cdt.application.properties.json').Actions;
238 public versionNoForApiCall = require('../../../../cdt.application.properties.json').versionNoForApiCall;
239 private displayVMBlock: boolean = true;
242 private buildDesignComponent: BuildDesignComponent, private apiService: APIService, private utilityService: UtilityService, private httpUtils: HttpUtilService, private referenceDataFormUtil: ReferenceDataFormUtil, private route: Router, private location: Location, private activeRoutes: ActivatedRoute, private notificationService: NotificationService,
243 private paramShareService: ParamShareService, private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService, private ngProgress: NgProgress,
244 private dialogService: DialogService)
246 console.log(this.classNm+
247 ": new: start: tracelvl="+this.utilityService.getTracelvl() );
251 let methName= "ngOnInit";
252 if( this.utilityService.getTracelvl() > 0 )
253 console.log( this.classNm+": "+methName+": start ");
254 // this.handleVMBlockDisplay();
255 if( this.utilityService.getTracelvl() > 0 ) {
256 console.log( this.classNm+": "+methName+
257 ": actions: count="+this.actions.length );
258 for( var i0=0; i0 < this.actions.length; i0++ ) {
259 console.log( this.classNm+": "+methName+
260 ": action #"+i0+" ["+this.actions[i0]+"]");
264 let path = this.location.path;
265 this.title = 'Reference Data';
266 this.displayVnfc = sessionStorage.getItem("vnfcSelectionFlag");
267 this.vnfcIdentifier= ' ';
268 if( this.utilityService.getTracelvl() > 0 )
269 console.log( this.classNm+": "+methName+
270 ": from storage: displayVnfc:["+this.displayVnfc+"]");
271 //.. setting the structure for the reference data object
272 this.referenceDataObject = {
274 'action-level': 'vnf',
275 scope: { 'vnf-type': '', 'vnfc-type-list': [] },
278 'device-protocol': '',
283 //getting the data from session data, calling get Artifact if the data is undefined
284 this.updateParams = sessionStorage.getItem('updateParams');
285 //getting the data from the referencenameobjects if the nav is changed and assiging it to the cace data
286 let cacheData = this.mappingEditorService.referenceNameObjects;
288 if (this.utilityService.checkNotNull(cacheData)) {
289 //if cache data exists then assiging the data to the latest temp all data object.
290 if( this.utilityService.getTracelvl() > 0 )
291 console.log( this.classNm+": ngOnInit: have cacheData.");
292 this.tempAllData = cacheData;
293 //calling the highligted method to highlight the selected actions in the action dropdown
294 this.highlightSelectedActions(this.tempAllData)
295 // getting the latest action that the user has selected and assiging it to the reference data object once the user toggles between tabs from reference
296 if (this.mappingEditorService.latestAction != undefined) {
297 //adding the latest action to the screen
298 this.referenceDataObject = this.mappingEditorService.latestAction;
299 this.toggleIdentifier(this.referenceDataObject.action);
300 //this.referenceDataObject['template-id-list'] = this.mappingEditorService.identifier
301 //use these commented objects to be used in template and pd pages
302 //this.templateIdentifier = this.mappingEditorService.identifier
303 //adding the scope from referencedata obj to referencescopeobject
304 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
305 //assigning the latest action fetched to the old action from reference data object
306 this.oldAction = this.referenceDataObject.action;
307 //this method is called with the action reterived and subsequent values are assigned to refdataobj for displaying
308 this.populateExistinAction(this.referenceDataObject.action);
309 this.displayHideVnfc();
311 } else if (this.updateParams != 'undefined') {
312 //calls the get artifact() to reterive the values if cache data is not present
315 //getting the appdata & downloadDataObject from mapping editor service and assiging it.
316 var appData = this.mappingEditorService.appDataObject;
317 if (appData != null || appData != undefined) this.appData = appData;
318 var downloadData = this.mappingEditorService.downloadDataObject;
319 if (downloadData != null || downloadData != undefined) this.downloadData = downloadData;
321 if (sessionStorage.getItem('vnfParams')) {
322 this.vnfParams = JSON.parse(sessionStorage.getItem('vnfParams'));
324 if (this.vnfParams && this.vnfParams.vnfType) {
325 if( this.utilityService.getTracelvl() > 0 )
326 console.log( this.classNm+": "+methName+": vnfParams.vnfType:["+
327 this.vnfParams.vnfType+"]");
328 this.referenceDataObject['scope']['vnf-type'] = this.vnfParams.vnfType;
330 if (this.vnfParams && this.vnfParams.vnfcType) {
331 if( this.utilityService.getTracelvl() > 0 )
332 console.log( this.classNm+": "+methName+": vnfParams.vnfcType:["+
333 this.vnfParams.vnfcType+"]");
334 this.referenceDataObject['scope']['vnfc-type'] = this.vnfParams.vnfcType;
336 this.uploadedDataArray = [];
337 this.remUploadedDataArray = [];
338 this.firstArrayElement = [];
339 this.uploadFileName = '';
340 this.templateIdentifier = this.mappingEditorService.identifier
341 // if (this.mappingEditorService.newObject) {
342 // this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
345 // this.vnfcIdentifier = '';
346 // this.referenceDataObject['vnfcIdentifier'] = '';
348 this.oldVnfcIdentifier = this.vnfcIdentifier;
349 if( this.utilityService.getTracelvl() > 1 )
350 console.log( this.classNm+": "+methName+": displayVnfc:["+
351 this.displayVnfc+"]");
352 if( this.utilityService.getTracelvl() > 1 )
353 console.log( this.classNm+": "+methName+": templateIdentifier:["+
354 this.templateIdentifier+"]");
355 // Enable or Block Template and PD Tabs
356 this.buildDesignComponent.getRefData(
357 { ...this.referenceDataObject, displayVnfc: this.displayVnfc },
358 { reqField: this.templateIdentifier });
359 //.. configure some drop-downs
360 this.configDrp(this.referenceDataObject.action);
361 if( this.utilityService.getTracelvl() > 0 )
362 console.log( this.classNm+": "+methName+": tempAllData:["+
363 JSON.stringify(this.tempAllData)+"]");
364 if( this.utilityService.getTracelvl() > 0 )
365 console.log( this.classNm+": "+methName+": finish.");
368 //setting the value to display or hide the template identifier dropdown in the screen
369 toggleIdentifier(data) {
370 if (data == 'ConfigScaleOut') {
371 this.isConfigScaleOut = true
374 this.isConfigScaleOut = false
377 if (data == 'ConfigScaleIn') {
378 this.isConfigScaleIn = true;
380 this.isConfigScaleIn = false;
384 //to retrive the data from appc and assign it to the vaiables, if no data display the message reterived from the API
386 if( this.utilityService.getTracelvl() > 0 )
387 console.log(this.classNm+": getArtifact: start...");
389 // setting the isVnfcTypeList & isVnfcType to false initially
390 this.isVnfcTypeList = false;
391 this.isVnfcType = false
392 let data = this.utilityService.createPayloadForRetrieve(true, '', '', '');
393 this.ngProgress.start();
394 let serviceCall = this.apiService.callGetArtifactsApi(data);
395 serviceCall.subscribe(resp => {
396 //getting the response and assigining it to the variables used and end the progress bar aftr the data is fetched.
397 if (resp.output.data.block != undefined) {
398 this.nService.success('Status', 'data fetched ');
399 let artifactInfo = JSON.parse(resp.output.data.block).artifactInfo[0];
400 let referenceDataAll = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
401 let reference_data = JSON.parse(artifactInfo['artifact-content'])['reference_data'][0];
402 this.referenceDataObject = reference_data;
403 this.toggleIdentifier(this.referenceDataObject.action);
404 if (this.referenceDataObject.action == 'ConfigScaleOut') {
405 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
407 if (this.referenceDataObject.action == 'ConfigScaleIn') {
408 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
410 this.highlightSelectedActions(referenceDataAll)
412 //chck vnfc or vnfcTypeList
413 this.displayHideVnfc();
415 // Enable or Block Template and PD Tabs
416 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
418 this.refernceScopeObj.sourceType = this.referenceDataObject['scopeType'];
419 this.mappingEditorService.getReferenceList().push(JSON.parse(artifactInfo['artifact-content']));
420 this.tempAllData = JSON.parse(artifactInfo['artifact-content'])['reference_data'];
421 this.oldAction = this.referenceDataObject.action;
422 this.oldVnfcIdentifier = this.vnfcIdentifier;
424 this.processReferenceDataAfterRetrieval();
425 this.getArtifactsOpenStack();
427 this.nService.success('Status', 'Sorry !!! I dont have any artifact Named : ' + (JSON.parse(sessionStorage.getItem('updateParams')))['artifact-name']);
429 this.ngProgress.done();
433 this.nService.warn('status', 'error while reteriving artifact');
436 this.ngProgress.done();
441 if( this.utilityService.getTracelvl() > 0 )
442 console.log(this.classNm+": displayHideVnfc: start...");
443 if( this.utilityService.getTracelvl() > 1 ) {
444 if( this.referenceDataObject.scope['vnfc-type-list'] ) {
445 console.log( this.classNm+
446 ": displayHideVnfc: refDataObj.scope.vnfc-type-list.length="+
447 this.referenceDataObject.scope['vnfc-type-list'].length );
449 console.log( this.classNm+
450 ": displayHideVnfc: refDataObj.scope.vnfc-type-list not defined");
452 console.log( this.classNm+": displayHideVnfc: scope.vnfc-type:["+
453 this.referenceDataObject.scope['vnfc-type']+"]");
455 if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && (this.referenceDataObject.scope['vnfc-type'] != undefined || this.referenceDataObject.scope['vnfc-type'] != "")) {
456 this.isVnfcType = true
457 this.displayVnfc = 'true'
458 this.isVnfcTypeList = false
460 if (this.referenceDataObject.scope['vnfc-type-list'] != undefined && this.referenceDataObject.scope['vnfc-type-list'].length != 0 && (this.referenceDataObject.scope['vnfc-type'] == undefined || this.referenceDataObject.scope['vnfc-type'] == "")) {
461 this.isVnfcType = false
462 this.displayVnfc = 'true'
463 this.isVnfcTypeList = true
464 if(!this.mappingEditorService.newObject || !this.mappingEditorService.newObject.vnfc) {
465 this.vnfcIdentifier = this.referenceDataObject.scope['vnfc-type-list'][0];
466 // this.mappingEditorService.newObject.vnfc = this.vnfcIdentifier;
468 this.vnfcIdentifier = this.mappingEditorService.newObject.vnfc;
470 this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
471 //this.vnfcChanged(this.vnfcIdentifier, FormData);
472 if( this.utilityService.getTracelvl() > 0 )
473 console.log(this.classNm+": displayHideVnfc: vnfcIdentifier:["+
474 this.vnfcIdentifier+"]");
476 if (this.referenceDataObject.scope['vnfc-type-list'] != undefined && this.referenceDataObject.scope['vnfc-type-list'].length == 0 && this.referenceDataObject.scope['vnfc-type'] != undefined && this.referenceDataObject.scope['vnfc-type'].length == 0) {
477 if(this.displayVnfc == 'true') {
478 this.isVnfcType = false
479 this.displayVnfc = 'true'
480 this.isVnfcTypeList = true
482 this.isVnfcType = false
483 this.displayVnfc = 'false'
484 this.isVnfcTypeList = false
487 if (this.referenceDataObject.scope['vnfc-type-list'] == undefined && this.referenceDataObject.scope['vnfc-type'] == '') {
488 this.isVnfcType = false
489 this.displayVnfc = 'false'
490 this.isVnfcTypeList = false
492 if( this.utilityService.getTracelvl() > 0 )
493 console.log(this.classNm+": displayHideVnfc: finish. isVnfcType:["+
494 this.isVnfcType+" displayVnfc:["+this.displayVnfc+"] isVnfcTypeList:["+
495 this.isVnfcTypeList+"]");
498 //reinitializing the required values. when changing to template or pd sending the values to mapping service
500 let referenceObject = this.prepareReferenceObject();
501 this.mappingEditorService.changeNavAppData(this.appData);
502 this.mappingEditorService.changeNavDownloadData(this.downloadData);
503 this.uploadedDataArray = [];
504 this.remUploadedDataArray = [];
505 this.firstArrayElement = [];
506 this.uploadFileName = '';
508 // vaidating the number
509 numberValidation(event: any) {
510 if (this.numberTest.test(event) && event != 0) {
511 this.numberOfVmTest = true;
514 this.numberOfVmTest = false;
517 // update my vnf pop up session values
518 updateSessionValues(event: any, type: string) {
519 if( this.utilityService.getTracelvl() > 0 )
520 console.log(this.classNm+": updateSessionValues: type:["+type+"]");
521 if (type === 'action') {
522 sessionStorage.setItem('action', event);
524 if (type === 'vnfType') {
525 sessionStorage.setItem('vnfType', event);
528 // adding vnfc data for each vm
529 addVnfcData(vmNumber: number) {
530 if( this.utilityService.getTracelvl() > 0 )
531 console.log(this.classNm+": addVnfcData: start: vmNumber="+ vmNumber);
533 'vnfc-instance': this.referenceDataObject.vm[vmNumber].vnfc.length + 1,
534 'vnfc-type': this.vnfcTypeData,
535 'vnfc-function-code': '',
536 'ipaddress-v4-oam-vip': '',
537 'group-notation-type': '',
538 'group-notation-value': ''
540 this.referenceDataObject.vm[vmNumber].vnfc.push(newObj);
542 //validating the vnf and vnfc data in the pop up
543 validateVnfcName(name) {
544 if( this.utilityService.getTracelvl() > 0 )
545 console.log( this.classNm+": validateVnfcName: start: name:["+name+"]");
546 if (!name.trim() || name.length < 1) {
547 this.errorMessage = '';
549 } else if (name.startsWith(' ') || name.endsWith(' ')) {
550 this.errorMessage = 'Leading and trailing spaces are not allowed';
552 } else if (name.includes(' ')) {
553 this.errorMessage = 'More than one space is not allowed in VNFC Type';
555 } else if (name.length > 50) {
556 this.errorMessage = 'VNFC Type should be of minimum one character and maximum 50 character';
559 this.invalid = false;
560 this.errorMessage = '';
565 //to remove the VM's created by the user
566 removeFeature(vmNumber: any, index: any, templateId) {
567 if (this.referenceDataObject.action == "Configure") {
568 this.referenceDataObject.vm.splice(vmNumber, 1);
569 this.referenceDataObject.vm.forEach((obj, arrIndex) => {
570 if (arrIndex >= vmNumber) {
571 obj["vm-instance"] = obj["vm-instance"] - 1
573 // obj["vm-instance"] = arrIndex+1
577 let data = this.referenceDataObject.vm.filter(obj => {
578 return obj['template-id'] == templateId;
581 let vmIndex = this.findVmindex(data, vmNumber, templateId)
582 this.referenceDataObject.vm.splice(vmIndex, 1);
584 this.referenceDataObject.vm.forEach((obj, arrIndex) => {
585 if (obj['template-id'] == templateId) {
587 obj["vm-instance"] = index + 1
595 //utility function while adding VM to check index
596 findVmindex(data, vmNumber, templateId) {
597 return this.referenceDataObject.vm.findIndex(obj => {
598 let x = obj['vm-instance'] == (vmNumber + 1) && templateId == obj['template-id']//true
604 //add new VM's to the configure and configmodify.
608 let mberOFVm = Number(this.refernceScopeObj.from);
610 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
612 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
615 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn' || this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
616 let existingVmsLength = this.referenceDataObject.vm.map(obj => {
617 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
618 return obj["vnfcType-id"] == this.templateIdentifier
619 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
620 return obj["template-id"] == this.templateIdentifier
623 //mberOFVm = existingVmsLength + mberOFVm;
626 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
627 identifierValue = this.templateIdentifier
628 } else if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
629 identifierValue = this.vnfcIdentifier
632 for (var i = 0; i < mberOFVm; i++) {
633 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
635 if (identifierValue && identifierValue != "") {
636 this.referenceDataObject.vm.push({ 'vnfcType-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
638 this.referenceDataObject.vm.push({ 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
641 } else if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
642 if (identifierValue && identifierValue != "") {
643 this.referenceDataObject.vm.push({ 'template-id': identifierValue, 'vm-instance': (existingVmsLength + index + 1), vnfc: [Object.assign({}, this.Sample)] });
652 let arrlength = this.referenceDataObject.vm.length;
653 mberOFVm = arrlength + mberOFVm;
654 for (var i = (arrlength); i < mberOFVm; i++) {
655 if (this.referenceDataObject.action == 'ConfigScaleOut' || this.referenceDataObject.action == 'ConfigScaleIn') {
656 this.referenceDataObject.vm.push({ 'template-id': this.templateIdentifier, 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
658 this.referenceDataObject.vm.push({ 'vm-instance': (i + 1), vnfc: [Object.assign({}, this.Sample)] });
664 //preparing reference obj with required business use cases
665 prepareReferenceObject(isSaving?: any) {
666 let methName= "prepareReferenceObject";
667 if( this.utilityService.getTracelvl() > 0 )
668 console.log( this.classNm+": "+methName+": start: isSaving:["+
670 let scopeName = this.resetParamsOnVnfcType();
671 let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
672 this.prepareArtifactList(scopeName, extension);
674 if (this.referenceDataObject.action === 'OpenStack Actions') {
675 this.referenceDataObject['template'] = 'N';
676 this.referenceDataObject['artifact-list'] = [];
677 this.referenceDataObject['firstRowVmSpreadSheet'] = this.firstArrayElement;
680 this.referenceDataObject['firstRowVmSpreadSheet']=undefined;
682 //ditaching the object from the form and processing pfurther
683 let newObj = $.extend(true, {}, this.referenceDataObject);
684 let action = this.referenceDataObject.action;
685 // if (action=="ConfigScaleOut"){
686 // this.referenceDataObject.action="true";
688 //preparing Obj for save/download
689 newObj = this.deleteVmsforNonActions(newObj, action)
691 if (newObj['device-protocol'] != 'REST') {
694 this.pushOrReplaceTempData(newObj, action);
695 this.addAllActionObj(newObj, scopeName);
701 //saving data to service
702 this.mappingEditorService.getReferenceList().push(JSON.parse(JSON.stringify(this.referenceDataObject)));
703 this.buildDesignComponent.updateAccessUpdatePages(this.referenceDataObject.action, this.mappingEditorService.getReferenceList());
704 this.mappingEditorService.changeNav(this.tempAllData);
705 //on action change or template identifier change reset the form by restting values of Reference data object
706 this.resetVmsForScaleout(this.currentAction)
707 return { totlaRefDtaa: this.tempAllData, scopeName: scopeName };
710 // utility function to check element existence
711 public checkIfelementExistsInArray(element, array) {
712 var result: boolean = false;
714 array.forEach(function (item) {
715 if (element === item) {
722 // when uploading the file
724 /* wire up file reader */
725 const target: DataTransfer = <DataTransfer>(evt.target);
726 this.uploadFileName = evt.target.files[0].name;
727 var fileExtension = this.uploadFileName.substr(this.uploadFileName.lastIndexOf('.') + 1);
728 if (target.files.length != 1) {
729 throw new Error('Cannot upload multiple files on the entry');
731 if (fileExtension.toUpperCase() === 'XLS' || fileExtension.toUpperCase() === 'XLSX') {
732 const reader = new FileReader();
733 reader.onload = (e: any) => {
735 const bstr = e.target.result;
736 const wb = XLSX.read(bstr, { type: 'binary' });
737 /* grab first sheet */
738 const wsname = wb.SheetNames[0];
739 const ws = wb.Sheets[wsname];
742 this.firstArrayElement = []
743 let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 })));
744 this.uploadedDataArray = arrData;
745 for (var i = 0; i < arrData[0].length; i++) {
746 this.firstArrayElement.push(arrData[0][i].replace(/[\n\r]+/g, ''))
748 var remUploadedDataArray = arrData;
749 remUploadedDataArray.shift();
750 this.remUploadedDataArray = remUploadedDataArray;
751 if (arrData != null) {
752 this.getExcelUploadStatus = true;
753 this.nService.success('Success', 'Vm capabilities data uploaded successfully');
757 this.nService.success('Error', 'Empty Vm capabilities file uploaded');
760 reader.readAsBinaryString(target.files[0]);
763 this.nService.error('Error', 'Incorrect VM capabilities file uploaded');
768 addVmCapabilitiesData() {
769 for (var i = 0; i < this.uploadedDataArray.length; i++) {
770 var vnfcFuncCodeArray = [];
771 var data = this.uploadedDataArray[i];
772 for (var j = 1; j < data.length; j++) {
773 if (data[j] != undefined) {
774 if (data[j].toUpperCase() === 'Y') {
775 vnfcFuncCodeArray.push(this.firstArrayElement[j]);
776 //vnfcFuncCodeArray.push({name:this.firstArrayElement[j]});
780 var action = this.uploadedDataArray[i][0];
781 if (action && action != undefined) {
784 'action-level': 'vm',
786 'vnf-type': this.referenceDataObject['scope']['vnf-type'], //need to confirm what should be this value
787 'vnfc-type-list': null
789 'vnfc-function-code-list': vnfcFuncCodeArray,
791 'device-protocol': 'OS'
794 this.tempAllData.push(json);
800 //download the templae pd and reference file with all the actions added.
801 save(form: any, isValid: boolean) {
802 // will show error message
803 this.showValidationErrors(this.referenceDataObject);
806 let referenceObject = this.prepareReferenceObject();
807 let removedKeysArray = []
808 this.tempAllData.forEach((data, index) => {
810 removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
813 this.tempAllData = removedKeysArray;
814 /* var tempAllData = this.tempAllData;
815 tempAllData=this.removeParamFileNameBeforeSave(tempAllData)*/
817 //tempAllData["artifact_list"]=newArtifactList;
818 let theJSON = JSON.stringify({ 'reference_data': this.tempAllData }, null, '\t');
819 let uri = 'data:application/json;charset=UTF-8,' + encodeURIComponent(theJSON);
820 this.downloadData.reference = theJSON;
821 let referenceFileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
822 this.utilityService.downloadArtifactToPc(theJSON, 'json', referenceFileName, 100);
823 this.validateTempAllData();
824 var templateData = JSON.stringify(this.downloadData.template.templateData);
825 var templateFileName = this.downloadData.template.templateFileName;
826 if (templateFileName != null || templateFileName != '') {
827 var fileExtensionArr = templateFileName.split('.');
829 var nameValueFileName = this.downloadData.template.nameValueFileName;
830 let pdFileName = this.downloadData.pd.pdFileName;
831 var nameValueData = JSON.stringify(this.downloadData.template.nameValueData);
832 var pdData = this.downloadData.pd.pdData;
833 if (templateData != '{}' && templateData != null && templateData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.templateData, fileExtensionArr[1], templateFileName, 130);
834 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.utilityService.downloadArtifactToPc(this.downloadData.template.nameValueData, 'json', nameValueFileName, 160);
835 if (pdData != '' && pdData != null && pdData != undefined) this.utilityService.downloadArtifactToPc(pdData, 'yaml', pdFileName, 180);
839 /* removeParamFileNameBeforeSave(tempAllData)
841 var newArtifactList = [];
843 for (var i = 0; i < tempAllData.length; i++) {
844 if (this.checkIfelementExistsInArray(tempAllData[i].action,this.actions)) {
845 var artifactList = tempAllData[i]["artifact-list"]
847 for (var j = 0; j < artifactList.length; j++) {
848 if (artifactList[j]["artifact-type"] != "param_values") {
849 element = artifactList[j];
850 newArtifactList.push(element);
853 tempAllData[i]["artifact-list"] = newArtifactList
854 newArtifactList = [];
860 // save the values to the cache, on action change without download
861 validateDataAndSaveToAppc( valid, form, event) {
862 let methName= "validateDataAndSaveToAppc";
863 if( this.utilityService.getTracelvl() > 0 )
864 console.log( this.classNm+": "+methName+": start: valid:["+valid+"]");
865 // will show error message
866 this.showValidationErrors(this.referenceDataObject);
867 if( this.utilityService.getTracelvl() > 0 )
868 console.log( this.classNm+": "+methName+": tempAllData:["+
869 JSON.stringify(this.tempAllData)+"]");
871 form._submitted = true;
873 let referenceObject = this.prepareReferenceObject(true);
874 let removedKeysArray = []
875 this.tempAllData.forEach((data, index) => {
877 removedKeysArray.push(JSON.parse(JSON.stringify(this.deleteUnwantedKeys(data))))
880 this.tempAllData = removedKeysArray;
882 this.validateTempAllData();
884 if (this.actionChanged) {
886 if (this.currentAction) {
887 this.referenceDataObject.action = this.currentAction;
890 this.populateExistinAction(this.referenceDataObject.action);
891 this.actionChanged = false;
896 this.nService.warn('status', 'unable to save the artifact');
899 //this method saves reference, template, param and PD data to APPC
901 if( this.utilityService.getTracelvl() > 0 )
902 console.log( this.classNm+": saveToAppc: start: vnf-type:["+
903 this.referenceDataObject.scope['vnf-type']+"]");
904 let theJSON = JSON.stringify( this.tempAllData );
905 if( this.utilityService.getTracelvl() > 0 )
906 console.log( this.classNm+": saveToAppc: tempAllData:["+theJSON+"]");
907 let fileName = 'reference_AllAction_' + this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
908 /*var tempAllData=this.removeParamFileNameBeforeSave(this.tempAllData);
909 this.tempAllData=tempAllData;*/
910 this.saveReferenceDataToAppc(JSON.stringify({ reference_data: this.tempAllData }), this.tempAllData[this.tempAllData.length - 1], fileName);
912 var templateData = JSON.stringify(this.appData.template.templateData);
913 var nameValueData = JSON.stringify(this.appData.template.nameValueData);
914 var pdData = JSON.stringify(this.appData.pd);
915 if (templateData != '{}' && templateData != null && templateData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.templateData, 'template data');
916 if (nameValueData != '{}' && nameValueData != null && nameValueData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.template.nameValueData, 'name value pairs');
917 if (pdData != '{}' && pdData != null && pdData != undefined) this.referenceDataFormUtil.handleApiData(this.appData.pd, 'PD file');
920 // valaidation of template data
921 validateTempAllData() {
922 if (this.tempAllData) {
923 var updatedData = [];
924 this.tempAllData.forEach(data => {
926 updatedData.push(data);
929 this.tempAllData = updatedData;
933 //preparig and send the data to the API.
934 saveReferenceDataToAppc(artifactData, dataJson, fileName) {
936 let slashedPayload = this.referenceDataFormUtil.appendSlashes(artifactData);
938 let payload = this.utilityService.createPayLoadForSave("reference_data", dataJson['scope']['vnf-type'], "AllAction", fileName, this.versionNoForApiCall, slashedPayload);
939 this.ngProgress.start();
940 this.httpUtils.post({
941 url: environment.getDesigns,
943 }).subscribe((resp) => {
944 if (resp != null && resp.output.status.code == '400') {
945 window.scrollTo(0, 0);
946 this.nService.success('Status', 'successfully uploaded the Reference Data');
948 this.nService.warn('Status', 'Error while saving Reference Data');
950 this.uploadStatusError = false;
951 this.getRefStatus = false;
952 this.ngProgress.done();
954 this.nService.error('Status', 'Error Connecting to the APPC Network');
955 window.scrollTo(0, 0);
957 this.appData.reference = payload;
959 this.ngProgress.done();
962 // if no data present in the session, fetching data from API
964 if (sessionStorage.getItem('updateParams') != 'undefined') {
966 this.noCacheData = false;
968 this.noCacheData = true;
972 public showUpload() {
973 this.selectedUploadType = this.uploadTypes[0].value;
975 // used when user uploads a file using upload file
976 public fileChange(input) {
977 this.fileName = input.target.files[0].name.replace(/C:\\fakepath\\/i, '');
978 this.fileUploaded = true;
979 this.disableRetrieve = true;
980 if (input.target.files && input.target.files[0]) {
981 // Create the file reader
982 let reader = new FileReader();
983 this.readFile(input.target.files[0], reader, (result) => {
984 // After the callback fires do:
985 if ('Reference Data' === this.selectedUploadType) {
988 let jsonObject = (JSON.parse(result))['reference_data'];
989 this.uploadedData = JSON.parse(JSON.stringify(jsonObject));
990 //check for legacy artifact and do not allow it
991 for (let i = 0; i < this.uploadedData.length; i++) {
992 obj = this.uploadedData[i];
993 if (obj.scope['vnfc-type'] != undefined && obj.scope['vnfc-type'] != '') {
994 this.nService.error('Error', 'The legacy reference artifact not supported');
999 this.displayVnfc = 'false';
1000 this.isVnfcType = false;
1001 this.isVnfcTypeList = false;
1002 for (let i = 0; i < this.uploadedData.length; i++) {
1003 obj = this.uploadedData[i];
1004 if (obj.scope['vnfc-type-list'] && obj.scope['vnfc-type-list'].length > 0) {
1005 this.displayVnfc = 'true';
1006 this.isVnfcTypeList = true;
1007 this.vnfcIdentifier = obj.scope['vnfc-type-list'][0];
1011 this.oldAction=obj.action;
1012 this.tempAllData = JSON.parse(JSON.stringify(jsonObject));
1013 //check vnfc tyoe list for old files
1014 // if (this.referenceDataObject.scope['vnfc-type-list'] == undefined) {
1015 // this.tempAllData = []
1016 // this.referenceDataObject = {
1018 // 'action-level': 'vnf',
1019 // scope: { 'vnf-type': '', 'vnfc-type-list': [] },
1022 // 'device-protocol': '',
1024 // 'port-number': '',
1025 // 'artifact-list': []
1027 // this.nService.error('Error', 'Incorrect file format');
1030 this.notificationService.notifySuccessMessage('Reference Data file successfully uploaded..');
1031 this.highlightSelectedActions(jsonObject)
1032 this.toggleIdentifier(this.referenceDataObject.action)
1033 this.populateExistinAction(this.referenceDataObject.action)
1034 this.configDrp(this.referenceDataObject.action)
1037 this.processReferenceDataAfterRetrieval();
1039 this.getArtifactsOpenStack();
1040 if (this.referenceDataObject.template == null) {
1041 this.referenceDataObject.template = 'Y';
1043 if (this.referenceDataObject['action-level'] == null) {
1044 this.referenceDataObject['action-level'] = 'VNF';
1048 // Enable or Block Template and PD Tabs
1049 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1051 this.nService.error('Error', 'Incorrect file format');
1054 this.hideModal = true;
1057 this.notificationService.notifyErrorMessage('Failed to read file..');
1062 // Highlights selected action on new file upload and on existing VNF
1063 public highlightSelectedActions(jsonObject) {
1064 if (jsonObject instanceof Array) {
1065 this.referenceDataObject = jsonObject[0];
1066 jsonObject.forEach(obj => {
1067 this.selectedActions.push(obj.action);
1070 this.referenceDataObject = jsonObject;
1072 this.selectedActions.push(jsonObject.action);
1076 public readFile(file, reader, callback) {
1077 // Set a callback funtion to fire after the file is fully loaded
1078 reader.onload = () => {
1079 // callback with the results
1080 callback(reader.result);
1082 this.notificationService.notifySuccessMessage('Uploading File ' + file.name + ':' + file.type + ':' + file.size);
1084 reader.readAsText(file, 'UTF-8');
1087 fileChangeEvent(fileInput: any) {
1088 let obj: any = fileInput.target.files;
1090 //resetting the values
1093 'vnfc-instance': '1',
1094 'vnfc-function-code': '',
1095 'ipaddress-v4-oam-vip': '',
1096 'group-notation-type': '',
1097 'group-notation-value': ''
1101 setVmInstance(index) {
1102 this.referenceDataObject.vm[index]['vm-instance'] = index + 1;
1105 // setVnfcType(str: String) {
1106 // this.Sample['vnfc-type'] = str;
1109 // getChange(value: String) {
1110 // if (value === 'vnfType') {
1111 // this.referenceDataObject.scope['vnfc-type'] = '';
1114 // resetting the form
1116 console.log( this.classNm+": resetForm: start.");
1117 this.referenceDataObject['action-level'] = 'vnf';
1118 this.referenceDataObject.template = 'Y';
1119 this.referenceDataObject['device-protocol'] = '';
1120 this.referenceDataObject['user-name'] = '';
1121 this.referenceDataObject['port-number'] = '';
1122 this.refernceScopeObj.sourceType = '';
1123 this.Sample['vnfc-type'] = '';
1126 //.. this method gets called with the action as parameter and
1127 // the respective action details are fetched and assigned to the current page
1128 populateExistinAction( action) {
1129 let methName= "populateExistinAction";
1130 if( this.utilityService.getTracelvl() > 0 )
1131 console.log( this.classNm+": "+methName+": start: action:["+action+"]");
1132 if( this.utilityService.getTracelvl() > 0 )
1133 console.log( this.classNm+": "+methName+": tempAllData:["+
1134 JSON.stringify(this.tempAllData)+"]");
1135 let existAction = this.tempAllData.findIndex(obj => {
1136 return obj.action == action;
1138 if( this.utilityService.getTracelvl() > 0 )
1139 console.log( this.classNm+": "+methName+": existAction="+existAction );
1140 if( existAction > -1) {
1141 let obj = $.extend(true, {}, this.tempAllData[existAction]);
1142 this.referenceDataObject = obj;
1143 this.referenceDataObject.scope['vnf-type'] = obj['scope']['vnf-type'];
1144 this.referenceDataObject.scope['vnfc-type-list'] = obj['scope']['vnfc-type-list'];
1145 this.referenceDataObject['device-protocol'] = obj['device-protocol'];
1146 this.refernceScopeObj['sourceType'] = obj['scopeType'];
1147 if( obj['scope']['vnfc-type-list'] != undefined &&
1148 obj['scope']['vnfc-type-list'].length >0)
1150 this.referenceDataObject['vnfcIdentifier']=
1151 obj['scope']['vnfc-type-list'][0];
1155 console.log( this.classNm+": populateExistinAction: action not found");
1157 this.referenceDataObject.action = action;
1159 //# iof healthCeck change deviceprotocol drp vaues
1162 this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST'];
1163 this.actionHealthCheck = true;
1165 case 'UpgradeBackout':
1166 case 'ResumeTraffic':
1167 case 'DistributeTraffic':
1168 case 'DistributeTrafficCheck':
1169 case 'QuiesceTraffic':
1170 case 'UpgradeBackup':
1171 case 'UpgradePostCheck':
1172 case 'UpgradePreCheck':
1173 case 'UpgradeSoftware':
1174 case 'ConfigRestore':
1175 case 'StartApplication':
1176 case 'StopApplication':
1177 case 'ConfigBackup':
1178 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE'];
1181 case 'LicenseManagement':
1182 case 'PostConfigure':
1183 case 'PostEvacuate':
1186 case 'PreConfigCheck':
1187 case 'PreConfigure':
1191 case 'ProvisionConfig':
1192 case 'ProvisionData':
1193 case 'Provisioning':
1194 case 'StartTraffic':
1195 case 'StatusTraffic':
1197 this.deviceProtocols = ['', 'ANSIBLE'];
1199 case 'OpenStack Actions':
1200 this.deviceProtocols = ['', 'OpenStack'];
1202 case 'ConfigScaleOut':
1203 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1205 case 'ConfigScaleIn':
1206 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF'];
1208 case 'GetRunningConfig':
1209 this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF', 'CLI', 'REST'];
1212 this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI'];
1213 this.actionHealthCheck = false;
1215 if( this.utilityService.getTracelvl() > 0 )
1216 console.log( this.classNm+": "+methName+
1217 ": deviceProtocols count="+this.deviceProtocols.length+" finish.");
1220 //Modal pop up for action change with values entered.
1221 actionChange( data, userForm) {
1222 let methName= "actionChange";
1223 if( this.utilityService.getTracelvl() > 0 )
1224 console.log( this.classNm+": "+methName+": start: data:["+data+"]"+
1225 " userForm.valid:["+userForm.valid+"]");
1226 if( this.utilityService.getTracelvl() > 0 )
1227 console.log( this.classNm+": "+methName+": tempAllData:["+
1228 JSON.stringify(this.tempAllData)+"]");
1229 this.disableGrpNotationValue = false
1231 console.log( this.classNm+": "+methName+": data == null");
1234 if((userForm.valid) && this.oldAction != '' && this.oldAction != undefined) {
1235 this.actionChanged = true;
1236 if( this.utilityService.getTracelvl() > 0 )
1237 console.log( this.classNm+": "+methName+
1238 ": userForm valid and oldAction defined");
1239 // Calling common Confirmation Modal
1240 let disposable = this.dialogService.addDialog(ConfirmComponent)
1241 .subscribe((isConfirmed)=>{
1242 //We get dialog result
1244 // User clicked on Yes
1245 this.currentAction = this.referenceDataObject.action;
1246 this.referenceDataObject.action = this.oldAction;
1247 $('#saveToAppc').click();//make sure the save all is done before the tempall obj is saved form the API
1248 this.toggleIdentifier(data)
1249 this.oldAction = this.currentAction;// this.referenceDataObject.action + '';
1250 this.referenceDataObject.action = this.currentAction
1252 this.populateExistinAction(data);
1253 if (this.oldAction === 'OpenStack Actions') {
1255 this.uploadedDataArray = [];
1256 this.remUploadedDataArray = [];
1257 this.firstArrayElement = [];
1258 this.uploadFileName = '';
1259 //this.tempAllData = [];
1262 this.refernceScopeObj.from = '';
1263 this.getArtifactsOpenStack();
1265 // Clears VNFC Information data on action change
1266 this.clearVnfcData()
1267 this.resetVmsForScaleout(data);
1270 // User clicked on No
1271 this.toggleIdentifier(data)
1272 this.currentAction = this.referenceDataObject.action;
1273 this.populateExistinAction(data);
1274 this.resetVmsForScaleout(data);
1275 this.oldAction = this.referenceDataObject.action + '';
1277 this.clearVnfcData()
1278 this.refernceScopeObj.from = '';
1281 if (this.referenceDataObject.action === 'Configure' || this.referenceDataObject.action === 'ConfigModify' || this.referenceDataObject.action === 'DistributeTraffic' || this.referenceDataObject.action === 'DistributeTrafficCheck') {
1282 this.isConfigOrConfigModify = true;
1284 this.isConfigOrConfigModify = false;
1285 delete this.mappingEditorService.newObject['vnfc'];
1288 // Enable or Block Template and PD Tabs
1289 if ((this.currentAction == 'ConfigScaleOut' || this.currentAction == 'ConfigScaleIn') && this.templateIdentifier && this.templateIdentifier != '') {
1290 // let referenceDataObjectTemp = this.referenceDataObject;
1291 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1292 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1293 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1296 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1300 console.log( this.classNm+": "+methName+
1301 ": userForm Not valid or oldAction not defined");
1302 this.actionChanged = true;
1303 this.currentAction = this.referenceDataObject.action;
1304 this.oldAction = this.referenceDataObject.action + '';
1305 this.populateExistinAction(data);
1306 this.resetVmsForScaleout(data);
1307 this.toggleIdentifier(data);
1309 // Enable or Block Template and PD Tabs
1310 if((this.currentAction == 'ConfigScaleOut' || this.currentAction == 'ConfigScaleOut') && this.templateIdentifier) {
1311 // let referenceDataObjectTemp = this.referenceDataObject;
1312 // referenceDataObjectTemp['template-id'] = this.templateIdentifier;
1313 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1314 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: this.templateIdentifier });
1316 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1319 if( this.utilityService.getTracelvl() > 0 )
1320 console.log( this.classNm+": "+methName+": tempAllData:["+
1321 JSON.stringify(this.tempAllData)+"]");
1322 this.configDrp(data)
1326 console.log( this.classNm+": configDrp: start: data:["+data+"]");
1327 if (data == 'ConfigScaleOut' || data == 'ConfigScaleIn') {
1328 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value', 'existing-group-name'];
1330 this.groupAnotationType = ['', 'first-vnfc-name', 'fixed-value', 'relative-value'];
1332 if (data == 'OpenStack Actions') {
1333 this.buildDesignComponent.tabs = this.referencDataTab;
1336 this.buildDesignComponent.tabs = this.allTabs;
1338 if (data == 'Configure' || data == 'ConfigModify' || data == 'DistributeTraffic' || data == 'DistributeTrafficCheck') {
1339 this.nonConfigureAction = false;
1341 this.nonConfigureAction = true;
1344 // removing and adding the url key based on the protocol selected
1345 deviceProtocolChange() {
1346 let methName= "deviceProtocolChange";
1347 if( this.utilityService.getTracelvl() > 0 )
1348 console.log( this.classNm+": "+methName+": start.");
1349 if (this.referenceDataObject['device-protocol'] == 'REST') {
1352 delete this.referenceDataObject['context-url']
1354 // Enable or Block Template and PD Tabs
1355 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, {reqField: this.templateIdentifier})
1356 if( this.utilityService.getTracelvl() > 0 )
1357 console.log( this.classNm+": "+methName+": tempAllData:["+
1358 JSON.stringify(this.tempAllData)+"]");
1361 // used to call or trigger save object on template Identifier changes
1362 idChange(data, userForm) {
1363 if( this.utilityService.getTracelvl() > 0 )
1364 console.log( this.classNm+": idChange: start: data:["+data+"]");
1369 // Enable or Block Template and PD Tabs
1370 // let referenceDataObjectTemp = this.referenceDataObject;
1371 // referenceDataObjectTemp['template-id'] = data;
1372 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1373 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1375 if ((userForm.valid)) {
1376 this.currentAction = "ConfigScaleOut"
1377 this.oldtemplateIdentifier = this.templateIdentifier
1378 let referenceObject = this.prepareReferenceObject();
1379 this.actionChanged = true;
1380 if (this.templateIdentifier) {
1381 // Calling common Confirmation Modal
1382 let disposable = this.dialogService.addDialog(ConfirmComponent)
1383 .subscribe((isConfirmed)=>{
1384 //We get dialog result
1386 // User clicked on Yes
1387 this.validateTempAllData();
1390 this.clearVnfcData();
1391 this.refernceScopeObj.from = '';
1394 // User clicked on No
1396 this.refernceScopeObj.from = '';
1401 this.oldtemplateIdentifier = this.templateIdentifier
1404 // if (this.referenceDataObject.action == 'ConfigScaleOut' && data ) {
1405 // let referenceDataObjectTemp = this.referenceDataObject;
1406 // referenceDataObjectTemp['selectedTemplateId'] = data;
1407 // this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1409 // this.buildDesignComponent.getRefData(this.referenceDataObject);
1413 // used to call or trigger save object on multiple VNFC's changes
1414 vnfcChanged( data, userForm) {
1415 if( this.utilityService.getTracelvl() > 0 )
1416 console.log( this.classNm+": vnfcChanged: new vnfcIdentifier:["+data+"]");
1417 if( this.utilityService.getTracelvl() > 1 )
1418 console.log( this.classNm+": vnfcChanged: oldVnfcIdentifier:["+
1419 this.oldVnfcIdentifier+"]");
1420 if( this.utilityService.getTracelvl() > 0 )
1421 console.log(this.classNm+": vnfcChanged: scope.vnfc-type:["+
1422 this.referenceDataObject.scope['vnfc-type']+"]");
1423 this.vnfcIdentifier = data;
1424 //this.clearCache();
1429 // Enable or Block Template and PD Tabs
1430 let referenceDataObjectTemp = this.referenceDataObject;
1431 referenceDataObjectTemp['vnfcIdentifier'] = data;
1432 if( this.utilityService.getTracelvl() > 0 )
1433 console.log( this.classNm+
1434 ": vnfcChanged: displayVnfc:["+this.displayVnfc+"]");
1435 //this.buildDesignComponent.getRefData(referenceDataObjectTemp);
1436 this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc }, { reqField: data });
1439 console.log( this.classNm+
1440 ": vnfcChanged: userForm.valid:["+userForm.valid+"]");
1441 if ((userForm.valid) && this.oldVnfcIdentifier != '' && this.oldVnfcIdentifier != undefined) {
1442 this.currentAction = this.referenceDataObject.action
1443 this.oldVnfcIdentifier = this.vnfcIdentifier
1444 let referenceObject = this.prepareReferenceObject();
1445 this.actionChanged = true;
1446 if (this.vnfcIdentifier) {
1447 // Calling common Confirmation Modal
1448 let disposable = this.dialogService.addDialog(ConfirmComponent)
1449 .subscribe((isConfirmed)=>{
1450 //We get dialog result
1452 // User clicked on Yes
1453 this.validateTempAllData();
1456 this.clearVnfcData()
1457 this.refernceScopeObj.from = '';
1458 //.. populate VNFC Type in Sample field
1459 this.setVnfcTypeInSample( this.vnfcIdentifier );
1462 // User clicked on No
1464 this.clearVnfcData()
1465 this.refernceScopeObj.from = '';
1466 //.. populate VNFC Type in Sample field
1467 this.setVnfcTypeInSample( this.vnfcIdentifier );
1473 this.oldVnfcIdentifier = this.vnfcIdentifier
1479 //needed for the the clearing template cache.
1481 // get the value and save the userid and persist it.
1482 this.clearTemplateCache();
1483 this.clearPdCache();
1484 this.appData = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
1485 this.downloadData = {
1487 template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
1488 pd: { pdData: '', pdFileName: '' }
1492 clearTemplateCache() {
1493 this.mappingEditorService.setTemplateMappingDataFromStore(undefined);
1494 localStorage['paramsContent'] = '{}';
1497 this.mappingEditorService.setParamContent(undefined);
1498 this.paramShareService.setSessionParamData(undefined);
1502 $('#inputFile').trigger('click');
1505 excelBrowseOption() {
1506 $('#excelInputFile').trigger('click');
1509 /* showIdentifier() {
1510 $('#identifierModal').modal();
1514 $('#vnfcModal').modal();
1518 if (!(this.referenceDataObject['template-id-list'])) {
1519 this.referenceDataObject['template-id-list'] = [];
1521 if (!(this.referenceDataObject['template-id-list'].indexOf(this.templateId.trim()) > -1)) {
1522 this.referenceDataObject['template-id-list'].push(this.templateId.trim());
1525 // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1526 this.templateId = ''
1528 // adds the vnfc to the vnfc dropdown list
1530 var newVnfcTypeV= this.newVnfcType.trim();
1531 if( this.utilityService.getTracelvl() > 0 )
1532 console.log(this.classNm+
1533 ": addVnfc: start: newVnfcTypeV:["+newVnfcTypeV+"]");
1534 if (!(this.referenceDataObject.scope['vnfc-type-list'])) {
1535 this.referenceDataObject.scope['vnfc-type-list'] = [];
1536 this.vnfcIdentifier = newVnfcTypeV;
1538 this.vnfcIdentifier = newVnfcTypeV;
1540 //this.referenceDataObject['vnfcIdentifier'] = this.vnfcIdentifier;
1541 if (!(this.referenceDataObject.scope['vnfc-type-list'].indexOf(newVnfcTypeV) > -1)) {
1542 this.referenceDataObject.scope['vnfc-type-list'].push(newVnfcTypeV);
1544 this.tempAllData.forEach(obj => {
1545 if (obj.action == "Configure" || obj.action == "ConfigModify" || obj.action == "DistributeTraffic" || obj.action == "DistributeTrafficCheck") {
1546 obj.scope['vnfc-type-list'] = this.referenceDataObject.scope['vnfc-type-list']
1548 this.resetArtifactList(obj);
1550 //this.buildDesignComponent.getRefData({ ...this.referenceDataObject, displayVnfc: this.displayVnfc });
1551 this.setVnfcTypeInSample( newVnfcTypeV );
1552 let userForm = {valid: true};
1553 this.vnfcChanged(this.newVnfcType, userForm)
1554 // Changing newVnfcType value to blank otherwise it will show previous value in text box of popup
1555 this.newVnfcType = ''
1559 this.referenceDataObject.vm = [];
1563 // this.referenceDataObject.vm = this.referenceDataObject.vm;
1565 // used to show and hide the group notation value in VNFC information
1566 resetGroupNotation() {
1567 if (this.Sample['group-notation-type'] == "existing-group-name") {
1568 this.Sample['group-notation-value'] = ""
1569 this.disableGrpNotationValue = true
1571 this.disableGrpNotationValue = false
1575 resetVmsForScaleout(action) {
1576 //reset currentform vms based on action
1577 if (action == "ConfigScaleOut" || action == "Configure") {
1578 let ConfigScaleOutIndex = this.tempAllData.findIndex(obj => {
1579 return obj['action'] == action
1581 if (ConfigScaleOutIndex > -1) {
1582 this.referenceDataObject.vm = this.tempAllData[ConfigScaleOutIndex].vm
1584 if (this.actionChanged) {
1585 this.referenceDataObject.vm = []
1591 resetVmsForScaleIn(action) {
1592 //reset currentform vms based on action
1593 if (action == "ConfigScaleIn" || action == "Configure") {
1594 let ConfigScaleInIndex = this.tempAllData.findIndex(obj => {
1595 return obj['action'] == action
1597 if (ConfigScaleInIndex > -1) {
1598 this.referenceDataObject.vm = this.tempAllData[ConfigScaleInIndex].vm
1600 if (this.actionChanged) {
1601 this.referenceDataObject.vm = []
1607 resetParamsOnVnfcType() {
1609 let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list']
1610 let vnfcType = this.referenceDataObject.scope['vnfc-type']
1611 let vnfType = this.referenceDataObject.scope['vnf-type'];
1612 //called only if only vnf is there
1613 if ((this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) && (this.referenceDataFormUtil.nullCheckForVnfcType(vnfcType))
1615 scopeName = vnfType;
1616 this.referenceDataObject.scope['vnfc-type'] = '';
1617 this.referenceDataObject['action-level'] = 'vnf';
1618 this.referenceDataObject['scopeType'] = 'vnf-type';
1619 scopeName = scopeName.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1621 //if VNFC is entered set action level & Scope type to VNFC for configure and configure modify, and default the values to vnf and vnf type for all other actions
1623 if (this.referenceDataFormUtil.nullCheckForVnfcTypeList(vnfcTypeList)) {
1624 scopeName = vnfcType ? vnfcType : "";
1626 // scopeName = this.referenceDataObject.scope['vnfc-type-list'];
1629 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
1630 this.referenceDataObject['action-level'] = 'vnf';
1631 this.referenceDataObject['scopeType'] = 'vnfc-type';
1633 this.referenceDataObject['action-level'] = 'vnf';
1634 this.referenceDataObject['scopeType'] = 'vnf-type';
1637 this.referenceDataObject.scope['vnfc-type'] = this.referenceDataObject.scope['vnfc-type'] ? this.referenceDataObject.scope['vnfc-type'] : "";
1641 //used to form the structure of the reference file
1642 prepareArtifactList(scopeName, extension) {
1643 this.referenceDataObject['artifact-list'] = [];
1647 let vnf = this.referenceDataObject.scope['vnf-type']
1648 if (this.referenceDataObject.action == 'Configure' || this.referenceDataObject.action == 'ConfigModify' || this.referenceDataObject.action == 'DistributeTraffic' || this.referenceDataObject.action == 'DistributeTrafficCheck') {
1649 let vnfcTypeList = this.referenceDataObject.scope['vnfc-type-list'];
1651 let config_template_fileName
1654 if (vnfcTypeList && vnfcTypeList.length > 0) {
1657 for (var x = 0; x < vnfcTypeList.length; x++) {
1658 //for replacing spaces and "/" with "_"
1659 let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1660 pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.yaml')
1661 config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, extension)
1662 param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, type, '.json')
1663 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1664 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1665 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1667 this.referenceDataObject['artifact-list'].push(configTemplate,
1668 pdTemplate, paramValue
1671 } else if (scopeName) {
1672 pd_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.yaml';
1673 config_template_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V' + extension;
1674 param_fileName = this.referenceDataObject.action + '_' + scopeName + '_' + '0.0.1V.json';
1675 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1676 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1677 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1678 this.referenceDataObject['artifact-list'].push(configTemplate,
1679 pdTemplate, paramValue
1685 //preparing the artifact list array file names along with extension
1686 let config_template_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', extension);
1687 let pd_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.yaml');
1688 let reference_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1689 let param_fileName = this.referenceDataFormUtil.createArtifactName(this.referenceDataObject.action, vnf, '', '.json');
1690 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1691 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1692 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1693 if (this.referenceDataObject.action != 'ConfigScaleOut' && this.referenceDataObject.action != 'ConfigScaleIn') {
1695 this.referenceDataObject['artifact-list'].push(configTemplate,
1696 pdTemplate, paramValue
1701 let identifiers = this.referenceDataObject['template-id-list'];
1703 for (var x = 0; x < identifiers.length; x++) {
1704 //for replacing spaces and "/" with "_"
1705 let type = identifiers[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1706 pd_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.yaml');
1707 config_template_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, extension);
1708 param_fileName = this.referenceDataFormUtil.createArtifactNameForIdentifiers(this.referenceDataObject.action, this.referenceDataObject.scope["vnf-type"], type, '.json');
1709 configTemplate = this.referenceDataFormUtil.createConfigTemplate(config_template_fileName);
1710 pdTemplate = this.referenceDataFormUtil.createPdTemplate(pd_fileName);
1711 paramValue = this.referenceDataFormUtil.createParamValue(param_fileName);
1713 this.referenceDataObject['artifact-list'].push(configTemplate,
1714 pdTemplate, paramValue
1722 // used to remove the added vms for actions other than configure & scaleout
1723 deleteVmsforNonActions(newObj, action) {
1724 let configureObject = (action == 'Configure');
1725 let ConfigScale = (action == 'ConfigScaleOut') || (action == 'ConfigScaleIn');
1726 //delete VM's if selected action is not configure.
1727 if (!ConfigScale && !configureObject && this.tempAllData.length != 0) {
1735 delete newObj['template-id-list'];
1741 // used to replace the data in tempall obj and form the artifact names
1742 pushOrReplaceTempData(newObj, action) {
1746 if (newObj.action == "Configure" || newObj.action == "ConfigModify" || newObj.action == "DistributeTraffic" || newObj.action == "DistributeTrafficCheck") {
1747 let extension = this.referenceDataFormUtil.decideExtension(this.referenceDataObject);
1748 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.yaml';
1749 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V' + extension;
1750 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + (newObj['vnfcIdentifier'] ? (newObj['vnfcIdentifier'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_') : "") + '0.0.1V.json';
1751 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1752 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1753 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1755 if (newObj.scope['vnfc-type']) {
1756 idValue = newObj.scope['vnfc-type']
1757 } else if (this.vnfcIdentifier) {
1758 idValue = this.vnfcIdentifier
1761 let arr = [configTemplate, pdTemplate, paramValue]
1762 this.mappingEditorService.selectedObj({
1763 action: newObj.action,
1764 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1766 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1767 param_artifact: paramValue['param_artifact'],
1768 pd_artifact: pdTemplate['pd_artifact'],
1769 template_artifact: configTemplate['template_artifact']
1771 } else if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1772 let extension = this.referenceDataFormUtil.decideExtension(newObj);
1773 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_0.0.1V' + '_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '')) : "") + ".yaml";
1774 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '') : "") + extension;
1775 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V_' + (this.templateIdentifier ? (this.templateIdentifier.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '') : "") + '.json';
1776 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1777 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1778 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1779 let arr = [configTemplate, pdTemplate, paramValue]
1780 this.mappingEditorService.selectedObj({
1781 action: newObj.action,
1782 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1783 //vnfc: newObj['vnfcIdentifier'] ? newObj['vnfcIdentifier'] : "",
1784 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1785 templateId: this.templateIdentifier,
1786 param_artifact: paramValue['param_artifact'],
1787 pd_artifact: pdTemplate['pd_artifact'],
1788 template_artifact: configTemplate['template_artifact']
1792 let extension = this.referenceDataFormUtil.decideExtension(newObj);
1793 let pd_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.yaml';
1794 let config_template_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V' + extension;
1795 let param_fileName = this.referenceDataObject.action + '_' + newObj.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + '0.0.1V.json';
1796 configTemplate = this.referenceDataFormUtil.createConfigTemplateForPushReplaceData(config_template_fileName);
1797 pdTemplate = this.referenceDataFormUtil.createPdTemplateForPushReplaceData(pd_fileName);
1798 paramValue = this.referenceDataFormUtil.createParamValueForPushReplaceData(param_fileName);
1799 let arr = [configTemplate, pdTemplate, paramValue]
1800 this.mappingEditorService.selectedObj({
1801 action: newObj.action,
1802 vnf: newObj.scope['vnf-type'] ? newObj.scope['vnf-type'] : "",
1803 protocol: newObj['device-protocol'] ? newObj['device-protocol'] : "",
1804 param_artifact: paramValue['param_artifact'],
1805 pd_artifact: pdTemplate['pd_artifact'],
1806 template_artifact: configTemplate['template_artifact']
1810 let actionObjIndex = this.tempAllData.findIndex(obj => {
1811 return obj['action'] == action;
1813 if (actionObjIndex > -1) {
1814 this.tempAllData[actionObjIndex] = newObj;
1815 this.mappingEditorService.saveLatestAction(this.tempAllData[actionObjIndex]);
1816 if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1817 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1820 this.templateIdentifier = ('')
1821 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1824 if (newObj.action != '') {
1826 this.tempAllData.push(newObj);
1827 this.mappingEditorService.saveLatestAction(newObj);
1829 if (newObj.action == "ConfigScaleOut" || newObj.action == "ConfigScaleIn") {
1830 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier);
1833 this.templateIdentifier = ('')
1834 this.mappingEditorService.saveLatestIdentifier(this.templateIdentifier)
1839 // removes the unwanted keys added in the artifact for vnfc level actions
1840 deleteUnwantedKeys(newObj) {
1841 newObj = JSON.parse(JSON.stringify(newObj))
1842 delete newObj['template-id']
1843 delete newObj['vnfcIdentifier']
1844 if (newObj.action != "ConfigScaleOut" && newObj.action != "ConfigScaleIn") {
1845 delete newObj['template-id-list']
1847 if (newObj.action != 'HealthCheck') {
1848 delete newObj['url'];
1850 if (newObj.action != "Configure" && newObj.action != "ConfigModify" && newObj.action != "DistributeTraffic" && newObj.action != "DistributeTrafficCheck") {
1851 newObj.scope['vnfc-type-list'] = [];
1856 addAllActionObj(newObj, scopeName) {
1858 //Creating all action block to allow mulitple actions at once
1860 action: 'AllAction',
1861 'action-level': 'vnf',
1862 scope: newObj.scope,
1865 let vnfType = this.referenceDataObject.scope['vnf-type'].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1867 allAction['artifact-list'].push({
1868 'artifact-name': 'reference_AllAction' + '_' + vnfType + '_' + '0.0.1V.json',
1869 'artifact-type': 'reference_template'
1872 let allActionIndex = this.tempAllData.findIndex(obj => {
1873 return obj['action'] == 'AllAction';
1875 if (allActionIndex > -1) {
1876 this.tempAllData[allActionIndex] = allAction;
1878 this.tempAllData.push(allAction);
1883 let methName= "resetTempData";
1884 if( this.utilityService.getTracelvl() > 0 )
1885 console.log( this.classNm+": "+methName+": start.");
1886 if( this.utilityService.getTracelvl() > 0 )
1887 console.log( this.classNm+": "+methName+": tempAllData:["+
1888 JSON.stringify(this.tempAllData)+"]");
1889 if (this.utilityService.checkNotNull(this.uploadedDataArray)) {
1891 if (this.utilityService.checkNotNull(this.tempAllData)) {
1892 for (var i = 0; i < this.tempAllData.length; i++) {
1895 if (this.tempAllData[i].action === 'AllAction') {
1899 result = this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions);
1902 this.tempAllData.splice(i, 1);
1908 this.addVmCapabilitiesData();
1912 trackByFn(index, item) {
1913 return index; // or item.id
1915 getArtifactsOpenStack() {
1917 var vnfcFunctionCodeArrayList = [];
1918 var vnfcSetArray = [];
1919 // var vnfcSet = new Set();
1920 for (var i = 0; i < this.tempAllData.length; i++) {
1921 if (!this.checkIfelementExistsInArray(this.tempAllData[i].action, this.actions) && (this.tempAllData[i].action != 'AllAction')) {
1922 var vnfcFunctionCodeArray = this.tempAllData[i]["vnfc-function-code-list"]
1923 // vnfcSet.add("Actions")
1924 /* for (var j = 0; j < vnfcFunctionCodeArray.length; j++) {
1925 vnfcSet.add(vnfcFunctionCodeArray[j])
1927 vnfcFunctionCodeArrayList.push([this.tempAllData[i].action].concat(this.tempAllData[i]["vnfc-function-code-list"]))
1929 if (this.tempAllData[i].action === 'OpenStack Actions') {
1930 vnfcSetArray = this.tempAllData[i]['firstRowVmSpreadSheet']
1935 let vnfcSetArrayLen = vnfcSetArray.length;
1937 for (let i = 0; i < vnfcFunctionCodeArrayList.length; i++) {
1938 let element = vnfcFunctionCodeArrayList[i];
1939 for (let j = 1; j < element.length; j++) {
1940 for (let k = j; k < vnfcSetArrayLen; k++) {
1941 if (element[j] === vnfcSetArray[k]) {
1945 element.splice(j, 0, '');
1951 this.firstArrayElement = vnfcSetArray;
1952 this.remUploadedDataArray = vnfcFunctionCodeArrayList;
1956 // Common method to show validation errors
1957 private showValidationErrors(referenceDataObject) {
1958 if (this.referenceDataObject.action === '') {
1959 this.nService.error('Error', 'Select a valid Action');
1962 if (this.referenceDataObject['device-protocol'] === '') {
1963 this.nService.error('Error', 'Select a valid Device protocol');
1967 if ((referenceDataObject.action === 'ConfigScaleOut'
1968 || referenceDataObject.action === 'ConfigScaleIn')
1969 && !this.templateIdentifier) {
1970 this.nService.error('Error', 'Select a valid Template Identifier');
1973 // if ((referenceDataObject.action === 'Configure' || referenceDataObject.action === 'ConfigModify') && !this.vnfcIdentifier && this.displayVnfc != 'false') {
1974 // this.nService.error('Error', 'Select a valid Vnfc Type');
1979 resetArtifactList(obj) {
1980 if( this.utilityService.getTracelvl() > 0 )
1981 console.log( this.classNm+": resetArtifactList: start...");
1982 let vnfcTypeList = obj.scope['vnfc-type-list'];
1983 let vnf = this.referenceDataObject.scope['vnf-type']
1985 let config_template_fileName
1990 obj['artifact-list'] = [];
1991 for (var x = 0; x < vnfcTypeList.length; x++) {
1992 let extension = this.referenceDataFormUtil.decideExtension(obj)
1993 //for replacing spaces and "/" with "_"
1994 let type = vnfcTypeList[x].replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '');
1995 pd_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.yaml';
1996 config_template_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V' + extension;
1997 param_fileName = this.referenceDataObject.action + '_' + vnf.replace(/ /g, '').replace(new RegExp('/', 'g'), '_').replace(/ /g, '') + '_' + type + '_' + '0.0.1V.json';
1999 'artifact-name': 'template_' + config_template_fileName,
2000 'artifact-type': 'config_template'
2003 'artifact-name': 'pd_' + pd_fileName,
2004 'artifact-type': 'parameter_definitions'
2007 'artifact-name': 'param_' + param_fileName,
2008 'artifact-type': 'param_values'
2011 this.referenceDataObject['artifact-list'].push(configTemplate,
2012 pdTemplate, paramValue
2014 obj['artifact-list'].push(configTemplate,
2015 pdTemplate, paramValue
2021 * Handles the display of VM block based on the action change
2023 handleVMBlockDisplay() {
2024 switch (this.referenceDataObject.action) {
2025 case this.actionList.ConfigScaleOut:
2026 case this.actionList.ConfigScaleIn:
2027 case this.actionList.Configure:
2030 this.displayVMBlock = true;
2033 this.displayVMBlock = false;
2037 //.. check VNFC Type equality in Upper Selection vs entered in Sample field
2038 checkVnfcTypeEqual( vnfctp: string ) {
2039 var methName= "checkVnfcTypeEqual";
2040 if( this.utilityService.getTracelvl() > 0 )
2041 console.log(this.classNm+": "+methName+": vnfctp:["+vnfctp+"]");
2042 if( this.utilityService.getTracelvl() > 0 )
2043 console.log( this.classNm+": "+methName+": vnfcIdentifier:["+
2044 this.vnfcIdentifier+"]");
2045 if( this.utilityService.getTracelvl() > 1 )
2046 console.log( this.classNm+": "+methName+": Sample[vnfc-type]:["+
2047 this.Sample['vnfc-type']+"]");
2048 if( vnfctp != null && vnfctp.length > 0 ) {
2049 if( this.vnfcIdentifier != null && this.vnfcIdentifier.length > 0 ) {
2051 this.classNm+": "+methName+": compare non empty VNFC Types...");
2052 if( vnfctp != this.vnfcIdentifier ) {
2053 if( this.utilityService.getTracelvl() > 0 )
2054 console.log( this.classNm+": "+methName+": Non-match WARNING !");
2055 //.. display in pop-up
2056 this.nService.warn( 'WARNING',
2057 "The specified VNFC Types don't match."+
2058 " Can cause discrepancy in the artifacts.", this.options );
2060 if( this.utilityService.getTracelvl() > 0 )
2061 console.log(this.classNm+": checkVnfcTypeEqual: VNFC Types're equal.");
2067 //.. populating VNFC Type in Sample fields
2068 setVnfcTypeInSample( vnfctp: string ) {
2069 //clear vnfc information samples
2070 this.clearVnfcData();
2072 if( this.utilityService.getTracelvl() > 0 )
2073 console.log( this.classNm+": setVnfcTypeInSample: vnfctp:["+vnfctp+"]");
2074 this.Sample['vnfc-type']= vnfctp;
2078 * Procesess reference data after retrieval from appc or after a reference file has been uploaded from PC.
2080 processReferenceDataAfterRetrieval() {
2081 if( this.utilityService.getTracelvl() > 0 )
2082 console.log( this.classNm+": processReferenceDataAfterRetr: start...");
2083 if (this.referenceDataObject.action === 'OpenStack Actions') {
2084 this.deviceProtocols = ['', 'OpenStack'];
2085 this.buildDesignComponent.tabs = this.referencDataTab;
2087 this.buildDesignComponent.tabs = this.allTabs;
2089 if( this.utilityService.getTracelvl() > 1 )
2090 console.log( this.classNm+": processReferenceDataAfterRetr: done.");
2091 if( this.utilityService.getTracelvl() > 0 )
2092 console.log( this.classNm+": vnfcIdentifier:["+this.vnfcIdentifier+"]");
2093 if( this.utilityService.getTracelvl() > 1 )
2094 console.log( this.classNm+": oldVnfcIdentifier:["+
2095 this.oldVnfcIdentifier+"]");
2096 if( this.utilityService.getTracelvl() > 0 )
2097 console.log( this.classNm+": refDataObj.scope.vnfc-type:["+
2098 this.referenceDataObject.scope['vnfc-type']+"]");
2099 this.setVnfcTypeInSample( this.vnfcIdentifier );