diff --git a/server/src/main/java/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/main/java/com/cloud/tags/TaggedResourceManagerImpl.java index ae7949863b4..5dd5d313bf4 100644 --- a/server/src/main/java/com/cloud/tags/TaggedResourceManagerImpl.java +++ b/server/src/main/java/com/cloud/tags/TaggedResourceManagerImpl.java @@ -217,7 +217,7 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso } if (resourceType == ResourceObjectType.Project) { - accountId = ((ProjectVO)entity).getProjectAccountId(); + accountId = ((ProjectVO)entity).getId(); } if (entity instanceof OwnedBy) { diff --git a/test/integration/component/test_tags.py b/test/integration/component/test_tags.py index be4c6e26bd9..1fa40b33c93 100644 --- a/test/integration/component/test_tags.py +++ b/test/integration/component/test_tags.py @@ -1751,6 +1751,13 @@ class TestResourceTags(cloudstackTestCase): ) self.debug("Tag created: %s" % tag.__dict__) + tag2 = Tag.list( + self.apiclient, + listall=True, + resourceType='project', + resourceIds=project.id, + key=tag_key, + ) tags = Tag.list( self.apiclient, listall=True, @@ -1760,17 +1767,35 @@ class TestResourceTags(cloudstackTestCase): key=tag_key, ) self.debug("tags = %s" % tags) + tag2 = Tag.list( + self.apiclient, + listall=True, + resourceType='project', + resourceIds=project.id, + key=tag_key, + ) + self.debug("tag2 = %s" % tags) self.assertEqual( isinstance(tags, list), True, "List tags should not return empty response" ) + self.assertEqual( + isinstance(tag2, list), + True, + "List tags should not return empty response" + ) self.assertEqual( tags[0].value, tag_value, 'The tag should have original value' ) + self.assertEqual( + tag2[0].value, + tag_value, + 'The tag should have original value' + ) projects = Project.list( self.apiclient,