Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 1339 #1404

Open
wants to merge 7 commits into
base: master-3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
<table class="table" mat-table [dataSource]="adapters">
<table class="table" mat-table [dataSource]="adapters">
<ng-container matColumnDef="adapter_number">
<th mat-header-cell *matHeaderCellDef>Adapter number</th>
<td mat-cell *matCellDef="let element">Adapter {{ element.adapter_number }}</td>
</ng-container>

<ng-container matColumnDef="port_name">
<th mat-header-cell *matHeaderCellDef>Port name</th>
<td mat-cell *matCellDef="let element">Ethernet {{ element.adapter_number }}</td>
<td mat-cell *matCellDef="let element">{{ element.short_name || element.port_name }}</td>
</ng-container>

<ng-container matColumnDef="adapter_type">
<th mat-header-cell *matHeaderCellDef>Adapter type</th>
<td mat-cell *matCellDef="let element; let i = index">
<td mat-cell *matCellDef="let element; let i = index" style="margin-right: 10px;">
<mat-select placeholder="Type" [(ngModel)]="element.adapter_type">
<mat-option *ngFor="let type of networkTypes" [value]="type.value">
{{ type.name }}
{{type.name}} ({{type.value}})
</mat-option>
</mat-select>
</td>
</ng-container>
<ng-container matColumnDef="mac_address">
<th mat-header-cell *matHeaderCellDef>MAC address</th>
<td mat-cell *matCellDef="let element">{{ element.mac_address }}</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>Actions</th>
<td mat-cell *matCellDef="let element">
<button mat-icon-button matTooltip="Delete adapter" matTooltipClass="custom-tooltip" (click)="delete(element)">
<mat-icon aria-label="Delete adapter">delete</mat-icon>
<mat-icon aria-label="Delete adapter">delete</mat-icon>
</button>
</td>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class CustomAdaptersTableComponent {
let adapter: CustomAdapter = {
adapter_number: this.adapters.length,
adapter_type: this.networkTypes[0],
mac_address:null,
port_name:null
};
this.adapters = this.adapters.concat([adapter]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export class CustomAdaptersComponent {
this.adapters.push({
adapter_number: n.adapter_number,
adapter_type: n.adapter_type,
mac_address:n.mac_address,
port_name:n.port_name
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { QemuService } from '../../../../services/qemu.service';
import { ControllerService } from '../../../../services/controller.service';
import { TemplateMocksService } from '../../../../services/template-mocks.service';
import { ToasterService } from '../../../../services/toaster.service';
import { CustomAdapter } from '@models/qemu/qemu-custom-adapter';

@Component({
selector: 'app-add-qemu-virtual-machine-template',
Expand Down Expand Up @@ -175,7 +176,13 @@ export class AddQemuVmTemplateComponent implements OnInit {
this.qemuTemplate.template_id = uuid();
this.qemuTemplate.name = this.nameForm.get('templateName').value;
this.qemuTemplate.compute_id = 'local';

// let adapter: CustomAdapter = {
// adapter_number: this.qemuTemplate.adapters,
// adapter_type:this.qemuTemplate.adapter_type ,
// mac_address:null,
// port_name:this.qemuTemplate.port_name_format
// };
// this.qemuTemplate.custom_adapters = this.qemuTemplate.custom_adapters.concat([adapter]);
this.qemuService.addTemplate(this.controller, this.qemuTemplate).subscribe((template: QemuTemplate) => {
this.goBack();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ export class QemuVmTemplateDetailsComponent implements OnInit {
this.fillCustomAdapters();
this.customAdaptersConfigurator.numberOfAdapters = this.qemuTemplate.adapters;
this.customAdaptersConfigurator.adapters = [];
this.qemuTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
this.qemuTemplate.custom_adapters.forEach((adapter: CustomAdapter,i) => {
this.customAdaptersConfigurator.adapters.push({
adapter_number: adapter.adapter_number,
adapter_type: adapter.adapter_type,
mac_address:null,
port_name:this.qemuTemplate.port_name_format +'/'+ `${i}`
});
});
}
Expand All @@ -118,16 +120,18 @@ export class QemuVmTemplateDetailsComponent implements OnInit {
}

fillCustomAdapters() {

let copyOfAdapters = this.qemuTemplate.custom_adapters ? this.qemuTemplate.custom_adapters : [];
this.qemuTemplate.custom_adapters = [];

for (let i = 0; i < this.qemuTemplate.adapters; i++) {
if (copyOfAdapters[i]) {
this.qemuTemplate.custom_adapters.push(copyOfAdapters[i]);
} else {
this.qemuTemplate.custom_adapters.push({
adapter_number: i,
adapter_type: 'e1000',
adapter_type: this.qemuTemplate.adapter_type,
mac_address:null,
port_name:this.qemuTemplate.port_name_format.replace(/[0-9]/g,`${i}`)
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export class VirtualBoxTemplateDetailsComponent implements OnInit {
this.customAdaptersConfigurator.adapters.push({
adapter_number: adapter.adapter_number,
adapter_type: adapter.adapter_type,
mac_address:adapter.mac_address,
port_name:adapter.port_name

});
});
}
Expand All @@ -109,6 +112,8 @@ export class VirtualBoxTemplateDetailsComponent implements OnInit {
this.virtualBoxTemplate.custom_adapters.push({
adapter_number: i,
adapter_type: 'e1000',
mac_address:'',
port_name:''
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export class VmwareTemplateDetailsComponent implements OnInit {
this.customAdaptersConfigurator.adapters.push({
adapter_number: adapter.adapter_number,
adapter_type: adapter.adapter_type,
mac_address:adapter.mac_address,
port_name:adapter.port_name
});
});
}
Expand All @@ -115,6 +117,8 @@ export class VmwareTemplateDetailsComponent implements OnInit {
this.vmwareTemplate.custom_adapters.push({
adapter_number: i,
adapter_type: 'e1000',
mac_address:'',
port_name:''
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<h1 mat-dialog-title>Configure custom adapters for node {{ node.name }}</h1>

<div *ngIf="node" class="modal-form-container">
Expand All @@ -8,11 +9,11 @@ <h1 mat-dialog-title>Configure custom adapters for node {{ node.name }}</h1>

<div>
<mat-list>
<mat-list-item *ngFor="let adapter of adapters; index as i">
<mat-list-item *ngFor="let adapter of node.ports; index as i">
<div class="header">
<span class="column"> Adapter {{ adapter.adapter_number }} </span>
<span class="column">
<input matInput type="text" [(ngModel)]="adapter.port_name" placeholder="Edit port name" />
<input matInput type="text" [(ngModel)]="adapter.short_name " placeholder="Edit port name" readonly/>
</span>
</div>
</mat-list-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ConfiguratorDialogQemuComponent implements OnInit {
bootPriorities = [];
diskInterfaces: string[] = [];

displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type', 'actions'];
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type','mac_address','actions'];
networkTypes = [];
qemuImages: QemuImage[] = [];
selectPlatform: string[] = [];
Expand Down Expand Up @@ -105,10 +105,12 @@ export class ConfiguratorDialogQemuComponent implements OnInit {
onSaveClick() {
if (this.generalSettingsForm.valid) {
this.node.custom_adapters = [];
this.customAdapters.adapters.forEach((n) => {
this.customAdapters.adapters.forEach((n,i) => {
this.node.custom_adapters.push({
adapter_number: n.adapter_number,
adapter_type: n.adapter_type,
mac_address: n.mac_address ?? n.mac_address,
port_name: n.port_name ?? this.node.port_name_format.replace(/[0-9]/g,`${i}`)
});
});

Expand Down
3 changes: 3 additions & 0 deletions src/app/models/qemu/qemu-custom-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export class CustomAdapter {
adapter_number: number;
adapter_type: string;
mac_address:string;
port_name: string;
}