Added KDU Level exection in UI
* Provision to perform the KDU Level execution action in NG-UI
Change-Id: Ide6e335b41268c75ad4b4efd8ef4aa0a14c6b6ee
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
diff --git a/src/app/instances/ns-primitive/NSPrimitiveComponent.html b/src/app/instances/ns-primitive/NSPrimitiveComponent.html
index 324642a..82e3992 100644
--- a/src/app/instances/ns-primitive/NSPrimitiveComponent.html
+++ b/src/app/instances/ns-primitive/NSPrimitiveComponent.html
@@ -21,42 +21,39 @@
<i class="fas fa-times-circle text-danger"></i>
</button>
</div>
-<form [formGroup]="primitiveForm" (ngSubmit)="execNSPrimitive()">
+<form [formGroup]="primitiveForm" (ngSubmit)="execPrimitive()">
<div class="modal-body">
<div class="form-group row">
<label class="col-sm-4 col-form-label">{{'PRIMITIVETYPE' | translate}}*</label>
<div class="col-sm-8">
- <ng-select (change)="primitiveTypeChange($event)" [clearable]="false"
- placeholder="{{'SELECT' | translate}}" [items]="primitiveTypeList" bindLabel="title"
- bindValue="value" [(ngModel)]="primitiveType" id="primitiveType"
- [ngModelOptions]="{standalone: true}"
+ <ng-select (change)="primitiveTypeChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="primitiveTypeList" bindLabel="title" bindValue="value" [(ngModel)]="primitiveType" id="primitiveType" [ngModelOptions]="{standalone: true}"
[ngClass]="{ 'is-invalid': submitted && !primitiveType }"></ng-select>
</div>
</div>
- <div class="form-group row" *ngIf="primitiveType === 'VNF_Primitive' || primitiveType === 'VDU_Primitive'">
+ <div class="form-group row" *ngIf="primitiveType === 'VNF_Primitive' || primitiveType === 'VDU_Primitive' || primitiveType === 'KDU_Primitive'">
<label class="col-sm-4 col-form-label">VNF {{'MEMBERINDEX' | translate}}*</label>
<div class="col-sm-3">
- <ng-select (change)="indexChange($event, primitiveType)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
- [items]="params.memberIndex" bindLabel="member-vnf-index" bindValue="member-vnf-index"
- formControlName="vnf_member_index" id="vnf_member_index"
+ <ng-select (change)="indexChange($event, primitiveType)" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="params.memberIndex" bindLabel="member-vnf-index" bindValue="member-vnf-index" formControlName="vnf_member_index" id="vnf_member_index"
[ngClass]="{ 'is-invalid': submitted && f.vnf_member_index.errors }"></ng-select>
</div>
</div>
<div class="form-group row" *ngIf="primitiveType === 'VDU_Primitive'">
<label class="col-sm-4 col-form-label">{{'SELECT' | translate}} VDU *</label>
<div class="col-sm-8">
- <ng-select (change)="getVDUPrimitive($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
- [items]="vduList" bindLabel="name" bindValue="id" formControlName="vdu_id" id="vdu_id"
- [ngClass]="{ 'is-invalid': submitted && f.vdu_id.errors }"></ng-select>
+ <ng-select (change)="getPrimitiveList($event, 'vdu')" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="vduList" bindLabel="name" bindValue="id" formControlName="vdu_id" id="vdu_id" [ngClass]="{ 'is-invalid': submitted && f.vdu_id.errors }"></ng-select>
+ </div>
+ </div>
+ <div class="form-group row" *ngIf="primitiveType === 'KDU_Primitive'">
+ <label class="col-sm-4 col-form-label">{{'SELECT' | translate}} KDU *</label>
+ <div class="col-sm-8">
+ <ng-select (change)="getPrimitiveList($event, 'kdu')" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="kduList" bindLabel="name" bindValue="name" formControlName="kdu_name" id="kdu_name" [ngClass]="{ 'is-invalid': submitted && f.kdu_name.errors }"></ng-select>
</div>
</div>
<div class="form-group row" *ngIf="primitiveType">
<label class="col-sm-4 col-form-label">
{{'PAGE.NSPRIMITIVE.PRIMITIVE' | translate}}*</label>
<div class="col-sm-8">
- <ng-select (change)="primitiveChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}"
- [items]="primitiveList" bindLabel="name" bindValue="name" formControlName="primitive" id="primitive"
- [ngClass]="{ 'is-invalid': submitted && f.primitive.errors }"></ng-select>
+ <ng-select (change)="primitiveChange($event)" [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="primitiveList" bindLabel="name" bindValue="name" formControlName="primitive" id="primitive" [ngClass]="{ 'is-invalid': submitted && f.primitive.errors }"></ng-select>
</div>
</div>
<ng-container *ngIf="primitiveParameter.length > 0">
@@ -71,21 +68,16 @@
<div class="form-group row" [formGroupName]="i">
<label class="col-sm-2 col-form-label">{{'NAME' | translate}}:</label>
<div class="col-sm-3">
- <ng-select placeholder="{{'SELECT' | translate}}" [clearable]="false"
- [items]="primitiveParameter" bindLabel="name" bindValue="name"
- formControlName="primitive_params_name" id="parameter{{i}}"
- [ngClass]="{ 'is-invalid': submitted && params.controls.primitive_params_name.errors }">
+ <ng-select placeholder="{{'SELECT' | translate}}" [clearable]="false" [items]="primitiveParameter" bindLabel="name" bindValue="name" formControlName="primitive_params_name" id="parameter{{i}}" [ngClass]="{ 'is-invalid': submitted && params.controls.primitive_params_name.errors }">
</ng-select>
</div>
<div class="col-sm-1"></div>
<label class="col-sm-2 col-form-label">{{'VALUE' | translate}}:</label>
<div class="col-sm-3">
- <input type="text" class="form-control" formControlName="primitive_params_value"
- [ngClass]="{ 'is-invalid': submitted && params.controls.primitive_params_value.errors }">
+ <input type="text" class="form-control" formControlName="primitive_params_value" [ngClass]="{ 'is-invalid': submitted && params.controls.primitive_params_value.errors }">
</div>
<div class="col-sm-1" [hidden]="i==0">
- <button type="button" class="btn btn-sm btn-danger remove-mapping"
- (click)="removePrimitiveParams(i)">
+ <button type="button" class="btn btn-sm btn-danger remove-mapping" (click)="removePrimitiveParams(i)">
<i class="fas fa-times-circle"></i>
</button>
</div>
diff --git a/src/app/instances/ns-primitive/NSPrimitiveComponent.ts b/src/app/instances/ns-primitive/NSPrimitiveComponent.ts
index 1086f49..d5cf565 100644
--- a/src/app/instances/ns-primitive/NSPrimitiveComponent.ts
+++ b/src/app/instances/ns-primitive/NSPrimitiveComponent.ts
@@ -26,7 +26,7 @@
import { APIURLHEADER, ERRORDATA, URLPARAMS } from 'CommonModel';
import { DataService } from 'DataService';
import { environment } from 'environment';
-import { NSData, VDUPRIMITIVELEVEL } from 'NSDModel';
+import { KDUPRIMITIVELEVEL, NSData, VDUPRIMITIVELEVEL } from 'NSDModel';
import { NSPrimitiveParams } from 'NSInstanceModel';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
@@ -84,6 +84,9 @@
/** Contains list of VDU primitive lists @public */
public vduList: {}[];
+ /** Contains list of KDU primitive lists @public */
+ public kduList: {}[];
+
/** FormBuilder instance added to the formBuilder @private */
private formBuilder: FormBuilder;
@@ -126,6 +129,10 @@
{
title: this.translateService.instant('VDUPRIMITIVE'),
value: 'VDU_Primitive'
+ },
+ {
+ title: this.translateService.instant('KDUPRIMITIVE'),
+ value: 'KDU_Primitive'
}
];
}
@@ -152,6 +159,7 @@
primitive: [null, [Validators.required]],
vnf_member_index: [null, [Validators.required]],
vdu_id: [null, [Validators.required]],
+ kdu_name: [null, [Validators.required]],
primitive_params: this.formBuilder.array([this.primitiveParamsBuilder()])
});
}
@@ -180,8 +188,8 @@
this.primitiveParams.removeAt(index);
}
- /** Execute NS Primitive @public */
- public execNSPrimitive(): void {
+ /** Execute Primitive @public */
+ public execPrimitive(): void {
this.submitted = true;
this.objectPrimitiveParams = {};
this.sharedService.cleanForm(this.primitiveForm);
@@ -206,6 +214,12 @@
// tslint:disable-next-line: no-string-literal
primitiveParamsPayLoads['vdu_id'] = this.primitiveForm.value.vdu_id;
}
+ if (this.primitiveType === 'KDU_Primitive') {
+ // tslint:disable-next-line: no-string-literal
+ primitiveParamsPayLoads['vnf_member_index'] = this.primitiveForm.value.vnf_member_index;
+ // tslint:disable-next-line: no-string-literal
+ primitiveParamsPayLoads['kdu_name'] = this.primitiveForm.value.kdu_name;
+ }
const apiURLHeader: APIURLHEADER = {
url: environment.NSDINSTANCES_URL + '/' + this.nsdId + '/action'
};
@@ -226,18 +240,19 @@
this.initializeForm();
if (data.value === 'NS_Primitive') {
this.getNSInfo(this.params.name);
- this.getFormControl('vnf_member_index').setValidators([]);
- this.getFormControl('vnf_member_index').updateValueAndValidity();
- this.getFormControl('vdu_id').setValidators([]);
- this.getFormControl('vdu_id').updateValueAndValidity();
- } else if (data.value === 'VNF_Primitive') {
- this.getFormControl('vdu_id').setValidators([]);
- this.getFormControl('vdu_id').updateValueAndValidity();
+ this.setUpdateValueandValidation('vnf_member_index');
+ }
+ if (data.value === 'VNF_Primitive' || data.value === 'KDU_Primitive' || data.value === 'NS_Primitive') {
+ this.setUpdateValueandValidation('vdu_id');
+ }
+ if (data.value === 'VDU_Primitive' || data.value === 'VNF_Primitive' || data.value === 'NS_Primitive') {
+ this.setUpdateValueandValidation('kdu_name');
}
}
/** Member index change event */
public indexChange(data: {}, getType?: string): void {
this.getFormControl('vdu_id').setValue(null);
+ this.getFormControl('kdu_name').setValue(null);
if (data) {
this.getVnfdInfo(data['vnfd-id-ref'], getType);
} else {
@@ -246,9 +261,9 @@
this.primitiveParameter = [];
}
}
- /** Get VDU Primitive from selected VDU id/name change event */
- public getVDUPrimitive(data: {}): void {
- this.primitiveList = data['vdu-configuration']['config-primitive'];
+ /** Get VDU/KDU primitive List for the selected event @public */
+ public getPrimitiveList(data: {}, selectedType: string): void {
+ this.primitiveList = data[selectedType + '-configuration']['config-primitive'];
}
/** Primivtive change event */
public primitiveChange(data: { parameter: {}[] }): void {
@@ -268,6 +283,19 @@
'vdu-configuration': vduData['vdu-configuration']
};
}
+ /** Generate kdu section @public */
+ public generateKDUData(kduData: KDUPRIMITIVELEVEL): KDUPRIMITIVELEVEL {
+ return {
+ name: kduData.name,
+ 'juju-bundle': kduData['juju-bundle'],
+ 'kdu-configuration': kduData['kdu-configuration']
+ };
+ }
+ /** Used to set the validation and value and update the validation and value @public */
+ public setUpdateValueandValidation(formName: string): void {
+ this.getFormControl(formName).setValidators([]);
+ this.getFormControl(formName).updateValueAndValidity();
+ }
/** Update primitive value based on parameter */
private updatePrimitive(primitive: { parameter: {}[] }): void {
if (primitive.parameter) {
@@ -294,17 +322,34 @@
.subscribe((vnfdInfo: {}) => {
if (vnfdInfo[0]['vnf-configuration'] !== undefined && vnfdInfo[0]['vnf-configuration']) {
this.getFormControl('vdu_id').setValidators([]);
+ this.getFormControl('kdu_name').setValidators([]);
this.primitiveList = vnfdInfo[0]['vnf-configuration']['config-primitive'];
}
if (getType === 'VDU_Primitive') {
+ this.kduList = [];
this.vduList = [];
this.primitiveList = [];
- vnfdInfo[0].vdu.forEach((vduData: VDUPRIMITIVELEVEL) => {
- if (vduData['vdu-configuration']) {
- const vduDataObj: VDUPRIMITIVELEVEL = this.generateVDUData(vduData);
- this.vduList.push(vduDataObj);
- }
- });
+ if (!isNullOrUndefined(vnfdInfo[0].vdu)) {
+ vnfdInfo[0].vdu.forEach((vduData: VDUPRIMITIVELEVEL) => {
+ if (vduData['vdu-configuration']) {
+ const vduDataObj: VDUPRIMITIVELEVEL = this.generateVDUData(vduData);
+ this.vduList.push(vduDataObj);
+ }
+ });
+ }
+ }
+ if (getType === 'KDU_Primitive') {
+ this.kduList = [];
+ this.vduList = [];
+ this.primitiveList = [];
+ if (!isNullOrUndefined(vnfdInfo[0].kdu)) {
+ vnfdInfo[0].kdu.forEach((kduData: KDUPRIMITIVELEVEL) => {
+ if (kduData['kdu-configuration']) {
+ const kduDataObj: KDUPRIMITIVELEVEL = this.generateKDUData(kduData);
+ this.kduList.push(kduDataObj);
+ }
+ });
+ }
}
this.isLoadingResults = false;
}, (error: ERRORDATA) => {
@@ -323,7 +368,7 @@
.subscribe((nsdInfo: {}) => {
if (!isNullOrUndefined(nsdInfo[0]['ns-configuration'])) {
this.primitiveList = !isNullOrUndefined(nsdInfo[0]['ns-configuration']['config-primitive']) ?
- nsdInfo[0]['ns-configuration']['config-primitive'] : [];
+ nsdInfo[0]['ns-configuration']['config-primitive'] : [];
} else {
this.primitiveList = [];
}
diff --git a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
index 2879d8b..823d99f 100644
--- a/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
+++ b/src/app/utilities/ns-instances-action/NSInstancesActionComponent.html
@@ -16,16 +16,13 @@
Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
-->
<div class="btn-group list action" role="group">
- <button type="button" class="btn btn-primary" (click)="metrics()" placement="top" container="body"
- [disabled]="operationalStatus == 'failed' || configStatus == 'failed'" ngbTooltip="{{'METRICS' | translate}}">
+ <button type="button" class="btn btn-primary" (click)="metrics()" placement="top" container="body" [disabled]="operationalStatus == 'failed' || configStatus == 'failed'" ngbTooltip="{{'METRICS' | translate}}">
<i class="fas fa-chart-bar icons"></i>
</button>
- <button type="button" class="btn btn-primary" [disabled]="operationalStatus != 'running'" (click)="nsTopology()"
- placement="top" container="body" ngbTooltip="{{'TOPOLOGY' | translate}}">
+ <button type="button" class="btn btn-primary" [disabled]="operationalStatus != 'running'" (click)="nsTopology()" placement="top" container="body" ngbTooltip="{{'TOPOLOGY' | translate}}">
<i class="fa fa-sitemap fa-fw icons"></i>
</button>
- <button type="button" class="btn btn-primary" (click)="deleteNSInstance(false)" placement="top" container="body"
- ngbTooltip="{{'DELETE' | translate}}">
+ <button type="button" class="btn btn-primary" (click)="deleteNSInstance(false)" placement="top" container="body" ngbTooltip="{{'DELETE' | translate}}">
<i class="far fa-trash-alt icons"></i>
</button>
<div class="btn-group" ngbDropdown display="dynamic" container="body">
@@ -33,21 +30,16 @@
{{'ACTION' | translate}}
</button>
<div class="dropdown-menu list-action-dropdown" ngbDropdownMenu>
- <button type="button" class="btn btn-primary dropdown-item" (click)="infoNs()" placement="left"
- container="body" ngbTooltip="{{'INFO' | translate}}">
+ <button type="button" class="btn btn-primary dropdown-item" (click)="infoNs()" placement="left" container="body" ngbTooltip="{{'INFO' | translate}}">
<i class="fas fa-info icons list" title="info"></i> {{'INFO' | translate}}
</button>
- <button type="button" class="btn btn-primary dropdown-item" (click)="execNSPrimitiveModal()"
- placement="left" container="body" ngbTooltip="{{'EXECNSPRIMITIVE' | translate}}"
- [disabled]="operationalStatus == 'failed' || configStatus == 'failed'">
- <i class="fas fa-magic"></i> {{'EXECNSPRIMITIVE' | translate}}
+ <button type="button" class="btn btn-primary dropdown-item" (click)="execNSPrimitiveModal()" placement="left" container="body" ngbTooltip="{{'EXECPRIMITIVE' | translate}}" [disabled]="operationalStatus == 'failed' || configStatus == 'failed'">
+ <i class="fas fa-magic"></i> {{'EXECPRIMITIVE' | translate}}
</button>
- <button type="button" class="btn btn-primary dropdown-item" (click)="historyOfOperations()" placement="left"
- container="body" ngbTooltip="{{'HISTORYOFOPERATIONS' | translate}}">
+ <button type="button" class="btn btn-primary dropdown-item" (click)="historyOfOperations()" placement="left" container="body" ngbTooltip="{{'HISTORYOFOPERATIONS' | translate}}">
<i class="fas fa-history"></i> {{'HISTORYOFOPERATIONS' | translate}}
</button>
- <button type="button" class="btn btn-primary dropdown-item text-danger" (click)="deleteNSInstance(true)"
- placement="left" container="body" ngbTooltip="{{'FORCEDELETE' | translate}}">
+ <button type="button" class="btn btn-primary dropdown-item text-danger" (click)="deleteNSInstance(true)" placement="left" container="body" ngbTooltip="{{'FORCEDELETE' | translate}}">
<i class="fas fa-trash-alt icons text-danger"></i> {{'FORCEDELETE' | translate}}
</button>
</div>