mirror of https://github.com/apache/jclouds.git
corrected syntax for network commands in cloudstack
This commit is contained in:
parent
de463ffb8e
commit
67d5d8f1e7
|
@ -25,7 +25,6 @@ import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
import org.jclouds.cloudstack.filters.QuerySigner;
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
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.annotations.Unwrap;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -77,17 +75,19 @@ public interface NetworkAsyncClient {
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "createNetwork")
|
@QueryParams(keys = "command", values = "createNetwork")
|
||||||
@Unwrap
|
@Unwrap(depth = 2)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@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("networkofferingid") long networkOfferingId, @QueryParam("name") String name,
|
||||||
@QueryParam("displaytext") String displayText, CreateNetworkOptions... options);
|
@QueryParam("displaytext") String displayText, CreateNetworkOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NetworkClient#deleteNetwork
|
* @see NetworkClient#deleteNetwork
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@QueryParams(keys = "command", values = "deleteNetwork")
|
@QueryParams(keys = "command", values = "deleteNetwork")
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
@Unwrap(depth = 2)
|
||||||
ListenableFuture<Void> deleteNetwork(@QueryParam("id") long id);
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Long> deleteNetwork(@QueryParam("id") long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudstack.features;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
||||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||||
|
@ -68,17 +67,18 @@ public interface NetworkClient {
|
||||||
* the display text of the network
|
* the display text of the network
|
||||||
* @param options
|
* @param options
|
||||||
* optional parameters
|
* 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);
|
CreateNetworkOptions... options);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a network
|
* Deletes a network
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* the ID of the network
|
* 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,14 +25,11 @@ import org.jclouds.cloudstack.domain.NetworkType;
|
||||||
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
import org.jclouds.cloudstack.options.CreateNetworkOptions;
|
||||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
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.UnwrapOnlyNestedJsonValue;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
|
||||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -108,7 +105,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||||
|
|
||||||
|
@ -128,7 +125,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||||
|
|
||||||
|
@ -142,12 +139,12 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest,
|
assertRequestLineEquals(httpRequest,
|
||||||
"GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1");
|
"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);
|
assertPayloadEquals(httpRequest, null, null, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyNestedJsonValue.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import static org.testng.Assert.assertTrue;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
|
||||||
import org.jclouds.cloudstack.domain.GuestIPType;
|
import org.jclouds.cloudstack.domain.GuestIPType;
|
||||||
import org.jclouds.cloudstack.domain.Network;
|
import org.jclouds.cloudstack.domain.Network;
|
||||||
import org.jclouds.cloudstack.domain.NetworkOffering;
|
import org.jclouds.cloudstack.domain.NetworkOffering;
|
||||||
|
@ -60,7 +59,7 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
zone = find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
|
zone = find(client.getZoneClient().listZones(), ZonePredicates.supportsAdvancedNetworks());
|
||||||
offering = Iterables.find(client.getOfferingClient().listNetworkOfferings(),new Predicate<NetworkOffering>(){
|
offering = Iterables.find(client.getOfferingClient().listNetworkOfferings(), new Predicate<NetworkOffering>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(NetworkOffering arg0) {
|
public boolean apply(NetworkOffering arg0) {
|
||||||
|
@ -76,17 +75,14 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
public void testCreateNetworks() throws Exception {
|
public void testCreateNetworks() throws Exception {
|
||||||
if (!networksSupported)
|
if (!networksSupported)
|
||||||
return;
|
return;
|
||||||
AsyncCreateResponse job = client.getNetworkClient().createNetworkInZone(zone.getId(), offering.getId(), prefix,
|
network = client.getNetworkClient().createNetworkInZone(zone.getId(), offering.getId(), prefix, prefix);
|
||||||
prefix);
|
|
||||||
assert jobComplete.apply(job.getJobId()) : job;
|
|
||||||
network = client.getNetworkClient().getNetwork(job.getId());
|
|
||||||
checkNetwork(network);
|
checkNetwork(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
client.getNetworkClient().deleteNetwork(network.getId());
|
jobComplete.apply(client.getNetworkClient().deleteNetwork(network.getId()));
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
@ -100,7 +96,7 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
assertTrue(networkCount >= 0);
|
assertTrue(networkCount >= 0);
|
||||||
for (Network network : response) {
|
for (Network network : response) {
|
||||||
Network newDetails = Iterables.getOnlyElement(client.getNetworkClient().listNetworks(
|
Network newDetails = Iterables.getOnlyElement(client.getNetworkClient().listNetworks(
|
||||||
ListNetworksOptions.Builder.id(network.getId())));
|
ListNetworksOptions.Builder.id(network.getId())));
|
||||||
assertEquals(network, newDetails);
|
assertEquals(network, newDetails);
|
||||||
assertEquals(network, client.getNetworkClient().getNetwork(network.getId()));
|
assertEquals(network, client.getNetworkClient().getNetwork(network.getId()));
|
||||||
checkNetwork(network);
|
checkNetwork(network);
|
||||||
|
@ -129,21 +125,21 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
assert network.getDomain() != null : network;
|
assert network.getDomain() != null : network;
|
||||||
assert network.getDomainId() > 0 : network;
|
assert network.getDomainId() > 0 : network;
|
||||||
switch (network.getGuestIPType()) {
|
switch (network.getGuestIPType()) {
|
||||||
case VIRTUAL:
|
case VIRTUAL:
|
||||||
assert network.getNetmask() == null : network;
|
assert network.getNetmask() == null : network;
|
||||||
assert network.getGateway() == null : network;
|
assert network.getGateway() == null : network;
|
||||||
assert network.getVLAN() == null : network;
|
assert network.getVLAN() == null : network;
|
||||||
assert network.getStartIP() == null : network;
|
assert network.getStartIP() == null : network;
|
||||||
assert network.getEndIP() == null : network;
|
assert network.getEndIP() == null : network;
|
||||||
break;
|
break;
|
||||||
case DIRECT:
|
case DIRECT:
|
||||||
assert network.getNetmask() != null : network;
|
assert network.getNetmask() != null : network;
|
||||||
assert network.getGateway() != null : network;
|
assert network.getGateway() != null : network;
|
||||||
assert network.getVLAN() != null : network;
|
assert network.getVLAN() != null : network;
|
||||||
assertEquals(network.getBroadcastURI(), "vlan://" + network.getVLAN());
|
assertEquals(network.getBroadcastURI(), "vlan://" + network.getVLAN());
|
||||||
assert network.getStartIP() != null : network;
|
assert network.getStartIP() != null : network;
|
||||||
assert network.getEndIP() != null : network;
|
assert network.getEndIP() != null : network;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue