Merge pull request #1168 from GNS3/Remove-GNS3-VM-specific-code

Remove gns3 vm specific code
This commit is contained in:
piotrpekala7 2021-06-22 09:34:03 +02:00 committed by GitHub
commit a2085e846a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 34 additions and 499 deletions

View File

@ -24,7 +24,6 @@ import { AddIosTemplateComponent } from './components/preferences/dynamips/add-i
import { CopyIosTemplateComponent } from './components/preferences/dynamips/copy-ios-template/copy-ios-template.component';
import { IosTemplateDetailsComponent } from './components/preferences/dynamips/ios-template-details/ios-template-details.component';
import { IosTemplatesComponent } from './components/preferences/dynamips/ios-templates/ios-templates.component';
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
import { AddIouTemplateComponent } from './components/preferences/ios-on-unix/add-iou-template/add-iou-template.component';
import { CopyIouTemplateComponent } from './components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component';
import { IouTemplateDetailsComponent } from './components/preferences/ios-on-unix/iou-template-details/iou-template-details.component';
@ -88,7 +87,6 @@ const routes: Routes = [
resolve: { server: ServerResolve },
},
{ path: 'server/:server_id/preferences', component: PreferencesComponent, canActivate: [LoginGuard] },
{ path: 'server/:server_id/preferences/gns3vm', component: Gns3vmComponent, canActivate: [LoginGuard] },
// { path: 'server/:server_id/preferences/general', component: GeneralPreferencesComponent },
{ path: 'server/:server_id/preferences/builtin', component: BuiltInPreferencesComponent, canActivate: [LoginGuard] },

View File

@ -74,7 +74,6 @@ import { DynamipsPreferencesComponent } from './components/preferences/dynamips/
import { IosTemplateDetailsComponent } from './components/preferences/dynamips/ios-template-details/ios-template-details.component';
import { IosTemplatesComponent } from './components/preferences/dynamips/ios-templates/ios-templates.component';
import { GeneralPreferencesComponent } from './components/preferences/general/general-preferences.component';
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
import { AddIouTemplateComponent } from './components/preferences/ios-on-unix/add-iou-template/add-iou-template.component';
import { CopyIouTemplateComponent } from './components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component';
import { IouTemplateDetailsComponent } from './components/preferences/ios-on-unix/iou-template-details/iou-template-details.component';
@ -185,7 +184,6 @@ import { NavigationDialogComponent } from './components/projects/navigation-dial
import { ProjectsComponent } from './components/projects/projects.component';
import { SaveProjectDialogComponent } from './components/projects/save-project-dialog/save-project-dialog.component';
import { AddServerDialogComponent } from './components/servers/add-server-dialog/add-server-dialog.component';
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
import { ServerDiscoveryComponent } from './components/servers/server-discovery/server-discovery.component';
import { ServersComponent } from './components/servers/servers.component';
import { ConsoleComponent } from './components/settings/console/console.component';
@ -221,7 +219,6 @@ import { DockerConfigurationService } from './services/docker-configuration.serv
import { DockerService } from './services/docker.service';
import { DrawingService } from './services/drawing.service';
import { ExternalSoftwareDefinitionService } from './services/external-software-definition.service';
import { Gns3vmService } from './services/gns3vm.service';
import { GoogleAnalyticsService } from './services/google-analytics.service';
import { HttpServer, ServerErrorHandler } from './services/http-server.service';
import { InfoService } from './services/info.service';
@ -436,8 +433,6 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
AlignVerticallyActionComponent,
ConfirmationBottomSheetComponent,
ConfigDialogComponent,
Gns3vmComponent,
ConfigureGns3VMDialogComponent,
ImportApplianceComponent,
DirectLinkComponent,
SystemStatusComponent,
@ -546,7 +541,6 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
ComputeService,
PacketCaptureService,
NotificationService,
Gns3vmService,
ThemeService,
GoogleAnalyticsService,
NodeConsoleService,
@ -579,7 +573,6 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
InfoDialogComponent,
ChangeSymbolDialogComponent,
EditProjectDialogComponent,
ConfigureGns3VMDialogComponent,
ConfiguratorDialogVpcsComponent,
ConfiguratorDialogEthernetHubComponent,
ConfiguratorDialogEthernetSwitchComponent,

View File

@ -10,13 +10,6 @@
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run the cloud node locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run the cloud node on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
<form [formGroup]="formGroup">

View File

