mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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 <dahn@onecht.net> Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
This commit is contained in:
parent
5f07e4daaf
commit
c1bba2a308
@ -2000,12 +2000,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
|
|||||||
Account caller = CallContext.current().getCallingAccount();
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
|
|
||||||
// Verify network id
|
// Verify network id
|
||||||
NetworkVO network = _networksDao.findById(networkId);
|
NetworkVO network = getNetworkVO(networkId, "Unable to find a network with the specified ID.");
|
||||||
if (network == null) {
|
|
||||||
// see NetworkVO.java
|
|
||||||
|
|
||||||
throwInvalidIdException("unable to find network with specified id", String.valueOf(networkId), "networkId");
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't allow to delete system network
|
// don't allow to delete system network
|
||||||
if (isNetworkSystem(network)) {
|
if (isNetworkSystem(network)) {
|
||||||
@ -2035,10 +2030,20 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
|
|||||||
@Override
|
@Override
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_RESTART, eventDescription = "restarting network", async = true)
|
@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 {
|
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);
|
NetworkVO network = _networksDao.findById(networkId);
|
||||||
if (network == null) {
|
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
|
// 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)) {
|
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;
|
cleanup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = _networkMgr.restartNetwork(networkId, callerAccount, user, cleanup);
|
long id = network.getId();
|
||||||
|
boolean success = _networkMgr.restartNetwork(id, callerAccount, user, cleanup);
|
||||||
if (success) {
|
if (success) {
|
||||||
s_logger.debug("Network id=" + networkId + " is restarted successfully.");
|
s_logger.debug(String.format("Network id=%d is restarted successfully.",id));
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("Network id=" + networkId + " failed to restart.");
|
s_logger.warn(String.format("Network id=%d failed to restart.",id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
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)
|
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_RESTART, eventDescription = "restarting network", async = true)
|
||||||
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
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
|
// 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();
|
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();
|
boolean makeRedundant = cmd.getMakeRedundant();
|
||||||
User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
|
User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
|
||||||
return restartNetwork(networkId, cleanup, makeRedundant, callerUser);
|
return restartNetwork(network, cleanup, makeRedundant, callerUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2219,11 +2228,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
|
|||||||
boolean restartNetwork = false;
|
boolean restartNetwork = false;
|
||||||
|
|
||||||
// verify input parameters
|
// verify input parameters
|
||||||
final NetworkVO network = _networksDao.findById(networkId);
|
final NetworkVO network = getNetworkVO(networkId, "Specified network id doesn't exist in the system");
|
||||||
if (network == null) {
|
|
||||||
// see NetworkVO.java
|
|
||||||
throwInvalidIdException("Specified network id doesn't exist in the system", String.valueOf(networkId), "networkId");
|
|
||||||
}
|
|
||||||
|
|
||||||
//perform below validation if the network is vpc network
|
//perform below validation if the network is vpc network
|
||||||
if (network.getVpcId() != null && networkOfferingId != null) {
|
if (network.getVpcId() != null && networkOfferingId != null) {
|
||||||
|
|||||||
@ -99,7 +99,7 @@ export default {
|
|||||||
label: 'label.restart.network',
|
label: 'label.restart.network',
|
||||||
message: 'message.restart.network',
|
message: 'message.restart.network',
|
||||||
dataView: true,
|
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',
|
show: (record) => record.type !== 'L2',
|
||||||
groupAction: true,
|
groupAction: true,
|
||||||
popup: true,
|
popup: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user