From c75c6baa3f56f98e7a41ccad7d6280753f8eb5ab Mon Sep 17 00:00:00 2001
From: Rakesh
Date: Mon, 5 Apr 2021 09:07:03 +0200
Subject: [PATCH] ui: Display public ip addresses for shared network (#4676)
If a vm belongs to shared network then display the list
of ip addresses available which can be used to assign for
secondary IP addresses.
Also display "Public IP addresses" tab for shared networks
---
ui/src/config/section/network.js | 2 +-
ui/src/views/compute/InstanceTab.vue | 36 +++++++++++++++++++++++--
ui/src/views/network/IpAddressesTab.vue | 14 +++++++---
3 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js
index 3ea3fe07104..f274fd51d73 100644
--- a/ui/src/config/section/network.js
+++ b/ui/src/config/section/network.js
@@ -48,7 +48,7 @@ export default {
}, {
name: 'public.ip.addresses',
component: () => import('@/views/network/IpAddressesTab.vue'),
- show: (record) => { return record.type === 'Isolated' && !('vpcid' in record) && 'listPublicIpAddresses' in store.getters.apis }
+ show: (record) => { return (record.type === 'Isolated' || record.type === 'Shared') && !('vpcid' in record) && 'listPublicIpAddresses' in store.getters.apis }
}, {
name: 'virtual.routers',
component: () => import('@/views/network/RoutersTab.vue'),
diff --git a/ui/src/views/compute/InstanceTab.vue b/ui/src/views/compute/InstanceTab.vue
index 29a5cdedebd..8ad259b290a 100644
--- a/ui/src/views/compute/InstanceTab.vue
+++ b/ui/src/views/compute/InstanceTab.vue
@@ -102,7 +102,7 @@
icon="environment"
shape="circle"
:disabled="(!('addIpToNic' in $store.getters.apis) && !('addIpToNic' in $store.getters.apis))"
- @click="fetchSecondaryIPs(record.nic.id)" />
+ @click="onAcquireSecondaryIPAddress(record)" />
@@ -220,7 +220,23 @@
{{ $t('message.network.secondaryip') }}
-
+
+
{{ $t('label.add.secondary.ip') }}
{{ $t('label.close') }}
@@ -298,6 +314,7 @@ export default {
loadingNic: false,
editIpAddressNic: '',
editIpAddressValue: '',
+ editNetworkId: '',
secondaryIPs: [],
selectedNicId: '',
newSecondaryIp: '',
@@ -444,6 +461,17 @@ export default {
this.fetchPublicIps(record.nic.networkid)
}
},
+ onAcquireSecondaryIPAddress (record) {
+ if (record.nic.type === 'Shared') {
+ this.fetchPublicIps(record.nic.networkid)
+ } else {
+ this.listIps.opts = []
+ }
+
+ this.editNicResource = record.nic
+ this.editNetworkId = record.nic.networkid
+ this.fetchSecondaryIPs(record.nic.id)
+ },
submitAddNetwork () {
const params = {}
params.virtualmachineid = this.vm.id
@@ -613,6 +641,9 @@ export default {
}).catch(error => {
this.$notifyError(error)
this.loadingNic = false
+ }).finally(() => {
+ this.newSecondaryIp = null
+ this.fetchPublicIps(this.editNetworkId)
})
},
removeSecondaryIP (id) {
@@ -625,6 +656,7 @@ export default {
successMethod: () => {
this.loadingNic = false
this.fetchSecondaryIPs(this.selectedNicId)
+ this.fetchPublicIps(this.editNetworkId)
this.parentFetchData()
},
errorMessage: this.$t('message.error.remove.secondary.ipaddress'),
diff --git a/ui/src/views/network/IpAddressesTab.vue b/ui/src/views/network/IpAddressesTab.vue
index ab7874cf057..111fbee9563 100644
--- a/ui/src/views/network/IpAddressesTab.vue
+++ b/ui/src/views/network/IpAddressesTab.vue
@@ -19,7 +19,7 @@
- {{ text }}
+ {{ text }}
+ {{ text }}
source-nat
@@ -66,12 +67,13 @@
- {{ record.associatednetworkname || record.associatednetworkid }}
+ {{ record.associatednetworkname || record.associatednetworkid }}
+ {{ record.networkname }}