Skip to content

Commit 7ad68aa

Browse files
GaOrtigaGabrielsureshanaparti
authored
Enable defining a network as redundant during restart through the UI (#7405)
Co-authored-by: Gabriel <gabriel.fernandes@scclouds.com.br> Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
1 parent 7562030 commit 7ad68aa

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

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

Lines changed: 9 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;
@@ -2998,8 +3001,12 @@ public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationE
29983001
throwInvalidIdException("Cannot restart a VPC tier with cleanup, please restart the whole VPC.", network.getUuid(), "network tier");
29993002
}
30003003
boolean makeRedundant = cmd.getMakeRedundant();
3001-
boolean livePatch = cmd.getLivePatch();
30023004
User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
3005+
if (makeRedundant && !_accountMgr.isRootAdmin(callerUser.getAccountId()) && !AllowUsersToMakeNetworksRedundant.value() ) {
3006+
throw new InvalidParameterValueException("Could not make the network redundant. Please contact administrator.");
3007+
}
3008+
3009+
boolean livePatch = cmd.getLivePatch();
30033010
return restartNetwork(network, cleanup, makeRedundant, livePatch, callerUser);
30043011
}
30053012

@@ -6278,7 +6285,7 @@ public String getConfigComponentName() {
62786285

62796286
@Override
62806287
public ConfigKey<?>[] getConfigKeys() {
6281-
return new ConfigKey<?>[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu};
6288+
return new ConfigKey<?>[] {AllowDuplicateNetworkName, AllowEmptyStartEndIpAddress, AllowUsersToMakeNetworksRedundant, VRPrivateInterfaceMtu, VRPublicInterfaceMtu, AllowUsersToSpecifyVRMtu};
62826289
}
62836290

62846291
public boolean isDefaultAcl(Long aclId) {

ui/public/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
]
9797
},
9898
"plugins": [],
99+
"allowMakingRouterRedundant": false,
99100
"apidocs": true,
100101
"basicZoneEnabled": true,
101102
"multipleServer": false,

ui/src/config/section/network.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import store from '@/store'
2020
import tungsten from '@/assets/icons/tungsten.svg?inline'
2121
import { isAdmin } from '@/role'
2222
import { isZoneCreated } from '@/utils/zone'
23+
import { vueProps } from '@/vue-app'
2324

2425
export default {
2526
name: 'network',
@@ -171,13 +172,16 @@ export default {
171172
if (isGroupAction || record.vpcid == null) {
172173
fields.push('cleanup')
173174
}
175+
if (!record.redundantrouter && vueProps.$config.allowMakingRouterRedundant) {
176+
fields.push('makeredundant')
177+
}
174178
fields.push('livepatch')
175179
return fields
176180
},
177181
show: (record) => record.type !== 'L2',
178182
groupAction: true,
179183
popup: true,
180-
groupMap: (selection, values) => { return selection.map(x => { return { id: x, cleanup: values.cleanup } }) }
184+
groupMap: (selection, values) => { return selection.map(x => { return { id: x, cleanup: values.cleanup, makeredundant: values.makeredundant } }) }
181185
},
182186
{
183187
api: 'replaceNetworkACLList',

0 commit comments

Comments
 (0)