mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 06:51:44 +00:00
feat: add DHCP ui config in subnet page (#504)
* feat: add dhcp ui setting in subnet page Signed-off-by: Andy Lee <andy.lee@suse.com> * feat: add dhcp option banner link Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
f932afee68
commit
c3e5c2161e
@ -14,6 +14,7 @@ import ArrayList from '@shell/components/form/ArrayList';
|
|||||||
import { allHash } from '@shell/utils/promise';
|
import { allHash } from '@shell/utils/promise';
|
||||||
import { HCI } from '../../types';
|
import { HCI } from '../../types';
|
||||||
import ResourceTabs from '@shell/components/form/ResourceTabs/index';
|
import ResourceTabs from '@shell/components/form/ResourceTabs/index';
|
||||||
|
import { Banner } from '@components/Banner';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EditSubnet',
|
name: 'EditSubnet',
|
||||||
@ -21,6 +22,7 @@ export default {
|
|||||||
emits: ['update:value'],
|
emits: ['update:value'],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
Banner,
|
||||||
CruResource,
|
CruResource,
|
||||||
LabeledInput,
|
LabeledInput,
|
||||||
LabeledSelect,
|
LabeledSelect,
|
||||||
@ -38,7 +40,9 @@ export default {
|
|||||||
|
|
||||||
created() {
|
created() {
|
||||||
const vpc = this.$route.query.vpc || '';
|
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 || {
|
set(this.value, 'spec', this.value.spec || {
|
||||||
cidrBlock: '',
|
cidrBlock: '',
|
||||||
protocol: NETWORK_PROTOCOL.IPv4,
|
protocol: NETWORK_PROTOCOL.IPv4,
|
||||||
@ -46,7 +50,8 @@ export default {
|
|||||||
vpc,
|
vpc,
|
||||||
gatewayIP: '',
|
gatewayIP: '',
|
||||||
excludeIps: [],
|
excludeIps: [],
|
||||||
private: false
|
private: false,
|
||||||
|
enableDHCP
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -81,7 +86,6 @@ export default {
|
|||||||
protocolOptions() {
|
protocolOptions() {
|
||||||
return Object.values(NETWORK_PROTOCOL);
|
return Object.values(NETWORK_PROTOCOL);
|
||||||
},
|
},
|
||||||
|
|
||||||
provider: {
|
provider: {
|
||||||
get() {
|
get() {
|
||||||
const raw = this.value.spec.provider;
|
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: {
|
methods: {
|
||||||
async saveSubnet(buttonCb) {
|
async saveSubnet(buttonCb) {
|
||||||
const errors = [];
|
const errors = [];
|
||||||
@ -245,6 +259,45 @@ export default {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mt-20">
|
||||||
|
<div class="col span-6">
|
||||||
|
<RadioGroup
|
||||||
|
v-model:value="value.spec.enableDHCP"
|
||||||
|
name="enabled"
|
||||||
|
:options="[true, false]"
|
||||||
|
:label="t('harvester.subnet.dhcp.label')"
|
||||||
|
:labels="[t('generic.enabled'), t('generic.disabled')]"
|
||||||
|
:mode="mode"
|
||||||
|
:tooltip="t('harvester.subnet.dhcp.tooltip')"
|
||||||
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
v-if="value.spec.enableDHCP && value.spec.protocol === 'IPv4'"
|
||||||
|
v-model:value="value.spec.dhcpV4Options"
|
||||||
|
class="mb-20 mt-20"
|
||||||
|
:placeholder="t('harvester.subnet.dhcp.placeholder')"
|
||||||
|
:label="t('harvester.subnet.dhcp.v4Options')"
|
||||||
|
:mode="mode"
|
||||||
|
/>
|
||||||
|
<LabeledInput
|
||||||
|
v-if="value.spec.enableDHCP && value.spec.protocol === 'IPv6'"
|
||||||
|
v-model:value="value.spec.dhcpV6Options"
|
||||||
|
:placeholder="t('harvester.subnet.dhcp.placeholder')"
|
||||||
|
class="mb-20 mt-20"
|
||||||
|
:label="t('harvester.subnet.dhcp.v6Options')"
|
||||||
|
:mode="mode"
|
||||||
|
/>
|
||||||
|
<Banner
|
||||||
|
v-if="value.spec.enableDHCP"
|
||||||
|
color="info"
|
||||||
|
class="dhcpOption-banner"
|
||||||
|
>
|
||||||
|
<t
|
||||||
|
k="harvester.subnet.dhcp.dhcpOptionBanner"
|
||||||
|
:raw="true"
|
||||||
|
/>
|
||||||
|
</Banner>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row mt-20">
|
<div class="row mt-20">
|
||||||
<div class="col span-6">
|
<div class="col span-6">
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
@ -321,3 +374,9 @@ export default {
|
|||||||
</ResourceTabs>
|
</ResourceTabs>
|
||||||
</CruResource>
|
</CruResource>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.dhcpOption-banner {
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -1045,6 +1045,13 @@ harvester:
|
|||||||
gateway:
|
gateway:
|
||||||
label: Gateway IP
|
label: Gateway IP
|
||||||
placeholder: e.g. 172.20.0.1
|
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 <a href="https://kubeovn.github.io/docs/v1.13.x/en/kubevirt/dhcp/" target="_blank">KubOVN document</a>
|
||||||
|
tooltip: Enable DHCP server for this subnet. When enabled, VMs can automatically obtain IP addresses from this subnet.
|
||||||
private:
|
private:
|
||||||
label: Private Subnet
|
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.
|
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.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user