Skip to content

Commit

Permalink
NAS-133730 / 25.04 / Add VNC Password field to Instances (#11379)
Browse files Browse the repository at this point in the history
  • Loading branch information
denysbutenko authored Jan 24, 2025
1 parent 0176b03 commit eca5b0a
Show file tree
Hide file tree
Showing 96 changed files with 238 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/app/interfaces/virtualization.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface VirtualizationInstance {
image: VirtualizationImage;
vnc_enabled: boolean;
vnc_port: number | null;
vnc_password: string | null;
}

export interface VirtualizationAlias {
Expand Down Expand Up @@ -66,6 +67,7 @@ export interface CreateVirtualizationInstance {
* Value must be greater or equal to 5900 and lesser or equal to 65535
*/
vnc_port?: number | null;
vnc_password?: string | null;
}

export interface UpdateVirtualizationInstance {
Expand All @@ -75,6 +77,7 @@ export interface UpdateVirtualizationInstance {
memory?: number;
enable_vnc?: boolean;
vnc_port?: number | null;
vnc_password?: string | null;
}

export type VirtualizationDevice =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,28 @@
@if (isVm) {
<ix-fieldset [title]="'VNC' | translate">

<ix-checkbox
formControlName="enable_vnc"
[label]="'Enable VNC' | translate"
[matTooltip]="isStopped ? '' : ('Instance must be stopped to update VNC.' | translate)"
></ix-checkbox>
<div [matTooltip]="isStopped ? '' : ('Instance must be stopped to update VNC.' | translate)">
<ix-checkbox
formControlName="enable_vnc"
[label]="'Enable VNC' | translate"
></ix-checkbox>

@if (form.value.enable_vnc) {
<ix-input
formControlName="vnc_port"
type="number"
[label]="'VNC Port' | translate"
[required]="true"
></ix-input>
}
@if (form.getRawValue().enable_vnc) {
<ix-input
formControlName="vnc_port"
type="number"
[label]="'VNC Port' | translate"
[required]="true"
></ix-input>

<ix-input
formControlName="vnc_password"
type="password"
[label]="'VNC Password' | translate"
[hint]="'VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.' | translate"
></ix-input>
}
</div>
</ix-fieldset>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('InstanceEditFormComponent', () => {
vnc_enabled: true,
vnc_port: 9001,
status: VirtualizationStatus.Stopped,
vnc_password: null,
} as VirtualizationInstance;

const createComponent = createComponentFactory({
Expand All @@ -59,6 +60,7 @@ describe('InstanceEditFormComponent', () => {
environment: {},
enable_vnc: true,
vnc_port: 9000,
vnc_password: 'testing',
},
})),
),
Expand All @@ -85,6 +87,7 @@ describe('InstanceEditFormComponent', () => {
'CPU Configuration': '1-3',
'Memory Size': '2 GiB',
'VNC Port': '9001',
'VNC Password': '',
});
});

Expand All @@ -94,6 +97,7 @@ describe('InstanceEditFormComponent', () => {
'CPU Configuration': '2-5',
'Memory Size': '1 GiB',
'VNC Port': 9000,
'VNC Password': 'testing',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
Expand All @@ -106,6 +110,7 @@ describe('InstanceEditFormComponent', () => {
environment: {},
enable_vnc: true,
vnc_port: 9000,
vnc_password: 'testing',
}]);
expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalled();
Expand All @@ -118,6 +123,7 @@ describe('InstanceEditFormComponent', () => {
environment: {},
enable_vnc: true,
vnc_port: 9000,
vnc_password: 'testing',
},
error: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class InstanceEditFormComponent {
memory: [null as number | null],
enable_vnc: [false],
vnc_port: [defaultVncPort, [Validators.required, Validators.min(5900), Validators.max(65535)]],
vnc_password: [null as string],
environmentVariables: new FormArray<InstanceEnvVariablesFormGroup>([]),
});

Expand All @@ -104,6 +105,7 @@ export class InstanceEditFormComponent {
memory: this.editingInstance.memory,
enable_vnc: this.editingInstance.vnc_enabled,
vnc_port: this.editingInstance.vnc_port,
vnc_password: this.editingInstance.vnc_password,
});

this.setVncControls();
Expand All @@ -115,6 +117,10 @@ export class InstanceEditFormComponent {

protected onSubmit(): void {
const payload = this.getSubmissionPayload();
if (!payload.enable_vnc) {
delete payload.vnc_port;
delete payload.vnc_password;
}
const job$ = this.api.job('virt.instance.update', [this.editingInstance.id, payload]);

this.dialogService.jobDialog(job$, {
Expand Down Expand Up @@ -156,6 +162,7 @@ export class InstanceEditFormComponent {
memory: values.memory,
enable_vnc: values.enable_vnc,
vnc_port: values.enable_vnc ? values.vnc_port || defaultVncPort : null,
vnc_password: values.enable_vnc ? values.vnc_password : null,
} as UpdateVirtualizationInstance;
}

Expand All @@ -172,7 +179,6 @@ export class InstanceEditFormComponent {
}

private setVncControls(): void {
this.form.controls.vnc_port.disable();
this.form.controls.enable_vnc.valueChanges.pipe(untilDestroyed(this)).subscribe((vncEnabled) => {
if (vncEnabled) {
this.form.controls.vnc_port.enable();
Expand All @@ -183,6 +189,8 @@ export class InstanceEditFormComponent {

if (!this.isStopped) {
this.form.controls.enable_vnc.disable();
this.form.controls.vnc_password.disable();
this.form.controls.vnc_port.disable();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const instance = {
aliases: {} as VirtualizationAlias,
raw: null,
vnc_enabled: true,
vnc_password: '123456',
vnc_port: 9000,
} as VirtualizationInstance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@
type="number"
[label]="'VNC Port' | translate"
></ix-input>

<ix-input
formControlName="vnc_password"
type="password"
[label]="'VNC Password' | translate"
[hint]="'VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.' | translate"
></ix-input>
}
</ix-form-section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ describe('InstanceWizardComponent', () => {
environment: {},
enable_vnc: false,
vnc_port: null,
vnc_password: null,
}]);
expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalled();
Expand Down Expand Up @@ -242,6 +243,7 @@ describe('InstanceWizardComponent', () => {
memory: GiB,
enable_vnc: false,
vnc_port: null,
vnc_password: null,
instance_type: 'CONTAINER',
environment: {},
}]);
Expand Down Expand Up @@ -303,8 +305,14 @@ describe('InstanceWizardComponent', () => {
const gpuDeviceCheckbox = await loader.getHarness(MatCheckboxHarness.with({ label: 'NVIDIA GeForce GTX 1080' }));
await gpuDeviceCheckbox.check();

await form.fillForm({ 'Enable VNC': true });
await form.fillForm({ 'VNC Port': 9000 });
await form.fillForm({
'Enable VNC': true,
});

await form.fillForm({
'VNC Port': 9000,
'VNC Password': 'testing',
});

const createButton = await loader.getHarness(MatButtonHarness.with({ text: 'Create' }));
await createButton.click();
Expand Down Expand Up @@ -334,6 +342,7 @@ describe('InstanceWizardComponent', () => {
memory: GiB,
enable_vnc: true,
vnc_port: 9000,
vnc_password: 'testing',
}]);
expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalled();
Expand Down Expand Up @@ -382,6 +391,7 @@ describe('InstanceWizardComponent', () => {
source_type: null,
memory: 1073741824,
vnc_port: null,
vnc_password: null,
}]);
expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalled();
Expand Down Expand Up @@ -421,6 +431,7 @@ describe('InstanceWizardComponent', () => {
instance_type: 'CONTAINER',
enable_vnc: false,
vnc_port: null,
vnc_password: null,
}]);
expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class InstanceWizardComponent {
image: ['', [Validators.required, Validators.minLength(1), Validators.maxLength(200)]],
enable_vnc: [false],
vnc_port: [defaultVncPort, [Validators.min(5900), Validators.max(65535)]],
vnc_password: [null as string],
cpu: ['', [cpuValidator()]],
memory: [null as number],
tpm: [false],
Expand Down Expand Up @@ -343,6 +344,7 @@ export class InstanceWizardComponent {
instance_type: this.form.controls.instance_type.value,
enable_vnc: this.isVm ? this.form.value.enable_vnc : false,
vnc_port: this.isVm && this.form.value.enable_vnc ? this.form.value.vnc_port || defaultVncPort : null,
vnc_password: this.isVm && this.form.value.enable_vnc ? this.form.value.vnc_password : null,
name: this.form.controls.name.value,
cpu: this.form.controls.cpu.value,
memory: this.form.controls.memory.value,
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4271,8 +4271,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate effective ACL": "",
"Variant": "",
"View logs": "",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5021,8 +5021,10 @@
"VMware Sync": "",
"VMware: Extent block size 512b, TPC enabled, no Xen compat mode, SSD speed": "",
"VNC": "",
"VNC Password": "",
"VNC Port": "",
"VNC connection is currently insecure. Secure the connection in other ways.": "",
"VNC password is not cryptographically secure. You should not rely on it as a single authentication mechanism for your VMs.": "",
"Validate Certificates": "",
"Validate Connection": "",
"Validate Remote Path": "",
Expand Down
Loading

0 comments on commit eca5b0a

Please sign in to comment.