Skip to content

Commit b310852

Browse files
committed
Merge branch 'main' into cks-enhancements-upstream
2 parents e8a96d4 + 0ed6895 commit b310852

File tree

29 files changed

+3034
-564
lines changed

29 files changed

+3034
-564
lines changed

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
description: "Thank you for reporting a bug!"
18+
name: bug
19+
title: "[SHORT PROBLEM DESCRIPTION]"
20+
labels: bug, needs-triageing
21+
body:
22+
- type: markdown
23+
attributes:
24+
value: "## Welcome, please describe your problem below;"
25+
- type: textarea
26+
attributes:
27+
label: problem
28+
value: The long description of your problem
29+
- type: textarea
30+
attributes:
31+
label: The steps to reproduce the bug
32+
value: |
33+
1.
34+
2.
35+
3.
36+
...
37+
- type: textarea
38+
attributes:
39+
label: "What to do about it?"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
description: "Thank you for your new feature idea!"
18+
name: feature
19+
title: "[SHORT FUNCTIONAL DESCRIPTION]"
20+
labels: new
21+
body:
22+
- type: textarea
23+
attributes:
24+
label: "The required feature described as a wish"
25+
value: As a User/Admin/Operator I would like to , ... have the system make my morning coffee.

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

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

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

476476
VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool);

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,14 @@ public class ApiConstants {
12131213
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
12141214
"value will be applied.";
12151215

1216+
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1217+
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1218+
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";
1219+
1220+
public static final String PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1221+
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1222+
"added, it will be interpreted as \"23:59:59\"). If the recommended format is not used, the date will be considered in the server timezone.";
1223+
12161224
/**
12171225
* This enum specifies IO Drivers, each option controls specific policies on I/O.
12181226
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
@@ -1235,14 +1243,6 @@ public String toString() {
12351243
}
12361244
}
12371245

1238-
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1239-
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1240-
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";
1241-
1242-
public static final String PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
1243-
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
1244-
"added, it will be interpreted as \"23:59:59\"). If the recommended format is not used, the date will be considered in the server timezone.";
1245-
12461246
public enum BootType {
12471247
UEFI, BIOS;
12481248

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

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/domain/dao/DomainDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ public interface DomainDao extends GenericDao<DomainVO, Long> {
4242

4343
List<Long> getDomainChildrenIds(String path);
4444

45+
List<Long> getDomainAndChildrenIds(long domainId);
46+
4547
boolean domainIdListContainsAccessibleDomain(String domainIdList, Account caller, Long domainId);
4648
}

engine/schema/src/main/java/com/cloud/domain/dao/DomainDaoImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.sql.PreparedStatement;
2020
import java.sql.ResultSet;
2121
import java.sql.SQLException;
22+
import java.util.ArrayList;
2223
import java.util.HashSet;
2324
import java.util.List;
2425
import java.util.Set;
@@ -238,6 +239,15 @@ public List<Long> getDomainChildrenIds(String path) {
238239
return customSearch(sc, null);
239240
}
240241

242+
@Override
243+
public List<Long> getDomainAndChildrenIds(long domainId) {
244+
DomainVO domain = findById(domainId);
245+
if (domain != null) {
246+
return getDomainChildrenIds(domain.getPath());
247+
}
248+
return new ArrayList<>();
249+
}
250+
241251
@Override
242252
public boolean isChildDomain(Long parentId, Long childId) {
243253
if ((parentId == null) || (childId == null)) {

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/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.console_session', 'console_endpoint_
2525
-- Add client_address column to cloud.console_session table
2626
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.console_session', 'client_address', 'VARCHAR(45)');
2727

28+
-- Allow default roles to use quotaCreditsList
29+
INSERT INTO `cloud`.`role_permissions` (uuid, role_id, rule, permission, sort_order)
30+
SELECT uuid(), role_id, 'quotaCreditsList', permission, sort_order
31+
FROM `cloud`.`role_permissions` rp
32+
WHERE rp.rule = 'quotaStatement'
33+
AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 'quotaCreditsList');
34+
2835
-----------------------------------------------------------
2936
-- CKS Enhancements:
3037
-----------------------------------------------------------

0 commit comments

Comments
 (0)