Skip to content

Commit e4295bf

Browse files
committed
Merge branch 'main' of https://github.com/apache/cloudstack into netris-integration-upstream
2 parents 5ec69d5 + 2d669db commit e4295bf

File tree

13 files changed

+1138
-975
lines changed

13 files changed

+1138
-975
lines changed

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

Lines changed: 2 additions & 6 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
@@ -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`

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<>() {

test/integration/plugins/storpool/TestTagsOnStorPool.py

Lines changed: 69 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def test_01_set_vcpolicy_tag_to_vm_with_attached_disks(self):
283283
virtualmachineid = self.virtual_machine.id, listall=True
284284
)
285285

286-
self.vc_policy_tags(volumes, vm_tags, vm, True)
286+
self.vc_policy_tags(volumes, vm_tags, vm, should_tags_exists=True)
287287

288288

289289
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
@@ -323,7 +323,7 @@ def test_03_create_vm_snapshot_vc_policy_tag(self):
323323
vm = list_virtual_machines(self.apiclient,id = self.virtual_machine.id, listall=True)
324324
vm_tags = vm[0].tags
325325

326-
self.vc_policy_tags(volumes, vm_tags, vm, True)
326+
self.vc_policy_tags(volumes, vm_tags, vm, should_tags_exists=True)
327327

328328

329329
self.assertEqual(volume_attached.id, self.volume.id, "Is not the same volume ")
@@ -455,7 +455,7 @@ def test_04_revert_vm_snapshots_vc_policy_tag(self):
455455
vm = list_virtual_machines(self.apiclient,id = self.virtual_machine.id, listall=True)
456456
vm_tags = vm[0].tags
457457

458-
self.vc_policy_tags(volumes, vm_tags, vm, True)
458+
self.vc_policy_tags(volumes, vm_tags, vm, should_tags_exists=True)
459459

460460
self.assertEqual(
461461
self.random_data_0,
@@ -491,14 +491,12 @@ def test_05_delete_vm_snapshots(self):
491491

492492
list_snapshot_response = VmSnapshot.list(
493493
self.apiclient,
494-
#vmid=self.virtual_machine.id,
495494
virtualmachineid=self.virtual_machine.id,
496495
listall=False)
497496
self.debug('list_snapshot_response -------------------- %s' % list_snapshot_response)
498497

499498
self.assertIsNone(list_snapshot_response, "snapshot is already deleted")
500499

501-
502500
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
503501
def test_06_remove_vcpolicy_tag_when_disk_detached(self):
504502
""" Test remove vc-policy tag to disk detached from VM"""
@@ -513,7 +511,7 @@ def test_06_remove_vcpolicy_tag_when_disk_detached(self):
513511
self.apiclient,
514512
self.volume_2
515513
)
516-
self.vc_policy_tags( volumes, vm_tags, vm, False)
514+
self.vc_policy_tags( volumes, vm_tags, vm, should_tags_exists=False)
517515

518516
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
519517
def test_07_delete_vcpolicy_tag(self):
@@ -550,7 +548,7 @@ def test_08_vcpolicy_tag_to_reverted_disk(self):
550548
virtualmachineid = self.virtual_machine2.id, listall=True,
551549
type = "ROOT"
552550
)
553-
self.vc_policy_tags(volume, vm_tags, vm, True)
551+
self.vc_policy_tags(volume, vm_tags, vm, should_tags_exists=True)
554552

555553
snapshot = Snapshot.create(
556554
self.apiclient,
@@ -571,8 +569,8 @@ def test_08_vcpolicy_tag_to_reverted_disk(self):
571569
vm = list_virtual_machines(self.apiclient,id = self.virtual_machine2.id)
572570
vm_tags = vm[0].tags
573571

574-
vol = list_volumes(self.apiclient, id = snapshot.volumeid, listall=True)
575-
self.vc_policy_tags(vol, vm_tags, vm, True)
572+
vol = list_volumes(self.apiclient, id=snapshot.volumeid, listall=True)
573+
self.vc_policy_tags(vol, vm_tags, vm, should_tags_exists=True)
576574

577575
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
578576
def test_09_remove_vm_tags_on_datadisks_attached_to_destroyed_vm(self):
@@ -586,38 +584,82 @@ def test_09_remove_vm_tags_on_datadisks_attached_to_destroyed_vm(self):
586584
vm_tags = vm[0].tags
587585
volumes = list_volumes(
588586
self.apiclient,
589-
virtualmachineid = self.virtual_machine3.id, listall=True
587+
virtualmachineid=self.virtual_machine3.id, listall=True
590588
)
591589

592-
self.vc_policy_tags(volumes, vm_tags, vm, True)
590+
self.vc_policy_tags(volumes, vm_tags, vm, should_tags_exists=True)
593591

594592
volumes = list_volumes(
595593
self.apiclient,
596-
virtualmachineid = self.virtual_machine3.id, listall=True, type="DATADISK"
594+
virtualmachineid=self.virtual_machine3.id, listall=True, type="DATADISK"
597595
)
598596
self.virtual_machine3.delete(self.apiclient, expunge=True)
599597

600-
self.vc_policy_tags(volumes, vm_tags, vm, False)
598+
self.vc_policy_tags(volumes, vm_tags, vm, should_tags_exists=False)
601599

602-
def vc_policy_tags(self, volumes, vm_tags, vm, should_tags_exists=None):
603-
vcPolicyTag = False
604-
cvmTag = False
600+
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
601+
def test_10_check_tags_on_deployed_vm_with_data_disk(self):
602+
"""
603+
Check disk and cvm tags are set on all volumes when VM is deployed with additional DATA disk
604+
Detach the DATA disk
605+
"""
606+
vm = VirtualMachine.create(
607+
self.apiclient,
608+
{"name":"StorPool-%s" % uuid.uuid4() },
609+
zoneid=self.zone.id,
610+
templateid=self.template.id,
611+
accountid=self.account.name,
612+
domainid=self.account.domainid,
613+
serviceofferingid=self.service_offering.id,
614+
hypervisor=self.hypervisor,
615+
diskofferingid=self.disk_offerings.id,
616+
size=2,
617+
rootdisksize=10
618+
)
619+
volumes = list_volumes(
620+
self.apiclient,
621+
virtualmachineid=vm.id, listall=True
622+
)
623+
vm1 = list_virtual_machines(self.apiclient,id=vm.id, listall=True)
624+
vm_tags = vm1[0].tags
625+
self.vc_policy_tags(volumes, vm_tags, vm1, False, True)
626+
vm.stop(self.apiclient, forced=True)
627+
volumes = list_volumes(
628+
self.apiclient,
629+
virtualmachineid=vm.id, listall=True, type="DATADISK"
630+
)
631+
632+
self.debug("detaching volume %s" % volumes)
633+
VirtualMachine.detach_volume(vm, self.apiclient, volumes[0])
634+
self.vc_policy_tags(volumes, vm_tags, vm1, False, False)
635+
636+
def vc_policy_tags(self, volumes, vm_tags, vm, tag_check=True, should_tags_exists=None,):
637+
vc_policy_tag = False
638+
cvm_tag = False
639+
disk_id_tag = False
605640
for v in volumes:
606641
name = v.path.split("/")[3]
607-
spvolume = self.spapi.volumeList(volumeName="~" + name)
608-
tags = spvolume[0].tags
642+
volume = self.spapi.volumeList(volumeName="~" + name)
643+
tags = volume[0].tags
644+
self.debug("Tags %s" % tags)
609645
for t in tags:
610646
for vm_tag in vm_tags:
611647
if t == vm_tag.key:
612-
vcPolicyTag = True
648+
vc_policy_tag = True
613649
self.assertEqual(tags[t], vm_tag.value, "Tags are not equal")
614-
if t == 'cvm':
615-
cvmTag = True
616-
self.assertEqual(tags[t], vm[0].id, "CVM tag is not the same as vm UUID")
617-
#self.assertEqual(tag.tags., second, msg)
650+
if t == 'cvm':
651+
cvm_tag = True
652+
self.assertEqual(tags[t], vm[0].id, "CVM tag is not the same as vm UUID")
653+
if t == 'disk':
654+
disk_id_tag = True
655+
self.assertEqual(tags[t], str(v.deviceid), "Disk tag is not equal to the device ID")
618656
if should_tags_exists:
619-
self.assertTrue(vcPolicyTag, "There aren't volumes with vm tags")
620-
self.assertTrue(cvmTag, "There aren't volumes with vm tags")
657+
if tag_check:
658+
self.assertTrue(vc_policy_tag, "There aren't volumes with vc policy tags")
659+
self.assertTrue(cvm_tag, "There aren't volumes with vm UUID tags")
660+
self.assertTrue(disk_id_tag, "There aren't volumes with vm disk tag")
621661
else:
622-
self.assertFalse(vcPolicyTag, "The tags should be removed")
623-
self.assertFalse(cvmTag, "The tags should be removed")
662+
if tag_check:
663+
self.assertFalse(vc_policy_tag, "The vc policy tag should be removed")
664+
self.assertFalse(cvm_tag, "The cvm tag should be removed")
665+
self.assertFalse(disk_id_tag, "The disk tag should be removed")

tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"format": "qcow2",
3333
"headless": true,
3434
"http_directory": "http",
35-
"iso_checksum": "sha512:022895e699231c94abf7012f86cabc587dc576f07f856c87609d5d40c1f921d805a5a862cba94c1a47d09aaa565ec445222e338e73d1fa1affc4fc5908bb50ad",
36-
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.10.0/arm64/iso-cd/debian-12.10.0-arm64-netinst.iso",
35+
"iso_checksum": "sha512:892cf1185a214d16ff62a18c6b89cdcd58719647c99916f6214bfca6f9915275d727b666c0b8fbf022c425ef18647e9759974abf7fc440431c39b50c296a98d3",
36+
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.11.0/arm64/iso-cd/debian-12.11.0-arm64-netinst.iso",
3737
"net_device": "virtio-net",
3838
"output_directory": "../dist",
3939
"qemu_binary": "qemu-system-aarch64",

0 commit comments

Comments
 (0)