Skip to content

Commit 5fa7801

Browse files
committed
CLOUDSTACK-7954:ListTags API is ignoring the resourceID and displaying
all the tags of all resources.
1 parent 7de9d2f commit 5fa7801

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎server/src/com/cloud/api/query/QueryManagerImpl.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,8 @@ private Pair<List<ResourceTagJoinVO>, Integer> listTagsInternal(ListTagsCmd cmd)
653653
sb.and("value", sb.entity().getValue(), SearchCriteria.Op.EQ);
654654

655655
if (resourceId != null) {
656-
sb.and().op("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.EQ);
657-
sb.or("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.EQ);
658-
sb.cp();
656+
sb.and("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.EQ);
657+
sb.and("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.EQ);
659658
}
660659

661660
sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ);
@@ -675,8 +674,13 @@ private Pair<List<ResourceTagJoinVO>, Integer> listTagsInternal(ListTagsCmd cmd)
675674
}
676675

677676
if (resourceId != null) {
678-
sc.setParameters("resourceId", resourceId);
679-
sc.setParameters("resourceUuid", resourceId);
677+
try {
678+
long rid = Long.parseLong(resourceId);
679+
sc.setParameters("resourceId", rid);
680+
} catch (NumberFormatException ex) {
681+
// internal id instead of resource id is passed
682+
sc.setParameters("resourceUuid", resourceId);
683+
}
680684
}
681685

682686
if (resourceType != null) {

0 commit comments

Comments
 (0)