Issue 112: added lifecycle commands

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2247 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-11-11 03:02:33 +00:00
parent 78fbcd0688
commit 6ef0f55ee4
42 changed files with 1351 additions and 277 deletions

View File

@ -25,21 +25,29 @@ package org.jclouds.vcloud;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
import java.net.URI;
import java.util.concurrent.Future;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.endpoints.TasksList;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.xml.CatalogHandler;
import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.TasksListHandler;
import org.jclouds.vcloud.xml.VDCHandler;
@ -66,10 +74,82 @@ public interface VCloudClient {
Future<? extends VDC> getDefaultVDC();
@GET
@Endpoint(TasksList.class)
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
Future<? extends org.jclouds.vcloud.domain.TasksList> getDefaultTasksList();
Future<? extends TasksList> getDefaultTasksList();
@POST
@Consumes(TASK_XML)
@Path("/action/deploy")
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> deploy(@Endpoint URI vApp);
@DELETE
Future<Void> delete(@Endpoint URI vApp);
@POST
@Consumes(TASK_XML)
@Path("/action/undeploy")
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> undeploy(@Endpoint URI vApp);
/**
* This call powers on the vApp, as specified in the vAppÕs ovf:Startup element.
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/powerOn")
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> powerOn(@Endpoint URI vApp);
/**
* This call powers off the vApp, as specified in the vAppÕs ovf:Startup element.
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/powerOff")
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> powerOff(@Endpoint URI vApp);
/**
* This call shuts down the vApp.
*/
@POST
@Path("/power/action/shutdown")
Future<Void> shutdown(@Endpoint URI vApp);
/**
* This call resets the vApp.
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/reset")
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> reset(@Endpoint URI vApp);
/**
* This call suspends the vApp.
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/suspend")
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> suspend(@Endpoint URI vApp);
@GET
@Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class)
Future<? extends Task> getTask(@Endpoint URI task);
@POST
@Path("/action/cancel")
Future<Void> cancelTask(@Endpoint URI task);
@GET
@Consumes(VAPP_XML)
// TODO parse
String getVApp(@Endpoint URI vApp);
//
// @GET

View File

@ -34,7 +34,7 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.endpoints.VCloud;
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
@ -55,7 +55,7 @@ public interface VCloudLogin {
String getVCloudToken();
@Org
Map<String, Link> getOrgs();
Map<String, NamedLink> getOrgs();
}
/**

View File

@ -25,7 +25,7 @@ package org.jclouds.vcloud.domain;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import com.google.inject.ImplementedBy;
@ -35,6 +35,6 @@ import com.google.inject.ImplementedBy;
*/
@org.jclouds.vcloud.endpoints.Catalog
@ImplementedBy(CatalogImpl.class)
public interface Catalog extends Link, Map<String, Link> {
public interface Catalog extends NamedLink, Map<String, NamedLink> {
}

View File

@ -26,6 +26,7 @@ package org.jclouds.vcloud.domain;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Org;
@ -39,15 +40,15 @@ import com.google.inject.ImplementedBy;
*/
@Org
@ImplementedBy(OrganizationImpl.class)
public interface Organization extends Link {
public interface Organization extends NamedLink {
@Catalog
Link getCatalog();
@VDC
Map<String, Link> getVDCs();
Map<String, NamedLink> getVDCs();
@TasksList
Map<String, Link> getTasksLists();
Map<String, NamedLink> getTasksLists();
}

View File

@ -23,9 +23,8 @@
*/
package org.jclouds.vcloud.domain;
import java.net.URI;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.joda.time.DateTime;
@ -35,10 +34,7 @@ import com.google.inject.ImplementedBy;
* @author Adrian Cole
*/
@ImplementedBy(TaskImpl.class)
public interface Task extends Comparable<Task> {
String getType();
URI getLocation();
public interface Task extends Link, Comparable<Task> {
TaskStatus getStatus();
@ -46,7 +42,7 @@ public interface Task extends Comparable<Task> {
DateTime getEndTime();
Link getOwner();
NamedLink getOwner();
Link getResult();
NamedLink getResult();
}

View File

@ -28,6 +28,7 @@ import java.util.SortedSet;
import org.jclouds.vcloud.domain.internal.TasksListImpl;
import com.google.common.collect.ListMultimap;
import com.google.inject.ImplementedBy;
/**
@ -40,4 +41,8 @@ public interface TasksList {
SortedSet<Task> getTasks();
ListMultimap<URI, Task> getTasksByResult();
ListMultimap<URI, Task> getTasksByOwner();
}

View File

@ -25,7 +25,7 @@ package org.jclouds.vcloud.domain;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import com.google.inject.ImplementedBy;
@ -35,10 +35,10 @@ import com.google.inject.ImplementedBy;
*/
@org.jclouds.vcloud.endpoints.VDC
@ImplementedBy(VDCImpl.class)
public interface VDC extends Link {
public interface VDC extends NamedLink {
Map<String, Link> getAvailableNetworks();
Map<String, NamedLink> getAvailableNetworks();
Map<String, Link> getResourceEntities();
Map<String, NamedLink> getResourceEntities();
}

View File

@ -29,8 +29,8 @@ import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.Catalog;
/**
@ -39,15 +39,15 @@ import org.jclouds.vcloud.domain.Catalog;
* @author Adrian Cole
*
*/
public class CatalogImpl extends HashMap<String, Link> implements Catalog {
public class CatalogImpl extends HashMap<String, NamedLink> implements Catalog {
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
private final Link catalog;
private final NamedLink catalog;
public CatalogImpl(String name, String type, URI location, Map<String, Link> contents) {
public CatalogImpl(String name, String type, URI location, Map<String, NamedLink> contents) {
super(contents.size());
this.catalog = new LinkImpl(checkNotNull(name, "name"), checkNotNull(type, "type"),
this.catalog = new NamedLinkImpl(checkNotNull(name, "name"), checkNotNull(type, "type"),
checkNotNull(location, "location"));
putAll(checkNotNull(contents, "contents"));
}

View File

@ -26,8 +26,8 @@ package org.jclouds.vcloud.domain.internal;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.TasksList;
@ -39,14 +39,14 @@ import org.jclouds.vcloud.endpoints.VDC;
* @author Adrian Cole
*
*/
public class OrganizationImpl extends LinkImpl implements Organization {
public class OrganizationImpl extends NamedLinkImpl implements Organization {
private final Link catalog;
private final Map<String, Link> vdcs;
private final Map<String, Link> tasksLists;
private final NamedLink catalog;
private final Map<String, NamedLink> vdcs;
private final Map<String, NamedLink> tasksLists;
public OrganizationImpl(String name, String type, URI location, Link catalog,
Map<String, Link> vdcs, Map<String, Link> tasksLists) {
public OrganizationImpl(String name, String type, URI location, NamedLink catalog,
Map<String, NamedLink> vdcs, Map<String, NamedLink> tasksLists) {
super(name, type, location);
this.catalog = catalog;
this.vdcs = vdcs;
@ -54,17 +54,17 @@ public class OrganizationImpl extends LinkImpl implements Organization {
}
@Catalog
public Link getCatalog() {
public NamedLink getCatalog() {
return catalog;
}
@VDC
public Map<String, Link> getVDCs() {
public Map<String, NamedLink> getVDCs() {
return vdcs;
}
@TasksList
public Map<String, Link> getTasksLists() {
public Map<String, NamedLink> getTasksLists() {
return tasksLists;
}

View File

@ -27,7 +27,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.joda.time.DateTime;
@ -40,21 +41,18 @@ import com.google.inject.internal.Nullable;
* @author Adrian Cole
*
*/
public class TaskImpl implements Task {
private final String type;
private final URI location;
public class TaskImpl extends LinkImpl implements Task {
private final TaskStatus status;
private final DateTime startTime;
@Nullable
private final DateTime endTime;
private final Link owner;
private final NamedLink owner;
@Nullable
private final Link result;
private final NamedLink result;
public TaskImpl(String type, URI location, TaskStatus status, DateTime startTime,
@Nullable DateTime endTime, Link owner, @Nullable Link result) {
this.type = checkNotNull(type, "type");
this.location = checkNotNull(location, "location");
@Nullable DateTime endTime, NamedLink owner, @Nullable NamedLink result) {
super(type, location);
this.status = checkNotNull(status, "status");
this.startTime = checkNotNull(startTime, "startTime");
this.endTime = endTime;
@ -70,11 +68,11 @@ public class TaskImpl implements Task {
return startTime;
}
public Link getOwner() {
public NamedLink getOwner() {
return owner;
}
public Link getResult() {
public NamedLink getResult() {
return result;
}
@ -86,25 +84,15 @@ public class TaskImpl implements Task {
return (this == o) ? 0 : getStartTime().compareTo(o.getStartTime());
}
public String getType() {
return type;
}
public URI getLocation() {
return location;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
int result = super.hashCode();
result = prime * result + ((endTime == null) ? 0 : endTime.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());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@ -112,7 +100,7 @@ public class TaskImpl implements Task {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
@ -122,11 +110,6 @@ public class TaskImpl implements Task {
return false;
} else if (!endTime.equals(other.endTime))
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;
@ -147,12 +130,13 @@ public class TaskImpl implements Task {
return false;
} else if (!status.equals(other.status))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
}
@Override
public String toString() {
return "TaskImpl [endTime=" + endTime + ", owner=" + owner + ", result=" + result
+ ", startTime=" + startTime + ", status=" + status + "]";
}
}

View File

@ -29,6 +29,12 @@ import java.util.SortedSet;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimaps;
/**
* Locations of resources in vCloud
*
@ -38,6 +44,9 @@ import org.jclouds.vcloud.domain.TasksList;
public class TasksListImpl implements TasksList {
private final SortedSet<Task> tasks;
private final ListMultimap<URI, Task> tasksByResult;
private final ListMultimap<URI, Task> tasksByOwner;
private final URI location;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
@ -45,6 +54,28 @@ public class TasksListImpl implements TasksList {
public TasksListImpl(URI location, SortedSet<Task> tasks) {
this.location = location;
this.tasks = tasks;
this.tasksByResult = Multimaps.index(Iterables.filter(tasks, new Predicate<Task>() {
public boolean apply(Task input) {
return input.getResult() != null;
}
}), new Function<Task, URI>() {
public URI apply(Task input) {
return input.getResult().getLocation();
}
});
this.tasksByOwner = Multimaps.index(tasks, new Function<Task, URI>() {
public URI apply(Task in) {
return in.getOwner().getLocation();
}
});
}
public SortedSet<Task> getTasks() {
@ -61,6 +92,7 @@ public class TasksListImpl implements TasksList {
int result = 1;
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
result = prime * result + ((tasksByResult == null) ? 0 : tasksByResult.hashCode());
return result;
}
@ -83,6 +115,19 @@ public class TasksListImpl implements TasksList {
return false;
} else if (!tasks.equals(other.tasks))
return false;
if (tasksByResult == null) {
if (other.tasksByResult != null)
return false;
} else if (!tasksByResult.equals(other.tasksByResult))
return false;
return true;
}
public ListMultimap<URI, Task> getTasksByResult() {
return tasksByResult;
}
public ListMultimap<URI, Task> getTasksByOwner() {
return tasksByOwner;
}
}

View File

@ -28,8 +28,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.VDC;
/**
@ -38,24 +38,24 @@ import org.jclouds.vcloud.domain.VDC;
* @author Adrian Cole
*
*/
public class VDCImpl extends LinkImpl implements VDC {
private final Map<String, Link> availableNetworks;
private final Map<String, Link> resourceEntities;
public class VDCImpl extends NamedLinkImpl implements VDC {
private final Map<String, NamedLink> availableNetworks;
private final Map<String, NamedLink> resourceEntities;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public VDCImpl(String name, String type, URI location, Map<String, Link> resourceEntities,
Map<String, Link> availableNetworks) {
public VDCImpl(String name, String type, URI location, Map<String, NamedLink> resourceEntities,
Map<String, NamedLink> availableNetworks) {
super(name, type, location);
this.availableNetworks = checkNotNull(availableNetworks, "availableNetworks");
this.resourceEntities = checkNotNull(resourceEntities, "resourceEntities");
}
public Map<String, Link> getAvailableNetworks() {
public Map<String, NamedLink> getAvailableNetworks() {
return availableNetworks;
}
public Map<String, Link> getResourceEntities() {
public Map<String, NamedLink> getResourceEntities() {
return resourceEntities;
}

View File

@ -38,7 +38,7 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.jclouds.vcloud.endpoints.Org;
@ -76,7 +76,7 @@ public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCl
boolean matchFound = matcher.find();
if (matchFound) {
final Map<String, Link> org = factory.create(orgHandlerProvider.get()).parse(
final Map<String, NamedLink> org = factory.create(orgHandlerProvider.get()).parse(
from.getContent());
return new VCloudSession() {
@ -86,7 +86,7 @@ public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCl
}
@Org
public Map<String, Link> getOrgs() {
public Map<String, NamedLink> getOrgs() {
return org;
}
};

View File

@ -43,6 +43,8 @@ import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.terremark.binders.BindInstantiateVAppTemplateParamsToXmlEntity;
import org.jclouds.vcloud.terremark.domain.VApp;
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
/**
@ -65,8 +67,9 @@ public interface TerremarkVCloudClient extends VCloudClient {
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@Path("/action/instantiatevAppTemplate")
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
@XMLResponseParser(TerremarkVAppHandler.class)
@MapBinder(BindInstantiateVAppTemplateParamsToXmlEntity.class)
String instantiateVAppTemplate(@MapEntityParam("name") String appName,
Future<? extends VApp> instantiateVAppTemplate(@MapEntityParam("name") String appName,
@MapEntityParam("template") URI vAppTemplate, @MapEntityParam("count") int cpuCount,
@MapEntityParam("megabytes") int megabytesMemory, @MapEntityParam("network") URI network);

View File

@ -0,0 +1,44 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.terremark.domain;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.terremark.domain.internal.VAppImpl;
import com.google.inject.ImplementedBy;
/**
* @author Adrian Cole
*/
@ImplementedBy(VAppImpl.class)
public interface VApp extends NamedLink {
int getStatus();
int getSize();
Link getVDC();
}

View File

@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
@ -40,31 +40,31 @@ import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
*/
public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC {
private final Link catalog;
private final Link publicIps;
private final Link internetServices;
private final NamedLink catalog;
private final NamedLink publicIps;
private final NamedLink internetServices;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public TerremarkVDCImpl(String name, String type, URI location,
Map<String, Link> availableNetworks, Map<String, Link> resourceEntities, Link catalog,
Link publicIps, Link internetServices) {
Map<String, NamedLink> availableNetworks, Map<String, NamedLink> resourceEntities, NamedLink catalog,
NamedLink publicIps, NamedLink internetServices) {
super(name, type, location, availableNetworks, resourceEntities);
this.catalog = checkNotNull(catalog, "catalog");
this.publicIps = checkNotNull(publicIps, "publicIps");
this.internetServices = checkNotNull(internetServices, "internetServices");
}
public Link getCatalog() {
public NamedLink getCatalog() {
return catalog;
}
public Link getPublicIps() {
public NamedLink getPublicIps() {
return publicIps;
}
public Link getInternetServices() {
public NamedLink getInternetServices() {
return internetServices;
}

View File

@ -0,0 +1,68 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.terremark.domain.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.terremark.domain.VApp;
/**
* Locations of resources in vCloud
*
* @author Adrian Cole
*
*/
public class VAppImpl extends NamedLinkImpl implements VApp {
private final int status;
private final int size;
private final Link vDC;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public VAppImpl(String name, String type, URI location, int status, int size, Link vDC) {
super(name, type, location);
this.status = status;
this.size = size;
this.vDC = checkNotNull(vDC, "vDC");
}
public int getStatus() {
return status;
}
public int getSize() {
return size;
}
public Link getVDC() {
return vDC;
}
}

View File

@ -0,0 +1,61 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.terremark.xml;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.util.Utils;
import org.jclouds.vcloud.terremark.domain.VApp;
import org.jclouds.vcloud.terremark.domain.internal.VAppImpl;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* @author Adrian Cole
*/
public class TerremarkVAppHandler extends ParseSax.HandlerWithResult<VApp> {
private NamedLink vApp;
private Link vDC;
private int status;
private int size;
public VApp getResult() {
return new VAppImpl(vApp.getName(), vApp.getType(), vApp.getLocation(), status, size, vDC);
}
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Link")) {
vDC = Utils.newLink(attributes);
} else if (qName.equals("VApp")) {
vApp = Utils.newNamedLink(attributes);
status = Integer.parseInt(attributes.getValue(attributes.getIndex("status")));
size = Integer.parseInt(attributes.getValue(attributes.getIndex("size")));
}
}
}

View File

@ -23,7 +23,7 @@
*/
package org.jclouds.vcloud.terremark.xml;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.util.Utils;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.VDC;
@ -38,9 +38,9 @@ import org.xml.sax.SAXException;
*/
public class TerremarkVDCHandler extends VDCHandler {
private Link catalog;
private Link publicIps;
private Link internetServices;
private NamedLink catalog;
private NamedLink publicIps;
private NamedLink internetServices;
public TerremarkVDC getResult() {
VDC vDC = super.getResult();
@ -56,13 +56,13 @@ public class TerremarkVDCHandler extends VDCHandler {
if (qName.equals("Link")) {
String name = attributes.getValue(attributes.getIndex("name"));
if (name.equals("Internet Services")) {
internetServices = Utils.newLink(attributes);
internetServices = Utils.newNamedLink(attributes);
} else if (name.equals("Public IPs")) {
publicIps = Utils.newLink(attributes);
publicIps = Utils.newNamedLink(attributes);
} else {
String type = attributes.getValue(attributes.getIndex("type"));
if (type.equals(VCloudMediaType.CATALOG_XML)) {
catalog = Utils.newLink(attributes);
catalog = Utils.newNamedLink(attributes);
}
}
}

View File

@ -0,0 +1,96 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.xml;
import java.text.ParseException;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.util.Utils;
import org.jclouds.util.DateService;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.joda.time.DateTime;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* @author Adrian Cole
*/
public abstract class BaseTaskHandler<T> extends ParseSax.HandlerWithResult<T> {
protected final DateService dateService;
private Link taskLink;
private NamedLink owner;
private NamedLink result;
private TaskStatus status;
private DateTime startTime;
private DateTime endTime;
@Inject
public BaseTaskHandler(DateService dateService) {
this.dateService = dateService;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Task")) {
taskLink = Utils.newLink(attributes);
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
startTime = dateService.iso8601DateParse(attributes.getValue(attributes
.getIndex("startTime")));
if (attributes.getIndex("endTime") != -1) {
try {
endTime = dateService.iso8601DateParse(attributes.getValue(attributes
.getIndex("endTime")));
} catch (RuntimeException e) {
if (!(e.getCause() instanceof ParseException)) // TODO.. format doesn't parse
// endTime="2009-11-11T02:27:25Z"
throw e;
}
}
} else if (qName.equals("Owner")) {
owner = Utils.newNamedLink(attributes);
} else if (qName.equals("Result")) {
result = Utils.newNamedLink(attributes);
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equals("Task")) {
newTask(new TaskImpl(taskLink.getType(), taskLink.getLocation(), status, startTime,
endTime, owner, result));
}
}
protected abstract void newTask(Task task);
}

View File

@ -23,14 +23,14 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.putLink;
import static org.jclouds.rest.util.Utils.putNamedLink;
import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.xml.sax.Attributes;
@ -42,8 +42,8 @@ import com.google.common.collect.Maps;
* @author Adrian Cole
*/
public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
private Link Catalog;
private Map<String, Link> contents = Maps.newHashMap();
private NamedLink Catalog;
private Map<String, NamedLink> contents = Maps.newHashMap();
public Catalog getResult() {
return new CatalogImpl(Catalog.getName(), Catalog.getType(), Catalog.getLocation(), contents);
@ -53,11 +53,11 @@ public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Catalog")) {
Catalog = new LinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
Catalog = new NamedLinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(attributes.getValue(attributes
.getIndex("href"))));
} else if (qName.equals("CatalogItem")) {
putLink(contents, attributes);
putNamedLink(contents, attributes);
}
}

View File

@ -23,8 +23,8 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.newLink;
import static org.jclouds.rest.util.Utils.putLink;
import static org.jclouds.rest.util.Utils.newNamedLink;
import static org.jclouds.rest.util.Utils.putNamedLink;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
@ -34,8 +34,8 @@ import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.xml.sax.Attributes;
@ -47,10 +47,10 @@ import com.google.common.collect.Maps;
* @author Adrian Cole
*/
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
private Link org;
private Map<String, Link> vdcs = Maps.newHashMap();
private Map<String, Link> tasksLists = Maps.newHashMap();
private Link catalog;
private NamedLink org;
private Map<String, NamedLink> vdcs = Maps.newHashMap();
private Map<String, NamedLink> tasksLists = Maps.newHashMap();
private NamedLink catalog;
public Organization getResult() {
return new OrganizationImpl(org.getName(), org.getType(), org.getLocation(), catalog, vdcs,
@ -61,17 +61,17 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Org")) {
org = new LinkImpl(attributes.getValue(attributes.getIndex("name")), ORG_XML, URI
org = new NamedLinkImpl(attributes.getValue(attributes.getIndex("name")), ORG_XML, URI
.create(attributes.getValue(attributes.getIndex("href"))));
} else if (qName.equals("Link")) {
int typeIndex = attributes.getIndex("type");
if (typeIndex != -1) {
if (attributes.getValue(typeIndex).equals(VDC_XML)) {
putLink(vdcs, attributes);
putNamedLink(vdcs, attributes);
} else if (attributes.getValue(typeIndex).equals(CATALOG_XML)) {
catalog = newLink(attributes);
catalog = newNamedLink(attributes);
} else if (attributes.getValue(typeIndex).equals(TASKSLIST_XML)) {
putLink(tasksLists, attributes);
putNamedLink(tasksLists, attributes);
}
}
}

View File

@ -23,13 +23,13 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.putLink;
import static org.jclouds.rest.util.Utils.putNamedLink;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -38,11 +38,11 @@ import com.google.common.collect.Maps;
/**
* @author Adrian Cole
*/
public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, Link>> {
public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, NamedLink>> {
private Map<String, Link> org = Maps.newHashMap();
private Map<String, NamedLink> org = Maps.newHashMap();
public Map<String, Link> getResult() {
public Map<String, NamedLink> getResult() {
return org;
}
@ -53,7 +53,7 @@ public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, Link>
int typeIndex = attributes.getIndex("type");
if (typeIndex != -1) {
if (attributes.getValue(typeIndex).equals(ORG_XML)) {
putLink(org, attributes);
putNamedLink(org, attributes);
}
}
}

View File

@ -0,0 +1,52 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.xml;
import javax.inject.Inject;
import org.jclouds.util.DateService;
import org.jclouds.vcloud.domain.Task;
/**
* @author Adrian Cole
*/
public class TaskHandler extends BaseTaskHandler<Task> {
@Inject
public TaskHandler(DateService dateService) {
super(dateService);
}
private Task task;
public Task getResult() {
return task;
}
@Override
protected void newTask(Task task) {
this.task = task;
}
}

View File

@ -28,16 +28,11 @@ import java.util.SortedSet;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.util.Utils;
import org.jclouds.util.DateService;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.jclouds.vcloud.domain.internal.TasksListImpl;
import org.joda.time.DateTime;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -46,53 +41,31 @@ import com.google.common.collect.Sets;
/**
* @author Adrian Cole
*/
public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
public class TasksListHandler extends BaseTaskHandler<TasksList> {
private SortedSet<Task> tasks = Sets.newTreeSet();
protected final DateService dateService;
private Link taskLink;
private Link owner;
private Link result;
private TaskStatus status;
private DateTime startTime;
private DateTime endTime;
private URI location;
@Inject
public TasksListHandler(DateService dateService) {
this.dateService = dateService;
super(dateService);
}
public TasksList getResult() {
return new TasksListImpl(location, tasks);
}
protected void newTask(Task task) {
this.tasks.add(task);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("TasksList")) {
location = Utils.newLink(attributes).getLocation();
} else if (qName.equals("Task")) {
taskLink = Utils.newLink(attributes);
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
startTime = dateService.iso8601DateParse(attributes.getValue(attributes
.getIndex("startTime")));
if (attributes.getIndex("endTime") != -1)
endTime = dateService.iso8601DateParse(attributes.getValue(attributes
.getIndex("endTime")));
} else if (qName.equals("Owner")) {
owner = Utils.newLink(attributes);
} else if (qName.equals("Result")) {
result = Utils.newLink(attributes);
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equals("Task")) {
tasks.add(new TaskImpl(taskLink.getType(), taskLink.getLocation(), status, startTime,
endTime, owner, result));
} else {
super.startElement(uri, localName, qName, attributes);
}
}

View File

@ -23,14 +23,14 @@
*/
package org.jclouds.vcloud.xml;
import static org.jclouds.rest.util.Utils.putLink;
import static org.jclouds.rest.util.Utils.putNamedLink;
import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import org.xml.sax.Attributes;
@ -42,9 +42,9 @@ import com.google.common.collect.Maps;
* @author Adrian Cole
*/
public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
private Link vDC;
private Map<String, Link> resourceEntities = Maps.newHashMap();
private Map<String, Link> availableNetworks = Maps.newHashMap();
private NamedLink vDC;
private Map<String, NamedLink> resourceEntities = Maps.newHashMap();
private Map<String, NamedLink> availableNetworks = Maps.newHashMap();
public VDC getResult() {
return new VDCImpl(vDC.getName(), vDC.getType(), vDC.getLocation(), resourceEntities,
@ -55,13 +55,13 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
if (qName.equals("Vdc")) {
vDC = new LinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
vDC = new NamedLinkImpl(attributes.getValue(attributes.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(attributes.getValue(attributes
.getIndex("href"))));
} else if (qName.equals("Network")) {
putLink(availableNetworks, attributes);
putNamedLink(availableNetworks, attributes);
} else if (qName.equals("ResourceEntity")) {
putLink(resourceEntities, attributes);
putNamedLink(resourceEntities, attributes);
}
}

View File

@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VDC;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@ -75,7 +76,19 @@ public class VCloudClientLiveTest {
assertNotNull(response);
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
}
@Test
public void testGetTask() throws Exception {
org.jclouds.vcloud.domain.TasksList response = connection.getDefaultTasksList().get(10,
TimeUnit.SECONDS);
assertNotNull(response);
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
for (Task t : response.getTasks()) {
assertEquals(connection.getTask(t.getLocation()).get(10, TimeUnit.SECONDS).getLocation(),
t.getLocation());
}
}
@BeforeGroups(groups = { "live" })

View File

@ -32,6 +32,7 @@ import java.net.URI;
import javax.inject.Provider;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReturnVoidIf2xx;
import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rest.RestClientTest;
@ -42,6 +43,7 @@ import org.jclouds.vcloud.endpoints.TasksList;
import org.jclouds.vcloud.endpoints.VDC;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.xml.CatalogHandler;
import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.TasksListHandler;
import org.jclouds.vcloud.xml.VDCHandler;
import org.testng.annotations.Test;
@ -104,6 +106,176 @@ public class VCloudClientTest extends RestClientTest<VCloudClient> {
checkFilters(httpMethod);
}
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("deploy", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/action/deploy HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("undeploy", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/action/undeploy HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("delete", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"DELETE https://services.vcloudexpress.terremark.com/vapp/1 HTTP/1.1");
assertHeadersEqual(httpMethod, "");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("powerOn", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/power/action/powerOn HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("powerOff", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/power/action/powerOff HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testReset() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("reset", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/power/action/reset HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testSuspend() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("suspend", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/power/action/suspend HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testShutdown() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("shutdown", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/vapp/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/vapp/1/power/action/shutdown HTTP/1.1");
assertHeadersEqual(httpMethod, "");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("getTask", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/task/1"));
assertRequestLineEquals(httpMethod,
"GET https://services.vcloudexpress.terremark.com/task/1 HTTP/1.1");
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudClient.class.getMethod("cancelTask", URI.class);
GeneratedHttpRequest<VCloudClient> httpMethod = processor.createRequest(method, URI
.create("https://services.vcloudexpress.terremark.com/task/1"));
assertRequestLineEquals(httpMethod,
"POST https://services.vcloudexpress.terremark.com/task/1/action/cancel HTTP/1.1");
assertHeadersEqual(httpMethod, "");
assertEntityEquals(httpMethod, null);
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
}
@Override
protected void checkFilters(GeneratedHttpRequest<VCloudClient> httpMethod) {
assertEquals(httpMethod.getFilters().size(), 1);

View File

@ -38,7 +38,7 @@ import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler;
import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.http.handlers.RedirectionRetryHandler;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.util.Jsr330;
import org.jclouds.vcloud.VCloudLogin;
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
@ -80,7 +80,7 @@ public class RestVCloudAuthenticationModuleTest {
public VCloudSession login() {
return new VCloudSession() {
public Map<String, Link> getOrgs() {
public Map<String, NamedLink> getOrgs() {
return null;
}

View File

@ -31,7 +31,7 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudLogin.VCloudSession;
import org.testng.annotations.BeforeTest;
@ -64,7 +64,7 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
"Content-Type: application/xml; charset=utf-8");
VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new LinkImpl(
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedLinkImpl(
"adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));

View File

@ -24,6 +24,7 @@
package org.jclouds.vcloud.terremark;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.net.URI;
@ -31,12 +32,18 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jclouds.http.HttpResponseException;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.vcloud.VCloudClientLiveTest;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.jclouds.vcloud.terremark.domain.VApp;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
* Tests behavior of {@code TerremarkVCloudClient}
*
@ -51,26 +58,95 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
@Test
public void testDefaultVDC() throws Exception {
super.testDefaultVDC();
TerremarkVDC response = (TerremarkVDC) tmClient.getDefaultVDC().get(10, TimeUnit.SECONDS);
TerremarkVDC response = (TerremarkVDC) tmClient.getDefaultVDC().get(45, TimeUnit.SECONDS);
assertNotNull(response);
assertNotNull(response.getCatalog());
assertNotNull(response.getInternetServices());
assertNotNull(response.getPublicIps());
}
@Test(enabled = false)
@Test
// disabled until stop functionality is added
public void testInstantiate() throws InterruptedException, ExecutionException, TimeoutException {
URI template = tmClient.getCatalog().get(10, TimeUnit.SECONDS).get(
URI template = tmClient.getCatalog().get(45, TimeUnit.SECONDS).get(
"Ubuntu Server 9.04 (32-bit)").getLocation();
URI network = tmClient.getDefaultVDC().get(10, TimeUnit.SECONDS).getAvailableNetworks()
URI network = tmClient.getDefaultVDC().get(45, TimeUnit.SECONDS).getAvailableNetworks()
.values().iterator().next().getLocation();
String response = tmClient.instantiateVAppTemplate("adriantest", template, 1, 512, network);
VApp vApp = tmClient.instantiateVAppTemplate("adriantest1", template, 1, 512, network).get(
45, TimeUnit.SECONDS);
Task instantiateTask = getLastTaskFor(vApp.getVDC().getLocation());
System.out.println(response);
// in terremark, this should be a no-op, as it should simply return the above task, which is
// already deploying
Task deployTask = tmClient.deploy(vApp.getLocation()).get(45, TimeUnit.SECONDS);
assertEquals(deployTask.getLocation(), instantiateTask.getLocation());
// check to see the result of calling deploy twice
deployTask = tmClient.deploy(vApp.getLocation()).get(45, TimeUnit.SECONDS);
assertEquals(deployTask.getLocation(), instantiateTask.getLocation());
try {// per docs, this is not supported
tmClient.cancelTask(deployTask.getLocation()).get(45, TimeUnit.SECONDS);
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass(), HttpResponseException.class);
assertEquals(((HttpResponseException) e.getCause()).getResponse().getStatusCode(), 501);
}
deployTask = blockUntilSuccess(deployTask);
// TODO verify from vapp status
try {// per docs, this is not supported
tmClient.undeploy(deployTask.getResult().getLocation()).get(45, TimeUnit.SECONDS);
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass(), HttpResponseException.class);
assertEquals(((HttpResponseException) e.getCause()).getResponse().getStatusCode(), 501);
}
deployTask = blockUntilSuccess(tmClient.powerOn(deployTask.getResult().getLocation()).get(45,
TimeUnit.SECONDS));
// TODO verify from vapp status
try {// per docs, this is not supported
tmClient.suspend(deployTask.getResult().getLocation()).get(45, TimeUnit.SECONDS);
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass(), HttpResponseException.class);
assertEquals(((HttpResponseException) e.getCause()).getResponse().getStatusCode(), 501);
}
deployTask = blockUntilSuccess(tmClient.reset(deployTask.getResult().getLocation()).get(45,
TimeUnit.SECONDS));
// TODO verify from vapp status
tmClient.shutdown(deployTask.getResult().getLocation()).get(45, TimeUnit.SECONDS);
// TODO verify from vapp status
deployTask = blockUntilSuccess(tmClient.powerOff(deployTask.getResult().getLocation()).get(
45, TimeUnit.SECONDS));
// TODO verify from vapp status
tmClient.delete(deployTask.getResult().getLocation()).get(45, TimeUnit.SECONDS);
// TODO verify from vapp status
}
private Task blockUntilSuccess(Task task) throws InterruptedException, ExecutionException,
TimeoutException {
for (task = tmClient.getTask(task.getLocation()).get(30, TimeUnit.SECONDS); task.getStatus() != TaskStatus.SUCCESS; task = tmClient
.getTask(task.getLocation()).get(30, TimeUnit.SECONDS)) {
System.out.printf("%s blocking on status active: currently: %s%n", task.getOwner()
.getName(), task.getStatus());
Thread.sleep(5 * 1000);
}
System.out.printf("%s complete%n", task.getResult().getName());
return task;
}
private Task getLastTaskFor(URI owner) throws InterruptedException, ExecutionException,
TimeoutException {
return Iterables.getLast(tmClient.getDefaultTasksList().get(45, TimeUnit.SECONDS)
.getTasksByOwner().get(owner));
}
@BeforeGroups(groups = { "live" })

View File

@ -36,7 +36,6 @@ import javax.inject.Singleton;
import org.apache.commons.io.IOUtils;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReturnStringIf200;
import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rest.RestClientTest;
@ -46,6 +45,7 @@ import org.jclouds.util.Utils;
import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.VDC;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
import org.testng.annotations.Test;
@ -94,8 +94,8 @@ public class TerremarkVCloudClientTest extends RestClientTest<TerremarkVCloudCli
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
"/terremark/InstantiateVAppTemplateParams-test.xml")));
assertResponseParserClassEquals(method, httpMethod, ReturnStringIf200.class);
assertSaxResponseParserClassEquals(method, null);
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);

View File

@ -0,0 +1,68 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.terremark.xml;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.vcloud.terremark.domain.VApp;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
/**
* Tests behavior of {@code TerremarkVAppHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.TerremarkVAppHandlerTest")
public class TerremarkVAppHandlerTest extends BaseHandlerTest {
@BeforeTest
@Override
protected void setUpInjector() {
super.setUpInjector();
}
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/terremark/launched_vapp.xml");
VApp result = (VApp) factory.create(injector.getInstance(TerremarkVAppHandler.class)).parse(
is);
assertEquals(result.getName(), "adriantest");
assertEquals(result.getStatus(), 0);
assertEquals(result.getSize(), 4);
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13775"));
assertEquals(result.getType(), "application/vnd.vmware.vcloud.vApp+xml");
assertEquals(result.getVDC(), new LinkImpl("application/vnd.vmware.vcloud.vdc+xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
}
}

View File

@ -30,8 +30,8 @@ import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -61,17 +61,17 @@ public class TerremarkVDCHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
assertEquals(result.getType(), "application/vnd.vmware.vcloud.vdc+xml");
assertEquals(result.getResourceEntities(), ImmutableMap.<String, Link> of());
assertEquals(result.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new LinkImpl(
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedLink> of());
assertEquals(result.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new NamedLinkImpl(
"10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml",
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
assertEquals(result.getCatalog(), new LinkImpl("Miami Environment 1", CATALOG_XML,
assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1", CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(result.getPublicIps(), new LinkImpl("Public IPs", "application/xml", URI
assertEquals(result.getPublicIps(), new NamedLinkImpl("Public IPs", "application/xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
assertEquals(
result.getInternetServices(),
new LinkImpl(
new NamedLinkImpl(
"Internet Services",
"application/xml",
URI

View File

@ -30,7 +30,7 @@ import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.Catalog;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -59,77 +59,77 @@ public class CatalogHandlerTest extends BaseHandlerTest {
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
assertEquals(result.getType(), "application/vnd.vmware.vcloud.catalog+xml");
assertEquals(result.get("CentOS 5.3 (32-bit)"), new LinkImpl("CentOS 5.3 (32-bit)",
assertEquals(result.get("CentOS 5.3 (32-bit)"), new NamedLinkImpl("CentOS 5.3 (32-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
assertEquals(result.get("CentOS 5.3 (64-bit)"), new LinkImpl("CentOS 5.3 (64-bit)",
assertEquals(result.get("CentOS 5.3 (64-bit)"), new NamedLinkImpl("CentOS 5.3 (64-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
assertEquals(result.get("RHEL 5.3 (32-bit)"), new LinkImpl("RHEL 5.3 (32-bit)",
assertEquals(result.get("RHEL 5.3 (32-bit)"), new NamedLinkImpl("RHEL 5.3 (32-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
assertEquals(result.get("RHEL 5.3 (64-bit)"), new LinkImpl("RHEL 5.3 (64-bit)",
assertEquals(result.get("RHEL 5.3 (64-bit)"), new NamedLinkImpl("RHEL 5.3 (64-bit)",
CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new LinkImpl(
assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new NamedLinkImpl(
"Ubuntu JeOS 9.04 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new LinkImpl(
assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new NamedLinkImpl(
"Ubuntu JeOS 9.04 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new LinkImpl(
assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new NamedLinkImpl(
"Ubuntu Server 9.04 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new LinkImpl(
assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new NamedLinkImpl(
"Ubuntu Server 9.04 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new LinkImpl(
assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new NamedLinkImpl(
"Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new NamedLinkImpl(
"Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new LinkImpl(
assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new NamedLinkImpl(
"Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new NamedLinkImpl(
"Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new NamedLinkImpl(
"Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new LinkImpl(
assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new NamedLinkImpl(
"Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new NamedLinkImpl(
"Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new NamedLinkImpl(
"Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new LinkImpl(
assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new NamedLinkImpl(
"Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new NamedLinkImpl(
"Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new NamedLinkImpl(
"Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
assertEquals(
result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"),
new LinkImpl(
new NamedLinkImpl(
"Windows Server 2008 Standard w.SQL 2008 Web (64-bit)",
CATALOGITEM_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new LinkImpl(
assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new NamedLinkImpl(
"Windows Web Server 2008 (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new NamedLinkImpl(
"Windows Web Server 2008 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new LinkImpl(
assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new NamedLinkImpl(
"Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));

View File

@ -32,7 +32,7 @@ import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Organization;
import org.testng.annotations.BeforeTest;
@ -63,9 +63,9 @@ public class OrgHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getType(), ORG_XML);
assertEquals(result.getCatalog(), new LinkImpl("Miami Environment 1 Catalog", CATALOG_XML,
assertEquals(result.getCatalog(), new NamedLinkImpl("Miami Environment 1 Catalog", CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new LinkImpl(
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new NamedLinkImpl(
"Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
assertEquals(
@ -73,7 +73,7 @@ public class OrgHandlerTest extends BaseHandlerTest {
ImmutableMap
.of(
"Miami Environment 1 Tasks List",
new LinkImpl(
new NamedLinkImpl(
"Miami Environment 1 Tasks List",
TASKSLIST_XML,
URI

View File

@ -30,8 +30,8 @@ import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.VCloudMediaType;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -55,10 +55,10 @@ public class OrgListHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/orglist.xml");
Map<String, Link> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(
is);
assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new LinkImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI
Map<String, NamedLink> result = factory.create(injector.getInstance(OrgListHandler.class))
.parse(is);
assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new NamedLinkImpl(
"adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}
}

View File

@ -0,0 +1,78 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*/
package org.jclouds.vcloud.xml;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.util.DateService;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
/**
* Tests behavior of {@code TaskHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.TaskHandlerTest")
public class TaskHandlerTest extends BaseHandlerTest {
private DateService dateService;
@BeforeTest
@Override
protected void setUpInjector() {
super.setUpInjector();
dateService = injector.getInstance(DateService.class);
}
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/taskslist.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl(VCloudMediaType.TASK_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedLinkImpl(
"VDC Name", VCloudMediaType.VDC_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedLinkImpl("Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
)
);
assertEquals(result, expects);
}
}

View File

@ -29,15 +29,17 @@ import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.util.DateService;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSortedSet;
/**
@ -63,49 +65,39 @@ public class TasksListHandlerTest extends BaseHandlerTest {
TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
Task task1 = new TaskImpl(VCloudMediaType.TASK_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"),
dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"), new NamedLinkImpl(
"VDC Name", VCloudMediaType.VDC_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedLinkImpl("Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")));
Task task2 = new TaskImpl(VCloudMediaType.TASK_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedLinkImpl(
"VDC Name", VCloudMediaType.VDC_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedLinkImpl("Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
)
);
assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
assertEquals(
result.getTasks(),
ImmutableSortedSet
result.getTasksByResult(),
ImmutableListMultimap
.of(
new TaskImpl(
VCloudMediaType.TASK_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
TaskStatus.SUCCESS,
dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"),
dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"),
new LinkImpl(
"VDC Name",
VCloudMediaType.VDC_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new LinkImpl(
"Server1",
VCloudMediaType.VAPP_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"))),
new TaskImpl(
VCloudMediaType.TASK_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
TaskStatus.SUCCESS,
dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"),
new LinkImpl(
"VDC Name",
VCloudMediaType.VDC_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new LinkImpl(
"Server1",
VCloudMediaType.VAPP_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
)
)));
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"),
task2,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"),
task1));
assertEquals(result.getTasksByOwner(), ImmutableListMultimap.of(URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1"), task2, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1"), task1));
}
}

View File

@ -29,8 +29,8 @@ import java.io.InputStream;
import java.net.URI;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.rest.domain.Link;
import org.jclouds.rest.domain.internal.LinkImpl;
import org.jclouds.rest.domain.NamedLink;
import org.jclouds.rest.domain.internal.NamedLinkImpl;
import org.jclouds.vcloud.domain.VDC;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -59,9 +59,16 @@ public class VDCHandlerTest extends BaseHandlerTest {
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
assertEquals(result.getType(), "application/vnd.vmware.vcloud.vdc+xml");
assertEquals(result.getResourceEntities(), ImmutableMap.<String, Link> of());
assertEquals(result.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new LinkImpl(
"10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml",
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedLink> of());
assertEquals(
result.getAvailableNetworks(),
ImmutableMap
.of(
"10.114.34.128/26",
new NamedLinkImpl(
"10.114.34.128/26",
"application/vnd.vmware.vcloud.network+xml",
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
}
}

View File

@ -0,0 +1,9 @@
<Task href="https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"
type="application/vnd.vmware.vcloud.task+xml" status="success"
startTime="2009-08-24T21:29:32.983Z" endTime="2009-08-24T21:29:44.65Z">
<Owner href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1"
type="application/vnd.vmware.vcloud.vdc+xml" name="VDC Name" />
<Result
href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"
type="application/vnd.vmware.vcloud.vApp+xml" name="Server1" />
</Task>

View File

@ -0,0 +1,251 @@
<VApp href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850"
type="application/vnd.vmware.vcloud.vApp+xml" name="adriantest1"
status="2" size="4194304" xmlns="http://www.vmware.com/vcloud/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Link rel="up"
href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"
type="application/vnd.vmware.vcloud.vdc+xml" />
<Link rel="down"
href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/compute"
type="application/xml" name="Compute Options" />
<Link rel="down"
href="https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13850/options/customization"
type="application/xml" name="Customization Options" />
<Section xsi:type="q1:NetworkConnectionSectionType" xmlns="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:q1="http://www.vmware.com/vcloud/v1">
<q1:NetworkConnection Network="Internal">
<q1:IpAddress>10.114.34.132</q1:IpAddress>
</q1:NetworkConnection>
</Section>
<OperatingSystemSection d2p1:id="45"
xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:d2p1="http://schemas.dmtf.org/ovf/envelope/1">
<Info>The kind of installed guest operating system</Info>
<Description>Ubuntu Linux (32-bit)</Description>
</OperatingSystemSection>
<Section xsi:type="q2:VirtualHardwareSection_Type" xmlns="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:q2="http://www.vmware.com/vcloud/v1">
<Info>Virtual Hardware</Info>
<q2:System>
<AutomaticRecoveryAction xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<AutomaticShutdownAction xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<AutomaticStartupAction xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<AutomaticStartupActionDelay
xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<AutomaticStartupActionSequenceNumber
xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<Caption xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<ConfigurationDataRoot xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<ConfigurationFile xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<ConfigurationID xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<CreationTime xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<Description xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<ElementName
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">Virtual Hardware Family</ElementName>
<InstanceID
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">0</InstanceID>
<LogDataRoot xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<RecoveryFile xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<SnapshotDataRoot xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<SuspendDataRoot xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<SwapFileDataRoot xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" />
<VirtualSystemIdentifier
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">adriantest1</VirtualSystemIdentifier>
<VirtualSystemType
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData">vmx-07</VirtualSystemType>
</q2:System>
<q2:Item>
<Address xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AddressOnParent xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AllocationUnits
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">hertz * 10^6</AllocationUnits>
<AutomaticAllocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AutomaticDeallocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Caption xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ConsumerVisibility xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Description
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">Number of Virtual CPUs</Description>
<ElementName
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1 virtual CPU(s)</ElementName>
<InstanceID
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID>
<Limit xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<MappingBehavior xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<OtherResourceType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Parent xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<PoolID xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Reservation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceSubType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceType
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType>
<VirtualQuantity
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</VirtualQuantity>
<VirtualQuantityUnits
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">count</VirtualQuantityUnits>
<Weight xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
</q2:Item>
<q2:Item>
<Address xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AddressOnParent xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AllocationUnits
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">byte * 2^20</AllocationUnits>
<AutomaticAllocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AutomaticDeallocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Caption xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ConsumerVisibility xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Description
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">Memory Size</Description>
<ElementName
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512MB of memory</ElementName>
<InstanceID
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID>
<Limit xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<MappingBehavior xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<OtherResourceType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Parent xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<PoolID xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Reservation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceSubType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceType
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType>
<VirtualQuantity
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512</VirtualQuantity>
<VirtualQuantityUnits
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">byte * 2^20</VirtualQuantityUnits>
<Weight xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
</q2:Item>
<q2:Item>
<Address
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</Address>
<AddressOnParent xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AllocationUnits xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AutomaticAllocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AutomaticDeallocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Caption xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ConsumerVisibility xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Description
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">SCSI Controller</Description>
<ElementName
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">SCSI Controller 0</ElementName>
<InstanceID
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</InstanceID>
<Limit xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<MappingBehavior xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<OtherResourceType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Parent xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<PoolID xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Reservation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceSubType
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">lsilogic</ResourceSubType>
<ResourceType
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">6</ResourceType>
<VirtualQuantity xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<VirtualQuantityUnits xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Weight xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
</q2:Item>
<q2:Item>
<Address xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AddressOnParent
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</AddressOnParent>
<AllocationUnits xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AutomaticAllocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<AutomaticDeallocation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Caption xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ConsumerVisibility xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Description xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ElementName
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">Hard Disk 1</ElementName>
<HostResource
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4194304</HostResource>
<InstanceID
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID>
<Limit xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<MappingBehavior xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<OtherResourceType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Parent
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</Parent>
<PoolID xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Reservation xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceSubType xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<ResourceType
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType>
<VirtualQuantity
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4194304</VirtualQuantity>
<VirtualQuantityUnits xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
<Weight xsi:nil="true"
xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" />
</q2:Item>
</Section>
</VApp>