From 5735272c657c296b872fbaf7bd26e01f16979a53 Mon Sep 17 00:00:00 2001 From: David Edler Date: Wed, 29 Jan 2025 17:58:56 +0100 Subject: [PATCH] feat(instance) add cluster.evacuate as instance and profile configuration. fixes #1078 Signed-off-by: David Edler --- src/components/forms/MigrationForm.tsx | 16 +++++++++++++++- src/util/instanceConfigFields.tsx | 1 + src/util/instanceEdit.tsx | 1 + src/util/instanceOptions.tsx | 24 ++++++++++++++++++++++++ tests/iso-volumes.spec.ts | 2 +- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/components/forms/MigrationForm.tsx b/src/components/forms/MigrationForm.tsx index ae30724601..9797f5704f 100644 --- a/src/components/forms/MigrationForm.tsx +++ b/src/components/forms/MigrationForm.tsx @@ -8,16 +8,21 @@ import { getConfigurationRow } from "components/ConfigurationRow"; import ScrollableConfigurationTable from "components/forms/ScrollableConfigurationTable"; import { getInstanceKey } from "util/instanceConfigFields"; import { optionRenderer } from "util/formFields"; -import { optionAllowDeny } from "util/instanceOptions"; +import { + clusterEvacuationOptions, + optionAllowDeny, +} from "util/instanceOptions"; import { CreateInstanceFormValues } from "pages/instances/CreateInstance"; export interface MigrationFormValues { migration_stateful?: string; + cluster_evacuate?: string; } export const migrationPayload = (values: InstanceAndProfileFormValues) => { return { [getInstanceKey("migration_stateful")]: values.migration_stateful, + [getInstanceKey("cluster_evacuate")]: values.cluster_evacuate, }; }; @@ -49,6 +54,15 @@ const MigrationForm: FC = ({ formik }) => { , + }), ]} /> ); diff --git a/src/util/instanceConfigFields.tsx b/src/util/instanceConfigFields.tsx index d347d049c0..60c418e279 100644 --- a/src/util/instanceConfigFields.tsx +++ b/src/util/instanceConfigFields.tsx @@ -20,6 +20,7 @@ const instanceConfigFormFieldsToPayload: Record = { snapshots_schedule: "snapshots.schedule", snapshots_schedule_stopped: "snapshots.schedule.stopped", migration_stateful: "migration.stateful", + cluster_evacuate: "cluster.evacuate", boot_autostart: "boot.autostart", boot_autostart_delay: "boot.autostart.delay", boot_autostart_priority: "boot.autostart.priority", diff --git a/src/util/instanceEdit.tsx b/src/util/instanceEdit.tsx index 521f3e735a..bee37f3d48 100644 --- a/src/util/instanceEdit.tsx +++ b/src/util/instanceEdit.tsx @@ -54,6 +54,7 @@ const getEditValues = ( snapshots_schedule_stopped: item.config["snapshots.schedule.stopped"], migration_stateful: item.config["migration.stateful"], + cluster_evacuate: item.config["cluster.evacuate"], boot_autostart: item.config["boot.autostart"], boot_autostart_delay: item.config["boot.autostart.delay"], diff --git a/src/util/instanceOptions.tsx b/src/util/instanceOptions.tsx index 8ec38a04bd..f5390dffbe 100644 --- a/src/util/instanceOptions.tsx +++ b/src/util/instanceOptions.tsx @@ -96,3 +96,27 @@ export const proxyAddressTypeOptions = [ value: "unix", }, ]; + +export const clusterEvacuationOptions = [ + { + label: "Select option", + value: "", + disabled: true, + }, + { + label: "auto", + value: "auto", + }, + { + label: "live-migrate", + value: "live-migrate", + }, + { + label: "migrate", + value: "migrate", + }, + { + label: "stop", + value: "stop", + }, +]; diff --git a/tests/iso-volumes.spec.ts b/tests/iso-volumes.spec.ts index 6c7161b1fb..b23dc4b954 100644 --- a/tests/iso-volumes.spec.ts +++ b/tests/iso-volumes.spec.ts @@ -79,7 +79,7 @@ test("use custom iso for instance launch", async ({ page, lxdVersion }) => { await page .getByRole("combobox", { name: "Stateful migration" }) .selectOption("Deny"); - await page.getByRole("button", { name: "Create" }).click(); + await page.getByRole("button", { name: "Create", exact: true }).click(); await page.waitForSelector(`text=Created instance ${instance}.`);