Skip to content

Commit 84f25c0

Browse files
committed
Merge remote-tracking branch 'apache/main' into ExternalDeploymentIntegration
2 parents 8296d48 + 28e2411 commit 84f25c0

File tree

14 files changed

+1150
-987
lines changed

14 files changed

+1150
-987
lines changed

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Install tools and dependencies used for development:
1818
# yum -y install git java-17-openjdk java-17-openjdk-devel \
1919
mysql mysql-server mkisofs git gcc python MySQL-python openssh-clients wget
2020

21-
Set up Maven (3.6.0):
21+
Set up Maven (3.9.9):
2222

2323
# wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
2424
# tar -zxvf apache-maven-3.9.9-bin.tar.gz -C /usr/local

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,11 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.cluster', 'storage_access_groups', '
8181
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host_pod_ref', 'storage_access_groups', 'varchar(255) DEFAULT NULL COMMENT "storage access groups for the hosts in the pod"');
8282
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.data_center', 'storage_access_groups', 'varchar(255) DEFAULT NULL COMMENT "storage access groups for the hosts in the zone"');
8383

84-
-- Add featured column for guest_os_category
84+
-- Add featured, sort_key, created, removed columns for guest_os_category
8585
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os_category', 'featured', 'tinyint(1) NOT NULL DEFAULT 0 COMMENT "whether the category is featured or not" AFTER `uuid`');
8686
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os_category', 'sort_key', 'int NOT NULL DEFAULT 0 COMMENT "sort key used for customising sort method" AFTER `featured`');
8787
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os_category', 'created', 'datetime COMMENT "date on which the category was created" AFTER `sort_key`');
8888
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os_category', 'removed', 'datetime COMMENT "date removed if not null" AFTER `created`');
89-
UPDATE `cloud`.`guest_os_category` SET `featured` = 1 WHERE `name` NOT IN ('Novel', 'None');
9089

9190
-- Begin: Changes for Guest OS category cleanup
9291
-- Add new OS categories if not present
@@ -102,7 +101,7 @@ BEGIN
102101

103102
CALL `cloud`.`INSERT_CATEGORY_IF_NOT_EXIST`('Fedora');
104103
CALL `cloud`.`INSERT_CATEGORY_IF_NOT_EXIST`('Rocky Linux');
105-
CALL `cloud`.`INSERT_CATEGORY_IF_NOT_EXIST`('Alma Linux');
104+
CALL `cloud`.`INSERT_CATEGORY_IF_NOT_EXIST`('AlmaLinux');
106105

107106
-- Move existing guest OS to new categories
108107
DROP PROCEDURE IF EXISTS `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`;
@@ -121,7 +120,7 @@ BEGIN
121120
WHERE `display_name` LIKE CONCAT('%', os_name, '%')
122121
; END;
123122
CALL `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`('Rocky Linux', 'Rocky Linux');
124-
CALL `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`('Alma Linux', 'Alma Linux');
123+
CALL `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`('AlmaLinux', 'AlmaLinux');
125124
CALL `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`('Fedora', 'Fedora');
126125

127126
-- Move existing guest OS whose category will be deleted to Other category
@@ -147,11 +146,8 @@ CALL `cloud`.`UPDATE_NEW_AND_DELETE_OLD_CATEGORY_FOR_GUEST_OS`('Other', 'None');
147146
CALL `cloud`.`UPDATE_NEW_AND_DELETE_OLD_CATEGORY_FOR_GUEST_OS`('Other', 'Unix');
148147
CALL `cloud`.`UPDATE_NEW_AND_DELETE_OLD_CATEGORY_FOR_GUEST_OS`('Other', 'Mac');
149148

150-
-- Add featured column for cloud.guest_os_category
151-
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os_category', 'featured', 'tinyint(1) NOT NULL DEFAULT 0 COMMENT "whether the category is featured or not" AFTER `uuid`');
149+
-- Update featured for existing guest OS categories
152150
UPDATE `cloud`.`guest_os_category` SET featured = 1;
153-
-- Add sort_key column for cloud.guest_os_category
154-
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.guest_os_category', 'sort_key', 'int NOT NULL DEFAULT 0 COMMENT "sort key used for customising sort method" AFTER `featured`');
155151

156152
-- Update sort order for all guest OS categories
157153
UPDATE `cloud`.`guest_os_category`
@@ -161,7 +157,7 @@ SET `sort_key` = CASE
161157
WHEN `name` = 'Fedora' THEN 3
162158
WHEN `name` = 'CentOS' THEN 4
163159
WHEN `name` = 'Rocky Linux' THEN 5
164-
WHEN `name` = 'Alma Linux' THEN 6
160+
WHEN `name` = 'AlmaLinux' THEN 6
165161
WHEN `name` = 'Oracle' THEN 7
166162
WHEN `name` = 'RedHat' THEN 8
167163
WHEN `name` = 'SUSE' THEN 9

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ public void revokeAccess(DataObject data, Host host, DataStore dataStore) {
222222
StorPoolUtil.volumeRemoveTags(StorPoolStorageAdaptor.getVolumeNameFromPath(volume.getPath(), true), conn);
223223
}
224224
}
225-
226225
}
227226

