corrected syntax for network commands in cloudstack

This commit is contained in:
Adrian Cole 2011-05-09 22:17:03 -07:00
parent de463ffb8e
commit 67d5d8f1e7
4 changed files with 39 additions and 46 deletions

View File

@ -25,7 +25,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.filters.QuerySigner;
import org.jclouds.cloudstack.options.CreateNetworkOptions;
@ -36,7 +35,6 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import com.google.common.util.concurrent.ListenableFuture;
@ -77,9 +75,9 @@ public interface NetworkAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "createNetwork")
@Unwrap
@Unwrap(depth = 2)
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<AsyncCreateResponse> createNetworkInZone(@QueryParam("zoneid") long zoneId,
ListenableFuture<Network> createNetworkInZone(@QueryParam("zoneid") long zoneId,
@QueryParam("networkofferingid") long networkOfferingId, @QueryParam("name") String name,
@QueryParam("displaytext") String displayText, CreateNetworkOptions... options);
@ -88,6 +86,8 @@ public interface NetworkAsyncClient {
*/
@GET
@QueryParams(keys = "command", values = "deleteNetwork")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> deleteNetwork(@QueryParam("id") long id);
@Unwrap(depth = 2)
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Long> deleteNetwork(@QueryParam("id") long id);
}

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudstack.features;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.options.CreateNetworkOptions;
import org.jclouds.cloudstack.options.ListNetworksOptions;
@ -68,17 +67,18 @@ public interface NetworkClient {
* the display text of the network
* @param options
* optional parameters
* @return task in progress
* @return newly created network
*/
AsyncCreateResponse createNetworkInZone(long zoneId, long networkOfferingId, String name, String displayText,
Network createNetworkInZone(long zoneId, long networkOfferingId, String name, String displayText,
CreateNetworkOptions... options);
/**
* Deletes a network
*
* @param id
* the ID of the network
* @return job id related to destroying the network, or null if resource was not
* found
*/
void deleteNetwork(long id);
Long deleteNetwork(long id);
}

View File

@ -25,14 +25,11 @@ import org.jclouds.cloudstack.domain.NetworkType;
import org.jclouds.cloudstack.options.CreateNetworkOptions;
import org.jclouds.cloudstack.options.ListNetworksOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
@ -108,7 +105,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -128,7 +125,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -142,12 +139,12 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(httpRequest);

View File

@ -25,7 +25,6 @@ import static org.testng.Assert.assertTrue;
import java.util.NoSuchElementException;
import java.util.Set;
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.GuestIPType;
import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.domain.NetworkOffering;
@ -76,17 +75,14 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
public void testCreateNetworks() throws Exception {
if (!networksSupported)
return;
AsyncCreateResponse job = client.getNetworkClient().createNetworkInZone(zone.getId(), offering.getId(), prefix,
prefix);
assert jobComplete.apply(job.getJobId()) : job;
network = client.getNetworkClient().getNetwork(job.getId());
network = client.getNetworkClient().createNetworkInZone(zone.getId(), offering.getId(), prefix, prefix);
checkNetwork(network);
}
@AfterGroups(groups = "live")
protected void tearDown() {
if (network != null) {
client.getNetworkClient().deleteNetwork(network.getId());
jobComplete.apply(client.getNetworkClient().deleteNetwork(network.getId()));
}
super.tearDown();
}