Skip to content

Commit ebc13cd

Browse files
committed
server: do not allocate nic on public network for NSX VPC VR
1 parent a18f1a6 commit ebc13cd

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,6 @@ public interface VpcManager {
174174
* @return
175175
*/
176176
boolean isSrcNatIpRequired(long vpcOfferingId);
177+
178+
boolean isSrcNatIpRequiredForVpcVr(long vpcOfferingId);
177179
}

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,6 +3402,15 @@ public boolean isSrcNatIpRequired(long vpcOfferingId) {
34023402
&& vpcOffSvcProvidersMap.get(Service.Gateway).contains(Network.Provider.VPCVirtualRouter));
34033403
}
34043404

3405+
@Override
3406+
public boolean isSrcNatIpRequiredForVpcVr(long vpcOfferingId) {
3407+
final Map<Network.Service, Set<Network.Provider>> vpcOffSvcProvidersMap = getVpcOffSvcProvidersMap(vpcOfferingId);
3408+
return (Objects.nonNull(vpcOffSvcProvidersMap.get(Network.Service.SourceNat))
3409+
&& vpcOffSvcProvidersMap.get(Network.Service.SourceNat).contains(Network.Provider.VPCVirtualRouter))
3410+
|| (Objects.nonNull(vpcOffSvcProvidersMap.get(Network.Service.Gateway))
3411+
&& vpcOffSvcProvidersMap.get(Service.Gateway).contains(Network.Provider.VPCVirtualRouter));
3412+
}
3413+
34053414
/**
34063415
* rollingRestartVpc performs restart of routers of a VPC by first
34073416
* deploying a new VR and then destroying old VRs in rolling fashion. For

server/src/main/java/org/apache/cloudstack/network/router/deployment/VpcRouterDeploymentDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected List<DeployDestination> findDestinations() {
113113
@Override
114114
protected boolean prepareDeployment() {
115115
//Check if the VR is the src NAT provider...
116-
isPublicNetwork = vpcMgr.isSrcNatIpRequired(vpc.getVpcOfferingId());
116+
isPublicNetwork = vpcMgr.isSrcNatIpRequiredForVpcVr(vpc.getVpcOfferingId());
117117

118118
// Check if public network has to be set on VR
119119
return true;

server/src/test/java/org/apache/cloudstack/network/router/deployment/VpcRouterDeploymentDefinitionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void testGetNumberOfRoutersToDeploy() {
173173

174174
protected void driveTestPrepareDeployment(final boolean isRedundant, final boolean isPublicNw) {
175175
// Prepare
176-
when(vpcMgr.isSrcNatIpRequired(mockVpc.getVpcOfferingId())).thenReturn(isPublicNw);
176+
when(vpcMgr.isSrcNatIpRequiredForVpcVr(mockVpc.getVpcOfferingId())).thenReturn(isPublicNw);
177177

178178
// Execute
179179
final boolean canProceedDeployment = deployment.prepareDeployment();

0 commit comments

Comments
 (0)