iso cleanup

This commit is contained in:
Adrian Cole 2011-12-21 23:29:53 -08:00
parent 70269a0091
commit 68820d5d61
8 changed files with 117 additions and 76 deletions

View File

@ -18,6 +18,8 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import java.util.Set;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
@ -71,7 +73,8 @@ public class ISOPermissions implements Comparable<ISOPermissions> {
} }
private long id; private long id;
private String account; @SerializedName("account")
private Set<String> accounts;
@SerializedName("domainid") @SerializedName("domainid")
private long domainId; private long domainId;
@SerializedName("ispublic") @SerializedName("ispublic")
@ -93,8 +96,8 @@ public class ISOPermissions implements Comparable<ISOPermissions> {
/** /**
* @return the list of accounts the template is available for * @return the list of accounts the template is available for
*/ */
public String getAccount() { public Set<String> getAccounts() {
return account; return accounts;
} }
/** /**
@ -112,26 +115,36 @@ public class ISOPermissions implements Comparable<ISOPermissions> {
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object obj) {
if (this == o) return true; if (this == obj)
if (o == null || getClass() != o.getClass()) return false; return true;
if (obj == null)
ISOPermissions that = (ISOPermissions) o; return false;
if (getClass() != obj.getClass())
if (domainId != that.domainId) return false; return false;
if (id != that.id) return false; ISOPermissions other = (ISOPermissions) obj;
if (isPublic != that.isPublic) return false; if (accounts == null) {
if (account != null ? !account.equals(that.account) : that.account != null) return false; if (other.accounts != null)
return false;
} else if (!accounts.equals(other.accounts))
return false;
if (domainId != other.domainId)
return false;
if (id != other.id)
return false;
if (isPublic != other.isPublic)
return false;
return true; return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = (int) (id ^ (id >>> 32)); final int prime = 31;
result = 31 * result + (account != null ? account.hashCode() : 0); int result = 1;
result = 31 * result + (int) (domainId ^ (domainId >>> 32)); result = prime * result + ((accounts == null) ? 0 : accounts.hashCode());
result = 31 * result + (isPublic ? 1 : 0); result = prime * result + (int) (domainId ^ (domainId >>> 32));
result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + (isPublic ? 1231 : 1237);
return result; return result;
} }
@ -139,7 +152,7 @@ public class ISOPermissions implements Comparable<ISOPermissions> {
public String toString() { public String toString() {
return "ISOPermissions{" + return "ISOPermissions{" +
"id=" + id + "id=" + id +
", account='" + account + '\'' + ", accounts='" + accounts + '\'' +
", domainId=" + domainId + ", domainId=" + domainId +
", isPublic=" + isPublic + ", isPublic=" + isPublic +
'}'; '}';

View File

@ -137,7 +137,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
@SerializedName("virtualmachinename") @SerializedName("virtualmachinename")
private String virtualMachineName; private String virtualMachineName;
@SerializedName("cidrlist") @SerializedName("cidrlist")
private String CIDRs = ""; private String CIDRs;
@SerializedName("privateendport") @SerializedName("privateendport")
private int privateEndPort; private int privateEndPort;
@SerializedName("publicendport") @SerializedName("publicendport")
@ -240,7 +240,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
* @return the cidr list to forward traffic from * @return the cidr list to forward traffic from
*/ */
public Set<String> getCIDRs() { public Set<String> getCIDRs() {
return ImmutableSet.copyOf(Splitter.on(' ').split(CIDRs)); return CIDRs != null ? ImmutableSet.copyOf(Splitter.on(' ').split(CIDRs)) : ImmutableSet.<String> of();
} }
/** /**
@ -334,7 +334,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
", virtualMachineDisplayName='" + virtualMachineDisplayName + '\'' + ", virtualMachineDisplayName='" + virtualMachineDisplayName + '\'' +
", virtualMachineId=" + virtualMachineId + ", virtualMachineId=" + virtualMachineId +
", virtualMachineName='" + virtualMachineName + '\'' + ", virtualMachineName='" + virtualMachineName + '\'' +
", CIDRs=" + CIDRs + ", CIDRs=" + getCIDRs() +
", privateEndPort=" + privateEndPort + ", privateEndPort=" + privateEndPort +
", publicEndPort=" + publicEndPort + ", publicEndPort=" + publicEndPort +
'}'; '}';

View File

@ -18,7 +18,13 @@
*/ */
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import com.google.common.util.concurrent.ListenableFuture; import java.util.Set;
import javax.ws.rs.Consumes;
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.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.ExtractMode; import org.jclouds.cloudstack.domain.ExtractMode;
import org.jclouds.cloudstack.domain.ISO; import org.jclouds.cloudstack.domain.ISO;
@ -31,16 +37,14 @@ import org.jclouds.cloudstack.options.ListISOsOptions;
import org.jclouds.cloudstack.options.RegisterISOOptions; import org.jclouds.cloudstack.options.RegisterISOOptions;
import org.jclouds.cloudstack.options.UpdateISOOptions; import org.jclouds.cloudstack.options.UpdateISOOptions;
import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions; import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.annotations.Unwrap;
import javax.ws.rs.Consumes; import com.google.common.util.concurrent.ListenableFuture;
import javax.ws.rs.GET;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.Set;
/** /**
* *
@ -64,7 +68,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "attachISO") @QueryParams(keys = "command", values = "attachIso")
@Unwrap @Unwrap
ListenableFuture<AsyncCreateResponse> attachISO(@QueryParam("id") long isoId, @QueryParam("virtualmachineid") long vmId); ListenableFuture<AsyncCreateResponse> attachISO(@QueryParam("id") long isoId, @QueryParam("virtualmachineid") long vmId);
@ -76,7 +80,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "detachISO") @QueryParams(keys = "command", values = "detachIso")
@Unwrap @Unwrap
ListenableFuture<AsyncCreateResponse> detachISO(@QueryParam("virtualmachineid") long vmId); ListenableFuture<AsyncCreateResponse> detachISO(@QueryParam("virtualmachineid") long vmId);
@ -88,8 +92,9 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "listISOs") @QueryParams(keys = "command", values = "listIsos")
@Unwrap @SelectJson("iso")
@OnlyElement
ListenableFuture<ISO> getISO(@QueryParam("id") long id); ListenableFuture<ISO> getISO(@QueryParam("id") long id);
/** /**
@ -100,8 +105,8 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "listISOs") @QueryParams(keys = "command", values = "listIsos")
@Unwrap @SelectJson("iso")
ListenableFuture<Set<ISO>> listISOs(ListISOsOptions... options); ListenableFuture<Set<ISO>> listISOs(ListISOsOptions... options);
/** /**
@ -116,7 +121,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "registerISO") @QueryParams(keys = "command", values = "registerIso")
@Unwrap @Unwrap
ListenableFuture<ISO> registerISO(@QueryParam("name") String name, @QueryParam("displaytext") String displayText, @QueryParam("url") String url, @QueryParam("zoneid") long zoneId, RegisterISOOptions... options); ListenableFuture<ISO> registerISO(@QueryParam("name") String name, @QueryParam("displaytext") String displayText, @QueryParam("url") String url, @QueryParam("zoneid") long zoneId, RegisterISOOptions... options);
@ -129,7 +134,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "updateISO") @QueryParams(keys = "command", values = "updateIso")
@Unwrap @Unwrap
ListenableFuture<ISO> updateISO(@QueryParam("id") long id, UpdateISOOptions... options); ListenableFuture<ISO> updateISO(@QueryParam("id") long id, UpdateISOOptions... options);
@ -142,7 +147,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "deleteISO") @QueryParams(keys = "command", values = "deleteIso")
@Unwrap @Unwrap
ListenableFuture<AsyncCreateResponse> deleteISO(@QueryParam("id") long id, DeleteISOOptions... options); ListenableFuture<AsyncCreateResponse> deleteISO(@QueryParam("id") long id, DeleteISOOptions... options);
@ -156,7 +161,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "copyISO") @QueryParams(keys = "command", values = "copyIso")
@Unwrap @Unwrap
ListenableFuture<AsyncCreateResponse> copyISO(@QueryParam("id") long isoId, @QueryParam("sourcezoneid") long sourceZoneId, @QueryParam("destzoneid") long destZoneId); ListenableFuture<AsyncCreateResponse> copyISO(@QueryParam("id") long isoId, @QueryParam("sourcezoneid") long sourceZoneId, @QueryParam("destzoneid") long destZoneId);
@ -169,7 +174,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "updateISOPermissions") @QueryParams(keys = "command", values = "updateIsoPermissions")
@Unwrap @Unwrap
ListenableFuture<Void> updateISOPermissions(@QueryParam("id") long id, UpdateISOPermissionsOptions... options); ListenableFuture<Void> updateISOPermissions(@QueryParam("id") long id, UpdateISOPermissionsOptions... options);
@ -182,9 +187,9 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "listISOPermissions") @QueryParams(keys = "command", values = "listIsoPermissions")
@Unwrap @SelectJson("templatepermission")
ListenableFuture<Set<ISOPermissions>> listISOPermissions(@QueryParam("id") long id, AccountInDomainOptions... options); ListenableFuture<ISOPermissions> listISOPermissions(@QueryParam("id") long id, AccountInDomainOptions... options);
/** /**
* Extracts an ISO * Extracts an ISO
@ -197,7 +202,7 @@ public interface ISOAsyncClient {
*/ */
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "command", values = "extractISO") @QueryParams(keys = "command", values = "extractIso")
@Unwrap @Unwrap
ListenableFuture<AsyncCreateResponse> extractISO(@QueryParam("id") long id, @QueryParam("mode") ExtractMode mode, @QueryParam("zoneid") long zoneId, ExtractISOOptions... options); ListenableFuture<AsyncCreateResponse> extractISO(@QueryParam("id") long id, @QueryParam("mode") ExtractMode mode, @QueryParam("zoneid") long zoneId, ExtractISOOptions... options);

