Fix VPC/network offering service list for external network providers in Routed mode (#32)

* Fix network offering service list for external network providers in Routed mode

* filter out unsupported services based on network mode

* fix supported services list for vpc offering for external providers in Routed mode
This commit is contained in:
Pearl Dsilva 2024-12-13 10:43:07 -05:00 committed by GitHub
parent 444fb7324d
commit bbb7acccbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 25 deletions

View File

@ -289,11 +289,14 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
List<String> services = new ArrayList<>(List.of(
Dhcp.getName(),
Dns.getName(),
StaticNat.getName(),
SourceNat.getName(),
PortForwarding.getName(),
UserData.getName()
));
if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode())) {
services.addAll(Arrays.asList(
StaticNat.getName(),
SourceNat.getName(),
PortForwarding.getName()));
}
if (getNsxSupportsLbService()) {
services.add(Lb.getName());
}
@ -405,8 +408,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
continue;
if (routerSupported.contains(service))
serviceProviderMap.put(service, List.of(routerProvider));
else
serviceProviderMap.put(service, List.of(provider));
else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode()) || NetworkACL.getName().equalsIgnoreCase(service)) {
serviceProviderMap.put(service, List.of(provider));
}
if (!getNsxSupportsLbService()) {
serviceProviderMap.remove(Lb.getName());
}

View File

@ -26,10 +26,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network;
import com.cloud.network.VirtualRouterProvider;
import com.cloud.offering.NetworkOffering;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.commons.collections.CollectionUtils;
@ -179,12 +181,15 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
supportedServices = new ArrayList<>(List.of(
Dhcp.getName(),
Dns.getName(),
StaticNat.getName(),
SourceNat.getName(),
NetworkACL.getName(),
PortForwarding.getName(),
UserData.getName()
));
if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode())) {
supportedServices.addAll(Arrays.asList(
StaticNat.getName(),
SourceNat.getName(),
PortForwarding.getName()));
}
if (getNsxSupportsLbService()) {
supportedServices.add(Lb.getName());
}
@ -243,8 +248,10 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
continue;
if (routerSupported.contains(service))
serviceProviderMap.put(service, List.of(VirtualRouterProvider.Type.VPCVirtualRouter.name()));
else
else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode()) ||
Stream.of(NetworkACL.getName()).anyMatch(s -> s.equalsIgnoreCase(service))) {
serviceProviderMap.put(service, List.of(provider));
}
}
if (!getNsxSupportsLbService()) {
serviceProviderMap.remove(Lb.getName());

View File

@ -956,10 +956,12 @@ export default {
Dhcp: this.forVpc ? this.VPCVR : this.VR,
Dns: this.forVpc ? this.VPCVR : this.VR,
UserData: this.forVpc ? this.VPCVR : this.VR,
SourceNat: this.NSX,
StaticNat: this.NSX,
PortForwarding: this.NSX,
Lb: this.NSX,
...(this.networkmode === 'NATTED' && {
SourceNat: this.NSX,
StaticNat: this.NSX,
PortForwarding: this.NSX,
Lb: this.NSX
}),
...(forVpc && { NetworkACL: this.NSX }),
...(!forVpc && { Firewall: this.NSX })
}
@ -968,10 +970,12 @@ export default {
Dhcp: this.forVpc ? this.VPCVR : this.VR,
Dns: this.forVpc ? this.VPCVR : this.VR,
UserData: this.forVpc ? this.VPCVR : this.VR,
SourceNat: this.Netris,
StaticNat: this.Netris,
PortForwarding: this.Netris,
Lb: this.Netris,
...(this.networkmode === 'NATTED' && {
SourceNat: this.Netris,
StaticNat: this.Netris,
PortForwarding: this.Netris,
Lb: this.Netris
}),
...(forVpc && { NetworkACL: this.Netris }),
...(!forVpc && { Firewall: this.Netris })
}
@ -985,10 +989,12 @@ export default {
Dhcp: this.forVpc ? this.VPCVR : this.VR,
Dns: this.forVpc ? this.VPCVR : this.VR,
UserData: this.forVpc ? this.VPCVR : this.VR,
SourceNat: this.NSX,
StaticNat: this.NSX,
PortForwarding: this.NSX,
Lb: this.NSX,
...(this.networkmode === 'NATTED' && {
SourceNat: this.NSX,
StaticNat: this.NSX,
PortForwarding: this.NSX,
Lb: this.NSX
}),
...(this.forVpc && { NetworkACL: this.NSX }),
...(!this.forVpc && { Firewall: this.NSX })
}
@ -997,10 +1003,12 @@ export default {
Dhcp: this.forVpc ? this.VPCVR : this.VR,
Dns: this.forVpc ? this.VPCVR : this.VR,
UserData: this.forVpc ? this.VPCVR : this.VR,
SourceNat: this.Netris,
StaticNat: this.Netris,
PortForwarding: this.Netris,
Lb: this.Netris,
...(this.networkmode === 'NATTED' && {
SourceNat: this.Netris,
StaticNat: this.Netris,
PortForwarding: this.Netris,
Lb: this.Netris
}),
...(this.forVpc && { NetworkACL: this.Netris }),
...(!this.forVpc && { Firewall: this.Netris })
}