Add missing adapter and mac address settings for Qemu and Docker nodes

This commit is contained in:
grossmj 2025-02-05 20:02:58 +10:00
parent 10c1461d93
commit 55bc69389d
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7
7 changed files with 75 additions and 50 deletions

View File

@ -70,6 +70,7 @@ export class Properties {
qemu_path: string;
environment: string;
extra_hosts: string;
start_command: string;
replicate_network_connection_state: boolean;
memory: number;
tpm: boolean;

View File

@ -33,17 +33,27 @@
</mat-form-field>
<mat-form-field class="form-field">
<input formControlName="memory" matInput type="number" min="1" [(ngModel)]="node.properties.memory" placeholder="Maximum memory">
<input
matInput
formControlName="mac_address"
type="text"
[(ngModel)]="node.properties.mac_address"
placeholder="Base MAC"
/>
</mat-form-field>
<mat-form-field class="form-field">
<input formControlName="memory" matInput type="number" min="0" [(ngModel)]="node.properties.memory" placeholder="Maximum memory">
<span matSuffix>MB</span>
</mat-form-field>
<mat-form-field class="form-field">
<input formControlName="cpus" matInput type="number" min="1" [(ngModel)]="node.properties.cpus" placeholder="Maximum CPUs">
<input formControlName="cpus" matInput type="number" min="0" [(ngModel)]="node.properties.cpus" placeholder="Maximum CPUs">
</mat-form-field>
<button mat-button class="form-field" (click)="configureCustomAdapters()">
Configure custom adapters
</button>
<!-- <button mat-button class="form-field" (click)="configureCustomAdapters()">-->
<!-- Configure custom adapters-->
<!-- </button>-->
<mat-form-field class="select">
<mat-select

View File

@ -42,6 +42,7 @@ export class ConfiguratorDialogDockerComponent implements OnInit {
this.generalSettingsForm = this.formBuilder.group({
name: new UntypedFormControl('', Validators.required),
adapter: new UntypedFormControl('', Validators.required),
mac_address: new UntypedFormControl('', Validators.pattern(this.dockerConfigurationService.getMacAddrRegex())),
memory: new UntypedFormControl('', nonNegativeValidator.get),
cpus: new UntypedFormControl('', nonNegativeValidator.get),
startCommand: new UntypedFormControl(''),

View File

@ -152,15 +152,43 @@
</mat-tab>
<mat-tab label="Network">
<br />
<br /><mat-checkbox [(ngModel)]="node.properties.replicate_network_connection_state">
<mat-form-field class="form-field">
<input
matInput
min=0
type="number"
[(ngModel)]="node.properties.adapters"
placeholder="Adapters"
/>
</mat-form-field>
<form [formGroup]="networkSettingsForm">
<mat-form-field class="form-field">
<input
matInput
formControlName="mac_address"
type="text"
[(ngModel)]="node.properties.mac_address"
placeholder="Base MAC"
/>
</mat-form-field>
</form>
<mat-select placeholder="Type" [(ngModel)]="node.properties.adapter_type">
<mat-option *ngFor="let type of networkTypes" [value]="type.value">
{{ type.name }} ({{ type.value }})
</mat-option>
</mat-select>
<!-- <button mat-button class="form-field" (click)="setCustomAdaptersConfiguratorState(true)">-->
<!-- Configure custom adapters-->
<!-- </button>-->
<br /><br /><mat-checkbox [(ngModel)]="node.properties.replicate_network_connection_state">
Replicate network connection state
</mat-checkbox>
<app-custom-adapters-table
#customAdapters
[networkTypes]="networkTypes"
[displayedColumns]="displayedColumns"
[adapters]="node.ports"
></app-custom-adapters-table>
<!-- <app-custom-adapters-table-->
<!-- #customAdapters-->
<!-- [networkTypes]="networkTypes"-->
<!-- [displayedColumns]="displayedColumns"-->
<!-- [adapters]="node.ports"-->
<!-- ></app-custom-adapters-table>-->
</mat-tab>
<mat-tab label="Advanced">
<mat-card>

View File

@ -22,6 +22,7 @@ export class ConfiguratorDialogQemuComponent implements OnInit {
node: Node;
name: string;
generalSettingsForm: UntypedFormGroup;
networkSettingsForm: UntypedFormGroup;
consoleTypes: string[] = [];
onCloseOptions = [];
bootPriorities = [];
@ -54,6 +55,10 @@ export class ConfiguratorDialogQemuComponent implements OnInit {
name: new UntypedFormControl('', Validators.required),
ram: new UntypedFormControl('', Validators.required),
});
this.networkSettingsForm = this.formBuilder.group({
mac_address: new UntypedFormControl('', Validators.pattern(this.qemuConfigurationService.getMacAddrRegex())),
});
}
ngOnInit() {
@ -103,16 +108,16 @@ export class ConfiguratorDialogQemuComponent implements OnInit {
}
onSaveClick() {
if (this.generalSettingsForm.valid) {
this.node.custom_adapters = [];
this.customAdapters.adapters.forEach((n) => {
this.node.custom_adapters.push({
adapter_number: n.adapter_number,
adapter_type: n.adapter_type,
});
});
this.node.properties.adapters = this.node.custom_adapters.length;
if (this.generalSettingsForm.valid && this.networkSettingsForm.valid) {
// this.node.custom_adapters = [];
// this.customAdapters.adapters.forEach((n) => {
// this.node.custom_adapters.push({
// adapter_number: n.adapter_number,
// adapter_type: n.adapter_type,
// });
// });
//
// this.node.properties.adapters = this.node.custom_adapters.length;
this.nodeService.updateNodeWithCustomAdapters(this.controller, this.node).subscribe(() => {
this.toasterService.success(`Node ${this.node.name} updated.`);

View File

@ -27,4 +27,8 @@ export class DockerConfigurationService {
return consoleResolutions;
}
getMacAddrRegex() {
return /^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$/;
}
}

View File

@ -76,34 +76,6 @@ export class QemuConfigurationService {
{ value: 'vmxnet3', name: 'VMWare Paravirtualized Ethernet v3' },
];
// let networkTypes = [
// 'e1000',
// 'e1000-82544gc',
// 'e1000-82545em',
// 'e1000e',
// 'rocker',
// 'Intel Gigabit Ethernet',
// 'i82550',
// 'i82551',
// 'i82557a',
// 'i82557b',
// 'i82557c',
// 'i82558a',
// 'i82558b',
// 'i82559a',
// 'i82559b',
// 'i82559c',
// 'i82559er',
// 'i82562',
// 'i82801',
// 'ne2k_pci',
// 'pcnet',
// 'rtl8139',
// 'virtio',
// 'virtio-net-pci',
// 'vmxnet3',
// ];
return networkTypes;
}
@ -146,4 +118,8 @@ export class QemuConfigurationService {
return priorities;
}
getMacAddrRegex() {
return /^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$/;
}
}