|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +export function buildServiceCapabilityParams (params, values, selectedServiceProviderMap, registeredServicePackages) { |
| 19 | + const supportedServices = Object.keys(selectedServiceProviderMap) |
| 20 | + params.supportedservices = supportedServices.join(',') |
| 21 | + for (const k in supportedServices) { |
| 22 | + params[`serviceProviderList[${k}].service`] = supportedServices[k] |
| 23 | + params[`serviceProviderList[${k}].provider`] = selectedServiceProviderMap[supportedServices[k]] |
| 24 | + } |
| 25 | + let serviceCapabilityIndex = 0 |
| 26 | + if (supportedServices.includes('Connectivity')) { |
| 27 | + if (values.supportsstrechedl2subnet === true) { |
| 28 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'Connectivity' |
| 29 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'RegionLevelVpc' |
| 30 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 31 | + serviceCapabilityIndex++ |
| 32 | + } |
| 33 | + if (values.supportspublicaccess === true) { |
| 34 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'Connectivity' |
| 35 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'DistributedRouter' |
| 36 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 37 | + serviceCapabilityIndex++ |
| 38 | + } |
| 39 | + delete params.supportsstrechedl2subnet |
| 40 | + delete params.supportspublicaccess |
| 41 | + } |
| 42 | + // SourceNat capabilities |
| 43 | + if (supportedServices.includes('SourceNat')) { |
| 44 | + if (values.redundantroutercapability === true) { |
| 45 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'SourceNat' |
| 46 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'RedundantRouter' |
| 47 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 48 | + serviceCapabilityIndex++ |
| 49 | + } |
| 50 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'SourceNat' |
| 51 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'SupportedSourceNatTypes' |
| 52 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = values.sourcenattype |
| 53 | + serviceCapabilityIndex++ |
| 54 | + delete params.redundantroutercapability |
| 55 | + delete params.sourcenattype |
| 56 | + } else if (values.redundantroutercapability === true) { |
| 57 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'Gateway' |
| 58 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'RedundantRouter' |
| 59 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 60 | + serviceCapabilityIndex++ |
| 61 | + } |
| 62 | + // StaticNat capabilities |
| 63 | + if (supportedServices.includes('SourceNat')) { |
| 64 | + if (values.elasticip === true) { |
| 65 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'StaticNat' |
| 66 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'ElasticIp' |
| 67 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 68 | + serviceCapabilityIndex++ |
| 69 | + } |
| 70 | + if (values.elasticip === true || values.associatepublicip === true) { |
| 71 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'StaticNat' |
| 72 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'associatePublicIP' |
| 73 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = values.associatepublicip |
| 74 | + serviceCapabilityIndex++ |
| 75 | + } |
| 76 | + delete params.elasticip |
| 77 | + delete params.associatepublicip |
| 78 | + } |
| 79 | + // Lb capabilities |
| 80 | + if (supportedServices.includes('Lb')) { |
| 81 | + if ('vmautoscalingcapability' in values) { |
| 82 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'lb' |
| 83 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'VmAutoScaling' |
| 84 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = values.vmautoscalingcapability |
| 85 | + serviceCapabilityIndex++ |
| 86 | + } |
| 87 | + if (values.elasticlb === true) { |
| 88 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'lb' |
| 89 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'ElasticLb' |
| 90 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 91 | + serviceCapabilityIndex++ |
| 92 | + } |
| 93 | + if (values.inlinemode === true && ((selectedServiceProviderMap.Lb === 'F5BigIp') || (selectedServiceProviderMap.Lb === 'Netscaler'))) { |
| 94 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'lb' |
| 95 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'InlineMode' |
| 96 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = values.inlinemode |
| 97 | + serviceCapabilityIndex++ |
| 98 | + } |
| 99 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'lb' |
| 100 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'SupportedLbIsolation' |
| 101 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = values.isolation || 'dedicated' |
| 102 | + serviceCapabilityIndex++ |
| 103 | + if (selectedServiceProviderMap.Lb === 'InternalLbVm') { |
| 104 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].service`] = 'lb' |
| 105 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilitytype`] = 'lbSchemes' |
| 106 | + params[`servicecapabilitylist[${serviceCapabilityIndex}].capabilityvalue`] = 'internal' |
| 107 | + serviceCapabilityIndex++ |
| 108 | + } |
| 109 | + if ('netscalerservicepackages' in values && |
| 110 | + registeredServicePackages.length > values.netscalerservicepackages && |
| 111 | + 'netscalerservicepackagesdescription' in values) { |
| 112 | + params['details[0].servicepackageuuid'] = registeredServicePackages[values.netscalerservicepackages].id |
| 113 | + params['details[1].servicepackagedescription'] = values.netscalerservicepackagesdescription |
| 114 | + } |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +/** |
| 119 | + * Build the VPC service capability params for Add/Clone VPC Offering forms. |
| 120 | + * Handles: RegionLevelVpc, DistributedRouter, RedundantRouter (SourceNat/Gateway) |
| 121 | + */ |
| 122 | +export function buildVpcServiceCapabilityParams (params, values, selectedServiceProviderMap, isVpcVirtualRouterForAtLeastOneService) { |
| 123 | + const supportedServices = Object.keys(selectedServiceProviderMap) |
| 124 | + let serviceCapabilityIndex = 0 |
| 125 | + if (supportedServices.includes('Connectivity')) { |
| 126 | + if (values.regionlevelvpc === true) { |
| 127 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'Connectivity' |
| 128 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'RegionLevelVpc' |
| 129 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 130 | + serviceCapabilityIndex++ |
| 131 | + } |
| 132 | + if (values.distributedrouter === true) { |
| 133 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'Connectivity' |
| 134 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'DistributedRouter' |
| 135 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 136 | + serviceCapabilityIndex++ |
| 137 | + } |
| 138 | + } |
| 139 | + if (supportedServices.includes('SourceNat') && values.redundantrouter === true) { |
| 140 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'SourceNat' |
| 141 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'RedundantRouter' |
| 142 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 143 | + serviceCapabilityIndex++ |
| 144 | + } else if (values.redundantrouter === true) { |
| 145 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].service`] = 'Gateway' |
| 146 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilitytype`] = 'RedundantRouter' |
| 147 | + params[`serviceCapabilityList[${serviceCapabilityIndex}].capabilityvalue`] = true |
| 148 | + serviceCapabilityIndex++ |
| 149 | + } |
| 150 | + if (values.serviceofferingid && isVpcVirtualRouterForAtLeastOneService) { |
| 151 | + params.serviceofferingid = values.serviceofferingid |
| 152 | + } |
| 153 | +} |
0 commit comments