@ -20,9 +20,6 @@ export class CloudNodesAddTemplateComponent implements OnInit {
server: Server;
templateName: string = '';
formGroup: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -44,19 +41,11 @@ export class CloudNodesAddTemplateComponent implements OnInit {
const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -75,7 +64,7 @@ export class CloudNodesAddTemplateComponent implements OnInit {
cloudTemplate.template_id = uuid();
cloudTemplate.name = this.formGroup.get('templateName').value;
cloudTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
cloudTemplate.compute_id = 'local';
this.builtInTemplatesService.addTemplate(this.server, cloudTemplate).subscribe((cloudNodeTemplate) => {
this.goBack();

View File

@ -10,13 +10,6 @@
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run the Ethernet Hub locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run the Ethernet Hub on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
<form [formGroup]="formGroup">

View File

@ -20,9 +20,6 @@ export class EthernetHubsAddTemplateComponent implements OnInit {
server: Server;
templateName: string = '';
formGroup: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -45,19 +42,11 @@ export class EthernetHubsAddTemplateComponent implements OnInit {
const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -76,7 +65,7 @@ export class EthernetHubsAddTemplateComponent implements OnInit {
ethernetHubTemplate.template_id = uuid();
ethernetHubTemplate.name = this.formGroup.get('templateName').value;
ethernetHubTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
ethernetHubTemplate.compute_id = 'local';
for (let i = 0; i < this.formGroup.get('numberOfPorts').value; i++) {
ethernetHubTemplate.ports_mapping.push({

View File

@ -10,13 +10,6 @@
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run the Ethernet switch locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run the Ethernet switch on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
<form [formGroup]="formGroup">

View File

@ -20,9 +20,6 @@ export class EthernetSwitchesAddTemplateComponent implements OnInit {
server: Server;
templateName: string = '';
formGroup: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -45,10 +42,6 @@ export class EthernetSwitchesAddTemplateComponent implements OnInit {
const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
@ -57,11 +50,7 @@ export class EthernetSwitchesAddTemplateComponent implements OnInit {
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -76,7 +65,7 @@ export class EthernetSwitchesAddTemplateComponent implements OnInit {
ethernetSwitchTemplate.template_id = uuid();
ethernetSwitchTemplate.name = this.formGroup.get('templateName').value;
ethernetSwitchTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
ethernetSwitchTemplate.compute_id = 'local';
for (let i = 0; i < this.formGroup.get('numberOfPorts').value; i++) {
ethernetSwitchTemplate.ports_mapping.push({

View File

@ -7,19 +7,12 @@
<div class="default-content">
<div class="container mat-elevation-z8">
<mat-vertical-stepper [linear]="true">
<mat-step label="Server type" [completed]="isGns3VmChosen || isLocalComputerChosen">
<mat-step label="Server type" [completed]="isLocalComputerChosen">
<mat-radio-group class="radio-group">
<!-- <mat-radio-button class="radio-button" value="1" (click)="setServerType('remote computer')">Run this Docker container on a remote computer</mat-radio-button> -->
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run this Docker container locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run this Docker container on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</mat-step>

View File

@ -30,9 +30,6 @@ export class AddDockerTemplateComponent implements OnInit {
virtualMachineForm: FormGroup;
containerNameForm: FormGroup;
networkAdaptersForm: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -72,10 +69,6 @@ export class AddDockerTemplateComponent implements OnInit {
this.dockerTemplate = dockerTemplate;
});
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
this.dockerService.getImages(server).subscribe((images) => {
this.dockerImages = images;
});
@ -83,11 +76,7 @@ export class AddDockerTemplateComponent implements OnInit {
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -116,7 +105,7 @@ export class AddDockerTemplateComponent implements OnInit {
this.dockerTemplate.name = this.containerNameForm.get('templateName').value;
this.dockerTemplate.adapters = +this.networkAdaptersForm.get('adapters').value;
this.dockerTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
this.dockerTemplate.compute_id = 'local';
this.dockerService.addTemplate(this.server, this.dockerTemplate).subscribe((template: DockerTemplate) => {
this.goBack();

View File

@ -7,18 +7,11 @@
<div class="default-content" *ngIf="iosTemplate">
<div class="container mat-elevation-z8">
<mat-vertical-stepper [linear]="true">
<mat-step label="Server type" [completed]="isGns3VmChosen || isLocalComputerChosen">
<mat-step label="Server type" [completed]="isLocalComputerChosen">
<mat-radio-group class="radio-group">
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run this IOS router locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run this IOS router on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</mat-step>

View File

@ -45,9 +45,6 @@ export class AddIosTemplateComponent implements OnInit {
ciscoUrl: string = 'https://cfn.cloudapps.cisco.com/ITDIT/CFN/jsp/SearchBySoftware.jsp';
uploader: FileUploader;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -114,19 +111,11 @@ export class AddIosTemplateComponent implements OnInit {
this.chassis = this.iosConfigurationService.getChassis();
this.defaultRam = this.iosConfigurationService.getDefaultRamSettings();
});
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -174,8 +163,7 @@ export class AddIosTemplateComponent implements OnInit {
if (this.networkAdaptersForTemplate.length > 0) this.completeAdaptersData();
if (this.networkModulesForTemplate.length > 0) this.completeModulesData();
this.iosTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
this.iosTemplate.compute_id = 'local';
this.iosService.addTemplate(this.server, this.iosTemplate).subscribe((template: IosTemplate) => {
this.goBack();

View File

@ -1,66 +0,0 @@
<div class="content">
<div class="default-header">
<div class="row">
<h1 class="col">GNS3 VM preferences</h1>
</div>
</div>
<div class="default-content">
<mat-card class="matCard" *ngIf="gns3vm">
<mat-checkbox [ngModelOptions]="{ standalone: true }" [(ngModel)]="gns3vm.enable">
Enable the GNS3 VM
</mat-checkbox>
<mat-form-field class="select">
<mat-select
(selectionChange)="changeVmEngine($event)"
[ngModelOptions]="{ standalone: true }"
placeholder="Virtualization engine"
[(ngModel)]="gns3vm.engine"
>
<mat-option *ngFor="let engine of vmEngines" [value]="engine.engine_id">
{{ engine.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="select">
<mat-select [ngModelOptions]="{ standalone: true }" placeholder="VM name" [(ngModel)]="gns3vm.vmname">
<mat-option *ngFor="let vm of vms" [value]="vm.vmname">
{{ vm.vmname }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-checkbox
*ngIf="gns3vm.engine === 'virtualbox' || gns3vm.engine === 'vmware'"
[ngModelOptions]="{ standalone: true }"
[(ngModel)]="gns3vm.headless"
>
Run the VM in headless mode
</mat-checkbox>
<form *ngIf="gns3vm.engine !== 'remote'" [formGroup]="vmForm">
<mat-form-field *ngIf="gns3vm.engine === 'virtualbox' || gns3vm.engine === 'vmware'" class="form-field">
<input matInput type="number" [ngModelOptions]="{ standalone: true }" [(ngModel)]="port" placeholder="Port" />
</mat-form-field>
<mat-form-field class="form-field">
<input matInput formControlName="ram" type="number" placeholder="RAM" />
<span matSuffix>MB</span>
</mat-form-field>
<mat-form-field class="form-field">
<input matInput formControlName="vcpus" type="number" placeholder="vCPUs" />
</mat-form-field>
</form>
<mat-radio-group
*ngIf="gns3vm.engine !== 'remote'"
[(ngModel)]="gns3vm.when_exit"
aria-label="Actions when closing GNS3"
class="radio-selection"
>
<mat-radio-button value="keep" (click)="setCloseAction('keep')">keep the GNS3 VM running</mat-radio-button>
<mat-radio-button value="suspend" (click)="setCloseAction('suspend')">suspend the GNS3 VM</mat-radio-button>
<mat-radio-button value="stop" (click)="setCloseAction('stop')">stop the GNS3 VM</mat-radio-button>
</mat-radio-group>
</mat-card>
<div class="buttons-bar">
<button mat-button class="cancel-button" (click)="goBack()">Cancel</button>
<button mat-raised-button color="primary" (click)="save()">Save</button>
</div>
</div>
</div>

View File

@ -1,12 +0,0 @@
.form-field {
width: 100%;
}
.select {
width: 100%;
}
.radio-selection {
display: flex;
justify-content: space-between;
}

View File

@ -1,89 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Gns3vm } from '../../../models/gns3vm/gns3vm';
import { Gns3vmEngine } from '../../../models/gns3vm/gns3vmEngine';
import { VM } from '../../../models/gns3vm/vm';
import { Server } from '../../../models/server';
import { Gns3vmService } from '../../../services/gns3vm.service';
import { ServerService } from '../../../services/server.service';
import { ToasterService } from '../../../services/toaster.service';
@Component({
selector: 'app-gns3vm',
templateUrl: './gns3vm.component.html',
styleUrls: ['./gns3vm.component.scss'],
})
export class Gns3vmComponent implements OnInit {
public server: Server;
public gns3vm: Gns3vm;
public vmEngines: Gns3vmEngine[];
public vms: VM[] = [];
public vmForm: FormGroup;
public port: number;
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
private gns3vmService: Gns3vmService,
private router: Router,
private formBuilder: FormBuilder,
private toasterService: ToasterService
) {
this.vmForm = this.formBuilder.group({
ram: new FormControl(null, [Validators.required]),
vcpus: new FormControl(null, [Validators.required]),
});
}
ngOnInit() {
const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.gns3vmService.getGns3vm(this.server).subscribe((vm: Gns3vm) => {
this.gns3vm = vm;
this.vmForm.controls['ram'].setValue(this.gns3vm.ram);
this.vmForm.controls['vcpus'].setValue(this.gns3vm.vcpus);
if (this.gns3vm.port) this.port = this.gns3vm.port;
this.gns3vmService.getGns3vmEngines(this.server).subscribe((vmEngines: Gns3vmEngine[]) => {
this.vmEngines = vmEngines;
});
this.gns3vmService.getVms(this.server, this.gns3vm.engine).subscribe((vms: VM[]) => {
this.vms = vms;
});
});
});
}
goBack() {
this.router.navigate(['/server', this.server.id, 'preferences']);
}
setCloseAction(action: string) {
this.gns3vm.when_exit = action;
}
changeVmEngine(event) {
this.gns3vmService.getVms(this.server, event.value).subscribe(
(vms: VM[]) => {
this.vms = vms;
},
(error) => {}
);
}
save() {
if ((this.vmForm.valid && this.gns3vm.vmname) || (this.gns3vm.engine === 'remote' && this.gns3vm.vmname)) {
this.gns3vm.ram = this.vmForm.get('ram').value;
this.gns3vm.vcpus = this.vmForm.get('vcpus').value;
if (this.port) this.gns3vm.port = this.port;
this.gns3vmService.updateGns3vm(this.server, this.gns3vm).subscribe(() => {
this.toasterService.success('GNS3 VM updated.');
});
this.goBack();
} else {
this.toasterService.error('Fill all required fields with correct values.');
}
}
}

View File

@ -7,18 +7,11 @@
<div class="default-content">
<div class="container mat-elevation-z8">
<mat-vertical-stepper [linear]="true">
<mat-step label="Server type" [completed]="isGns3VmChosen || isLocalComputerChosen">
<mat-step label="Server type" [completed]="isLocalComputerChosen">
<mat-radio-group class="radio-group">
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run this IOU device locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run this IOU device on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</mat-step>

View File

@ -30,9 +30,6 @@ export class AddIouTemplateComponent implements OnInit {
templateNameForm: FormGroup;
imageForm: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -82,10 +79,6 @@ export class AddIouTemplateComponent implements OnInit {
this.templateMocksService.getIouTemplate().subscribe((iouTemplate: IouTemplate) => {
this.iouTemplate = iouTemplate;
});
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
@ -96,11 +89,7 @@ export class AddIouTemplateComponent implements OnInit {
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -134,7 +123,7 @@ export class AddIouTemplateComponent implements OnInit {
this.iouTemplate.template_id = uuid();
this.iouTemplate.name = this.templateNameForm.get('templateName').value;
if (this.newImageSelected) this.iouTemplate.path = this.imageForm.get('imageName').value;
this.iouTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
this.iouTemplate.compute_id = 'local';
if (this.selectedType === 'L2 image') {
this.iouTemplate.ethernet_adapters = 4;

View File

@ -7,7 +7,6 @@
<div class="default-content">
<div class="listcontainer mat-elevation-z8">
<mat-nav-list>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/gns3vm"> GNS3 VM </mat-list-item>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/builtin"> Built-in </mat-list-item>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/dynamips/templates"> Dynamips </mat-list-item>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/iou/templates"> IOS on Unix </mat-list-item>

View File

@ -7,18 +7,11 @@
<div class="default-content">
<div class="container mat-elevation-z8">
<mat-vertical-stepper [linear]="true">
<mat-step label="Server type" [completed]="isGns3VmChosen || isLocalComputerChosen">
<mat-step label="Server type" [completed]="isLocalComputerChosen">
<mat-radio-group class="radio-group">
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run this QEMU VM locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run this QEMU VM on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</mat-step>

View File

@ -36,9 +36,6 @@ export class AddQemuVmTemplateComponent implements OnInit {
nameForm: FormGroup;
memoryForm: FormGroup;
diskForm: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -105,19 +102,11 @@ export class AddQemuVmTemplateComponent implements OnInit {
});
this.consoleTypes = this.configurationService.getConsoleTypes();
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -154,7 +143,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
}
this.qemuTemplate.template_id = uuid();
this.qemuTemplate.name = this.nameForm.get('templateName').value;
this.qemuTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
this.qemuTemplate.compute_id = 'local';
this.qemuService.addTemplate(this.server, this.qemuTemplate).subscribe((template: QemuTemplate) => {
this.goBack();

View File

@ -10,13 +10,6 @@
<mat-radio-button class="radio-button" value="1" (click)="setServerType('local')" checked
>Run the VPCS node locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Run the VPCS node on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
<form [formGroup]="templateNameForm">

View File

@ -20,9 +20,6 @@ export class AddVpcsTemplateComponent implements OnInit {
server: Server;
templateName: string = '';
templateNameForm: FormGroup;
isGns3VmAvailable: boolean = false;
isGns3VmChosen: boolean = false;
isLocalComputerChosen: boolean = true;
constructor(
@ -44,19 +41,11 @@ export class AddVpcsTemplateComponent implements OnInit {
const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.computeService.getComputes(server).subscribe((computes: Compute[]) => {
if (computes.filter((compute) => compute.compute_id === 'vm').length > 0) this.isGns3VmAvailable = true;
});
});
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm' && this.isGns3VmAvailable) {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
if (serverType === 'local') {
this.isLocalComputerChosen = true;
}
}
@ -76,8 +65,8 @@ export class AddVpcsTemplateComponent implements OnInit {
});
(vpcsTemplate.template_id = uuid()),
(vpcsTemplate.name = this.templateName),
(vpcsTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local');
(vpcsTemplate.name = this.templateName),
(vpcsTemplate.compute_id = 'local');
this.vpcsService.addTemplate(this.server, vpcsTemplate).subscribe(() => {
this.goBack();

View File

@ -129,31 +129,23 @@
<mat-step *ngIf="applianceToInstall">
<ng-template matStepLabel>{{ secondActionTitle }}</ng-template>
<mat-card [hidden]="!(!isLinuxPlatform && !isGns3VmAvailable && !applianceToInstall.dynamips)">
<mat-card [hidden]="!(!isLinuxPlatform && !applianceToInstall.dynamips)">
Please configure GNS3 VM to install selected appliance
</mat-card>
<mat-card [hidden]="!(isLinuxPlatform || isGns3VmAvailable || applianceToInstall.dynamips)">
<mat-card [hidden]="!(isLinuxPlatform || applianceToInstall.dynamips)">
<div *ngIf="applianceToInstall.qemu">
<div>
Server type<br />
<mat-radio-group class="radio-group">
<mat-radio-button
[disabled]="!isLinuxPlatform"
[checked]="!isGns3VmChosen"
[checked]="isLocalComputerChosen"
class="radio-button"
value="1"
(click)="setServerType('local')"
>Install the appliance locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
[checked]="isGns3VmChosen"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Install the appliance on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</div>
<div>
@ -302,20 +294,12 @@
<mat-radio-group class="radio-group">
<mat-radio-button
[disabled]="!isLinuxPlatform"
[checked]="!isGns3VmChosen"
[checked]="isLocalComputerChosen"
class="radio-button"
value="1"
(click)="setServerType('local')"
>Install the appliance locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
[checked]="isGns3VmChosen"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Install the appliance on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</div>
<button mat-raised-button color="primary" (click)="createDockerTemplate()" class="create-button">
@ -328,20 +312,12 @@
Server type<br />
<mat-radio-group class="radio-group">
<mat-radio-button
[checked]="!isGns3VmChosen"
[checked]="isLocalComputerChosen"
class="radio-button"
value="1"
(click)="setServerType('local')"
>Install the appliance locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
[checked]="isGns3VmChosen"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Install the appliance on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</div>
<div>
@ -386,20 +362,12 @@
<mat-radio-group class="radio-group">
<mat-radio-button
[disabled]="!isLinuxPlatform"
[checked]="!isGns3VmChosen"
[checked]="isLocalComputerChosen"
class="radio-button"
value="1"
(click)="setServerType('local')"
>Install the appliance locally</mat-radio-button
>
<mat-radio-button
[disabled]="!isGns3VmAvailable"
[checked]="isGns3VmChosen"
class="radio-button"
value="2"
(click)="setServerType('gns3 vm')"
>Install the appliance on the GNS3 VM</mat-radio-button
>
</mat-radio-group>
</div>
<div>

View File

@ -58,11 +58,7 @@ export class NewTemplateDialogComponent implements OnInit {
public appliances: Appliance[] = [];
public applianceToInstall: Appliance;
public selectedImages: any[];
public isGns3VmAvailable = false;
public isLinuxPlatform = false;
private isGns3VmChosen = false;
private isLocalComputerChosen = false;
public qemuBinaries: QemuBinary[] = [];
@ -106,10 +102,6 @@ export class NewTemplateDialogComponent implements OnInit {
this.computeService.getComputes(this.server).subscribe((computes) => {
computes.forEach((compute) => {
if (compute.compute_id === 'vm') {
this.isGns3VmAvailable = true;
this.isGns3VmChosen = true;
}
if (compute.capabilities.platform === 'linux') this.isLinuxPlatform = true;
});
});
@ -283,13 +275,7 @@ export class NewTemplateDialogComponent implements OnInit {
}
setServerType(serverType: string) {
if (serverType === 'gns3 vm') {
this.isGns3VmChosen = true;
this.isLocalComputerChosen = false;
} else {
this.isGns3VmChosen = false;
this.isLocalComputerChosen = true;
}
this.isLocalComputerChosen = true;
}
sortData(sort: Sort) {
@ -487,7 +473,7 @@ export class NewTemplateDialogComponent implements OnInit {
iouTemplate.category = this.getCategory();
iouTemplate.default_name_format = this.applianceToInstall.port_name_format;
iouTemplate.symbol = this.applianceToInstall.symbol;
iouTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
iouTemplate.compute_id = 'local';
iouTemplate.template_id = uuid();
iouTemplate.path = image.filename;
iouTemplate.template_type = 'iou';
@ -536,7 +522,7 @@ export class NewTemplateDialogComponent implements OnInit {
iosTemplate.category = this.getCategory();
iosTemplate.default_name_format = this.applianceToInstall.port_name_format;
iosTemplate.symbol = this.applianceToInstall.symbol;
iosTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
iosTemplate.compute_id = 'local';
iosTemplate.template_id = uuid();
iosTemplate.image = image.filename;
iosTemplate.template_type = 'dynamips';
@ -574,7 +560,7 @@ export class NewTemplateDialogComponent implements OnInit {
dockerTemplate.category = this.getCategory();
dockerTemplate.default_name_format = this.applianceToInstall.port_name_format;
dockerTemplate.symbol = this.applianceToInstall.symbol;
dockerTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
dockerTemplate.compute_id = 'local';
dockerTemplate.template_id = uuid();
dockerTemplate.image = this.applianceToInstall.docker.image;
dockerTemplate.template_type = 'docker';
@ -631,7 +617,7 @@ export class NewTemplateDialogComponent implements OnInit {
qemuTemplate.port_name_format = this.applianceToInstall.port_name_format;
qemuTemplate.symbol = this.applianceToInstall.symbol;
qemuTemplate.qemu_path = this.selectedBinary.path;
qemuTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
qemuTemplate.compute_id = 'local';
qemuTemplate.template_id = uuid();
qemuTemplate.hda_disk_image = version.images.hda_disk_image;
qemuTemplate.hdb_disk_image = version.images.hdb_disk_image;

View File

@ -24,7 +24,6 @@ import { ServerService } from '../../services/server.service';
import { MockedServerService } from '../../services/server.service.spec';
import { Settings, SettingsService } from '../../services/settings.service';
import { ToasterService } from '../../services/toaster.service';
import { ConfigureGns3VMDialogComponent } from '../servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
import { ProjectsComponent } from './projects.component';
@ -74,11 +73,11 @@ xdescribe('ProjectsComponent', () => {
{ provide: ElectronService, useValue: electronService },
ProgressService,
],
declarations: [ProjectsComponent, ChooseNameDialogComponent, ConfigureGns3VMDialogComponent, ProjectsFilter],
declarations: [ProjectsComponent, ChooseNameDialogComponent, ProjectsFilter],
schemas: [NO_ERRORS_SCHEMA],
})
.overrideModule(BrowserDynamicTestingModule, {
set: { entryComponents: [ChooseNameDialogComponent, ConfigureGns3VMDialogComponent] },
set: { entryComponents: [ChooseNameDialogComponent] },
})
.compileComponents();

View File

@ -14,7 +14,6 @@ import { ProjectService } from '../../services/project.service';
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
import { Settings, SettingsService } from '../../services/settings.service';
import { ToasterService } from '../../services/toaster.service';
import { ConfigureGns3VMDialogComponent } from '../servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
import { AddBlankProjectDialogComponent } from './add-blank-project-dialog/add-blank-project-dialog.component';
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
import { ConfirmationBottomSheetComponent } from './confirmation-bottomsheet/confirmation-bottomsheet.component';
@ -64,23 +63,6 @@ export class ProjectsComponent implements OnInit {
this.settings = this.settingsService.getAll();
this.projectService.projectListSubject.subscribe(() => this.refresh());
let gns3vmConfig = localStorage.getItem('gns3vmConfig');
if (this.electronService.isElectronApp && gns3vmConfig !== 'configured') {
const dialogRef = this.dialog.open(ConfigureGns3VMDialogComponent, {
width: '350px',
height: '120px',
autoFocus: false,
disableClose: true,
});
dialogRef.afterClosed().subscribe((answer: boolean) => {
if (answer) {
localStorage.setItem('gns3vmConfig', 'configured');
this.router.navigate(['/server', this.server.id, 'preferences', 'gns3vm']);
}
});
}
}
goToPreferences() {

View File

@ -1,7 +0,0 @@
<span class="message">{{ message }}</span>
<div mat-dialog-actions>
<button mat-button class="cancelButton" (click)="onNoClick()" color="accent">No</button>
<button mat-button class="confirmButton" (click)="onYesClick()" tabindex="2" mat-raised-button color="primary">
Yes
</button>
</div>

View File

@ -1,22 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'app-configure-gns3-vm-dialog',
templateUrl: 'configure-gns3vm-dialog.component.html',
styleUrls: ['configure-gns3vm-dialog.component.scss'],
})
export class ConfigureGns3VMDialogComponent implements OnInit {
public message: string = 'Do you want to configure GNS3 VM?';
constructor(public dialogRef: MatDialogRef<ConfigureGns3VMDialogComponent>) {}
ngOnInit() {}
onNoClick(): void {
this.dialogRef.close(false);
}
onYesClick(): void {
this.dialogRef.close(true);
}
}

View File

@ -1,10 +0,0 @@
export interface Gns3vm {
enable: boolean;
engine: string;
headless: boolean;
port: number;
ram: number;
vcpus: number;
vmname: string;
when_exit: string;
}

View File

@ -1,8 +0,0 @@
export interface Gns3vmEngine {
description: string;
engine_id: string;
name: string;
support_headless: boolean;
support_ram: boolean;
support_when_exit: boolean;
}

View File

@ -1,3 +0,0 @@
export interface VM {
vmname: string;
}

View File

@ -1,28 +0,0 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Gns3vm } from '../models/gns3vm/gns3vm';
import { Gns3vmEngine } from '../models/gns3vm/gns3vmEngine';
import { VM } from '../models/gns3vm/vm';
import { Server } from '../models/server';
import { HttpServer } from './http-server.service';
@Injectable()
export class Gns3vmService {
constructor(private httpServer: HttpServer) {}
getGns3vm(server: Server): Observable<Gns3vm> {
return this.httpServer.get<Gns3vm>(server, '/gns3vm') as Observable<Gns3vm>;
}
updateGns3vm(server: Server, gns3vm: Gns3vm): Observable<Gns3vm> {
return this.httpServer.put<Gns3vm>(server, `/gns3vm`, gns3vm) as Observable<Gns3vm>;
}
getGns3vmEngines(server: Server): Observable<Gns3vmEngine[]> {
return this.httpServer.get<Gns3vmEngine[]>(server, '/gns3vm/engines') as Observable<Gns3vmEngine[]>;
}
getVms(server: Server, engine: string): Observable<VM[]> {
return this.httpServer.get<VM[]>(server, `/gns3vm/engines/${engine}/vms`);
}
}