From c3e5c2161e4d29e95e424f8a2fb51da761d13ae5 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Wed, 3 Sep 2025 12:04:20 +0800 Subject: [PATCH] feat: add DHCP ui config in subnet page (#504) * feat: add dhcp ui setting in subnet page Signed-off-by: Andy Lee * feat: add dhcp option banner link Signed-off-by: Andy Lee --------- Signed-off-by: Andy Lee --- .../edit/kubeovn.io.subnet/index.vue | 63 ++++++++++++++++++- pkg/harvester/l10n/en-us.yaml | 7 +++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/pkg/harvester/edit/kubeovn.io.subnet/index.vue b/pkg/harvester/edit/kubeovn.io.subnet/index.vue index 98eb12bc..016a8f0f 100644 --- a/pkg/harvester/edit/kubeovn.io.subnet/index.vue +++ b/pkg/harvester/edit/kubeovn.io.subnet/index.vue @@ -14,6 +14,7 @@ import ArrayList from '@shell/components/form/ArrayList'; import { allHash } from '@shell/utils/promise'; import { HCI } from '../../types'; import ResourceTabs from '@shell/components/form/ResourceTabs/index'; +import { Banner } from '@components/Banner'; export default { name: 'EditSubnet', @@ -21,6 +22,7 @@ export default { emits: ['update:value'], components: { + Banner, CruResource, LabeledInput, LabeledSelect, @@ -38,7 +40,9 @@ export default { created() { const vpc = this.$route.query.vpc || ''; + const enableDHCP = this.value?.spec?.enableDHCP || false; + set(this.value.spec, 'enableDHCP', enableDHCP); set(this.value, 'spec', this.value.spec || { cidrBlock: '', protocol: NETWORK_PROTOCOL.IPv4, @@ -46,7 +50,8 @@ export default { vpc, gatewayIP: '', excludeIps: [], - private: false + private: false, + enableDHCP }); }, @@ -81,7 +86,6 @@ export default { protocolOptions() { return Object.values(NETWORK_PROTOCOL); }, - provider: { get() { const raw = this.value.spec.provider; @@ -125,6 +129,16 @@ export default { } }, + watch: { + 'value.spec.enableDHCP': { + handler(newValue) { + if (newValue === false) { + this.value.spec.dhcpV4Options = ''; + this.value.spec.dhcpV6Options = ''; + } + }, + } + }, methods: { async saveSubnet(buttonCb) { const errors = []; @@ -245,6 +259,45 @@ export default { /> +
+
+ + + + + + +
+
+ + diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index a68f047c..4aa15815 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -1045,6 +1045,13 @@ harvester: gateway: label: Gateway IP placeholder: e.g. 172.20.0.1 + dhcp: + label: Dynamic Host Configuration Protocol (DHCP) + v4Options: DHCPV4Options + v6Options: DHCPV6Options + placeholder: key1=value1, key2=value2 + dhcpOptionBanner: DHCP options is a key/value string concatenate with comma. For more detail, please refer to KubOVN document + tooltip: Enable DHCP server for this subnet. When enabled, VMs can automatically obtain IP addresses from this subnet. private: label: Private Subnet tooltip: Enable network isolation for this Subnet. When enabled, VMs can only communicate within this subnet, even if other subnets exist under the same VPC.