View File

@ -18,6 +18,9 @@
*/ */
package org.jclouds.cloudstack.features; 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.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.ExtractMode; import org.jclouds.cloudstack.domain.ExtractMode;
import org.jclouds.cloudstack.domain.ISO; import org.jclouds.cloudstack.domain.ISO;
@ -31,9 +34,6 @@ import org.jclouds.cloudstack.options.UpdateISOOptions;
import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions; import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/** /**
* *
* <p/> * <p/>
@ -134,7 +134,7 @@ public interface ISOClient {
* @param options optional arguments * @param options optional arguments
* @return A set of the permissions on this ISO * @return A set of the permissions on this ISO
*/ */
Set<ISOPermissions> listISOPermissions(long id, AccountInDomainOptions... options); ISOPermissions listISOPermissions(long id, AccountInDomainOptions... options);
/** /**
* Extracts an ISO * Extracts an ISO

View File

@ -18,8 +18,8 @@
*/ */
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import com.google.common.collect.ImmutableSet; import java.lang.reflect.Method;
import com.google.inject.TypeLiteral;
import org.jclouds.cloudstack.domain.ExtractMode; import org.jclouds.cloudstack.domain.ExtractMode;
import org.jclouds.cloudstack.domain.ISO; import org.jclouds.cloudstack.domain.ISO;
import org.jclouds.cloudstack.domain.PermissionOperation; import org.jclouds.cloudstack.domain.PermissionOperation;
@ -31,13 +31,15 @@ import org.jclouds.cloudstack.options.RegisterISOOptions;
import org.jclouds.cloudstack.options.UpdateISOOptions; import org.jclouds.cloudstack.options.UpdateISOOptions;
import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions; import org.jclouds.cloudstack.options.UpdateISOPermissionsOptions;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.lang.reflect.Method; import com.google.common.collect.ImmutableSet;
import com.google.inject.TypeLiteral;
/** /**
* Tests the behaviour of ISOAsyncClient. * Tests the behaviour of ISOAsyncClient.
* *
@ -54,7 +56,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, 5); HttpRequest httpRequest = processor.createRequest(method, 3, 5);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=attachISO&id=3&virtualmachineid=5 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=attachIso&id=3&virtualmachineid=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);
@ -70,7 +72,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3); HttpRequest httpRequest = processor.createRequest(method, 3);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=detachISO&virtualmachineid=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=detachIso&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);
@ -86,11 +88,10 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3); HttpRequest httpRequest = processor.createRequest(method, 3);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listISOs&id=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIsos&id=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);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
assertSaxResponseParserClassEquals(method, null); assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -102,11 +103,11 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method); HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listISOs HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIsos 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);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class); assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null); assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -118,11 +119,11 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, ListISOsOptions.Builder.accountInDomain("fred", 5).bootable().hypervisor("xen").id(3).isoFilter(ISO.ISOFilter.featured).isPublic().isReady().keyword("bob").name("bob's iso").zoneId(7)); HttpRequest httpRequest = processor.createRequest(method, ListISOsOptions.Builder.accountInDomain("fred", 5).bootable().hypervisor("xen").id(3).isoFilter(ISO.ISOFilter.featured).isPublic().isReady().keyword("bob").name("bob's iso").zoneId(7));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listISOs&account=fred&domainid=5&bootable=true&hypervisor=xen&id=3&isofilter=featured&ispublic=true&isready=true&keyword=bob&name=bob%27s%20iso&zoneid=7 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIsos&account=fred&domainid=5&bootable=true&hypervisor=xen&id=3&isofilter=featured&ispublic=true&isready=true&keyword=bob&name=bob%27s%20iso&zoneid=7 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);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class); assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null); assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -134,7 +135,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, "bob's iso", "bob's copy of linux", "http://example.com/", 9); HttpRequest httpRequest = processor.createRequest(method, "bob's iso", "bob's copy of linux", "http://example.com/", 9);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=registerISO&name=bob%27s%20iso&url=http%3A//example.com/&displaytext=bob%27s%20copy%20of%20linux&zoneid=9 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=registerIso&name=bob%27s%20iso&url=http%3A//example.com/&displaytext=bob%27s%20copy%20of%20linux&zoneid=9 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);
@ -150,7 +151,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, "bob's iso", "bob's copy of linux", "http://example.com/", 9, RegisterISOOptions.Builder.accountInDomain("fred", 5).bootable(true).isExtractable(true).isFeatured(true).isPublic(true).osTypeId(7)); HttpRequest httpRequest = processor.createRequest(method, "bob's iso", "bob's copy of linux", "http://example.com/", 9, RegisterISOOptions.Builder.accountInDomain("fred", 5).bootable(true).isExtractable(true).isFeatured(true).isPublic(true).osTypeId(7));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=registerISO&name=bob%27s%20iso&url=http%3A//example.com/&displaytext=bob%27s%20copy%20of%20linux&zoneid=9&account=fred&domainid=5&bootable=true&isextractable=true&isfeatured=true&ispublic=true&ostypeid=7 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=registerIso&name=bob%27s%20iso&url=http%3A//example.com/&displaytext=bob%27s%20copy%20of%20linux&zoneid=9&account=fred&domainid=5&bootable=true&isextractable=true&isfeatured=true&ispublic=true&ostypeid=7 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);
@ -166,7 +167,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3); HttpRequest httpRequest = processor.createRequest(method, 3);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateISO&id=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=updateIso&id=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);
@ -182,7 +183,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId(9).passwordEnabled(true)); HttpRequest httpRequest = processor.createRequest(method, 3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId(9).passwordEnabled(true));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateISO&id=3&bootable=true&displaytext=robert&format=format&name=bob&ostypeid=9&passwordenabled=true HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=updateIso&id=3&bootable=true&displaytext=robert&format=format&name=bob&ostypeid=9&passwordenabled=true 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);
@ -198,7 +199,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3); HttpRequest httpRequest = processor.createRequest(method, 3);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteISO&id=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=deleteIso&id=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);
@ -214,7 +215,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, DeleteISOOptions.Builder.zoneId(5)); HttpRequest httpRequest = processor.createRequest(method, 3, DeleteISOOptions.Builder.zoneId(5));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteISO&id=3&zoneid=5 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=deleteIso&id=3&zoneid=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);
@ -230,7 +231,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, 5, 7); HttpRequest httpRequest = processor.createRequest(method, 3, 5, 7);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=copyISO&id=3&destzoneid=7&sourcezoneid=5 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=copyIso&id=3&destzoneid=7&sourcezoneid=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);
@ -246,7 +247,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3); HttpRequest httpRequest = processor.createRequest(method, 3);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateISOPermissions&id=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=updateIsoPermissions&id=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);
@ -262,7 +263,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.<String>of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add)); HttpRequest httpRequest = processor.createRequest(method, 3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.<String>of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateISOPermissions&id=3&accounts=fred,bob&isextractable=true&isfeatured=true&ispublic=true&op=add HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=updateIsoPermissions&id=3&accounts=fred,bob&isextractable=true&isfeatured=true&ispublic=true&op=add 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);
@ -278,11 +279,11 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3); HttpRequest httpRequest = processor.createRequest(method, 3);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listISOPermissions&id=3 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIsoPermissions&id=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);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class); assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null); assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -294,11 +295,11 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, AccountInDomainOptions.Builder.accountInDomain("fred", 5)); HttpRequest httpRequest = processor.createRequest(method, 3, AccountInDomainOptions.Builder.accountInDomain("fred", 5));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listISOPermissions&id=3&account=fred&domainid=5 HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=listIsoPermissions&id=3&account=fred&domainid=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);
assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class); assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
assertSaxResponseParserClassEquals(method, null); assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
@ -310,7 +311,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5); HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5);
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=extractISO&id=3&zoneid=5&mode=HTTP_DOWNLOAD HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=extractIso&id=3&zoneid=5&mode=HTTP_DOWNLOAD 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);
@ -326,7 +327,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/")); HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/"));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=extractISO&id=3&zoneid=5&mode=HTTP_DOWNLOAD&url=http%3A//example.com/ HTTP/1.1"); "GET http://localhost:8080/client/api?response=json&command=extractIso&id=3&zoneid=5&mode=HTTP_DOWNLOAD&url=http%3A//example.com/ 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

@ -18,12 +18,15 @@
*/ */
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudstack.domain.ISO; import org.jclouds.cloudstack.domain.ISO;
import org.jclouds.cloudstack.domain.ISOPermissions;
import org.jclouds.cloudstack.options.ListISOsOptions; import org.jclouds.cloudstack.options.ListISOsOptions;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -38,5 +41,25 @@ public class ISOClientLiveTest extends BaseCloudStackClientLiveTest {
Set<ISO> response = client.getISOClient().listISOs(ListISOsOptions.Builder.isPublic()); Set<ISO> response = client.getISOClient().listISOs(ListISOsOptions.Builder.isPublic());
assertNotNull(response); assertNotNull(response);
assertFalse(response.isEmpty()); assertFalse(response.isEmpty());
long isoCount = response.size();
assertTrue(isoCount >= 0);
for (ISO iso : response) {
ISO query = client.getISOClient().getISO(iso.getId());
assertEquals(query.getId(), iso.getId());
}
}
public void testListISOPermissions() throws Exception {
Set<ISO> response = client.getISOClient().listISOs(ListISOsOptions.Builder.isPublic());
assertNotNull(response);
assertFalse(response.isEmpty());
long isoCount = response.size();
assertTrue(isoCount >= 0);
for (ISO iso : response) {
ISOPermissions perms = client.getISOClient().listISOPermissions(iso.getId());
assertNotNull(perms);
}
} }
} }

