Merge branch 'master' of git@github.com:jclouds/jclouds

* 'master' of git@github.com:jclouds/jclouds:
  fixed nat relationship in cloudstack
This commit is contained in:
Adrian Cole 2011-02-24 11:18:02 -08:00
commit f459100c75
4 changed files with 29 additions and 34 deletions

View File

@ -73,16 +73,15 @@ public interface NATAsyncClient {
ListenableFuture<IPForwardingRule> getIPForwardingRule(@QueryParam("id") long id); ListenableFuture<IPForwardingRule> getIPForwardingRule(@QueryParam("id") long id);
/** /**
* @see NATClient#createIPForwardingRuleForVirtualMachine * @see NATClient#createIPForwardingRule
*/ */
@GET @GET
@QueryParams(keys = "command", values = "createIpForwardingRule") @QueryParams(keys = "command", values = "createIpForwardingRule")
@Unwrap @Unwrap
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<AsyncCreateResponse> createIPForwardingRuleForVirtualMachine( ListenableFuture<AsyncCreateResponse> createIPForwardingRule(@QueryParam("ipaddressid") long IPAddressId,
@QueryParam("virtualmachineid") long virtualMachineId, @QueryParam("ipaddressid") long IPAddressId, @QueryParam("protocol") String protocol, @QueryParam("startport") int startPort,
@QueryParam("protocol") String protocol, @QueryParam("startport") int startPort, CreateIPForwardingRuleOptions... options);
CreateIPForwardingRuleOptions... options);
/** /**
* @see NATClient#enableStaticNATForVirtualMachine * @see NATClient#enableStaticNATForVirtualMachine
@ -92,7 +91,7 @@ public interface NATAsyncClient {
@Unwrap @Unwrap
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<AsyncCreateResponse> enableStaticNATForVirtualMachine( ListenableFuture<AsyncCreateResponse> enableStaticNATForVirtualMachine(
@QueryParam("virtualmachineid") long virtualMachineId, @QueryParam("ipaddressid") long IPAddressId); @QueryParam("virtualmachineid") long virtualMachineId, @QueryParam("ipaddressid") long IPAddressId);
/** /**
* @see NATClient#deleteIPForwardingRule * @see NATClient#deleteIPForwardingRule

View File

@ -59,9 +59,6 @@ public interface NATClient {
/** /**
* Creates an ip forwarding rule * Creates an ip forwarding rule
* *
* @param virtualMachineId
* the virtual machine this rule applies to.
*
* @param IPAddressId * @param IPAddressId
* the public IP address id of the forwarding rule, already associated via associateIp * the public IP address id of the forwarding rule, already associated via associateIp
* @param protocol * @param protocol
@ -70,8 +67,8 @@ public interface NATClient {
* the start port for the rule * the start port for the rule
* @return response used to track creation * @return response used to track creation
*/ */
AsyncCreateResponse createIPForwardingRuleForVirtualMachine(long virtualMachineId, long IPAddressId, AsyncCreateResponse createIPForwardingRule(long IPAddressId, String protocol, int startPort,
String protocol, int startPort, CreateIPForwardingRuleOptions... options); CreateIPForwardingRuleOptions... options);
/** /**
* Deletes an ip forwarding rule * Deletes an ip forwarding rule

View File

@ -49,7 +49,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
HttpRequest httpRequest = processor.createRequest(method); HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
@ -63,11 +63,11 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
public void testListIPForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException { public void testListIPForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class); Method method = NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListIPForwardingRulesOptions.Builder HttpRequest httpRequest = processor.createRequest(method,
.virtualMachineId(3)); ListIPForwardingRulesOptions.Builder.virtualMachineId(3));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&virtualmachineid=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&virtualmachineid=3 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
@ -84,7 +84,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 5); HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&id=5 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
@ -97,14 +97,14 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
} }
public void testCreateIPForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException, public void testCreateIPForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException,
IOException { IOException {
Method method = NATAsyncClient.class.getMethod("createIPForwardingRuleForVirtualMachine", long.class, long.class, Method method = NATAsyncClient.class.getMethod("createIPForwardingRule", long.class, String.class, int.class,
String.class, int.class, CreateIPForwardingRuleOptions[].class); CreateIPForwardingRuleOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 6, 7, "tcp", 22); HttpRequest httpRequest = processor.createRequest(method, 7, "tcp", 22);
assertRequestLineEquals( assertRequestLineEquals(
httpRequest, httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createIpForwardingRule&virtualmachineid=6&protocol=tcp&ipaddressid=7&startport=22 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=createIpForwardingRule&ipaddressid=7&startport=22&protocol=tcp HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
@ -117,15 +117,15 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
} }
public void testCreateIPForwardingRuleForVirtualMachineOptions() throws SecurityException, NoSuchMethodException, public void testCreateIPForwardingRuleForVirtualMachineOptions() throws SecurityException, NoSuchMethodException,
IOException { IOException {
Method method = NATAsyncClient.class.getMethod("createIPForwardingRuleForVirtualMachine", long.class, long.class, Method method = NATAsyncClient.class.getMethod("createIPForwardingRule", long.class, String.class, int.class,
String.class, int.class, CreateIPForwardingRuleOptions[].class); CreateIPForwardingRuleOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 6, 7, "tcp", 22, CreateIPForwardingRuleOptions.Builder HttpRequest httpRequest = processor.createRequest(method, 7, "tcp", 22,
.endPort(22)); CreateIPForwardingRuleOptions.Builder.endPort(22));
assertRequestLineEquals( assertRequestLineEquals(
httpRequest, httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createIpForwardingRule&virtualmachineid=6&protocol=tcp&ipaddressid=7&startport=22&endport=22 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=createIpForwardingRule&ipaddressid=7&startport=22&protocol=tcp&endport=22 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
@ -142,7 +142,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 5, 6); HttpRequest httpRequest = processor.createRequest(method, 5, 6);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=enableStaticNat&virtualmachineid=5&ipaddressid=6 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=enableStaticNat&virtualmachineid=5&ipaddressid=6 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
@ -159,7 +159,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 5); HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteIpForwardingRule&id=5 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=deleteIpForwardingRule&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);

View File

@ -64,8 +64,7 @@ public class NATClientLiveTest extends BaseCloudStackClientLiveTest {
ip = client.getAddressClient().getPublicIPAddress(ip.getId()); ip = client.getAddressClient().getPublicIPAddress(ip.getId());
assert ip.isStaticNAT(); assert ip.isStaticNAT();
AsyncCreateResponse job = client.getNATClient().createIPForwardingRuleForVirtualMachine(vm.getId(), ip.getId(), AsyncCreateResponse job = client.getNATClient().createIPForwardingRule(ip.getId(), "tcp", 22);
"tcp", 22);
assert jobComplete.apply(job.getJobId()); assert jobComplete.apply(job.getJobId());
rule = client.getNATClient().getIPForwardingRule(job.getId()); rule = client.getNATClient().getIPForwardingRule(job.getId());
assertEquals(rule.getIPAddressId(), ip.getId()); assertEquals(rule.getIPAddressId(), ip.getId());
@ -106,7 +105,7 @@ public class NATClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(response.size() >= 0); assertTrue(response.size() >= 0);
for (IPForwardingRule rule : response) { for (IPForwardingRule rule : response) {
IPForwardingRule newDetails = getOnlyElement(client.getNATClient().listIPForwardingRules( IPForwardingRule newDetails = getOnlyElement(client.getNATClient().listIPForwardingRules(
ListIPForwardingRulesOptions.Builder.id(rule.getId()))); ListIPForwardingRulesOptions.Builder.id(rule.getId())));
assertEquals(rule.getId(), newDetails.getId()); assertEquals(rule.getId(), newDetails.getId());
checkRule(rule); checkRule(rule);
} }