Support for IOU appliances

This commit is contained in:
piotrpekala7 2020-06-22 15:25:02 +02:00
parent d07fad3c79
commit b0c331d054
2 changed files with 54 additions and 4 deletions

View File

@ -209,7 +209,36 @@
</div>
<div *ngIf="applianceToInstall.iou">
<div>
Server type<br/>
<mat-radio-group class="radio-group">
<mat-radio-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
<mat-radio-button class="radio-button" value="2" checked (click)="setServerType('gns3 vm')">Install the appliance on the GNS3 VM</mat-radio-button>
</mat-radio-group>
</div>
<div>
Install required files
<mat-list>
<mat-list-item *ngFor="let image of applianceToInstall.images">
<div class="list-item">
<div>
{{image.filename}}
</div>
<div>
<input
type="file"
class="non-visible"
#file2
(change)="importImage($event)"
ng2FileSelect
[uploader]="uploaderImage"/>
<button class="button" mat-raised-button (click)="file2.click()">Import</button>
<button class="button" mat-raised-button color="primary" (click)="createIouTemplate(image)">Create</button>
</div>
</div>
</mat-list-item>
</mat-list>
</div>
</div>
</mat-card>

View File

@ -18,6 +18,7 @@ import { DockerService } from '../../../services/docker.service';
import { IosTemplate } from '../../../models/templates/ios-template';
import { IosService } from '../../../services/ios.service';
import { IouService } from '../../../services/iou.service';
import { IouTemplate } from '../../../models/templates/iou-template';
@Component({
selector: 'app-new-template-dialog',
@ -238,6 +239,7 @@ export class NewTemplateDialogComponent implements OnInit {
fileReader.onloadend = () => {
if (this.applianceToInstall.qemu) emulator = 'qemu';
if (this.applianceToInstall.dynamips) emulator = 'dynamips';
if (this.applianceToInstall.iou) emulator = 'iou';
const url = this.applianceService.getUploadPath(this.server, emulator, fileName);
this.uploaderImage.queue.forEach(elem => (elem.url = url));
@ -255,8 +257,27 @@ export class NewTemplateDialogComponent implements OnInit {
window.open(image.download_url);
}
createIouTemplate () {
createIouTemplate (image: Image) {
let iouTemplate: IouTemplate = new IouTemplate();
iouTemplate.name = this.applianceToInstall.name;
iouTemplate.nvram = this.applianceToInstall.iou.nvram;
iouTemplate.ram = this.applianceToInstall.iou.ram;
iouTemplate.ethernet_adapters = this.applianceToInstall.iou.ethernet_adapters;
iouTemplate.serial_adapters = this.applianceToInstall.iou.serial_adapters;
iouTemplate.startup_config = this.applianceToInstall.iou.startup_config;
iouTemplate.builtin = this.applianceToInstall.builtin;
iouTemplate.category = this.applianceToInstall.category;
iouTemplate.default_name_format = this.applianceToInstall.port_name_format;
iouTemplate.symbol = this.applianceToInstall.symbol;
iouTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
iouTemplate.template_id = uuid();
iouTemplate.path = image.filename;
iouTemplate.template_type = 'iou';
this.iouService.addTemplate(this.server, iouTemplate).subscribe(() => {
this.toasterService.success('Template added');
this.dialogRef.close();
});
}
createIosTemplate(image: Image) {
@ -286,7 +307,7 @@ export class NewTemplateDialogComponent implements OnInit {
this.iosService.addTemplate(this.server, iosTemplate).subscribe(() => {
this.toasterService.success('Template added');
this.dialogRef.close()
this.dialogRef.close();
});
}