View File

@ -11,8 +11,7 @@
"ipaddress": "10.27.27.64", "ipaddress": "10.27.27.64",
"startport": 22, "startport": 22,
"endport": 22, "endport": 22,
"state": "Active", "state": "Active"
"cidrlist":""
}] }]
} }
} }

View File

@ -1 +1 @@
{ "listportforwardingrulesresponse" : { "portforwardingrule" : [ {"id":18,"privateport":"22","protocol":"tcp","publicport":"22","virtualmachineid":89,"virtualmachinename":"i-3-89-VM","ipaddressid":34,"ipaddress":"72.52.126.63","state":"Active"}, {"id":15,"privateport":"22","protocol":"tcp","publicport":"2022","virtualmachineid":3,"virtualmachinename":"i-3-3-VM","ipaddressid":3,"ipaddress":"72.52.126.32","state":"Active"} ] } } { "listportforwardingrulesresponse" : { "portforwardingrule" : [ {"id":18,"privateport":"22","protocol":"tcp","publicport":"22","virtualmachineid":89,"virtualmachinename":"i-3-89-VM","ipaddressid":34,"ipaddress":"72.52.126.63","state":"Active"}, {"id":15,"privateport":"22","protocol":"tcp","publicport":"2022","virtualmachineid":3,"virtualmachinename":"i-3-3-VM","ipaddressid":3,"ipaddress":"72.52.126.32","state":"Active","cidrlist":""} ] } }