From a018b8e0ef81ae81e729a80bc6ae2378a82b5381 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Tue, 20 Aug 2024 11:08:10 -0300 Subject: [PATCH 1/4] UI: Fix VPC network offerings listing on VPC tier creation --- ui/src/views/network/VpcTiersTab.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/src/views/network/VpcTiersTab.vue b/ui/src/views/network/VpcTiersTab.vue index 214ea1afd6d1..72dfdc105afb 100644 --- a/ui/src/views/network/VpcTiersTab.vue +++ b/ui/src/views/network/VpcTiersTab.vue @@ -538,12 +538,16 @@ export default { fetchNetworkOfferings () { this.fetchLoading = true this.modalLoading = true - api('listNetworkOfferings', { + const params = { forvpc: true, guestiptype: 'Isolated', - supportedServices: 'SourceNat', state: 'Enabled' - }).then(json => { + } + params.supportedServices = 'SourceNat' + if (this.resource.service.map(svc => { return svc.name }).indexOf('Lb') > -1) { + params.supportedServices += ',Lb' + } + api('listNetworkOfferings', params).then(json => { this.networkOfferings = json.listnetworkofferingsresponse.networkoffering || [] var filteredOfferings = [] if (this.publicLBExists) { From 98392d1b333495c3d88b65640a153e93ca87bb55 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Wed, 21 Aug 2024 23:21:21 -0300 Subject: [PATCH 2/4] Refactor logic --- ui/src/views/network/VpcTiersTab.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/src/views/network/VpcTiersTab.vue b/ui/src/views/network/VpcTiersTab.vue index 72dfdc105afb..416d6e0803bb 100644 --- a/ui/src/views/network/VpcTiersTab.vue +++ b/ui/src/views/network/VpcTiersTab.vue @@ -544,8 +544,11 @@ export default { state: 'Enabled' } params.supportedServices = 'SourceNat' - if (this.resource.service.map(svc => { return svc.name }).indexOf('Lb') > -1) { + const vpcServiceLbIndex = this.resource.service.map(svc => { return svc.name }).indexOf('Lb') + var vpcLbProvider = null + if (vpcServiceLbIndex > -1) { params.supportedServices += ',Lb' + vpcLbProvider = this.resource.service[vpcServiceLbIndex].provider[0].name } api('listNetworkOfferings', params).then(json => { this.networkOfferings = json.listnetworkofferingsresponse.networkoffering || [] @@ -559,6 +562,15 @@ export default { } } this.networkOfferings = filteredOfferings + } else if (vpcServiceLbIndex > -1) { + for (var i in this.networkOfferings) { + const offering = this.networkOfferings[i] + const lbIndex = offering.service.map(svc => { return svc.name }).indexOf('Lb') + if (lbIndex > -1 && offering.service[lbIndex].provider[0].name === vpcLbProvider) { + filteredOfferings.push(offering) + } + } + this.networkOfferings = filteredOfferings } this.form.networkOffering = this.networkOfferings[0].id }).catch(error => { From bcefbfdda948d0d0e782c10bad375a1f15e8c431 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Thu, 22 Aug 2024 01:16:12 -0300 Subject: [PATCH 3/4] Revisit logic --- ui/src/views/network/VpcTiersTab.vue | 43 +++++++++++----------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/ui/src/views/network/VpcTiersTab.vue b/ui/src/views/network/VpcTiersTab.vue index 416d6e0803bb..2559bdaab780 100644 --- a/ui/src/views/network/VpcTiersTab.vue +++ b/ui/src/views/network/VpcTiersTab.vue @@ -522,7 +522,7 @@ export default { }).then(async json => { var lbNetworks = json.listnetworksresponse.network || [] if (lbNetworks.length > 0) { - this.publicLBExists = true + this.publicLBExists = false for (var idx = 0; idx < lbNetworks.length; idx++) { const lbNetworkOffering = await this.getNetworkOffering(lbNetworks[idx].networkofferingid) const index = lbNetworkOffering.service.map(svc => { return svc.name }).indexOf('Lb') @@ -538,40 +538,31 @@ export default { fetchNetworkOfferings () { this.fetchLoading = true this.modalLoading = true - const params = { + api('listNetworkOfferings', { forvpc: true, guestiptype: 'Isolated', + supportedServices: 'SourceNat', state: 'Enabled' - } - params.supportedServices = 'SourceNat' - const vpcServiceLbIndex = this.resource.service.map(svc => { return svc.name }).indexOf('Lb') - var vpcLbProvider = null - if (vpcServiceLbIndex > -1) { - params.supportedServices += ',Lb' - vpcLbProvider = this.resource.service[vpcServiceLbIndex].provider[0].name - } - api('listNetworkOfferings', params).then(json => { + }).then(json => { this.networkOfferings = json.listnetworkofferingsresponse.networkoffering || [] var filteredOfferings = [] - if (this.publicLBExists) { - for (var index in this.networkOfferings) { - const offering = this.networkOfferings[index] - const idx = offering.service.map(svc => { return svc.name }).indexOf('Lb') - if (idx === -1 || this.lbProviderMap.publicLb.vpc.indexOf(offering.service.map(svc => { return svc.provider[0].name })[idx]) === -1) { - filteredOfferings.push(offering) - } - } - this.networkOfferings = filteredOfferings - } else if (vpcServiceLbIndex > -1) { - for (var i in this.networkOfferings) { - const offering = this.networkOfferings[i] - const lbIndex = offering.service.map(svc => { return svc.name }).indexOf('Lb') - if (lbIndex > -1 && offering.service[lbIndex].provider[0].name === vpcLbProvider) { + const vpcLbServiceIndex = this.resource.service.map(svc => { return svc.name }).indexOf('Lb') + for (var index in this.networkOfferings) { + const offering = this.networkOfferings[index] + const idx = offering.service.map(svc => { return svc.name }).indexOf('Lb') + if (this.publicLBExists && (idx === -1 || this.lbProviderMap.publicLb.vpc.indexOf(offering.service.map(svc => { return svc.provider[0].name })[idx]) === -1)) { + filteredOfferings.push(offering) + } else if (!this.publicLBExists && vpcLbServiceIndex > -1) { + const vpcLbServiceProvider = vpcLbServiceIndex === -1 ? undefined : this.resource.service[vpcLbServiceIndex].provider[0].name + const offeringLbServiceProvider = idx === -1 ? undefined : offering.service[idx].provider[0].name + if (vpcLbServiceProvider && offeringLbServiceProvider && vpcLbServiceProvider === offeringLbServiceProvider) { filteredOfferings.push(offering) } + } else { + filteredOfferings.push(offering) } - this.networkOfferings = filteredOfferings } + this.networkOfferings = filteredOfferings this.form.networkOffering = this.networkOfferings[0].id }).catch(error => { this.$notifyError(error) From f07c7df340f941e52f83231e448f528ab7487243 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Thu, 22 Aug 2024 10:52:58 -0300 Subject: [PATCH 4/4] Fix offerings listing --- ui/src/views/network/VpcTiersTab.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/views/network/VpcTiersTab.vue b/ui/src/views/network/VpcTiersTab.vue index 2559bdaab780..402f9f06115b 100644 --- a/ui/src/views/network/VpcTiersTab.vue +++ b/ui/src/views/network/VpcTiersTab.vue @@ -555,7 +555,7 @@ export default { } else if (!this.publicLBExists && vpcLbServiceIndex > -1) { const vpcLbServiceProvider = vpcLbServiceIndex === -1 ? undefined : this.resource.service[vpcLbServiceIndex].provider[0].name const offeringLbServiceProvider = idx === -1 ? undefined : offering.service[idx].provider[0].name - if (vpcLbServiceProvider && offeringLbServiceProvider && vpcLbServiceProvider === offeringLbServiceProvider) { + if (vpcLbServiceProvider && (!offeringLbServiceProvider || (offeringLbServiceProvider && vpcLbServiceProvider === offeringLbServiceProvider))) { filteredOfferings.push(offering) } } else {