mirror of https://github.com/apache/jclouds.git
workaround for error handling on deltacloud
This commit is contained in:
parent
eb4a8393fb
commit
12d927f40d
|
@ -50,10 +50,8 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- when instances are hung, open a ticket and add here -->
|
|
||||||
<jclouds.compute.blacklist-nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist-nodes>
|
|
||||||
<test.deltacloud.endpoint>http://localhost:3001/api</test.deltacloud.endpoint>
|
<test.deltacloud.endpoint>http://localhost:3001/api</test.deltacloud.endpoint>
|
||||||
<test.deltacloud.apiversion>0.1.2</test.deltacloud.apiversion>
|
<test.deltacloud.apiversion>0.3.0</test.deltacloud.apiversion>
|
||||||
<test.deltacloud.identity>mockuser</test.deltacloud.identity>
|
<test.deltacloud.identity>mockuser</test.deltacloud.identity>
|
||||||
<test.deltacloud.credential>mockpassword</test.deltacloud.credential>
|
<test.deltacloud.credential>mockpassword</test.deltacloud.credential>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -127,10 +125,6 @@
|
||||||
<name>test.deltacloud.credential</name>
|
<name>test.deltacloud.credential</name>
|
||||||
<value>${test.deltacloud.credential}</value>
|
<value>${test.deltacloud.credential}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
|
||||||
<name>jclouds.compute.blacklist-nodes</name>
|
|
||||||
<value>${jclouds.compute.blacklist-nodes}</value>
|
|
||||||
</property>
|
|
||||||
</systemProperties>
|
</systemProperties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class DeltacloudPropertiesBuilder extends PropertiesBuilder {
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "0.1.2");
|
properties.setProperty(PROPERTY_API_VERSION, "0.3.0");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,9 @@ public class DeltacloudErrorHandler implements HttpErrorHandler {
|
||||||
try {
|
try {
|
||||||
message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
|
message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
|
||||||
response.getStatusLine());
|
response.getStatusLine());
|
||||||
|
if (message.indexOf("ItemNotFound") != -1) {
|
||||||
|
exception = new ResourceNotFoundException(message, exception);
|
||||||
|
} else {
|
||||||
switch (response.getStatusCode()) {
|
switch (response.getStatusCode()) {
|
||||||
case 400:
|
case 400:
|
||||||
exception = new IllegalArgumentException(message, exception);
|
exception = new IllegalArgumentException(message, exception);
|
||||||
|
@ -73,6 +76,7 @@ public class DeltacloudErrorHandler implements HttpErrorHandler {
|
||||||
exception = new IllegalStateException(message, exception);
|
exception = new IllegalStateException(message, exception);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (response.getPayload() != null)
|
if (response.getPayload() != null)
|
||||||
Closeables.closeQuietly(response.getPayload().getInput());
|
Closeables.closeQuietly(response.getPayload().getInput());
|
||||||
|
|
|
@ -64,6 +64,12 @@ public class DeltacloudErrorHandlerTest {
|
||||||
ResourceNotFoundException.class);
|
ResourceNotFoundException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testItemNotFoundMakesResourceNotFoundException() {
|
||||||
|
assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 500, "", "ItemNotFound",
|
||||||
|
ResourceNotFoundException.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test405MakesIllegalArgumentException() {
|
public void test405MakesIllegalArgumentException() {
|
||||||
assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 405, "", "Method Not Allowed",
|
assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 405, "", "Method Not Allowed",
|
||||||
|
|
Loading…
Reference in New Issue