You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by su...@apache.org on 2022/01/31 12:29:50 UTC
[cloudstack] branch 4.16 updated: Do not restart VPC tiers with cleanup (#5873)
This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.16 by this push:
new c1bba2a Do not restart VPC tiers with cleanup (#5873)
c1bba2a is described below
commit c1bba2a308e2df1eefb772b8ffa8a3abc2240d9b
Author: dahn <da...@shapeblue.com>
AuthorDate: Mon Jan 31 13:29:26 2022 +0100
Do not restart VPC tiers with cleanup (#5873)
* do not restart VPC tiers with cleanup
* no option for cleanup for VPC tiers
* Update server/src/main/java/com/cloud/network/NetworkServiceImpl.java
* paramNames
* remove superfluent parameter
Co-authored-by: Daan Hoogland <da...@onecht.net>
Co-authored-by: Daniel Augusto Veronezi Salvador <38...@users.noreply.github.com>
---
.../java/com/cloud/network/NetworkServiceImpl.java | 39 ++++++++++++----------
ui/src/config/section/network.js | 2 +-
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java
index de97c29..de13cd7 100644
--- a/server/src/main/java/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/main/java/com/cloud/network/NetworkServiceImpl.java
@@ -2000,12 +2000,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
Account caller = CallContext.current().getCallingAccount();
// Verify network id
- NetworkVO network = _networksDao.findById(networkId);
- if (network == null) {
- // see NetworkVO.java
-
- throwInvalidIdException("unable to find network with specified id", String.valueOf(networkId), "networkId");
- }
+ NetworkVO network = getNetworkVO(networkId, "Unable to find a network with the specified ID.");
// don't allow to delete system network
if (isNetworkSystem(network)) {
@@ -2035,10 +2030,20 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_RESTART, eventDescription = "restarting network", async = true)
public boolean restartNetwork(Long networkId, boolean cleanup, boolean makeRedundant, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
+ NetworkVO network = getNetworkVO(networkId, "Network with specified id doesn't exist");
+ return restartNetwork(network, cleanup, makeRedundant, user);
+ }
+
+ private NetworkVO getNetworkVO(Long networkId, String errMsgFormat) {
NetworkVO network = _networksDao.findById(networkId);
if (network == null) {
- throwInvalidIdException("Network with specified id doesn't exist", networkId.toString(), "networkId");
+ throwInvalidIdException(errMsgFormat, networkId.toString(), "networkId");
}
+ return network;
+ }
+
+ @ActionEvent(eventType = EventTypes.EVENT_NETWORK_RESTART, eventDescription = "restarting network", async = true)
+ public boolean restartNetwork(NetworkVO network, boolean cleanup, boolean makeRedundant, User user) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
// Don't allow to restart network if it's not in Implemented/Setup state
if (!(network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup)) {
@@ -2064,11 +2069,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
cleanup = true;
}
- boolean success = _networkMgr.restartNetwork(networkId, callerAccount, user, cleanup);
+ long id = network.getId();
+ boolean success = _networkMgr.restartNetwork(id, callerAccount, user, cleanup);
if (success) {
- s_logger.debug("Network id=" + networkId + " is restarted successfully.");
+ s_logger.debug(String.format("Network id=%d is restarted successfully.",id));
} else {
- s_logger.warn("Network id=" + networkId + " failed to restart.");
+ s_logger.warn(String.format("Network id=%d failed to restart.",id));
}
return success;
@@ -2078,11 +2084,14 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_RESTART, eventDescription = "restarting network", async = true)
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
// This method restarts all network elements belonging to the network and re-applies all the rules
- Long networkId = cmd.getNetworkId();
+ NetworkVO network = getNetworkVO(cmd.getNetworkId(), "Network [%s] to restart was not found.");
boolean cleanup = cmd.getCleanup();
+ if (network.getVpcId() != null && cleanup) {
+ throwInvalidIdException("Cannot restart a VPC tier with cleanup, please restart the whole VPC.", network.getUuid(), "network tier");
+ }
boolean makeRedundant = cmd.getMakeRedundant();
User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
- return restartNetwork(networkId, cleanup, makeRedundant, callerUser);
+ return restartNetwork(network, cleanup, makeRedundant, callerUser);
}
@Override
@@ -2219,11 +2228,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
boolean restartNetwork = false;
// verify input parameters
- final NetworkVO network = _networksDao.findById(networkId);
- if (network == null) {
- // see NetworkVO.java
- throwInvalidIdException("Specified network id doesn't exist in the system", String.valueOf(networkId), "networkId");
- }
+ final NetworkVO network = getNetworkVO(networkId, "Specified network id doesn't exist in the system");
//perform below validation if the network is vpc network
if (network.getVpcId() != null && networkOfferingId != null) {
diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js
index 95c2415..43992e8 100644
--- a/ui/src/config/section/network.js
+++ b/ui/src/config/section/network.js
@@ -99,7 +99,7 @@ export default {
label: 'label.restart.network',
message: 'message.restart.network',
dataView: true,
- args: ['cleanup'],
+ args: (record) => record.vpcid == null ? ['cleanup'] : [], // if it is a tier in a VPC and so it has a vpc do not allow "cleanup
show: (record) => record.type !== 'L2',
groupAction: true,
popup: true,