Skip to content

Commit 6442663

Browse files
authored
Merge branch '4.20' into ui-improv
2 parents a7a8cdf + 7e295ec commit 6442663

File tree

32 files changed

+2472
-508
lines changed

32 files changed

+2472
-508
lines changed

agent/conf/agent.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ hypervisor.type=kvm
286286

287287
# The model of Watchdog timer to present to the Guest.
288288
# For all models refer to the libvirt documentation.
289+
# PLEASE NOTE: to disable the watchdogs definitions, use value: none
289290
#vm.watchdog.model=i6300esb
290291

291292
# Action to take when the Guest/Instance is no longer notifying the Watchdog timer.

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ public class AgentProperties{
516516
/**
517517
* The model of Watchdog timer to present to the Guest.<br>
518518
* For all models refer to the libvirt documentation.<br>
519+
* PLEASE NOTE: to disable the watchdogs definitions, use value: none
519520
* Data type: String.<br>
520521
* Default value: <code>i6300esb</code>
521522
*/

api/src/main/java/com/cloud/vm/UserVmService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ VirtualMachine migrateVirtualMachine(Long vmId, Host destinationHost) throws Res
469469
VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinationHost, Map<String, String> volumeToPool) throws ResourceUnavailableException,
470470
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
471471

472-
UserVm moveVMToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException,
472+
UserVm moveVmToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException,
473473
InsufficientCapacityException;
474474