228227
private void updateStoragePool(final long poolId, final long deltaUsedBytes) {
@@ -327,19 +326,14 @@ private SpApiResponse createStorPoolVolume(String template, String tier, VolumeI
327326
Long vmId, SpConnectionDesc conn) {
328327
SpApiResponse resp = new SpApiResponse();
329328
Map<String, String> tags = StorPoolHelper.addStorPoolTags(name, getVMInstanceUUID(vmId), "volume", getVcPolicyTag(vmId), tier);
330-
if (tier != null || template != null) {
331-
StorPoolUtil.spLog(
332-
"Creating volume [%s] with template [%s] or tier tags [%s] described in disk/service offerings details",
333-
vinfo.getUuid(), template, tier);
334-
resp = StorPoolUtil.volumeCreate(size, null, template, tags, conn);
335-
} else {
336-
StorPoolUtil.spLog(
337-
"StorpoolPrimaryDataStoreDriver.createAsync volume: name=%s, uuid=%s, isAttached=%s vm=%s, payload=%s, template: %s",
338-
vinfo.getName(), vinfo.getUuid(), vinfo.isAttachedVM(), vinfo.getAttachedVmName(),
339-
vinfo.getpayload(), conn.getTemplateName());
340-
resp = StorPoolUtil.volumeCreate(name, null, size, getVMInstanceUUID(vinfo.getInstanceId()), null,
341-
"volume", vinfo.getMaxIops(), conn);
329+
if (vinfo.getDeviceId() != null) {
330+
tags.put("disk", vinfo.getDeviceId().toString());
331+
}
332+
if (template == null) {
333+
template = conn.getTemplateName();
342334
}
335+
StorPoolVolumeDef volume = new StorPoolVolumeDef(null, size, tags, null, vinfo.getMaxIops(), template, null, null, null);
336+
resp = StorPoolUtil.volumeCreate(volume, conn);
343337
return resp;
344338
}
345339

@@ -827,20 +821,24 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
827821
if (tier == null) {
828822
template = getTemplateFromOfferingDetail(vinfo.getDiskOfferingId());
829823
}
830-
}
831-
832-
if (tier != null || template != null) {
833-
Map<String, String> tags = StorPoolHelper.addStorPoolTags(name, getVMInstanceUUID(vmId), "volume", getVcPolicyTag(vmId), tier);
834-
835824
StorPoolUtil.spLog(
836825
"Creating volume [%s] with template [%s] or tier tags [%s] described in disk/service offerings details",
837826
vinfo.getUuid(), template, tier);
838-
resp = StorPoolUtil.volumeCreate(size, parentName, template, tags, conn);
839-
} else {
840-
resp = StorPoolUtil.volumeCreate(name, parentName, size, getVMInstanceUUID(vmId),
841-
getVcPolicyTag(vmId), "volume", vinfo.getMaxIops(), conn);
842827
}
843828

829+
Map<String, String> tags = StorPoolHelper.addStorPoolTags(name, getVMInstanceUUID(vmId), "volume", getVcPolicyTag(vmId), tier);
830+
831+
if (vinfo.getDeviceId() != null) {
832+
tags.put("disk", vinfo.getDeviceId().toString());
833+
}
834+
835+
if (template == null) {
836+
template = conn.getTemplateName();
837+
}
838+
839+
StorPoolVolumeDef volumeDef = new StorPoolVolumeDef(null, size, tags, parentName, null, template, null, null, null);
840+
resp = StorPoolUtil.volumeCreate(volumeDef, conn);
841+
844842
if (resp.getError() == null) {
845843
updateStoragePool(dstData.getDataStore().getId(), vinfo.getSize());
846844
updateVolumePoolType(vinfo);
@@ -1309,7 +1307,13 @@ public void provideVmInfo(long vmId, long volumeId) {
13091307
SpConnectionDesc conn = StorPoolUtil.getSpConnection(poolVO.getUuid(), poolVO.getId(), storagePoolDetailsDao, primaryStoreDao);
13101308
String volName = StorPoolStorageAdaptor.getVolumeNameFromPath(volume.getPath(), true);
13111309
VMInstanceVO userVM = vmInstanceDao.findById(vmId);
1312-
SpApiResponse resp = StorPoolUtil.volumeUpdateIopsAndTags(volName, volume.getInstanceId() != null ? userVM.getUuid() : "", null, conn, getVcPolicyTag(vmId));
1310+
Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, userVM.getUuid(), null, getVcPolicyTag(vmId), null);
1311+
if (volume.getDeviceId() != null) {
1312+
tags.put("disk", volume.getDeviceId().toString());
1313+
}
1314+
StorPoolVolumeDef spVolume = new StorPoolVolumeDef(volName, null, tags, null, null, null, null, null, null);
1315+
1316+
SpApiResponse resp = StorPoolUtil.volumeUpdate(spVolume, conn);
13131317
if (resp.getError() != null) {
13141318
logger.warn(String.format("Could not update VC policy tags of a volume with id [%s]", volume.getUuid()));
13151319
}

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/util/StorPoolUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ public static SpApiResponse volumeCreate(Long size, String parentName, String te
520520
return POST("MultiCluster/VolumeCreate", json, conn);
521521
}
522522

523+
public static SpApiResponse volumeCreate(StorPoolVolumeDef volume, SpConnectionDesc conn) {
524+
return POST("MultiCluster/VolumeCreate", volume, conn);
525+
}
526+
523527
public static SpApiResponse volumeCreate(SpConnectionDesc conn) {
524528
Map<String, Object> json = new LinkedHashMap<>();
525529
json.put("name", "");
@@ -568,6 +572,7 @@ public static SpApiResponse volumeUpdate(final String name, final Long newSize,
568572
public static SpApiResponse volumeRemoveTags(String name, SpConnectionDesc conn) {
569573
Map<String, Object> json = new HashMap<>();
570574
Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, "", null, "", null);
575+
tags.put("disk", "");
571576
json.put("tags", tags);
572577
return POST("MultiCluster/VolumeUpdate/" + name, json, conn);
573578
}

server/src/main/java/com/cloud/user/AccountManagerImpl.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,16 +1579,20 @@ public UserAccount updateUser(UpdateUserCmd updateUserCmd) {
15791579
public void verifyCallerPrivilegeForUserOrAccountOperations(Account userAccount) {
15801580
logger.debug(String.format("Verifying whether the caller has the correct privileges based on the user's role type and API permissions: %s", userAccount));
15811581

1582-
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, null);
1583-
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1582+
if (!Account.Type.PROJECT.equals(userAccount.getType())) {
1583+
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, null);
1584+
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1585+
}
15841586
}
15851587

15861588
protected void verifyCallerPrivilegeForUserOrAccountOperations(User user) {
15871589
logger.debug(String.format("Verifying whether the caller has the correct privileges based on the user's role type and API permissions: %s", user));
15881590

15891591
Account userAccount = getAccount(user.getAccountId());
1590-
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, user);
1591-
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1592+
if (!Account.Type.PROJECT.equals(userAccount.getType())) {
1593+
checkCallerRoleTypeAllowedForUserOrAccountOperations(userAccount, user);
1594+
checkCallerApiPermissionsForUserOrAccountOperations(userAccount);
1595+
}
15921596
}
15931597

15941598
protected void checkCallerRoleTypeAllowedForUserOrAccountOperations(Account userAccount, User user) {
@@ -1597,7 +1601,7 @@ protected void checkCallerRoleTypeAllowedForUserOrAccountOperations(Account user
15971601
RoleType userAccountRoleType = getRoleType(userAccount);
15981602

15991603
if (RoleType.Unknown == callerRoleType || RoleType.Unknown == userAccountRoleType) {
1600-
String errMsg = String.format("The role type of account [%s, %s] or [%s, %s] is unknown",
1604+
String errMsg = String.format("The role type of caller account [%s, %s] or target account [%s, %s] is unknown",
16011605
callingAccount.getName(), callingAccount.getUuid(), userAccount.getName(), userAccount.getUuid());
16021606
throw new PermissionDeniedException(errMsg);
16031607
}
@@ -2707,10 +2711,8 @@ public AccountVO createAccount(final String accountName, final Account.Type acco
27072711
}
27082712
}
27092713

2710-
if (!Account.Type.PROJECT.equals(accountType)) {
2711-
AccountVO newAccount = new AccountVO(accountName, domainId, networkDomain, accountType, roleId, uuid);
2712-
verifyCallerPrivilegeForUserOrAccountOperations(newAccount);
2713-
}
2714+
AccountVO newAccount = new AccountVO(accountName, domainId, networkDomain, accountType, roleId, uuid);
2715+
verifyCallerPrivilegeForUserOrAccountOperations(newAccount);
27142716

27152717
// Create the account
27162718
return Transaction.execute(new TransactionCallback<>() {

0 commit comments

Comments
 (0)