From b94347ca37a38c837e5977713587002c40d7e1e6 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Mon, 5 Aug 2024 15:26:07 +0200 Subject: [PATCH] Dynamic: small code optimization --- .../ConfigurationManagerImpl.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java index 3d51ce520dda..bb24b9772000 100644 --- a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java @@ -6633,32 +6633,31 @@ public NetworkOfferingVO createNetworkOffering(final String name, final String d if (type != GuestType.Isolated) { throw new InvalidParameterValueException("networkMode should be set only for Isolated network offerings"); } - } - - if (NetworkOffering.NetworkMode.ROUTED.equals(networkMode)) { - boolean useVirtualRouterOnly = true; - for (Service service : serviceProviderMap.keySet()) { - Set providers = serviceProviderMap.get(service); - if (Arrays.asList(Service.SourceNat, Service.StaticNat, Service.Lb, Service.PortForwarding, Service.Vpn).contains(service)) { - if (providers != null) { - throw new InvalidParameterValueException("SourceNat/StaticNat/Lb/PortForwarding/Vpn service are not supported in ROUTED mode"); + if (NetworkOffering.NetworkMode.ROUTED.equals(networkMode)) { + boolean useVirtualRouterOnly = true; + for (Service service : serviceProviderMap.keySet()) { + Set providers = serviceProviderMap.get(service); + if (Arrays.asList(Service.SourceNat, Service.StaticNat, Service.Lb, Service.PortForwarding, Service.Vpn).contains(service)) { + if (providers != null) { + throw new InvalidParameterValueException("SourceNat/StaticNat/Lb/PortForwarding/Vpn service are not supported in ROUTED mode"); + } } - } - if (useVirtualRouterOnly && Arrays.asList(Service.Firewall, Service.NetworkACL).contains(service)) { - for (Provider provider : providers) { - if (!Provider.VirtualRouter.equals(provider) && !Provider.VPCVirtualRouter.equals(provider)) { - useVirtualRouterOnly = false; - break; + if (useVirtualRouterOnly && Arrays.asList(Service.Firewall, Service.NetworkACL).contains(service)) { + for (Provider provider : providers) { + if (!Provider.VirtualRouter.equals(provider) && !Provider.VPCVirtualRouter.equals(provider)) { + useVirtualRouterOnly = false; + break; + } } } } - } - if (useVirtualRouterOnly) { - // Add VirtualRouter/VPCVirtualRouter as provider of Gateway service - if (forVpc) { - serviceProviderMap.put(Service.Gateway, Sets.newHashSet(Provider.VPCVirtualRouter)); - } else { - serviceProviderMap.put(Service.Gateway, Sets.newHashSet(Provider.VirtualRouter)); + if (useVirtualRouterOnly) { + // Add VirtualRouter/VPCVirtualRouter as provider of Gateway service + if (forVpc) { + serviceProviderMap.put(Service.Gateway, Sets.newHashSet(Provider.VPCVirtualRouter)); + } else { + serviceProviderMap.put(Service.Gateway, Sets.newHashSet(Provider.VirtualRouter)); + } } } }