Skip to content

Commit fef8f6d

Browse files
Likitha ShettyPrachi Damle
authored andcommitted
CS-15703: EC2 tag support, improve error handling. Component: AWSAPI.
Handle exceptions thrown when invalid syntax is used to create or delete tags.
1 parent 21904cf commit fef8f6d

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ private EC2Tags toResourceTypeAndIds(ResourceIdSetType resourceIds) {
259259
List<String> resourceTypeList = new ArrayList<String>();
260260
if (items != null) {
261261
for( int i=0; i < items.length; i++ ) {
262+
if (!items[i].getResourceId().contains(":") || items[i].getResourceId().split(":").length != 2) {
263+
throw new EC2ServiceException( ClientError.InvalidResourceId_Format,
264+
"Invalid Format. ResourceId format is resource-type:resource-uuid");
265+
}
262266
String resourceType = items[i].getResourceId().split(":")[0];
263267
if (resourceTypeList.isEmpty())
264268
resourceTypeList.add(resourceType);

‎awsapi/src/com/cloud/bridge/service/exception/EC2ServiceException.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public static enum ClientError {
7878
InvalidPermission_Malformed("Client.InvalidPermission.Malformed", 400),
7979
InvalidReservationID_Malformed("Client.InvalidReservationID.Malformed", 400),
8080
InvalidReservationID_NotFound("Client.InvalidReservationID.NotFound", 400),
81+
InvalidResourceId_Format("Client.InvalidResourceId.Format", 400),
8182
InvalidSnapshotID_Malformed("Client.InvalidSnapshotID.Malformed", 400),
8283
InvalidSnapshot_NotFound("Client.InvalidSnapshot.NotFound", 400),
8384
InvalidUserID_Malformed("Client.InvalidUserID.Malformed", 400),

0 commit comments

Comments
 (0)