Skip to content

Commit cc7eb93

Browse files
author
gabriel
committed
addConfig
1 parent 37da6da commit cc7eb93

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
280280
private static final ConfigKey<Boolean> AllowEmptyStartEndIpAddress = new ConfigKey<>("Advanced", Boolean.class,
281281
"allow.empty.start.end.ipaddress", "true", "Allow creating network without mentioning start and end IP address",
282282
true, ConfigKey.Scope.Account);
283+
public static final ConfigKey<Boolean> AllowUsersToMakeNetworksRedundant = new ConfigKey<>("Advanced", Boolean.class,
284+
"allow.users.to.make.networks.redundant", "true", "Allow Users to make Networks Redundant",
285+
true, ConfigKey.Scope.Global);
283286
private static final long MIN_VLAN_ID = 0L;
284287
private static final long MAX_VLAN_ID = 4095L; // 2^12 - 1
285288
private static final long MIN_GRE_KEY = 0L;
@@ -2986,8 +2989,13 @@ public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationE
29862989
throwInvalidIdException("Cannot restart a VPC tier with cleanup, please restart the whole VPC.", network.getUuid(), "network tier");
29872990
}
29882991
boolean makeRedundant = cmd.getMakeRedundant();
2989-
boolean livePatch = cmd.getLivePatch();
29902992
User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
2993+
if (makeRedundant && !_accountMgr.isRootAdmin(callerUser.getAccountId()) && !AllowUsersToMakeNetworksRedundant.value() ) {
2994+
throw new InvalidParameterValueException(String.format("Could not make network redundant as calling user is not Root Admin and [%s] is set to false.",
2995+
AllowUsersToMakeNetworksRedundant.key()));
2996+
}
2997+
2998+
boolean livePatch = cmd.getLivePatch();
29912999
return restartNetwork(network, cleanup, makeRedundant, livePatch, callerUser);
29923000
}
29933001

@@ -6266,7 +6274,7 @@ public String getConfigComponentName() {
62666274

62676275
@Override
62686276
public ConfigKey<?>[] getConfigKeys() {
6269-
return new ConfigKey<?>[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu};
6277+
return new ConfigKey<?>[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, AllowUsersToMakeNetworksRedundant, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu};
62706278
}
62716279

62726280
public boolean isDefaultAcl(Long aclId) {

0 commit comments

Comments
 (0)