Issue 112: fixed catalog and orgs to be plural; added error to task

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2605 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-01-06 01:28:14 +00:00
parent 15c147cd25
commit e2235e48f8
32 changed files with 842 additions and 561 deletions

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.vcloud; package org.jclouds.vcloud;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML; import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML; import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML; import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML;
@ -82,15 +83,29 @@ public interface VCloudAsyncClient {
@GET @GET
@Endpoint(Org.class) @Endpoint(Org.class)
@Consumes(VCloudMediaType.ORG_XML) @Consumes(ORG_XML)
@XMLResponseParser(OrgHandler.class) @XMLResponseParser(OrgHandler.class)
Future<? extends Organization> getOrganization(); Future<? extends Organization> getDefaultOrganization();
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/org/{orgId}")
@XMLResponseParser(OrgHandler.class)
@Consumes(ORG_XML)
Future<? extends Organization> getOrganization(@PathParam("orgId") String orgId);
@GET @GET
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class) @Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
@Consumes(CATALOG_XML) @Consumes(CATALOG_XML)
@XMLResponseParser(CatalogHandler.class) @XMLResponseParser(CatalogHandler.class)
Future<? extends Catalog> getCatalog(); Future<? extends Catalog> getDefaultCatalog();
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/catalog/{catalogId}")
@XMLResponseParser(CatalogHandler.class)
@Consumes(CATALOG_XML)
Future<? extends Catalog> getCatalog(@PathParam("catalogId") String catalogId);
@GET @GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class) @Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)

View File

