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

View File

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

View File

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

View File

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