475475
VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool);

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,16 @@ public List<Long> getSecurityGroupIdList() {
120120
@Override
121121
public void execute() {
122122
try {
123-
UserVm userVm = _userVmService.moveVMToUser(this);
124-
if (userVm == null) {
125-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm");
126-
}
123+
UserVm userVm = _userVmService.moveVmToUser(this);
127124
UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", userVm).get(0);
128125
response.setResponseName(getCommandName());
129126
setResponseObject(response);
130-
} catch (InvalidParameterValueException e){
131-
e.printStackTrace();
132-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
133127
} catch (Exception e) {
134-
logger.error("Failed to move vm due to: " + e.getStackTrace());
135-
if (e.getMessage() != null) {
136-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm due to " + e.getMessage());
137-
} else if (e.getCause() != null) {
138-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm due to " + e.getCause());
139-
} else {
140-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm");
141-
}
128+
ApiErrorCode errorCode = e instanceof InvalidParameterValueException ? ApiErrorCode.PARAM_ERROR : ApiErrorCode.INTERNAL_ERROR;
129+
String msg = String.format("Failed to move VM [%s].", getVmId());
130+
logger.error(msg, e);
131+
throw new ServerApiException(errorCode, msg);
142132
}
143-
144133
}
145134

146135
@Override

client/conf/server.properties.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ session.timeout=30
3232
# Max allowed API request payload/content size in bytes
3333
request.content.size=1048576
3434

35+
# Max allowed API request form keys
36+
request.max.form.keys=5000
37+
3538
# Options to configure and enable HTTPS on the management server
3639
#
3740
# For the management server to pick up these configuration settings, the configured

client/src/main/java/org/apache/cloudstack/ServerDaemon.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public class ServerDaemon implements Daemon {
8282
private static final String ACCESS_LOG = "access.log";
8383
private static final String REQUEST_CONTENT_SIZE_KEY = "request.content.size";
8484
private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576;
85+
private static final String REQUEST_MAX_FORM_KEYS_KEY = "request.max.form.keys";
86+
private static final int DEFAULT_REQUEST_MAX_FORM_KEYS = 5000;
8587

8688
////////////////////////////////////////////////////////
8789
/////////////// Server Configuration ///////////////////
@@ -94,6 +96,7 @@ public class ServerDaemon implements Daemon {
9496
private int httpsPort = 8443;
9597
private int sessionTimeout = 30;
9698
private int maxFormContentSize = DEFAULT_REQUEST_CONTENT_SIZE;
99+
private int maxFormKeys = DEFAULT_REQUEST_MAX_FORM_KEYS;
97100
private boolean httpsEnable = false;
98101
private String accessLogFile = "access.log";
99102
private String bindInterface = null;
@@ -141,6 +144,7 @@ public void init(final DaemonContext context) {
141144
setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log"));
142145
setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30")));
143146
setMaxFormContentSize(Integer.valueOf(properties.getProperty(REQUEST_CONTENT_SIZE_KEY, String.valueOf(DEFAULT_REQUEST_CONTENT_SIZE))));
147+
setMaxFormKeys(Integer.valueOf(properties.getProperty(REQUEST_MAX_FORM_KEYS_KEY, String.valueOf(DEFAULT_REQUEST_MAX_FORM_KEYS))));
144148
} catch (final IOException e) {
145149
logger.warn("Failed to read configuration from server.properties file", e);
146150
} finally {
@@ -192,6 +196,7 @@ public void start() throws Exception {
192196
// Extra config options
193197
server.setStopAtShutdown(true);
194198
server.setAttribute(ContextHandler.MAX_FORM_CONTENT_SIZE_KEY, maxFormContentSize);
199+
server.setAttribute(ContextHandler.MAX_FORM_KEYS_KEY, maxFormKeys);
195200

196201
// HTTPS Connector
197202
createHttpsConnector(httpConfig);
@@ -264,6 +269,7 @@ private Pair<SessionHandler,HandlerCollection> createHandlers() {
264269
webApp.setContextPath(contextPath);
265270
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
266271
webApp.setMaxFormContentSize(maxFormContentSize);
272+
webApp.setMaxFormKeys(maxFormKeys);
267273

268274
// GZIP handler
269275
final GzipHandler gzipHandler = new GzipHandler();
@@ -366,4 +372,8 @@ public void setSessionTimeout(int sessionTimeout) {
366372
public void setMaxFormContentSize(int maxFormContentSize) {
367373
this.maxFormContentSize = maxFormContentSize;
368374
}
375+
376+
public void setMaxFormKeys(int maxFormKeys) {
377+
this.maxFormKeys = maxFormKeys;
378+
}
369379
}

core/src/main/java/com/cloud/agent/api/CheckOnHostCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public CheckOnHostCommand(Host host) {
3535
}
3636

3737
public CheckOnHostCommand(Host host, boolean reportCheckFailureIfOneStorageIsDown) {
38-
super();
39-
this.host = new HostTO(host);
38+
this(host);
4039
this.reportCheckFailureIfOneStorageIsDown = reportCheckFailureIfOneStorageIsDown;
4140
}
4241

engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,16 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
796796
Long templateId = getRegisteredTemplateId(hypervisorAndTemplateName);
797797
if (templateId != null) {
798798
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
799-
TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByTemplate(templateId, DataStoreRole.Image);
800-
String installPath = templateDataStoreVO.getInstallPath();
801-
if (validateIfSeeded(storeUrlAndId.first(), installPath, nfsVersion)) {
802-
continue;
803-
} else if (templateVO != null) {
799+
TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByStoreTemplate(storeUrlAndId.second(), templateId);
800+
if (templateDataStoreVO != null) {
801+
String installPath = templateDataStoreVO.getInstallPath();
802+
if (validateIfSeeded(storeUrlAndId.first(), installPath, nfsVersion)) {
803+
continue;
804+
}
805+
}
806+
if (templateVO != null) {
804807
registerTemplate(hypervisorAndTemplateName, storeUrlAndId, templateVO, templateDataStoreVO, filePath);
808+
updateRegisteredTemplateDetails(templateId, hypervisorAndTemplateName);
805809
continue;
806810
}
807811
}
@@ -825,6 +829,11 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
825829
}
826830

827831
private void updateRegisteredTemplateDetails(Long templateId, Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName) {
832+
Pair<Hypervisor.HypervisorType, String> entry = new Pair<>(hypervisorAndTemplateName.getKey(), hypervisorAndTemplateName.getValue());
833+
updateRegisteredTemplateDetails(templateId, entry);
834+
}
835+
836+
private void updateRegisteredTemplateDetails(Long templateId, Pair<Hypervisor.HypervisorType, String> hypervisorAndTemplateName) {
828837
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
829838
templateVO.setTemplateType(Storage.TemplateType.SYSTEM);
830839
boolean updated = vmTemplateDao.update(templateVO.getId(), templateVO);
@@ -834,11 +843,11 @@ private void updateRegisteredTemplateDetails(Long templateId, Map.Entry<Hypervis
834843
throw new CloudRuntimeException(errMsg);
835844
}
836845

837-
updateSystemVMEntries(templateId, hypervisorAndTemplateName.getKey());
846+
updateSystemVMEntries(templateId, hypervisorAndTemplateName.first());
838847

839848
// Change value of global configuration parameter router.template.* for the corresponding hypervisor and minreq.sysvmtemplate.version for the ACS version
840849
Map<String, String> configParams = new HashMap<>();
841-
configParams.put(RouterTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()), hypervisorAndTemplateName.getValue());
850+
configParams.put(RouterTemplateConfigurationNames.get(hypervisorAndTemplateName.first()), hypervisorAndTemplateName.second());
842851
configParams.put("minreq.sysvmtemplate.version", getSystemVmTemplateVersion());
843852
updateConfigurationParams(configParams);
844853
}

engine/schema/src/main/java/org/apache/cloudstack/network/dao/NetworkPermissionDao.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public interface NetworkPermissionDao extends GenericDao<NetworkPermissionVO, Lo
4040
*/
4141
void removeAllPermissions(long networkId);
4242

43+
/**
44+
* Removes all network permissions associated with a given account.
45+
*
46+
* @param accountId The ID of the account from which all network permissions will be removed.
47+
*/
48+
void removeAccountPermissions(long accountId);
49+
4350
/**
4451
* Find a Network permission by networkId, accountName, and domainId
4552
*

engine/schema/src/main/java/org/apache/cloudstack/network/dao/NetworkPermissionDaoImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class NetworkPermissionDaoImpl extends GenericDaoBase<NetworkPermissionVO
3333

3434
private SearchBuilder<NetworkPermissionVO> NetworkAndAccountSearch;
3535
private SearchBuilder<NetworkPermissionVO> NetworkIdSearch;
36+
private SearchBuilder<NetworkPermissionVO> accountSearch;
3637
private GenericSearchBuilder<NetworkPermissionVO, Long> FindNetworkIdsByAccount;
3738

3839
protected NetworkPermissionDaoImpl() {
@@ -45,6 +46,10 @@ protected NetworkPermissionDaoImpl() {
4546
NetworkIdSearch.and("networkId", NetworkIdSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
4647
NetworkIdSearch.done();
4748

49+
accountSearch = createSearchBuilder();
50+
accountSearch.and("accountId", accountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
51+
accountSearch.done();
52+
4853
FindNetworkIdsByAccount = createSearchBuilder(Long.class);
4954
FindNetworkIdsByAccount.select(null, SearchCriteria.Func.DISTINCT, FindNetworkIdsByAccount.entity().getNetworkId());
5055
FindNetworkIdsByAccount.and("account", FindNetworkIdsByAccount.entity().getAccountId(), SearchCriteria.Op.IN);
@@ -69,6 +74,16 @@ public void removeAllPermissions(long networkId) {
6974
expunge(sc);
7075
}
7176

77+
@Override
78+
public void removeAccountPermissions(long accountId) {
79+
SearchCriteria<NetworkPermissionVO> sc = accountSearch.create();
80+
sc.setParameters("accountId", accountId);
81+
int networkPermissionRemoved = expunge(sc);
82+
if (networkPermissionRemoved > 0) {
83+
logger.debug(String.format("Removed [%s] network permission(s) for the account with Id [%s]", networkPermissionRemoved, accountId));
84+
}
85+
}
86+
7287
@Override
7388
public NetworkPermissionVO findByNetworkAndAccount(long networkId, long accountId) {
7489
SearchCriteria<NetworkPermissionVO> sc = NetworkAndAccountSearch.create();

0 commit comments

Comments
 (0)