@ -46,9 +46,13 @@ public interface VCloudClient {
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within * This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within
* the organization. * the organization.
*/ */
Organization getOrganization(); Organization getDefaultOrganization();
Catalog getCatalog(); Organization getOrganization(String orgId);
Catalog getDefaultCatalog();
Catalog getCatalog(String catalogId);
CatalogItem getCatalogItem(String catalogItemId); CatalogItem getCatalogItem(String catalogItemId);

View File

@ -181,7 +181,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
} }
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name, protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name,
String network) { String network) {
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e( XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e(
"NetworkConfig").a("name", name); "NetworkConfig").a("name", name);
XMLBuilder featuresBuilder = networkConfigBuilder.e("Features"); XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");

View File

@ -33,6 +33,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import javax.annotation.Resource;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -41,6 +42,7 @@ import org.jclouds.concurrent.internal.SyncProxy;
import org.jclouds.encryption.EncryptionService; import org.jclouds.encryption.EncryptionService;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.logging.Logger;
import org.jclouds.predicates.AddressReachable; import org.jclouds.predicates.AddressReachable;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen; import org.jclouds.predicates.SocketOpen;
@ -81,6 +83,8 @@ import com.google.inject.Provides;
@RequiresHttp @RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
public class VCloudRestClientModule extends AbstractModule { public class VCloudRestClientModule extends AbstractModule {
@Resource
protected Logger logger = Logger.NULL;
@Provides @Provides
@Singleton @Singleton
@ -102,6 +106,7 @@ public class VCloudRestClientModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
requestInjection(this);
} }
@VCloudToken @VCloudToken
@ -217,21 +222,21 @@ public class VCloudRestClientModule extends AbstractModule {
@Singleton @Singleton
protected Organization provideOrganization(VCloudClient discovery) throws ExecutionException, protected Organization provideOrganization(VCloudClient discovery) throws ExecutionException,
TimeoutException, InterruptedException { TimeoutException, InterruptedException {
return discovery.getOrganization(); return discovery.getDefaultOrganization();
} }
@Provides @Provides
@VDC @VDC
@Singleton @Singleton
protected URI provideDefaultVDC(Organization org) { protected URI provideDefaultVDC(Organization org) {
return org.getVDCs().values().iterator().next().getLocation(); return Iterables.get(org.getVDCs().values(), 0).getLocation();
} }
@Provides @Provides
@Catalog @Catalog
@Singleton @Singleton
protected URI provideCatalog(Organization org) { protected URI provideCatalog(Organization org) {
return org.getCatalog().getLocation(); return Iterables.get(org.getCatalogs().values(), 0).getLocation();
} }
@Provides @Provides
@ -239,8 +244,7 @@ public class VCloudRestClientModule extends AbstractModule {
@Singleton @Singleton
protected URI provideDefaultNetwork(VCloudAsyncClient client) throws InterruptedException, protected URI provideDefaultNetwork(VCloudAsyncClient client) throws InterruptedException,
ExecutionException, TimeoutException { ExecutionException, TimeoutException {
return client.getDefaultVDC().get(180, TimeUnit.SECONDS).getAvailableNetworks().values() return Iterables.get(client.getDefaultVDC().get(180, TimeUnit.SECONDS).getAvailableNetworks().values(), 0).getLocation();
.iterator().next().getLocation();
} }
@Provides @Provides

View File

@ -36,7 +36,7 @@ import com.google.inject.ImplementedBy;
public interface Organization extends NamedResource { public interface Organization extends NamedResource {
@Catalog @Catalog
NamedResource getCatalog(); Map<String, NamedResource> getCatalogs();
@VDC @VDC
Map<String, NamedResource> getVDCs(); Map<String, NamedResource> getVDCs();

View File

@ -126,90 +126,96 @@ public class ResourceAllocation implements Comparable<ResourceAllocation> {
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((address == null) ? 0 : address.hashCode()); result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode()); result = prime * result
result = prime * result + ((connected == null) ? 0 : connected.hashCode()); + ((addressOnParent == null) ? 0 : addressOnParent.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((connected == null) ? 0 : connected.hashCode());
result = prime * result + ((hostResource == null) ? 0 : hostResource.hashCode()); result = prime * result
result = prime * result + id; + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result
result = prime * result + ((parent == null) ? 0 : parent.hashCode()); + ((hostResource == null) ? 0 : hostResource.hashCode());
result = prime * result + ((subType == null) ? 0 : subType.hashCode()); result = prime * result + id;
result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32)); result = prime * result + ((parent == null) ? 0 : parent.hashCode());
result = prime * result result = prime * result + ((subType == null) ? 0 : subType.hashCode());
+ ((virtualQuantityUnits == null) ? 0 : virtualQuantityUnits.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode());
return result; result = prime * result
} + (int) (virtualQuantity ^ (virtualQuantity >>> 32));
result = prime
* result
+ ((virtualQuantityUnits == null) ? 0 : virtualQuantityUnits
.hashCode());
return result;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
return true; return true;
if (obj == null) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
ResourceAllocation other = (ResourceAllocation) obj; ResourceAllocation other = (ResourceAllocation) obj;
if (address == null) { if (address == null) {
if (other.address != null) if (other.address != null)
return false; return false;
} else if (!address.equals(other.address)) } else if (!address.equals(other.address))
return false; return false;
if (addressOnParent == null) { if (addressOnParent == null) {
if (other.addressOnParent != null) if (other.addressOnParent != null)
return false; return false;
} else if (!addressOnParent.equals(other.addressOnParent)) } else if (!addressOnParent.equals(other.addressOnParent))
return false; return false;
if (connected == null) { if (connected == null) {
if (other.connected != null) if (other.connected != null)
return false; return false;
} else if (!connected.equals(other.connected)) } else if (!connected.equals(other.connected))
return false; return false;
if (description == null) { if (description == null) {
if (other.description != null) if (other.description != null)
return false; return false;
} else if (!description.equals(other.description)) } else if (!description.equals(other.description))
return false; return false;
if (hostResource == null) { if (hostResource == null) {
if (other.hostResource != null) if (other.hostResource != null)
return false; return false;
} else if (!hostResource.equals(other.hostResource)) } else if (!hostResource.equals(other.hostResource))
return false; return false;
if (id != other.id) if (id != other.id)
return false; return false;
if (name == null) { if (name == null) {
if (other.name != null) if (other.name != null)
return false; return false;
} else if (!name.equals(other.name)) } else if (!name.equals(other.name))
return false; return false;
if (parent == null) { if (parent == null) {
if (other.parent != null) if (other.parent != null)
return false; return false;
} else if (!parent.equals(other.parent)) } else if (!parent.equals(other.parent))
return false; return false;
if (subType == null) { if (subType == null) {
if (other.subType != null) if (other.subType != null)
return false; return false;
} else if (!subType.equals(other.subType)) } else if (!subType.equals(other.subType))
return false; return false;
if (type == null) { if (type == null) {
if (other.type != null) if (other.type != null)
return false; return false;
} else if (!type.equals(other.type)) } else if (!type.equals(other.type))
return false; return false;
if (virtualQuantity != other.virtualQuantity) if (virtualQuantity != other.virtualQuantity)
return false; return false;
if (virtualQuantityUnits == null) { if (virtualQuantityUnits == null) {
if (other.virtualQuantityUnits != null) if (other.virtualQuantityUnits != null)
return false; return false;
} else if (!virtualQuantityUnits.equals(other.virtualQuantityUnits)) } else if (!virtualQuantityUnits.equals(other.virtualQuantityUnits))
return false; return false;
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {

View File

@ -49,4 +49,13 @@ public interface Task extends Comparable<Task> {
* A link to the result of the task * A link to the result of the task
*/ */
NamedResource getResult(); NamedResource getResult();
Error getError();
@ImplementedBy(TaskImpl.ErrorImpl.class)
static interface Error {
String getMessage();
String getMajorErrorCode();
String getMinorErrorCode();
}
} }

View File

@ -19,7 +19,7 @@
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.SortedSet; import java.util.Set;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
@ -43,7 +43,7 @@ public interface VApp extends NamedResource {
VirtualSystem getSystem(); VirtualSystem getSystem();
SortedSet<ResourceAllocation> getResourceAllocations(); Set<ResourceAllocation> getResourceAllocations();
Multimap<ResourceType, ResourceAllocation> getResourceAllocationByType(); Multimap<ResourceType, ResourceAllocation> getResourceAllocationByType();

View File

@ -50,44 +50,45 @@ public class VirtualSystem {
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + id; result = prime * result + id;
result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); result = prime * result
result = prime * result + ((name == null) ? 0 : name.hashCode()); + ((identifier == null) ? 0 : identifier.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
return result; result = prime * result + ((type == null) ? 0 : type.hashCode());
} return result;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
return true; return true;
if (obj == null) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
VirtualSystem other = (VirtualSystem) obj; VirtualSystem other = (VirtualSystem) obj;
if (id != other.id) if (id != other.id)
return false; return false;
if (identifier == null) { if (identifier == null) {
if (other.identifier != null) if (other.identifier != null)
return false; return false;
} else if (!identifier.equals(other.identifier)) } else if (!identifier.equals(other.identifier))
return false; return false;
if (name == null) { if (name == null) {
if (other.name != null) if (other.name != null)
return false; return false;
} else if (!name.equals(other.name)) } else if (!name.equals(other.name))
return false; return false;
if (type == null) { if (type == null) {
if (other.type != null) if (other.type != null)
return false; return false;
} else if (!type.equals(other.type)) } else if (!type.equals(other.type))
return false; return false;
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {

View File

@ -38,16 +38,16 @@ public class OrganizationImpl implements Organization {
private final String id; private final String id;
private final String name; private final String name;
private final URI location; private final URI location;
private final NamedResource catalog; private final Map<String, NamedResource> catalogs;
private final Map<String, NamedResource> vdcs; private final Map<String, NamedResource> vdcs;
private final Map<String, NamedResource> tasksLists; private final Map<String, NamedResource> tasksLists;
public OrganizationImpl(String id, String name, URI location, NamedResource catalog, public OrganizationImpl(String id, String name, URI location, Map<String, NamedResource> catalogs,
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) { Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.location = location; this.location = location;
this.catalog = catalog; this.catalogs = catalogs;
this.vdcs = vdcs; this.vdcs = vdcs;
this.tasksLists = tasksLists; this.tasksLists = tasksLists;
} }
@ -65,8 +65,8 @@ public class OrganizationImpl implements Organization {
} }
@Catalog @Catalog
public NamedResource getCatalog() { public Map<String, NamedResource> getCatalogs() {
return catalog; return catalogs;
} }
@VDC @VDC
@ -83,7 +83,7 @@ public class OrganizationImpl implements Organization {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((catalog == null) ? 0 : catalog.hashCode()); result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
@ -101,10 +101,10 @@ public class OrganizationImpl implements Organization {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
OrganizationImpl other = (OrganizationImpl) obj; OrganizationImpl other = (OrganizationImpl) obj;
if (catalog == null) { if (catalogs == null) {
if (other.catalog != null) if (other.catalogs != null)
return false; return false;
} else if (!catalog.equals(other.catalog)) } else if (!catalogs.equals(other.catalogs))
return false; return false;
if (id == null) { if (id == null) {
if (other.id != null) if (other.id != null)

View File

@ -30,135 +30,217 @@ import org.jclouds.vcloud.domain.TaskStatus;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;
/** /**
* Locations of resources in vCloud
* *
* @author Adrian Cole * @author Adrian Cole
* *
*/ */
public class TaskImpl implements Task { public class TaskImpl implements Task {
private final String id;
private final URI location;
private final TaskStatus status;
private final Date startTime;
@Nullable
private final Date endTime;
private final NamedResource owner;
@Nullable
private final NamedResource result;
public TaskImpl(String id, URI location, TaskStatus status, Date startTime, public static class ErrorImpl implements Error {
@Nullable Date endTime, NamedResource owner, private final String message;
@Nullable NamedResource result) { private final String majorErrorCode;
this.id = checkNotNull(id, "id"); private final String minorErrorCode;
this.location = checkNotNull(location, "location");
this.status = checkNotNull(status, "status");
this.startTime = startTime;
this.endTime = endTime;
this.owner = owner;
this.result = result;
}
public TaskStatus getStatus() { public ErrorImpl(String message, String majorErrorCode,
return status; String minorErrorCode) {
} this.message = message;
this.majorErrorCode = majorErrorCode;
this.minorErrorCode = minorErrorCode;
}
public Date getStartTime() { public String getMessage() {
return startTime; return message;
} }
public NamedResource getOwner() { public String getMajorErrorCode() {
return owner; return majorErrorCode;
} }
public NamedResource getResult() { public String getMinorErrorCode() {
return result; return minorErrorCode;
} }
public Date getEndTime() { @Override
return endTime; public int hashCode() {
} final int prime = 31;
int result = 1;
result = prime * result
+ ((majorErrorCode == null) ? 0 : majorErrorCode.hashCode());
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result
+ ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode());
return result;
}
public int compareTo(Task o) { @Override
return (this == o) ? 0 : getId().compareTo(o.getId()); public boolean equals(Object obj) {
} if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ErrorImpl other = (ErrorImpl) obj;
if (majorErrorCode == null) {
if (other.majorErrorCode != null)
return false;
} else if (!majorErrorCode.equals(other.majorErrorCode))
return false;
if (message == null) {
if (other.message != null)
return false;
} else if (!message.equals(other.message))
return false;
if (minorErrorCode == null) {
if (other.minorErrorCode != null)
return false;
} else if (!minorErrorCode.equals(other.minorErrorCode))
return false;
return true;
}
public String getId() { @Override
return id; public String toString() {
} return "ErrorImpl [majorErrorCode=" + majorErrorCode + ", message="
+ message + ", minorErrorCode=" + minorErrorCode + "]";
}
}
public URI getLocation() { private final String id;
return location; private final URI location;
} private final TaskStatus status;
private final Date startTime;
@Nullable
private final Date endTime;
private final NamedResource owner;
@Nullable
private final NamedResource result;
@Nullable
private final Error error;
@Override public TaskImpl(String id, URI location, TaskStatus status, Date startTime,
public int hashCode() { @Nullable Date endTime, NamedResource owner,
final int prime = 31; @Nullable NamedResource result, Error error) {
int result = 1; this.id = checkNotNull(id, "id");
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); this.location = checkNotNull(location, "location");
result = prime * result + ((id == null) ? 0 : id.hashCode()); this.status = checkNotNull(status, "status");
result = prime * result this.startTime = startTime;
+ ((location == null) ? 0 : location.hashCode()); this.endTime = endTime;
result = prime * result + ((owner == null) ? 0 : owner.hashCode()); this.owner = owner;
result = prime * result this.result = result;
+ ((this.result == null) ? 0 : this.result.hashCode()); this.error = error;
result = prime * result }
+ ((startTime == null) ? 0 : startTime.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
return result;
}
@Override public TaskStatus getStatus() {
public boolean equals(Object obj) { return status;
if (this == obj) }
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TaskImpl other = (TaskImpl) obj;
if (endTime == null) {
if (other.endTime != null)
return false;
} else if (!endTime.equals(other.endTime))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (owner == null) {
if (other.owner != null)
return false;
} else if (!owner.equals(other.owner))
return false;
if (result == null) {
if (other.result != null)
return false;
} else if (!result.equals(other.result))
return false;
if (startTime == null) {
if (other.startTime != null)
return false;
} else if (!startTime.equals(other.startTime))
return false;
if (status == null) {
if (other.status != null)
return false;
} else if (!status.equals(other.status))
return false;
return true;
}
@Override public Date getStartTime() {
public String toString() { return startTime;
return "TaskImpl [endTime=" + endTime + ", id=" + id + ", location=" }
+ location + ", owner=" + owner + ", result=" + result
+ ", startTime=" + startTime + ", status=" + status + "]"; public NamedResource getOwner() {
} return owner;
}
public NamedResource getResult() {
return result;
}
public Date getEndTime() {
return endTime;
}
public int compareTo(Task o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
public String getId() {
return id;
}
public URI getLocation() {
return location;
}
public Error getError() {
return error;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
result = prime * result + ((error == null) ? 0 : error.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
result = prime * result
+ ((this.result == null) ? 0 : this.result.hashCode());
result = prime * result
+ ((startTime == null) ? 0 : startTime.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TaskImpl other = (TaskImpl) obj;
if (endTime == null) {
if (other.endTime != null)
return false;
} else if (!endTime.equals(other.endTime))
return false;
if (error == null) {
if (other.error != null)
return false;
} else if (!error.equals(other.error))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (owner == null) {
if (other.owner != null)
return false;
} else if (!owner.equals(other.owner))
return false;
if (result == null) {
if (other.result != null)
return false;
} else if (!result.equals(other.result))
return false;
if (startTime == null) {
if (other.startTime != null)
return false;
} else if (!startTime.equals(other.startTime))
return false;
if (status == null) {
if (other.status != null)
return false;
} else if (!status.equals(other.status))
return false;
return true;
}
@Override
public String toString() {
return "TaskImpl [endTime=" + endTime + ", error=" + error + ", id=" + id
+ ", location=" + location + ", owner=" + owner + ", result="
+ result + ", startTime=" + startTime + ", status=" + status + "]";
}
} }

View File

@ -20,7 +20,7 @@ package org.jclouds.vcloud.domain.internal;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URI; import java.net.URI;
import java.util.SortedSet; import java.util.Set;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.NamedResource;
@ -49,7 +49,7 @@ public class VAppImpl implements VApp {
private final ListMultimap<String, InetAddress> networkToAddresses; private final ListMultimap<String, InetAddress> networkToAddresses;
private final String operatingSystemDescription; private final String operatingSystemDescription;
private final VirtualSystem system; private final VirtualSystem system;
private final SortedSet<ResourceAllocation> resourceAllocations; private final Set<ResourceAllocation> resourceAllocations;
private final ListMultimap<ResourceType, ResourceAllocation> resourceAllocationByType; private final ListMultimap<ResourceType, ResourceAllocation> resourceAllocationByType;
/** The serialVersionUID */ /** The serialVersionUID */
@ -58,7 +58,7 @@ public class VAppImpl implements VApp {
public VAppImpl(String id, String name, URI location, VAppStatus status, Long size, public VAppImpl(String id, String name, URI location, VAppStatus status, Long size,
ListMultimap<String, InetAddress> networkToAddresses, ListMultimap<String, InetAddress> networkToAddresses,
String operatingSystemDescription, VirtualSystem system, String operatingSystemDescription, VirtualSystem system,
SortedSet<ResourceAllocation> resourceAllocations) { Set<ResourceAllocation> resourceAllocations) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.location = location; this.location = location;
@ -93,7 +93,7 @@ public class VAppImpl implements VApp {
return system; return system;
} }
public SortedSet<ResourceAllocation> getResourceAllocations() { public Set<ResourceAllocation> getResourceAllocations() {
return resourceAllocations; return resourceAllocations;
} }
@ -102,79 +102,95 @@ public class VAppImpl implements VApp {
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode()); result = prime
result = prime * result * result
+ ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode()); + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode());
result = prime * result result = prime
+ ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); * result
result = prime * result + ((size == null) ? 0 : size.hashCode()); + ((operatingSystemDescription == null) ? 0
result = prime * result + ((status == null) ? 0 : status.hashCode()); : operatingSystemDescription.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode()); result = prime
return result; * result
} + ((resourceAllocationByType == null) ? 0
: resourceAllocationByType.hashCode());
result = prime
* result
+ ((resourceAllocations == null) ? 0 : resourceAllocations
.hashCode());
result = prime * result + ((size == null) ? 0 : size.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode());
return result;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
return true; return true;
if (obj == null) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
VAppImpl other = (VAppImpl) obj; VAppImpl other = (VAppImpl) obj;
if (id == null) { if (id == null) {
if (other.id != null) if (other.id != null)
return false; return false;
} else if (!id.equals(other.id)) } else if (!id.equals(other.id))
return false; return false;
if (location == null) { if (location == null) {
if (other.location != null) if (other.location != null)
return false; return false;
} else if (!location.equals(other.location)) } else if (!location.equals(other.location))
return false; return false;
if (name == null) { if (name == null) {
if (other.name != null) if (other.name != null)
return false; return false;
} else if (!name.equals(other.name)) } else if (!name.equals(other.name))
return false; return false;
if (networkToAddresses == null) { if (networkToAddresses == null) {
if (other.networkToAddresses != null) if (other.networkToAddresses != null)
return false; return false;
} else if (!networkToAddresses.equals(other.networkToAddresses)) } else if (!networkToAddresses.equals(other.networkToAddresses))
return false; return false;
if (operatingSystemDescription == null) { if (operatingSystemDescription == null) {
if (other.operatingSystemDescription != null) if (other.operatingSystemDescription != null)
return false; return false;
} else if (!operatingSystemDescription.equals(other.operatingSystemDescription)) } else if (!operatingSystemDescription
return false; .equals(other.operatingSystemDescription))
if (resourceAllocations == null) { return false;
if (other.resourceAllocations != null) if (resourceAllocationByType == null) {
return false; if (other.resourceAllocationByType != null)
} else if (!resourceAllocations.equals(other.resourceAllocations)) return false;
return false; } else if (!resourceAllocationByType.equals(other.resourceAllocationByType))
if (size == null) { return false;
if (other.size != null) if (resourceAllocations == null) {
return false; if (other.resourceAllocations != null)
} else if (!size.equals(other.size)) return false;
return false; } else if (!resourceAllocations.equals(other.resourceAllocations))
if (status == null) { return false;
if (other.status != null) if (size == null) {
return false; if (other.size != null)
} else if (!status.equals(other.status)) return false;
return false; } else if (!size.equals(other.size))
if (system == null) { return false;
if (other.system != null) if (status == null) {
return false; if (other.status != null)
} else if (!system.equals(other.system)) return false;
return false; } else if (!status.equals(other.status))
return true; return false;
} if (system == null) {
if (other.system != null)
return false;
} else if (!system.equals(other.system))
return false;
return true;
}
public String getId() { public String getId() {
return id; return id;

View File

@ -22,7 +22,9 @@ import java.net.URI;
import java.util.Map; import java.util.Map;
import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl; import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl.ErrorImpl;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
/** /**
@ -31,15 +33,28 @@ import org.xml.sax.Attributes;
*/ */
public class Utils { public class Utils {
public static NamedResource newNamedResource(Attributes attributes) { public static NamedResource newNamedResource(Attributes attributes) {
String uri = attributes.getValue(attributes.getIndex("href")); String uri = attributes.getValue(attributes.getIndex("href"));
String id = uri.substring(uri.lastIndexOf('/') + 1); String id = uri.substring(uri.lastIndexOf('/') + 1);
return new NamedResourceImpl(id, attributes.getValue(attributes.getIndex("name")), attributes return new NamedResourceImpl(id, attributes.getValue(attributes
.getValue(attributes.getIndex("type")), URI.create(uri)); .getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(uri));
} }
public static void putNamedResource(Map<String, NamedResource> map, Attributes attributes) { public static Task.Error newError(Attributes attributes) {
map.put(attributes.getValue(attributes.getIndex("name")), newNamedResource(attributes)); return new ErrorImpl(attrOrNull(attributes, "message"), attrOrNull(
attributes, "majorErrorCode"), attrOrNull(attributes,
"minorErrorCode"));
}
private static String attrOrNull(Attributes attributes, String attr) {
return attributes.getIndex(attr) >= 0 ? attributes.getValue(attributes
.getIndex(attr)) : null;
}
public static void putNamedResource(Map<String, NamedResource> map,
Attributes attributes) {
map.put(attributes.getValue(attributes.getIndex("name")),
newNamedResource(attributes));
} }
} }

View File

@ -40,12 +40,12 @@ import com.google.common.collect.Maps;
*/ */
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> { public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
private NamedResource org; private NamedResource org;
private Map<String, NamedResource> vdcs = Maps.newHashMap(); private Map<String, NamedResource> vdcs = Maps.newLinkedHashMap();
private Map<String, NamedResource> tasksLists = Maps.newHashMap(); private Map<String, NamedResource> tasksLists = Maps.newLinkedHashMap();
private NamedResource catalog; private Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
public Organization getResult() { public Organization getResult() {
return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalog, vdcs, return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalogs, vdcs,
tasksLists); tasksLists);
} }
@ -60,7 +60,7 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
if (attributes.getValue(typeIndex).equals(VDC_XML)) { if (attributes.getValue(typeIndex).equals(VDC_XML)) {
putNamedResource(vdcs, attributes); putNamedResource(vdcs, attributes);
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) { } else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
catalog = newNamedResource(attributes); putNamedResource(catalogs, attributes);
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) { } else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) {
putNamedResource(tasksLists, attributes); putNamedResource(tasksLists, attributes);
} }

View File

@ -54,7 +54,7 @@ public class ResourceAllocationHandler extends ParseSax.HandlerWithResult<Resour
@Override @Override
public void startElement(String uri, String localName, String qName, Attributes attributes) public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException { throws SAXException {
if (qName.equals("Connection")) { if (qName.endsWith("Connection")) {
connected = new Boolean(attributes.getValue(attributes.getIndex("connected"))); connected = new Boolean(attributes.getValue(attributes.getIndex("connected")));
} }
} }
@ -63,34 +63,34 @@ public class ResourceAllocationHandler extends ParseSax.HandlerWithResult<Resour
public void endElement(String uri, String localName, String qName) throws SAXException { public void endElement(String uri, String localName, String qName) throws SAXException {
String current = currentOrNull(); String current = currentOrNull();
if (current != null) { if (current != null) {
if (qName.equals("Address")) { if (qName.endsWith("Address")) {
address = Integer.parseInt(current); address = Integer.parseInt(current);
} else if (qName.equals("AddressOnParent")) { } else if (qName.endsWith("AddressOnParent")) {
addressOnParent = Integer.parseInt(current); addressOnParent = Integer.parseInt(current);
} else if (qName.equals("AllocationUnits")) { } else if (qName.endsWith("AllocationUnits")) {
allocationUnits = current; allocationUnits = current;
} else if (qName.equals("Description")) { } else if (qName.endsWith("Description")) {
description = current; description = current;
} else if (qName.equals("ElementName")) { } else if (qName.endsWith("ElementName")) {
elementName = current; elementName = current;
} else if (qName.equals("InstanceID")) { } else if (qName.endsWith("InstanceID")) {
instanceID = Integer.parseInt(current); instanceID = Integer.parseInt(current);
} else if (qName.equals("Parent")) { } else if (qName.endsWith("Parent")) {
parent = Integer.parseInt(current); parent = Integer.parseInt(current);
} else if (qName.equals("ResourceSubType")) { } else if (qName.endsWith("ResourceSubType")) {
resourceSubType = current; resourceSubType = current;
} else if (qName.equals("ResourceType")) { } else if (qName.endsWith("ResourceType")) {
resourceType = ResourceType.fromValue(current); resourceType = ResourceType.fromValue(current);
} else if (qName.equals("VirtualQuantity")) { } else if (qName.endsWith("VirtualQuantity")) {
virtualQuantity = Long.parseLong(current); virtualQuantity = Long.parseLong(current);
} else if (qName.equals("VirtualQuantityUnits")) { } else if (qName.endsWith("VirtualQuantityUnits")) {
virtualQuantityUnits = current; virtualQuantityUnits = current;
} else if (qName.equals("HostResource")) { } else if (qName.endsWith("HostResource")) {
hostResource = currentText.toString().trim(); hostResource = currentText.toString().trim();
virtualQuantity = Long.parseLong(current); virtualQuantity = Long.parseLong(current);
virtualQuantityUnits = "byte * 2^20"; virtualQuantityUnits = "byte * 2^20";
} }
} else if (qName.equals("Item")) { } else if (qName.endsWith("Item")) {
if (allocationUnits != null) if (allocationUnits != null)
virtualQuantityUnits = allocationUnits; virtualQuantityUnits = allocationUnits;
this.allocation = new ResourceAllocation(instanceID, elementName, description, this.allocation = new ResourceAllocation(instanceID, elementName, description,

View File

@ -30,6 +30,7 @@ import org.jclouds.logging.Logger;
import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus; import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.Task.Error;
import org.jclouds.vcloud.domain.internal.TaskImpl; import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.jclouds.vcloud.util.Utils; import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -48,10 +49,12 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
private Date startTime; private Date startTime;
private Date endTime; private Date endTime;
private Task task; private Task task;
private Error error;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public TaskHandler(DateService dateService) { public TaskHandler(DateService dateService) {
this.dateService = dateService; this.dateService = dateService;
@ -80,18 +83,21 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
taskLink = Utils.newNamedResource(attributes); taskLink = Utils.newNamedResource(attributes);
} else if (qName.equals("Result")) { } else if (qName.equals("Result")) {
result = Utils.newNamedResource(attributes); result = Utils.newNamedResource(attributes);
} else if (qName.equals("Error")) {
error = Utils.newError(attributes);
} }
} }
private Date parseDate(Attributes attributes, String attribute) { private Date parseDate(Attributes attributes, String attribute) {
String toParse =attributes.getValue(attributes.getIndex(attribute));
try { try {
return dateService.iso8601DateParse(attributes.getValue(attributes.getIndex(attribute))); return dateService.iso8601DateParse(toParse);
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (e.getCause() instanceof ParseException) { if (e.getCause() instanceof ParseException) {
try { try {
return dateService.iso8601SecondsDateParse(attributes.getValue(attributes if (!toParse.endsWith("Z"))
.getIndex(attribute))); toParse+="Z";
return dateService.iso8601SecondsDateParse(toParse);
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
logger.error(e, "error parsing date"); logger.error(e, "error parsing date");
} }
@ -105,13 +111,14 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
@Override @Override
public void endElement(String uri, String localName, String qName) throws SAXException { public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equalsIgnoreCase("Task")) { if (qName.equalsIgnoreCase("Task")) {
this.task = new TaskImpl(taskLink.getId(), taskLink.getLocation(), status, startTime, endTime, owner, result); this.task = new TaskImpl(taskLink.getId(), taskLink.getLocation(), status, startTime, endTime, owner, result, error);
taskLink = null; taskLink = null;
status = null; status = null;
startTime = null; startTime = null;
endTime = null; endTime = null;
owner = null; owner = null;
result = null; result = null;
error = null;
} }
} }

View File

@ -21,18 +21,20 @@ package org.jclouds.vcloud.xml;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URI; import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.SortedSet; import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.VirtualSystem;
import org.jclouds.vcloud.domain.internal.VAppImpl; import org.jclouds.vcloud.domain.internal.VAppImpl;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -58,7 +60,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
} }
protected VirtualSystem system; protected VirtualSystem system;
protected SortedSet<ResourceAllocation> allocations = Sets.newTreeSet(); protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet();
protected VAppStatus status; protected VAppStatus status;
protected final ListMultimap<String, InetAddress> networkToAddresses = ArrayListMultimap protected final ListMultimap<String, InetAddress> networkToAddresses = ArrayListMultimap
.create(); .create();
@ -79,8 +81,10 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
public void startElement(String uri, String localName, String qName, Attributes attributes) public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException { throws SAXException {
if (qName.equals("VApp")) { if (qName.equals("VApp")) {
name = id = attributes.getValue(attributes.getIndex("name")); NamedResource resource = Utils.newNamedResource(attributes);
location = URI.create(attributes.getValue(attributes.getIndex("href"))); name = resource.getName();
id = resource.getId();
location = resource.getLocation();
status = VAppStatus.fromValue(attributes.getValue(attributes.getIndex("status"))); status = VAppStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
if (attributes.getIndex("size") != -1) if (attributes.getIndex("size") != -1)
size = new Long(attributes.getValue(attributes.getIndex("size"))); size = new Long(attributes.getValue(attributes.getIndex("size")));

View File

@ -42,15 +42,15 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSyst
@Override @Override
public void endElement(String uri, String localName, String qName) throws SAXException { public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equals("ElementName")) { if (qName.endsWith("ElementName")) {
this.elementName = currentText.toString().trim(); this.elementName = currentText.toString().trim();
} else if (qName.equals("InstanceID")) { } else if (qName.endsWith("InstanceID")) {
this.instanceID = Integer.parseInt(currentText.toString().trim()); this.instanceID = Integer.parseInt(currentText.toString().trim());
} else if (qName.equals("VirtualSystemIdentifier")) { } else if (qName.endsWith("VirtualSystemIdentifier")) {
this.virtualSystemIdentifier = currentText.toString().trim(); this.virtualSystemIdentifier = currentText.toString().trim();
} else if (qName.equals("VirtualSystemType")) { } else if (qName.endsWith("VirtualSystemType")) {
this.virtualSystemType = currentText.toString().trim(); this.virtualSystemType = currentText.toString().trim();
} else if (qName.equals("System")) { } else if (qName.endsWith("System")) {
this.system = new org.jclouds.vcloud.domain.VirtualSystem(instanceID, elementName, this.system = new org.jclouds.vcloud.domain.VirtualSystem(instanceID, elementName,
virtualSystemIdentifier, virtualSystemType); virtualSystemIdentifier, virtualSystemType);
this.elementName = null; this.elementName = null;

View File

@ -161,8 +161,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod); checkFilters(httpMethod);
} }
public void testOrganization() throws SecurityException, NoSuchMethodException, IOException { public void testDefaultOrganization() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getOrganization"); Method method = VCloudAsyncClient.class.getMethod("getDefaultOrganization");
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method); GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method);
assertRequestLineEquals(httpMethod, "GET http://org HTTP/1.1"); assertRequestLineEquals(httpMethod, "GET http://org HTTP/1.1");
@ -176,8 +176,23 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod); checkFilters(httpMethod);
} }
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { public void testOrganization() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getCatalog"); Method method = VCloudAsyncClient.class.getMethod("getOrganization", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
assertRequestLineEquals(httpMethod, "GET http://vcloud/org/1 HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, OrgHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testDefaultCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getDefaultCatalog");
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method); GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method);
assertRequestLineEquals(httpMethod, "GET http://catalog HTTP/1.1"); assertRequestLineEquals(httpMethod, "GET http://catalog HTTP/1.1");
@ -191,6 +206,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(httpMethod); checkFilters(httpMethod);
} }
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getCatalog", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
assertRequestLineEquals(httpMethod, "GET http://vcloud/catalog/1 HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertPayloadEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class); Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class);
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "2"); GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "2");

View File

@ -49,23 +49,25 @@ public class VCloudClientLiveTest {
@Test @Test
public void testOrganization() throws Exception { public void testOrganization() throws Exception {
Organization response = connection.getOrganization(); Organization response = connection.getDefaultOrganization();
assertNotNull(response); assertNotNull(response);
assertNotNull(response.getId()); assertNotNull(response.getId());
assertNotNull(account); assertNotNull(account);
assertNotNull(response.getCatalog()); assert response.getCatalogs().size() >=1;
assertEquals(response.getTasksLists().size(), 1); assert response.getTasksLists().size() >=1;
assertEquals(response.getVDCs().size(), 1); assert response.getVDCs().size() >=1;
assertEquals(connection.getOrganization(response.getId()), response);
} }
@Test @Test
public void testCatalog() throws Exception { public void testCatalog() throws Exception {
Catalog response = connection.getCatalog(); Catalog response = connection.getDefaultCatalog();
assertNotNull(response); assertNotNull(response);
assertNotNull(response.getId()); assertNotNull(response.getId());
assertNotNull(response.getName()); assertNotNull(response.getName());
assertNotNull(response.getLocation()); assertNotNull(response.getLocation());
assert response.size() > 0; assert response.size() > 0;
assertEquals(connection.getCatalog(response.getId()), response);
} }
@Test @Test
@ -81,7 +83,7 @@ public class VCloudClientLiveTest {
@Test @Test
public void testGetCatalogItem() throws Exception { public void testGetCatalogItem() throws Exception {
Catalog response = connection.getCatalog(); Catalog response = connection.getDefaultCatalog();
for (NamedResource resource : response.values()) { for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getId()); CatalogItem item = connection.getCatalogItem(resource.getId());
@ -97,7 +99,7 @@ public class VCloudClientLiveTest {
@Test @Test
public void testGetVAppTemplate() throws Exception { public void testGetVAppTemplate() throws Exception {
Catalog response = connection.getCatalog(); Catalog response = connection.getDefaultCatalog();
for (NamedResource resource : response.values()) { for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getId()); CatalogItem item = connection.getCatalogItem(resource.getId());

View File

@ -47,7 +47,7 @@ import com.google.inject.TypeLiteral;
import com.google.inject.internal.ImmutableMap; import com.google.inject.internal.ImmutableMap;
/** /**
* Tests behavior of {@code HostingDotComVCloudClient} * Tests behavior of {@code VCloudComputeClientLiveTest}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */

View File

@ -130,7 +130,7 @@ public class VCloudLoginLiveTest {
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {
final String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), final String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"),
"jclouds.test.endpoint"); "jclouds.test.endpoint")+"/v0.8/login";
final String account = checkNotNull(System.getProperty("jclouds.test.user"), final String account = checkNotNull(System.getProperty("jclouds.test.user"),
"jclouds.test.user"); "jclouds.test.user");
final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");

View File

@ -77,9 +77,9 @@ public class OrgHandlerTest {
assertEquals(result.getId(), 48 + ""); assertEquals(result.getId(), 48 + "");
assertEquals(result.getLocation(), URI assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")); .create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getCatalog(), new NamedResourceImpl("catalog", assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog",new NamedResourceImpl("catalog",
"Miami Environment 1 Catalog", CATALOG_XML, "Miami Environment 1 Catalog", CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))); URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))));
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedResourceImpl( assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedResourceImpl(
"32", "Miami Environment 1", VCloudMediaType.VDC_XML, URI "32", "Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
@ -121,8 +121,8 @@ public class OrgHandlerTest {
assertEquals(result.getId(), 188849 + ""); assertEquals(result.getId(), 188849 + "");
assertEquals(result.getLocation(), URI assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849")); .create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
assertEquals(result.getCatalog(), new NamedResourceImpl("1", "HMS Shared Catalog", assertEquals(result.getCatalogs(), ImmutableMap.of( "HMS Shared Catalog", new NamedResourceImpl("1", "HMS Shared Catalog",
CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))); CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter",
new NamedResourceImpl("188849", "188849 Virtual DataCenter", new NamedResourceImpl("188849", "188849 Virtual DataCenter",
VCloudMediaType.VDC_XML, URI VCloudMediaType.VDC_XML, URI

View File

@ -53,18 +53,30 @@ public class TaskHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/task.xml"); InputStream is = getClass().getResourceAsStream("/task.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task result = factory.create(injector.getInstance(TaskHandler.class))
.parse(is);
Task expects = new TaskImpl("3299", URI Task expects = new TaskImpl(
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), "3299",
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), URI
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedResourceImpl("1", .create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
"VDC Name", VCloudMediaType.VDC_XML, TaskStatus.SUCCESS,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"),
new NamedResourceImpl(
"1",
"VDC Name",
VCloudMediaType.VDC_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl(
"4012",
"Server1",
VCloudMediaType.VAPP_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012") .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
) ), null
); );
assertEquals(result, expects); assertEquals(result, expects);
@ -74,12 +86,14 @@ public class TaskHandlerTest extends BaseHandlerTest {
public void testSelf() { public void testSelf() {
InputStream is = getClass().getResourceAsStream("/task-self.xml"); InputStream is = getClass().getResourceAsStream("/task-self.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task result = factory.create(injector.getInstance(TaskHandler.class))
.parse(is);
Task expects = new TaskImpl("d188849-78", URI Task expects = new TaskImpl(
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), "d188849-78",
TaskStatus.QUEUED, null, null, null, null URI
); .create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
TaskStatus.QUEUED, null, null, null, null, null);
assertEquals(result, expects); assertEquals(result, expects);
} }
@ -87,13 +101,45 @@ public class TaskHandlerTest extends BaseHandlerTest {
public void testApplyInputStream2() { public void testApplyInputStream2() {
InputStream is = getClass().getResourceAsStream("/task-hosting.xml"); InputStream is = getClass().getResourceAsStream("/task-hosting.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task result = factory.create(injector.getInstance(TaskHandler.class))
.parse(is);
Task expects = new TaskImpl("d188849-72", URI Task expects = new TaskImpl(
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72"), "d188849-72",
TaskStatus.RUNNING, dateService.iso8601SecondsDateParse("2001-01-01T05:00:00Z"), URI
null, new NamedResourceImpl("188849", "188849", VCloudMediaType.VDC_XML, URI .create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72"),
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")), null); TaskStatus.RUNNING,
dateService.iso8601SecondsDateParse("2001-01-01T05:00:00Z"),
null,
new NamedResourceImpl(
"188849",
"188849",
VCloudMediaType.VDC_XML,
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")),
null, null);
assertEquals(result, expects);
}
public void testError() {
InputStream is = getClass().getResourceAsStream("/task-error.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class))
.parse(is);
Task expects = new TaskImpl(
"23",
URI.create("http://10.150.4.49/api/v0.8/task/23"),
TaskStatus.ERROR,
dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"),
new NamedResourceImpl("1", "APIOrg", VCloudMediaType.ORG_XML, URI
.create("http://10.150.4.49/api/v0.8/org/1")),
new NamedResourceImpl("1", "testapp1", VCloudMediaType.VAPP_XML,
URI.create("http://10.150.4.49/api/v0.8/vapp/1")),
new TaskImpl.ErrorImpl("Error processing job", "500",
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00"));
assertEquals(result, expects); assertEquals(result, expects);
} }

View File

@ -67,7 +67,7 @@ public class TasksListHandlerTest extends BaseHandlerTest {
"VDC Name", VCloudMediaType.VDC_XML, "VDC Name", VCloudMediaType.VDC_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"))); .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")),null);
Task task2 = new TaskImpl("3299", URI Task task2 = new TaskImpl("3299", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), .create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
@ -76,9 +76,7 @@ public class TasksListHandlerTest extends BaseHandlerTest {
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012") .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
), null
)
); );
assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2)); assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
assertEquals( assertEquals(

View File

@ -48,7 +48,7 @@ import com.google.common.collect.ListMultimap;
public class VAppHandlerTest extends BaseHandlerTest { public class VAppHandlerTest extends BaseHandlerTest {
// TODO why does this fail? // TODO why does this fail?
@Test(enabled = false) @Test(enabled = false)
public void testApplyInputStream() throws UnknownHostException { public void testHosting() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/vapp-hosting.xml"); InputStream is = getClass().getResourceAsStream("/vapp-hosting.xml");
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
@ -80,6 +80,43 @@ public class VAppHandlerTest extends BaseHandlerTest {
new Long(20971520), networkToAddresses, null, system, resourceAllocations); new Long(20971520), networkToAddresses, null, system, resourceAllocations);
assertEquals(result, expects); assertEquals(result, expects);
}
// TODO why does this fail?
@Test(enabled = false)
public void testDefault() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/vapp.xml");
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
ListMultimap<String, InetAddress> networkToAddresses = ImmutableListMultimap
.<String, InetAddress> of();
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "Oracle", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
"hertz * 10^6"),
new ResourceAllocation(2, "16MB of memory", "Memory Size",
ResourceType.MEMORY, null, null, null, null, null, null, 16,
"byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1", "PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null,
true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
null, "104857", null, 0, 3, null, 104857, "byte * 2^20"))
.build();
VApp expects = new VAppImpl("4", "Oracle", URI
.create("http://10.150.4.49/api/v0.8/vApp/4"), VAppStatus.ON,
new Long(104857), networkToAddresses, "Other Linux (32-bit)", system, resourceAllocations);
assertEquals(result, expects);
} }
} }

View File

@ -1,144 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<VApp href="http://10.150.4.49/api/v0.8/vApp/5" type="application/vnd.vmware.vcloud.vApp+xml" <VApp href="http://10.150.4.49/api/v0.8/vApp/4" type="application/vnd.vmware.vcloud.vApp+xml"
name="SQL" status="4" name="Oracle" status="4"
xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://10.150.4.49/api/v0.8/vcloud/vApp.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns="http://www.vmware.com/vcloud/v0.8"
<Link rel="up" xmlns:vmw="http://www.vmware.com/schema/ovf"
href="http://10.150.4.49/api/v0.8/vdc/3" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
type="application/vnd.vmware.vcloud.vdc+xml"/> xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
<OperatingSystemSection ovf:id="36" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" size="104857">
<Info>The kind of installed guest operating system</Info> <Link rel="up" href="http://10.150.4.49/api/v0.8/vdc/4" type="application/vnd.vmware.vcloud.vdc+xml" />
<Description>Other Linux (32-bit)</Description> <OperatingSystemSection d2p1:id="36"
</OperatingSystemSection> xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:d2p1="http://schemas.dmtf.org/ovf/envelope/1">
<VirtualHardwareSection xmlns="http://schemas.dmtf.org/ovf/envelope/1" <Info>The kind of installed guest operating system</Info>
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" <Description>Other Linux (32-bit)</Description>
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"> </OperatingSystemSection>
<Info>Virtual hardware</Info> <VirtualHardwareSection xmlns="http://schemas.dmtf.org/ovf/envelope/1">
<Link rel="edit" href="http://10.150.4.49/api/v0.8/vApp/5" type="application/vnd.vmware.ovf.virtualHardwareSection+xml"/> <Info>Virtual hardware</Info>
<System> <Link rel="edit" href="http://10.150.4.49/api/v0.8/vApp/4"
<rasd:AutomaticRecoveryAction xsi:nil="true" /> type="application/vnd.vmware.ovf.virtualHardwareSection+xml" />
<rasd:AutomaticShutdownAction xsi:nil="true" /> <System>
<rasd:AutomaticStartupAction xsi:nil="true" /> <vssd:AutomaticRecoveryAction xsi:nil="true" />
<rasd:AutomaticStartupActionDelay xsi:nil="true" /> <vssd:AutomaticShutdownAction xsi:nil="true" />
<rasd:AutomaticStartupActionSequenceNumber xsi:nil="true" /> <vssd:AutomaticStartupAction xsi:nil="true" />
<rasd:Caption xsi:nil="true" /> <vssd:AutomaticStartupActionDelay
<rasd:ConfigurationDataRoot xsi:nil="true" /> xsi:nil="true" />
<rasd:ConfigurationFile xsi:nil="true" /> <vssd:AutomaticStartupActionSequenceNumber
<rasd:ConfigurationID xsi:nil="true" /> xsi:nil="true" />
<rasd:CreationTime xsi:nil="true" /> <vssd:Caption xsi:nil="true" />
<rasd:Description xsi:nil="true" /> <vssd:ConfigurationDataRoot xsi:nil="true" />
<rasd:ElementName>Virtual Hardware Family</rasd:ElementName> <vssd:ConfigurationFile xsi:nil="true" />
<rasd:InstanceID>0</rasd:InstanceID> <vssd:ConfigurationID xsi:nil="true" />
<rasd:LogDataRoot xsi:nil="true" /> <vssd:CreationTime xsi:nil="true" />
<rasd:RecoveryFile xsi:nil="true" /> <vssd:Description xsi:nil="true" />
<rasd:SnapshotDataRoot xsi:nil="true" /> <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
<rasd:SuspendDataRoot xsi:nil="true" /> <vssd:InstanceID>0</vssd:InstanceID>
<rasd:SwapFileDataRoot xsi:nil="true" /> <vssd:LogDataRoot xsi:nil="true" />
<rasd:VirtualSystemIdentifier>SQL</rasd:VirtualSystemIdentifier> <vssd:RecoveryFile xsi:nil="true" />
<rasd:VirtualSystemType>vmx-07</rasd:VirtualSystemType> <vssd:SnapshotDataRoot xsi:nil="true" />
</System> <vssd:SuspendDataRoot xsi:nil="true" />
<Item> <vssd:SwapFileDataRoot xsi:nil="true" />
<rasd:Address xsi:nil="true" /> <vssd:VirtualSystemIdentifier>Oracle</vssd:VirtualSystemIdentifier>
<rasd:AddressOnParent xsi:nil="true" /> <vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits> </System>
<rasd:AutomaticAllocation xsi:nil="true" /> <Item>
<rasd:AutomaticDeallocation xsi:nil="true" /> <rasd:Address xsi:nil="true" />
<rasd:Caption xsi:nil="true" /> <rasd:AddressOnParent xsi:nil="true" />
<rasd:ConsumerVisibility xsi:nil="true" /> <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description> <rasd:AutomaticAllocation xsi:nil="true" />
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName> <rasd:AutomaticDeallocation xsi:nil="true" />
<rasd:InstanceID>1</rasd:InstanceID> <rasd:Caption xsi:nil="true" />
<rasd:Limit xsi:nil="true" /> <rasd:ConsumerVisibility xsi:nil="true" />
<rasd:MappingBehavior xsi:nil="true" /> <rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:OtherResourceType xsi:nil="true" /> <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
<rasd:Parent xsi:nil="true" /> <rasd:InstanceID>1</rasd:InstanceID>
<rasd:PoolID xsi:nil="true" /> <rasd:Limit xsi:nil="true" />
<rasd:Reservation xsi:nil="true" /> <rasd:MappingBehavior xsi:nil="true" />
<rasd:ResourceSubType xsi:nil="true" /> <rasd:OtherResourceType xsi:nil="true" />
<rasd:ResourceType>3</rasd:ResourceType> <rasd:Parent xsi:nil="true" />
<rasd:VirtualQuantity>1</rasd:VirtualQuantity> <rasd:PoolID xsi:nil="true" />
<rasd:VirtualQuantityUnits>count</rasd:VirtualQuantityUnits> <rasd:Reservation xsi:nil="true" />
<rasd:Weight xsi:nil="true" /> <rasd:ResourceSubType xsi:nil="true" />
</Item> <rasd:ResourceType>3</rasd:ResourceType>
<Item> <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
<rasd:Address xsi:nil="true" /> <rasd:VirtualQuantityUnits>count</rasd:VirtualQuantityUnits>
<rasd:AddressOnParent xsi:nil="true" /> <rasd:Weight xsi:nil="true" />
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits> </Item>
<rasd:AutomaticAllocation xsi:nil="true" /> <Item>
<rasd:AutomaticDeallocation xsi:nil="true" /> <rasd:Address xsi:nil="true" />
<rasd:Caption xsi:nil="true" /> <rasd:AddressOnParent xsi:nil="true" />
<rasd:ConsumerVisibility xsi:nil="true" /> <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description> <rasd:AutomaticAllocation xsi:nil="true" />
<rasd:ElementName>16MB of memory</rasd:ElementName> <rasd:AutomaticDeallocation xsi:nil="true" />
<rasd:InstanceID>2</rasd:InstanceID> <rasd:Caption xsi:nil="true" />
<rasd:Limit xsi:nil="true" /> <rasd:ConsumerVisibility xsi:nil="true" />
<rasd:MappingBehavior xsi:nil="true" /> <rasd:Description>Memory Size</rasd:Description>
<rasd:OtherResourceType xsi:nil="true" /> <rasd:ElementName>16MB of memory</rasd:ElementName>
<rasd:Parent xsi:nil="true" /> <rasd:InstanceID>2</rasd:InstanceID>
<rasd:PoolID xsi:nil="true" /> <rasd:Limit xsi:nil="true" />
<rasd:Reservation xsi:nil="true" /> <rasd:MappingBehavior xsi:nil="true" />
<rasd:ResourceSubType xsi:nil="true" /> <rasd:OtherResourceType xsi:nil="true" />
<rasd:ResourceType>4</rasd:ResourceType> <rasd:Parent xsi:nil="true" />
<rasd:VirtualQuantity>16</rasd:VirtualQuantity> <rasd:PoolID xsi:nil="true" />
<rasd:VirtualQuantityUnits>byte * 2^20</rasd:VirtualQuantityUnits> <rasd:Reservation xsi:nil="true" />
<rasd:Weight xsi:nil="true" /> <rasd:ResourceSubType xsi:nil="true" />
</Item> <rasd:ResourceType>4</rasd:ResourceType>
<Item> <rasd:VirtualQuantity>16</rasd:VirtualQuantity>
<rasd:Address>0</rasd:Address> <rasd:VirtualQuantityUnits>byte * 2^20</rasd:VirtualQuantityUnits>
<rasd:AddressOnParent xsi:nil="true" /> <rasd:Weight xsi:nil="true" />
<rasd:AllocationUnits xsi:nil="true" /> </Item>
<rasd:AutomaticAllocation xsi:nil="true" /> <Item>
<rasd:AutomaticDeallocation xsi:nil="true" /> <rasd:Address>0</rasd:Address>
<rasd:Caption xsi:nil="true" /> <rasd:AddressOnParent xsi:nil="true" />
<rasd:ConsumerVisibility xsi:nil="true" /> <rasd:AllocationUnits xsi:nil="true" />
<rasd:Description>SCSI Controller</rasd:Description> <rasd:AutomaticAllocation xsi:nil="true" />
<rasd:ElementName>SCSI Controller 0</rasd:ElementName> <rasd:AutomaticDeallocation xsi:nil="true" />
<rasd:InstanceID>3</rasd:InstanceID> <rasd:Caption xsi:nil="true" />
<rasd:Limit xsi:nil="true" /> <rasd:ConsumerVisibility xsi:nil="true" />
<rasd:MappingBehavior xsi:nil="true" /> <rasd:Description>SCSI Controller</rasd:Description>
<rasd:OtherResourceType xsi:nil="true" /> <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
<rasd:Parent xsi:nil="true" /> <rasd:InstanceID>3</rasd:InstanceID>
<rasd:PoolID xsi:nil="true" /> <rasd:Limit xsi:nil="true" />
<rasd:Reservation xsi:nil="true" /> <rasd:MappingBehavior xsi:nil="true" />
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType> <rasd:OtherResourceType xsi:nil="true" />
<rasd:ResourceType>6</rasd:ResourceType> <rasd:Parent xsi:nil="true" />
<rasd:VirtualQuantity xsi:nil="true" /> <rasd:PoolID xsi:nil="true" />
<rasd:VirtualQuantityUnits xsi:nil="true" /> <rasd:Reservation xsi:nil="true" />
<rasd:Weight xsi:nil="true" /> <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
</Item> <rasd:ResourceType>6</rasd:ResourceType>
<Item> <rasd:VirtualQuantity xsi:nil="true" />
<rasd:AddressOnParent>7</rasd:AddressOnParent> <rasd:VirtualQuantityUnits xsi:nil="true" />
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> <rasd:Weight xsi:nil="true" />
<rasd:Connection connected="true">Internal</rasd:Connection> </Item>
<rasd:Description>PCNet32 ethernet adapter on "Internal" network</rasd:Description> <Item>
<rasd:ElementName>Network Adapter 1</rasd:ElementName> <rasd:AddressOnParent>7</rasd:AddressOnParent>
<rasd:InstanceID>8</rasd:InstanceID> <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
<rasd:ResourceSubType>PCNet32</rasd:ResourceSubType> <rasd:Connection connected="true">Internal</rasd:Connection>
<rasd:ResourceType>10</rasd:ResourceType> <rasd:Description>PCNet32 ethernet adapter on "Internal" network
</Item> </rasd:Description>
<Item> <rasd:ElementName>Network Adapter 1</rasd:ElementName>
<rasd:Address xsi:nil="true" /> <rasd:InstanceID>8</rasd:InstanceID>
<rasd:AddressOnParent>0</rasd:AddressOnParent> <rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
<rasd:AllocationUnits xsi:nil="true" /> <rasd:ResourceType>10</rasd:ResourceType>
<rasd:AutomaticAllocation xsi:nil="true" /> </Item>
<rasd:AutomaticDeallocation xsi:nil="true" /> <Item>
<rasd:Caption xsi:nil="true" /> <rasd:Address xsi:nil="true" />
<rasd:ConsumerVisibility xsi:nil="true" /> <rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:Description xsi:nil="true" /> <rasd:AllocationUnits xsi:nil="true" />
<rasd:ElementName>Hard Disk 1</rasd:ElementName> <rasd:AutomaticAllocation xsi:nil="true" />
<rasd:HostResource>104857</rasd:HostResource> <rasd:AutomaticDeallocation xsi:nil="true" />
<rasd:InstanceID>9</rasd:InstanceID> <rasd:Caption xsi:nil="true" />
<rasd:Limit xsi:nil="true" /> <rasd:ConsumerVisibility xsi:nil="true" />
<rasd:MappingBehavior xsi:nil="true" /> <rasd:Description xsi:nil="true" />
<rasd:OtherResourceType xsi:nil="true" /> <rasd:ElementName>Hard Disk 1</rasd:ElementName>
<rasd:Parent>3</rasd:Parent> <rasd:HostResource>104857</rasd:HostResource>
<rasd:PoolID xsi:nil="true" /> <rasd:InstanceID>9</rasd:InstanceID>
<rasd:Reservation xsi:nil="true" /> <rasd:Limit xsi:nil="true" />
<rasd:ResourceSubType xsi:nil="true" /> <rasd:MappingBehavior xsi:nil="true" />
<rasd:ResourceType>17</rasd:ResourceType> <rasd:OtherResourceType xsi:nil="true" />
<rasd:VirtualQuantity>104857</rasd:VirtualQuantity> <rasd:Parent>3</rasd:Parent>
<rasd:VirtualQuantityUnits xsi:nil="true" /> <rasd:PoolID xsi:nil="true" />
<rasd:Weight xsi:nil="true" /> <rasd:Reservation xsi:nil="true" />
</Item> <rasd:ResourceSubType xsi:nil="true" />
</VirtualHardwareSection> <rasd:ResourceType>17</rasd:ResourceType>
<rasd:VirtualQuantity>104857</rasd:VirtualQuantity>
<rasd:VirtualQuantityUnits xsi:nil="true" />
<rasd:Weight xsi:nil="true" />
</Item>
</VirtualHardwareSection>
</VApp> </VApp>

View File

@ -63,7 +63,7 @@ public interface HostingDotComVCloudAsyncClient extends VCloudAsyncClient {
// produces is incorrect, but required for hosting.com to operate // produces is incorrect, but required for hosting.com to operate
@XMLResponseParser(CatalogHandler.class) @XMLResponseParser(CatalogHandler.class)
@Override @Override
Future<? extends Catalog> getCatalog(); Future<? extends Catalog> getDefaultCatalog();
@GET @GET
@Consumes(VAPP_XML) @Consumes(VAPP_XML)

View File

@ -20,7 +20,7 @@ package org.jclouds.vcloud.hostingdotcom.domain.internal;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URI; import java.net.URI;
import java.util.SortedSet; import java.util.Set;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppStatus;
@ -47,7 +47,7 @@ public class HostingDotComVAppImpl extends VAppImpl implements HostingDotComVApp
public HostingDotComVAppImpl(String id, String name, URI location, VAppStatus status, Long size, public HostingDotComVAppImpl(String id, String name, URI location, VAppStatus status, Long size,
ListMultimap<String, InetAddress> networkToAddresses, ListMultimap<String, InetAddress> networkToAddresses,
String operatingSystemDescription, VirtualSystem system, String operatingSystemDescription, VirtualSystem system,
SortedSet<ResourceAllocation> resourceAllocations, String username, String password) { Set<ResourceAllocation> resourceAllocations, String username, String password) {
super(id, name, location, status, size, networkToAddresses, operatingSystemDescription, super(id, name, location, status, size, networkToAddresses, operatingSystemDescription,
system, resourceAllocations); system, resourceAllocations);
this.username = username; this.username = username;

View File

@ -59,7 +59,7 @@ import com.google.inject.TypeLiteral;
public class HostingDotComVCloudAsyncClientTest extends public class HostingDotComVCloudAsyncClientTest extends
RestClientTest<HostingDotComVCloudAsyncClient> { RestClientTest<HostingDotComVCloudAsyncClient> {
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = HostingDotComVCloudAsyncClient.class.getMethod("getCatalog"); Method method = HostingDotComVCloudAsyncClient.class.getMethod("getDefaultCatalog");
GeneratedHttpRequest<HostingDotComVCloudAsyncClient> httpMethod = processor GeneratedHttpRequest<HostingDotComVCloudAsyncClient> httpMethod = processor
.createRequest(method); .createRequest(method);

View File

@ -44,7 +44,7 @@ public class ParseTaskFromLocationHeader implements Function<HttpResponse, Task>
if (location != null) { if (location != null) {
String taskId = location.substring(location.lastIndexOf('/') + 1); String taskId = location.substring(location.lastIndexOf('/') + 1);
return new TaskImpl(taskId, URI.create(location), TaskStatus.QUEUED, new Date(), null, return new TaskImpl(taskId, URI.create(location), TaskStatus.QUEUED, new Date(), null,
null, null); null, null, null);
} else { } else {
throw new HttpResponseException("no uri in headers or content", null, from); throw new HttpResponseException("no uri in headers or content", null, from);
} }

View File

@ -130,7 +130,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
@Test @Test
public void testGetConfigCustomizationOptions() throws Exception { public void testGetConfigCustomizationOptions() throws Exception {
Catalog response = connection.getCatalog(); Catalog response = connection.getDefaultCatalog();
for (NamedResource resource : response.values()) { for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getId()); CatalogItem item = connection.getCatalogItem(resource.getId());
@ -168,7 +168,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
String vDCId = tmClient.getDefaultVDC().getId(); String vDCId = tmClient.getDefaultVDC().getId();
// lookup the id of the item in the catalog you wish to deploy by name // lookup the id of the item in the catalog you wish to deploy by name
String itemId = tmClient.getCatalog().get("Ubuntu JeOS 9.04 (32-bit)").getId(); String itemId = tmClient.getDefaultCatalog().get("Ubuntu JeOS 9.04 (32-bit)").getId();
// determine the cheapest configuration size // determine the cheapest configuration size
SortedSet<ComputeOptions> sizeOptions = tmClient.getComputeOptionsOfCatalogItem(itemId); SortedSet<ComputeOptions> sizeOptions = tmClient.getComputeOptionsOfCatalogItem(itemId);