import { SharedService } from 'SharedService';
/** This is added globally by the tar.js library */
-// tslint:disable-next-line: no-any
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const Tar: any;
/**
styleUrls: ['./ComposePackages.scss']
})
/** Exporting a class @exports ComposePackages */
+// eslint-disable-next-line @angular-eslint/component-class-suffix
export class ComposePackages implements OnInit {
/** Invoke service injectors @public */
public injector: Injector;
this.sharedService = this.injector.get(SharedService);
}
+ /** convenience getter for easy access to form fields */
+ get f(): FormGroup['controls'] { return this.packagesForm.controls; }
+
/**
* Lifecyle Hooks the trigger before component is instantiate
*/
});
}
- /** convenience getter for easy access to form fields */
- get f(): FormGroup['controls'] { return this.packagesForm.controls; }
-
/** Create packages @public */
public createPackages(): void {
this.submitted = true;
}
const descriptor: string = this.packageYaml(this.params.page);
try {
- // tslint:disable-next-line: no-any
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const tar: any = new Tar();
const out: Uint8Array = tar.append(this.packagesForm.value.name + '/' + this.packagesForm.value.name + '.yaml',
descriptor, { type: '0' });
url: this.endPoint,
httpOptions: { headers: this.headers }
};
- this.restService.postResource(apiURLHeader, packageContent).subscribe((result: { id: string }) => {
+ this.restService.postResource(apiURLHeader, packageContent).subscribe((result: { id: string }): void => {
this.isLoadingResults = false;
this.activeModal.close();
this.composeNSPackages(result.id);
- }, (error: ERRORDATA) => {
+ }, (error: ERRORDATA): void => {
this.isLoadingResults = false;
this.restService.handleError(error, 'post');
});
this.notifierService.notify('success', this.packagesForm.value.name + ' ' +
this.translateService.instant('PAGE.VNFPACKAGE.CREATEDSUCCESSFULLY'));
}
- this.router.navigate([packageUrl, id]).catch(() => {
+ this.router.navigate([packageUrl, id]).catch((): void => {
// Catch Navigation Error
});
}
/** Deafult template for NS and VNF Packages @private */
private packageYaml(descriptorType: string): string {
let packageYaml: {} = {};
+ const composerName: string = 'NGUI Composer';
+ const composerDefaultVersion: string = '1.0';
if (descriptorType === 'ns-package') {
packageYaml = {
- 'nsd:nsd-catalog': {
+ nsd: {
nsd: [
{
- 'short-name': this.packagesForm.value.name,
- vendor: 'OSM Composer',
- description: this.packagesForm.value.name + ' descriptor',
- vld: [],
- 'constituent-vnfd': [],
- version: '1.0',
id: this.packagesForm.value.name,
- name: this.packagesForm.value.name
+ name: this.packagesForm.value.name,
+ version: composerDefaultVersion,
+ description: this.packagesForm.value.name + ' descriptor',
+ designer: composerName,
+ df: [
+ {
+ id: 'default-df',
+ 'vnf-profile': []
+ }
+ ]
}
]
}
};
} else {
packageYaml = {
- 'vnfd:vnfd-catalog': {
- vnfd: [
+ vnfd: {
+ id: this.packagesForm.value.name,
+ 'product-name': this.packagesForm.value.name,
+ version: composerDefaultVersion,
+ description: this.packagesForm.value.name + ' descriptor',
+ provider: composerName,
+ df: [
{
- 'short-name': this.packagesForm.value.name,
- vdu: [],
- description: '',
- 'mgmt-interface': {
- cp: ''
- },
- id: this.packagesForm.value.name,
- version: '1.0',
- 'internal-vld': [],
- 'connection-point': [],
- name: this.packagesForm.value.name
+ id: 'default-df',
+ 'instantiation-level': [],
+ 'vdu-profile': []
}
- ]
+ ],
+ 'ext-cpd': [],
+ vdu: [],
+ 'sw-image-desc': [],
+ 'virtual-storage-desc': []
}
};
}
- return jsyaml.dump(packageYaml);
+ return jsyaml.dump(packageYaml, { sortKeys: true });
}
}