Skip to content

Commit 3a26191

Browse files
weizhouapachedhslove
authored andcommitted
server: check if redundant router is supported when restart network with makeredundant = true (apache#10612)
1 parent bdfb829 commit 3a26191

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,12 @@ public boolean restartNetwork(NetworkVO network, boolean cleanup, boolean makeRe
29222922
Account callerAccount = _accountMgr.getActiveAccountById(user.getAccountId());
29232923
_accountMgr.checkAccess(callerAccount, AccessType.OperateEntry, true, network);
29242924
if (!network.isRedundant() && makeRedundant) {
2925+
NetworkOffering networkOffering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
2926+
Map<Network.Capability, String> sourceNatCapabilities = getNetworkOfferingServiceCapabilities(networkOffering, Service.SourceNat);
2927+
String isRedundantRouterSupported = sourceNatCapabilities.get(Capability.RedundantRouter);
2928+
if (!Boolean.parseBoolean(isRedundantRouterSupported)) {
2929+
throw new InvalidParameterValueException(String.format("Redundant router is not supported by the network offering %s", networkOffering));
2930+
}
29252931
network.setRedundant(true);
29262932
if (!_networksDao.update(network.getId(), network)) {
29272933
throw new CloudRuntimeException("Failed to update network into a redundant one, please try again");

0 commit comments

Comments
 (0)