Skip to content

Commit e383dd3

Browse files
committed
Display public ip addresses for shared network
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
1 parent c1a02e1 commit e383dd3

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

ui/src/config/section/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
}, {
4949
name: 'public.ip.addresses',
5050
component: () => import('@/views/network/IpAddressesTab.vue'),
51-
show: (record) => { return record.type === 'Isolated' && !('vpcid' in record) && 'listPublicIpAddresses' in store.getters.apis }
51+
show: (record) => { return (record.type === 'Isolated' || record.type === 'Shared') && !('vpcid' in record) && 'listPublicIpAddresses' in store.getters.apis }
5252
}, {
5353
name: 'virtual.routers',
5454
component: () => import('@/views/network/RoutersTab.vue'),

ui/src/views/compute/InstanceTab.vue

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
icon="environment"
103103
shape="circle"
104104
:disabled="(!('addIpToNic' in $store.getters.apis) && !('addIpToNic' in $store.getters.apis))"
105-
@click="fetchSecondaryIPs(record.nic.id)" />
105+
@click="onAcquireSecondaryIPAddress(record)" />
106106
</a-tooltip>
107107
<a-tooltip placement="bottom">
108108
<template slot="title">
@@ -220,9 +220,25 @@
220220
{{ $t('message.network.secondaryip') }}
221221
</p>
222222
<a-divider />
223-
<a-input :placeholder="$t('label.new.secondaryip.description')" v-model="newSecondaryIp" autoFocus></a-input>
223+
<div class="modal-form">
224+
<p class="modal-form__label">{{ $t('label.publicip') }}:</p>
225+
<a-select
226+
showSearch
227+
v-if="editNicResource.type==='Shared'"
228+
v-model="newSecondaryIp"
229+
:loading="listIps.loading">
230+
<a-select-option v-for="ip in listIps.opts" :key="ip.ipaddress">
231+
{{ ip.ipaddress }}
232+
</a-select-option>
233+
</a-select>
234+
<a-input
235+
v-else
236+
:placeholder="$t('label.new.secondaryip.description')"
237+
v-model="newSecondaryIp"></a-input>
238+
</div>
239+
224240
<div style="margin-top: 10px; display: flex; justify-content:flex-end;">
225-
<a-button @click="submitSecondaryIP" type="primary" style="margin-right: 10px;">{{ $t('label.add.secondary.ip') }}</a-button>
241+
<a-button :disabled="listIps.opts.length === 0" @click="submitSecondaryIP" type="primary" style="margin-right: 10px;">{{ $t('label.add.secondary.ip') }}</a-button>
226242
<a-button @click="closeModals">{{ $t('label.close') }}</a-button>
227243
</div>
228244

@@ -298,6 +314,7 @@ export default {
298314
loadingNic: false,
299315
editIpAddressNic: '',
300316
editIpAddressValue: '',
317+
editNetworkId: '',
301318
secondaryIPs: [],
302319
selectedNicId: '',
303320
newSecondaryIp: '',
@@ -444,6 +461,15 @@ export default {
444461
this.fetchPublicIps(record.nic.networkid)
445462
}
446463
},
464+
onAcquireSecondaryIPAddress (record) {
465+
if (record.nic.type === 'Shared') {
466+
this.editNicResource = record.nic
467+
this.editNetworkId = record.nic.networkid
468+
this.fetchPublicIps(record.nic.networkid)
469+
}
470+
471+
this.fetchSecondaryIPs(record.nic.id)
472+
},
447473
submitAddNetwork () {
448474
const params = {}
449475
params.virtualmachineid = this.vm.id
@@ -613,6 +639,9 @@ export default {
613639
}).catch(error => {
614640
this.$notifyError(error)
615641
this.loadingNic = false
642+
}).finally(() => {
643+
this.newSecondaryIp = null
644+
this.fetchPublicIps(this.editNetworkId)
616645
})
617646
},
618647
removeSecondaryIP (id) {
@@ -625,6 +654,7 @@ export default {
625654
successMethod: () => {
626655
this.loadingNic = false
627656
this.fetchSecondaryIPs(this.selectedNicId)
657+
this.fetchPublicIps(this.editNetworkId)
628658
this.parentFetchData()
629659
},
630660
errorMessage: this.$t('message.error.remove.secondary.ipaddress'),

ui/src/views/network/IpAddressesTab.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div>
2020
<a-spin :spinning="fetchLoading">
2121
<a-button
22-
:disabled="!('associateIpAddress' in $store.getters.apis)"
22+
:disabled="!('associateIpAddress' in $store.getters.apis) || resource.type === 'Shared'"
2323
type="dashed"
2424
icon="plus"
2525
style="width: 100%; margin-bottom: 15px"
@@ -66,12 +66,12 @@
6666
</template>
6767

6868
<template slot="associatednetworkname" slot-scope="text, record">
69-
<router-link :to="{ path: '/guestnetwork/' + record.associatednetworkid }" > {{ record.associatednetworkname || record.associatednetworkid }} </router-link>
69+
<router-link :to="{ path: '/guestnetwork/' + record.associatednetworkid }" > {{ record.associatednetworkname || record.associatednetworkid || record.networkname }} </router-link>
7070
</template>
7171

7272
<template slot="action" slot-scope="text, record">
7373
<a-button
74-
v-if="record.issourcenat !== true"
74+
v-if="record.issourcenat !== true && record.forvirtualnetwork === true"
7575
type="danger"
7676
icon="delete"
7777
shape="circle"
@@ -212,6 +212,10 @@ export default {
212212
if (this.vpcTier) {
213213
params.associatednetworkid = this.vpcTier
214214
}
215+
} else if (this.resource.type === 'Shared') {
216+
params.networkid = this.resource.id
217+
params.allocatedonly = false
218+
params.forvirtualnetwork = false
215219
} else {
216220
params.associatednetworkid = this.resource.id
217221
}

0 commit comments

Comments
 (0)