server: check if redundant router is supported when restart network with makeredundant = true (#10612)

This commit is contained in:
Wei Zhou 2025-05-12 08:58:21 +02:00 committed by GitHub
parent e68abcd85d
commit bcd23ebb8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2739,6 +2739,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
Account callerAccount = _accountMgr.getActiveAccountById(user.getAccountId());
_accountMgr.checkAccess(callerAccount, AccessType.OperateEntry, true, network);
if (!network.isRedundant() && makeRedundant) {
NetworkOffering networkOffering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
Map<Network.Capability, String> sourceNatCapabilities = getNetworkOfferingServiceCapabilities(networkOffering, Service.SourceNat);
String isRedundantRouterSupported = sourceNatCapabilities.get(Capability.RedundantRouter);
if (!Boolean.parseBoolean(isRedundantRouterSupported)) {
throw new InvalidParameterValueException(String.format("Redundant router is not supported by the network offering %s", networkOffering));
}
network.setRedundant(true);
if (!_networksDao.update(network.getId(), network)) {
throw new CloudRuntimeException("Failed to update network into a redundant one, please try again");