diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java index b2c7e984f9..6960e693a4 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandler.java @@ -29,6 +29,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; import org.jclouds.logging.Logger; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.InsufficientResourcesException; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.util.Strings2; @@ -77,6 +78,11 @@ public class CloudStackErrorHandler implements HttpErrorHandler { exception = new IllegalStateException(message, exception); } break; + case 534: + if (message.contains("Maximum number of resources of type")) { + exception = new InsufficientResourcesException(message, exception); + } + break; case 537: exception = new IllegalStateException(message, exception); break; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandlerTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandlerTest.java index f337f34eed..2ff5e70110 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandlerTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/handlers/CloudStackErrorHandlerTest.java @@ -31,6 +31,7 @@ import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.InsufficientResourcesException; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; @@ -94,6 +95,17 @@ public class CloudStackErrorHandlerTest { AuthorizationException.class); } + @Test + void test534WithMaximumResourcesMakesInsufficientResourcesException() { + assertCodeMakes( + "GET", + URI.create("http://10.26.26.155:8080/client/api?response=json&command=deployVirtualMachine&zoneid=7dbc4787-ec2f-498d-95f0-848c8c81e5da&templateid=240937c8-d695-419c-9908-5c7b2a07e6f1&serviceofferingid=c376102e-b683-4d43-b583-4eeab4627e65&displayname=bousa-4&name=bousa-4"), + 534, + "", + "{ \"createipforwardingruleresponse\" : {\"errorcode\" : 534, \"errortext\" : \"Maximum number of resources of type 'volume' for account name=jarcec in domain id=1 has been exceeded.\"} }", + InsufficientResourcesException.class); + } + @Test void test537MakesIllegalStateException() { assertCodeMakes(