mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
feat: allow user specify static IP when VM creation (#973)
* feat: allow suer give static IP for VM Signed-off-by: Andy Lee <andy.lee@suse.com> * feat: add feature flag Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
@@ -36,6 +36,10 @@ export default {
|
||||
|
||||
computed: {
|
||||
ips() {
|
||||
if (this.staticAnnotationIP.length) {
|
||||
return this.staticAnnotationIP;
|
||||
}
|
||||
|
||||
if (this.vmiIp.length) {
|
||||
return [...this.vmiIp, ...this.networkAnnotationIP]
|
||||
.filter(Boolean)
|
||||
@@ -45,6 +49,24 @@ export default {
|
||||
return this.customAnnotationIP;
|
||||
},
|
||||
|
||||
staticAnnotationIP() {
|
||||
const annotations = this.row?.metadata?.annotations || {};
|
||||
const staticIpPrefix = `${ HCI_ANNOTATIONS.STATIC_IP }/`;
|
||||
|
||||
return Object.entries(annotations)
|
||||
.filter(([key, value]) => key.startsWith(staticIpPrefix) && !!value)
|
||||
.map(([key, value]) => {
|
||||
const nicName = key.slice(staticIpPrefix.length);
|
||||
const ip = String(value).replace(/\/[\d\D]*/, '');
|
||||
|
||||
return {
|
||||
ip,
|
||||
name: nicName
|
||||
};
|
||||
})
|
||||
.filter(({ ip }) => isIpv4(ip));
|
||||
},
|
||||
|
||||
customAnnotationIP() {
|
||||
const annotationIp = get(this.row, `metadata.annotations."${ HCI_ANNOTATIONS.CUSTOM_IP }"`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user