Issue 327: completed conversion of vapp to use URIs for IDs consistently

This commit is contained in:
Adrian Cole 2010-08-15 00:55:58 -07:00
parent 828fa38568
commit 09e155bf0d
153 changed files with 2018 additions and 2755 deletions

View File

@ -385,6 +385,7 @@ See http://code.google.com/p/jclouds for details."
(f builder value)
(println "Unknown option" option))))
;; TODO look at clojure-datalog
(defn build-template
"Creates a template that can be used to run nodes.

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.bluelock.compute;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
@ -44,7 +45,7 @@ public class BlueLockVCloudComputeClient extends BaseVCloudComputeClient {
@Inject
protected BlueLockVCloudComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
VCloudClient client, Predicate<String> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
VCloudClient client, Predicate<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState);
this.credentialsProvider = credentialsProvider;
}

View File

@ -78,8 +78,9 @@ public class ParseVAppTemplatesInVDCToSizeProvider implements Provider<Set<? ext
public Set<? extends Size> get() {
final Set<Size> sizes = Sets.newHashSet();
logger.debug(">> providing vAppTemplates");
for (final NamedResource vDC : client.getDefaultOrganization().getVDCs().values()) {
VDC vdc = client.getVDC(vDC.getLocation());
// TODO all orgs!
for (final NamedResource vDC : client.findOrganizationNamed(null).getVDCs().values()) {
VDC vdc = client.getVDC(vDC.getId());
addSizesFromVAppTemplatesInVDC(vdc, sizes);
}
return sizes;
@ -98,9 +99,9 @@ public class ParseVAppTemplatesInVDCToSizeProvider implements Provider<Set<? ext
ram *= 1024;
int disk = Integer.parseInt(matcher.group(3));
String name = resource.getName().split(" ")[1];
String id = vdc.getId() + "/" + resource.getId();
sizes.add(new SizeImpl(resource.getId(), name, id, location, null, ImmutableMap.<String, String> of(),
cores, ram, disk, ImagePredicates.idEquals(id)));
String id = resource.getId().toASCIIString();
sizes.add(new SizeImpl(id, name, id, location, null, ImmutableMap.<String, String> of(), cores, ram,
disk, ImagePredicates.idEquals(id)));
} catch (NoSuchElementException e) {
logger.debug("<< didn't match at all(%s)", resource);
}

View File

@ -40,7 +40,8 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
/**
* Configures the VCloud authentication service connection, including logging and http transport.
* Configures the VCloud authentication service connection, including logging
* and http transport.
*
* @author Adrian Cole
*/
@ -49,33 +50,31 @@ import com.google.common.collect.Iterables;
public class BlueLockVCloudRestClientModule extends VCloudRestClientModule {
@Override
protected URI provideDefaultNetwork(VCloudClient client) throws InterruptedException,
ExecutionException, TimeoutException {
org.jclouds.vcloud.domain.VDC vDC = client.getDefaultVDC();
protected URI provideDefaultNetwork(VCloudClient client) throws InterruptedException, ExecutionException,
TimeoutException {
org.jclouds.vcloud.domain.VDC vDC = client.findVDCInOrgNamed(null, null);
Map<String, NamedResource> networks = vDC.getAvailableNetworks();
checkState(networks.size() > 0, "No networks present in vDC: " + vDC.getName());
return Iterables.getOnlyElement(
Iterables.filter(networks.values(), new Predicate<NamedResource>() {
return Iterables.getOnlyElement(Iterables.filter(networks.values(), new Predicate<NamedResource>() {
@Override
public boolean apply(NamedResource input) {
return input.getName().equals("Internal In and Out");
}
@Override
public boolean apply(NamedResource input) {
return input.getName().equals("Internal In and Out");
}
})).getLocation();
})).getId();
}
@Override
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) final String user) {
checkState(org.getCatalogs().size() > 0, "No catalogs present in org: " + org.getName());
return Iterables.getOnlyElement(
Iterables.filter(org.getCatalogs().values(), new Predicate<NamedResource>() {
return Iterables.getOnlyElement(Iterables.filter(org.getCatalogs().values(), new Predicate<NamedResource>() {
@Override
public boolean apply(NamedResource input) {
return input.getName().startsWith(user);
}
@Override
public boolean apply(NamedResource input) {
return input.getName().startsWith(user);
}
})).getLocation();
})).getId();
}
}

View File

@ -53,9 +53,9 @@ public class VCloudSessionRefreshLiveTest {
@Test
public void testSessionRefresh() throws Exception {
connection.getDefaultOrganization();
connection.findOrganizationNamed(null);
Thread.sleep(timeOut * 1000);
connection.getDefaultOrganization();
connection.findOrganizationNamed(null);
}
@BeforeGroups(groups = { "live" })
@ -66,8 +66,8 @@ public class VCloudSessionRefreshLiveTest {
Properties props = new Properties();
props.setProperty(PROPERTY_SESSION_INTERVAL, 40 + "");
context = new ComputeServiceContextFactory().createContext("bluelock", identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule()), props);
context = new ComputeServiceContextFactory().createContext("bluelock", identity, credential, ImmutableSet
.<Module> of(new Log4JLoggingModule()), props);
connection = VCloudClient.class.cast(context.getProviderSpecificContext().getApi());
}

View File

@ -26,8 +26,6 @@ import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.http.HttpResponseException;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -63,17 +61,4 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi
return template;
}
@Test
public void testErrorWhereAllNetworksReturn403() throws Exception {
VCloudClient bluelockClient = VCloudClient.class.cast(context.getProviderSpecificContext()
.getApi());
for (String i : new String[] { "1", "2", "3", "4" }) {
try {
bluelockClient.getNetwork(i);
} catch (HttpResponseException e) {
assertEquals(e.getResponse().getStatusCode(), 403);
}
}
}
}

View File

@ -27,7 +27,6 @@ import static org.easymock.classextension.EasyMock.verify;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.net.URI;
import java.util.Set;
import org.jclouds.compute.domain.Size;
@ -40,17 +39,14 @@ import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.jclouds.vcloud.xml.VDCHandler;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Provides;
/**
* Tests behavior of {@code ParseVAppTemplatesInVDCToSizeProvider}
@ -62,20 +58,7 @@ public class ParseVAppTemplatesInVDCToSizeProviderTest {
public void testParse() {
InputStream is = getClass().getResourceAsStream("/bluelock/vdc.xml");
Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@VCloudApi
URI provide() {
return URI.create("https://express3.bluelock.com/api/v0.8");
}
});
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
VDC vdc = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
@ -95,14 +78,14 @@ public class ParseVAppTemplatesInVDCToSizeProviderTest {
providerParser.addSizesFromVAppTemplatesInVDC(vdc, sizes);
assertEquals(sizes.size(), vdc.getResourceEntities().size());
assertEquals(Iterables.get(sizes, 0), new SizeImpl("396", "4CPUx2GBx20GB", "396", null, null, ImmutableMap
.<String, String> of(), 4.0, 2048, 20, ImagePredicates.idEquals("396")));
assertEquals(Iterables.get(sizes, 0), new SizeImpl("https://express3.bluelock.com/api/v0.8/vAppTemplate/396", "4CPUx2GBx20GB", "https://express3.bluelock.com/api/v0.8/vAppTemplate/396", null, null, ImmutableMap
.<String, String> of(), 4.0, 2048, 20, ImagePredicates.idEquals("https://express3.bluelock.com/api/v0.8/vAppTemplate/396")));
assertEquals(Iterables.get(sizes, 116), new SizeImpl("434", "1CPUx512MBx40GB", "434", null, null, ImmutableMap
.<String, String> of(), 1.0, 512, 40, ImagePredicates.idEquals("434")));
assertEquals(Iterables.get(sizes, 116), new SizeImpl("https://express3.bluelock.com/api/v0.8/vAppTemplate/434", "1CPUx512MBx40GB", "https://express3.bluelock.com/api/v0.8/vAppTemplate/434", null, null, ImmutableMap
.<String, String> of(), 1.0, 512, 40, ImagePredicates.idEquals("https://express3.bluelock.com/api/v0.8/vAppTemplate/434")));
assertEquals(Iterables.getLast(sizes), new SizeImpl("383", "1CPUx1GBx20GB", "383", null, null, ImmutableMap
.<String, String> of(), 1.0, 1024, 20, ImagePredicates.idEquals("396")));
assertEquals(Iterables.getLast(sizes), new SizeImpl("https://express3.bluelock.com/api/v0.8/vAppTemplate/383", "1CPUx1GBx20GB", "https://express3.bluelock.com/api/v0.8/vAppTemplate/383", null, null, ImmutableMap
.<String, String> of(), 1.0, 1024, 20, ImagePredicates.idEquals("https://express3.bluelock.com/api/v0.8/vAppTemplate/383")));
verify(client);
verify(findLocationForResourceInVDC);

View File

@ -37,7 +37,6 @@ import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.predicates.validators.DnsNameValidator;
@ -70,6 +69,7 @@ import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.xml.CatalogHandler;
@ -136,14 +136,11 @@ public interface VCloudAsyncClient {
/**
* @see VCloudClient#getCatalog
*/
@Deprecated
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/catalog/{catalogId}")
@XMLResponseParser(CatalogHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<? extends Catalog> getCatalog(@PathParam("catalogId") String catalogId);
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
/**
* @see VCloudClient#findCatalogInOrgNamed
@ -175,7 +172,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends VAppTemplate> findVAppTemplateInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
/**
* @see VCloudClient#getCatalogItem
@ -196,18 +193,28 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
/**
* @see VCloudClient#findNetworkInOrgVDCNamed
*/
@GET
@Consumes(NETWORK_XML)
@XMLResponseParser(NetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Network> findNetworkInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
/**
* @see VCloudClient#getNetwork
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/network/{networkId}")
@Consumes(NETWORK_XML)
@XMLResponseParser(NetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Network> getNetwork(@PathParam("networkId") String networkId);
ListenableFuture<? extends Network> getNetwork(@EndpointParam URI network);
/**
* @see VCloudClient#getDefaultVDC
@ -242,14 +249,11 @@ public interface VCloudAsyncClient {
/**
* @see VCloudClient#getTasksList
*/
@Deprecated
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/tasksList/{tasksListId}")
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends TasksList> getTasksList(@PathParam("tasksListId") String tasksListId);
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
/**
* @see VCloudClient#getTasksListInOrg
@ -277,107 +281,105 @@ public interface VCloudAsyncClient {
*/
@POST
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/action/deploy")
@Path("/action/deploy")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#deleteVApp
*/
@DELETE
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
@Path("/vApp/{vAppId}")
ListenableFuture<Void> deleteVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<Void> deleteVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#undeployVApp
*/
@POST
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/action/undeploy")
@Path("/action/undeploy")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#powerOnVApp
*/
@POST
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/power/action/powerOn")
@Path("/power/action/powerOn")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOnVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#powerOffVApp
*/
@POST
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/power/action/powerOff")
@Path("/power/action/powerOff")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOffVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#shutdownVApp
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/power/action/shutdown")
ListenableFuture<Void> shutdownVApp(@PathParam("vAppId") String vAppId);
@Path("/power/action/shutdown")
ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#resetVApp
*/
@POST
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/power/action/reset")
@Path("/power/action/reset")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> resetVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#suspendVApp
*/
@POST
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}/power/action/suspend")
@Path("/power/action/suspend")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> suspendVApp(@PathParam("vAppId") String vAppId);
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#getTask
*/
@GET
@Consumes(TASK_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/task/{taskId}")
@XMLResponseParser(TaskHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Task> getTask(@PathParam("taskId") String taskId);
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
/**
* @see VCloudClient#cancelTask
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/task/{taskId}/action/cancel")
ListenableFuture<Void> cancelTask(@PathParam("taskId") String taskId);
@Path("/action/cancel")
ListenableFuture<Void> cancelTask(@EndpointParam URI taskId);
/**
* @see VCloudClient#findVAppInOrgVDCNamed
*/
@GET
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VApp> findVAppInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
/**
* @see VCloudClient#getVApp
*/
@GET
@Consumes(VAPP_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vApp/{vAppId}")
@XMLResponseParser(VAppHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VApp> getVApp(@PathParam("vAppId") String appId);
ListenableFuture<? extends VApp> getVApp(@EndpointParam URI vApp);
/**
* @see VCloudClient#instantiateVAppTemplateInVDC

View File

@ -20,8 +20,11 @@
package org.jclouds.vcloud;
import java.net.URI;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
@ -60,8 +63,10 @@ public interface VCloudClient {
*
* @param name
* organization name, or null for the default
* @throws NoSuchElementException
* if you specified an org name that isn't present
*/
Organization findOrganizationNamed(String name);
Organization findOrganizationNamed(@Nullable String name);
/**
* Please use #findCatalogInOrgNamed(null, null)
@ -69,26 +74,79 @@ public interface VCloudClient {
@Deprecated
Catalog getDefaultCatalog();
/**
* Please use #findCatalogInOrgNamed
*/
@Deprecated
Catalog getCatalog(String catalogId);
Catalog getCatalog(URI catalogId);
Catalog findCatalogInOrgNamed(String orgName, String catalogName);
/**
* returns the catalog in the organization associated with the specified
* name. Note that both parameters can be null to choose default.
*
* @param orgName
* organization name, or null for the default
* @param catalogName
* catalog name, or null for the default
* @throws NoSuchElementException
* if you specified an org or catalog name that isn't present
*/
Catalog findCatalogInOrgNamed(@Nullable String orgName, @Nullable String catalogName);
CatalogItem getCatalogItem(URI catalogItem);
CatalogItem findCatalogItemInOrgCatalogNamed(String orgName, String catalogName, String itemName);
/**
* returns the catalog item in the catalog associated with the specified
* name. Note that the org and catalog parameters can be null to choose
* default.
*
* @param orgName
* organization name, or null for the default
* @param catalogName
* catalog name, or null for the default
* @param itemName
* item you wish to lookup
*
* @throws NoSuchElementException
* if you specified an org, catalog, or catalog item name that
* isn't present
*/
CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, String itemName);
VAppTemplate getVAppTemplate(URI vAppTemplate);
VAppTemplate findVAppTemplateInOrgCatalogNamed(String orgName, String catalogName, String templateName);
/**
* returns the vapp template corresponding to a catalog item in the catalog
* associated with the specified name. Note that the org and catalog
* parameters can be null to choose default.
*
* @param orgName
* organization name, or null for the default
* @param catalogName
* catalog name, or null for the default
* @param itemName
* item you wish to lookup
*
* @throws NoSuchElementException
* if you specified an org, catalog, or catalog item name that
* isn't present
*/
VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName,
String itemName);
Network getNetwork(String networkId);
Network findNetworkInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String networkName);
Network getNetwork(URI network);
VDC getVDC(URI vdc);
/**
* returns the VDC in the organization associated with the specified name.
* Note that both parameters can be null to choose default.
*
* @param orgName
* organization name, or null for the default
* @param vdcName
* catalog name, or null for the default
* @throws NoSuchElementException
* if you specified an org or vdc name that isn't present
*/
VDC findVDCInOrgNamed(String orgName, String vdcName);
/**
@ -97,11 +155,7 @@ public interface VCloudClient {
@Deprecated
VDC getDefaultVDC();
/**
* Please use #findTasksListInOrgNamed
*/
@Deprecated
TasksList getTasksList(String tasksListId);
TasksList getTasksList(URI tasksListId);
TasksList findTasksListInOrgNamed(String orgName, String tasksListName);
@ -111,44 +165,46 @@ public interface VCloudClient {
@Deprecated
TasksList getDefaultTasksList();
Task deployVApp(String vAppId);
Task deployVApp(URI vAppId);
void deleteVApp(String vAppId);
void deleteVApp(URI vAppId);
Task undeployVApp(String vAppId);
Task undeployVApp(URI vAppId);
/**
* This call powers on the vApp, as specified in the vApp's ovf:Startup
* element.
*/
Task powerOnVApp(String vAppId);
Task powerOnVApp(URI vAppId);
/**
* This call powers off the vApp, as specified in the vApp's ovf:Startup
* element.
*/
Task powerOffVApp(String vAppId);
Task powerOffVApp(URI vAppId);
/**
* This call shuts down the vApp.
*/
void shutdownVApp(String vAppId);
void shutdownVApp(URI vAppId);
/**
* This call resets the vApp.
*/
Task resetVApp(String vAppId);
Task resetVApp(URI vAppId);
/**
* This call suspends the vApp.
*/
Task suspendVApp(String vAppId);
Task suspendVApp(URI vAppId);
Task getTask(String taskId);
Task getTask(URI taskId);
void cancelTask(String taskId);
void cancelTask(URI taskId);
VApp getVApp(String appId);
VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName);
VApp getVApp(URI vApp);
VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options);

View File

@ -58,11 +58,11 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
protected Logger logger = Logger.NULL;
protected final VCloudClient client;
protected final Predicate<String> taskTester;
protected final Predicate<URI> taskTester;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
@Inject
public BaseVCloudComputeClient(VCloudClient client, Predicate<String> successTester,
public BaseVCloudComputeClient(VCloudClient client, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
this.client = client;
this.taskTester = successTester;
@ -78,24 +78,24 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
VDC vdc = client.getVDC(VDC);
VAppTemplate template = client.getVAppTemplate(templateId);
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vdc.getLocation(), template.getLocation(), name, options);
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vdc.getId(), template.getId(), name, options);
logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
logger.debug(">> deploying vApp(%s)", vAppResponse.getName());
Task task = client.deployVApp(vAppResponse.getId());
if (options.shouldBlockOnDeploy()) {
if (!taskTester.apply(task.getId())) {
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("deploy", vAppResponse, task);
}
logger.debug("<< deployed vApp(%s)", vAppResponse.getId());
logger.debug("<< deployed vApp(%s)", vAppResponse.getName());
logger.debug(">> powering vApp(%s)", vAppResponse.getId());
logger.debug(">> powering vApp(%s)", vAppResponse.getName());
task = client.powerOnVApp(vAppResponse.getId());
if (!taskTester.apply(task.getId())) {
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("powerOn", vAppResponse, task);
}
logger.debug("<< on vApp(%s)", vAppResponse.getId());
logger.debug("<< on vApp(%s)", vAppResponse.getName());
}
return parseAndValidateResponse(template, vAppResponse);
}
@ -110,57 +110,59 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
protected Map<String, String> parseResponse(VAppTemplate template, VApp vAppResponse) {
Map<String, String> config = Maps.newLinkedHashMap();// Allows nulls
config.put("id", vAppResponse.getId());
config.put("id", vAppResponse.getId().toASCIIString());
config.put("username", null);
config.put("password", null);
return config;
}
public void reboot(String id) {
@Override
public void reboot(URI id) {
VApp vApp = client.getVApp(id);
logger.debug(">> resetting vApp(%s)", vApp.getId());
logger.debug(">> resetting vApp(%s)", vApp.getName());
Task task = client.resetVApp(vApp.getId());
if (!taskTester.apply(task.getId())) {
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("resetVApp", vApp, task);
}
logger.debug("<< on vApp(%s)", vApp.getId());
logger.debug("<< on vApp(%s)", vApp.getName());
}
public void stop(String id) {
@Override
public void stop(URI id) {
VApp vApp = client.getVApp(id);
vApp = powerOffVAppIfDeployed(vApp);
vApp = undeployVAppIfDeployed(vApp);
deleteVApp(vApp);
logger.debug("<< deleted vApp(%s)", vApp.getId());
logger.debug("<< deleted vApp(%s)", vApp.getName());
}
private void deleteVApp(VApp vApp) {
logger.debug(">> deleting vApp(%s)", vApp.getId());
logger.debug(">> deleting vApp(%s)", vApp.getName());
client.deleteVApp(vApp.getId());
}
private VApp undeployVAppIfDeployed(VApp vApp) {
if (vApp.getStatus().compareTo(VAppStatus.RESOLVED) > 0) {
logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getId(), vApp.getStatus());
logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
Task task = client.undeployVApp(vApp.getId());
if (!taskTester.apply(task.getId())) {
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("undeploy", vApp, task);
}
vApp = client.getVApp(vApp.getId());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getId());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
}
return vApp;
}
private VApp powerOffVAppIfDeployed(VApp vApp) {
if (vApp.getStatus().compareTo(VAppStatus.OFF) > 0) {
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getId(), vApp.getStatus());
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
Task task = client.powerOffVApp(vApp.getId());
if (!taskTester.apply(task.getId())) {
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("powerOff", vApp, task);
}
vApp = client.getVApp(vApp.getId());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getId());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
}
return vApp;
}
@ -172,8 +174,8 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
private static final long serialVersionUID = 251801929573211256L;
public TaskException(String type, VApp vApp, Task task) {
super(String.format("failed to %s vApp %s status %s;task %s status %s", type, vApp.getId(), vApp.getStatus(),
task.getLocation(), task.getStatus()), vApp);
super(String.format("failed to %s vApp %s status %s;task %s status %s", type, vApp.getName(),
vApp.getStatus(), task.getLocation(), task.getStatus()), vApp);
this.task = task;
}
@ -201,12 +203,12 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
}
@Override
public Set<String> getPrivateAddresses(String id) {
public Set<String> getPrivateAddresses(URI id) {
return ImmutableSet.of();
}
@Override
public Set<String> getPublicAddresses(String id) {
public Set<String> getPublicAddresses(URI id) {
VApp vApp = client.getVApp(id);
return Sets.newHashSet(vApp.getNetworkToAddresses().values());
}

View File

@ -43,16 +43,12 @@ public interface VCloudComputeClient {
* <p/>
* This command blocks until the vApp is in state {@code VAppStatus#ON}
*
* @param orgName
* name of the organization
*
* @param vDCName
* name of the virtual datacenter {@code
* VCloudClient#getDefaultVDC}
* @param name
* name of the vApp
* @param VDC
* id of the virtual datacenter {@code VCloudClient#getDefaultVDC}
* @param templateId
* id of the vAppTemplate you wish to instantiate
* @param name
* name of the vApp
* @param cores
* amount of virtual cpu cores
* @param megs
@ -73,12 +69,12 @@ public interface VCloudComputeClient {
/**
* returns a set of addresses that are only visible to the private network.
*/
Set<String> getPrivateAddresses(String vAppId);
Set<String> getPrivateAddresses(URI vAppId);
/**
* returns a set of addresses that are publically visible
*/
Set<String> getPublicAddresses(String vAppId);
Set<String> getPublicAddresses(URI vAppId);
/**
* reboots the vApp, blocking until the following state transition is
@ -89,7 +85,7 @@ public interface VCloudComputeClient {
* @param vAppId
* vApp to reboot
*/
void reboot(String vAppId);
void reboot(URI vAppId);
/**
* Destroys dependent resources, powers off and deletes the vApp, blocking
@ -100,6 +96,6 @@ public interface VCloudComputeClient {
* @param vAppId
* vApp to stop
*/
void stop(String vAppId);
void stop(URI vAppId);
}

View File

@ -164,7 +164,7 @@ public class VCloudComputeServiceContextModule extends AbstractModule {
@Override
public boolean apply(Location input) {
return VCloudLocation.class.cast(input).getResource().getLocation().equals(vdc.getLocation());
return VCloudLocation.class.cast(input).getResource().getId().equals(vdc.getId());
}
});

View File

@ -38,7 +38,7 @@ public class VCloudLocation extends LocationImpl {
public VCloudLocation(NamedResource resource, Location parent) {
super(checkNotNull(resource, "resource").getType().endsWith("org+xml") ? LocationScope.REGION
: LocationScope.ZONE, resource.getLocation().toASCIIString(), resource.getName(), parent);
: LocationScope.ZONE, resource.getId().toASCIIString(), resource.getName(), parent);
this.resource = resource;
}

View File

@ -61,7 +61,7 @@ public class FindLocationForResource {
do {
// The "name" isn't always present, ex inside a vApp we have a rel
// link that only includes href and type.
if (VCloudLocation.class.cast(input).getResource().getLocation().equals(resource.getLocation()))
if (VCloudLocation.class.cast(input).getResource().getId().equals(resource.getId()))
return input;
input = input.getParent();
} while (input.getParent() != null);

View File

@ -19,6 +19,11 @@
package org.jclouds.vcloud.compute.functions;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Maps.newHashMap;
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
import java.util.Map;
import java.util.Map.Entry;
@ -32,12 +37,10 @@ import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
/**
* Configures the {@link VCloudComputeServiceContext}; requires {@link BaseVCloudComputeClient}
* bound.
* Configures the {@link VCloudComputeServiceContext}; requires
* {@link BaseVCloudComputeClient} bound.
*
* @author Adrian Cole
*/
@ -48,19 +51,16 @@ public class GetExtra implements Function<VApp, Map<String, String>> {
protected Logger logger = Logger.NULL;
public Map<String, String> apply(VApp vApp) {
Map<String, String> extra = Maps.newHashMap();
Map<String, String> extra = newHashMap();
try {
extra.put("memory/mb", Iterables.getOnlyElement(
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity()
+ "");
extra.put("processor/count", Iterables.getOnlyElement(
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
.getVirtualQuantity()
+ "");
for (ResourceAllocation disk : vApp.getResourceAllocationByType().get(
ResourceType.PROCESSOR)) {
extra.put(String.format("disk_drive/%s/kb", disk.getId()), disk.getVirtualQuantity()
+ "");
extra.put("memory/mb", find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY))
.getVirtualQuantity()
+ "");
extra.put("processor/count", find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR))
.getVirtualQuantity()
+ "");
for (ResourceAllocation disk : filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))) {
extra.put(String.format("disk_drive/%s/kb", disk.getId()), disk.getVirtualQuantity() + "");
}
for (Entry<String, String> net : vApp.getNetworkToAddresses().entries()) {

View File

@ -63,8 +63,8 @@ public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
Location location = findLocationForResource.apply(parent);
String name = getName(from.getName());
String desc = from.getDescription() != null ? from.getDescription() : from.getName();
return new ImageImpl(from.getLocation().toASCIIString(), name, from.getLocation().toASCIIString(), location, from
.getLocation(), ImmutableMap.<String, String> of(), desc, "", myOs, name, arch, credentialsProvider
return new ImageImpl(from.getId().toASCIIString(), name, from.getId().toASCIIString(), location, from
.getId(), ImmutableMap.<String, String> of(), desc, "", myOs, name, arch, credentialsProvider
.execute(from));
}

View File

@ -19,15 +19,19 @@
package org.jclouds.vcloud.compute.functions;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Iterables.transform;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Image;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.functions.AllVDCsInOrganization;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.base.Supplier;
/**
* @author Adrian Cole
@ -35,18 +39,21 @@ import com.google.common.collect.Iterables;
@Singleton
public class ImagesInOrganization implements Function<Organization, Iterable<? extends Image>> {
private final AllVDCsInOrganization allVDCsInOrganization;
private final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> allVDCsInOrganization;
private final ImagesInVDC imagesInVDC;
@Inject
public ImagesInOrganization(AllVDCsInOrganization allVDCsInOrganization, ImagesInVDC imagesInVDC) {
public ImagesInOrganization(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> allVDCsInOrganization,
ImagesInVDC imagesInVDC) {
this.allVDCsInOrganization = allVDCsInOrganization;
this.imagesInVDC = imagesInVDC;
}
@SuppressWarnings("unchecked")
@Override
public Iterable<? extends Image> apply(Organization from) {
return Iterables.concat(Iterables.transform(allVDCsInOrganization.apply(from), imagesInVDC));
return concat(transform(concat(allVDCsInOrganization.get().get(from).values()), imagesInVDC));
}
}

View File

@ -21,6 +21,7 @@ package org.jclouds.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
@ -80,7 +81,8 @@ public class VCloudGetNodeMetadata {
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
}
public NodeMetadata execute(String id) {
public NodeMetadata execute(String in) {
URI id = URI.create(in);
VApp vApp = client.getVApp(id);
if (vApp == null)
return null;
@ -94,8 +96,9 @@ public class VCloudGetNodeMetadata {
tag = "NOTAG-" + vApp.getName();
}
Location location = findLocationForResourceInVDC.apply(vApp.getVDC());
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(), location, vApp.getLocation(),
ImmutableMap.<String, String> of(), tag, image, vAppStatusToNodeState.get(vApp.getStatus()), computeClient
.getPublicAddresses(id), computeClient.getPrivateAddresses(id), getExtra.apply(vApp), null);
return new NodeMetadataImpl(vApp.getId().toASCIIString(), vApp.getName(), vApp.getId()
.toASCIIString(), location, vApp.getId(), ImmutableMap.<String, String> of(), tag, image,
vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(id), computeClient
.getPrivateAddresses(id), getExtra.apply(vApp), null);
}
}

View File

@ -66,16 +66,16 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
options.blockOnDeploy(false);
Map<String, String> metaMap = computeClient.start(URI.create(template.getLocation().getDescription()), URI
.create(template.getImage().getId()), name, options, template.getOptions().getInboundPorts());
VApp vApp = client.getVApp(metaMap.get("id"));
VApp vApp = client.getVApp(URI.create(metaMap.get("id")));
return newCreateNodeResponse(tag, template, metaMap, vApp);
}
protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map<String, String> metaMap, VApp vApp) {
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(), template.getLocation(), vApp
.getLocation(), ImmutableMap.<String, String> of(), tag, template.getImage(), vAppStatusToNodeState
.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getId()), computeClient
.getPrivateAddresses(vApp.getId()), ImmutableMap.<String, String> of(), new Credentials(metaMap
.get("username"), metaMap.get("password")));
return new NodeMetadataImpl(vApp.getId().toASCIIString(), vApp.getName(), vApp.getId()
.toASCIIString(), template.getLocation(), vApp.getId(), ImmutableMap.<String, String> of(), tag,
template.getImage(), vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp
.getId()), computeClient.getPrivateAddresses(vApp.getId()), ImmutableMap
.<String, String> of(), new Credentials(metaMap.get("username"), metaMap.get("password")));
}
}

View File

@ -21,6 +21,8 @@ package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -35,11 +37,10 @@ import org.jclouds.vcloud.compute.VCloudComputeClient;
@Singleton
public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy {
protected final VCloudComputeClient computeClient;
protected final GetNodeMetadataStrategy getNode;
protected final GetNodeMetadataStrategy getNode;
@Inject
protected VCloudDestroyNodeStrategy(VCloudComputeClient computeClient,
GetNodeMetadataStrategy getNode) {
protected VCloudDestroyNodeStrategy(VCloudComputeClient computeClient, GetNodeMetadataStrategy getNode) {
this.computeClient = computeClient;
this.getNode = getNode;
@ -47,7 +48,7 @@ public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy {
@Override
public NodeMetadata execute(String id) {
computeClient.stop(checkNotNull(id, "node.id"));
computeClient.stop(URI.create(checkNotNull(id, "node.id")));
return getNode.execute(id);
}

View File

@ -87,7 +87,7 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
Set<ComputeMetadata> nodes = Sets.newHashSet();
for (String org : orgNameToEndpoint.get().keySet()) {
for (NamedResource vdc : client.findOrganizationNamed(org).getVDCs().values()) {
for (NamedResource resource : client.getVDC(vdc.getLocation()).getResourceEntities().values()) {
for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) {
if (validVApp(resource)) {
nodes.add(convertVAppToComputeMetadata(vdc, resource));
}
@ -103,8 +103,8 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc, NamedResource resource) {
Location location = findLocationForResourceInVDC.apply(vdc);
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId(), resource.getName(), resource.getId(),
location, null, ImmutableMap.<String, String> of());
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId().toASCIIString(), resource.getName(),
resource.getId().toASCIIString(), location, null, ImmutableMap.<String, String> of());
}
@Override
@ -112,7 +112,7 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
Set<NodeMetadata> nodes = Sets.newHashSet();
for (String org : orgNameToEndpoint.get().keySet()) {
for (NamedResource vdc : client.findOrganizationNamed(org).getVDCs().values()) {
for (NamedResource resource : client.getVDC(vdc.getLocation()).getResourceEntities().values()) {
for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) {
if (validVApp(resource) && filter.apply(convertVAppToComputeMetadata(vdc, resource))) {
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
}
@ -128,10 +128,10 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
int i = 0;
while (node == null && i++ < 3) {
try {
node = getNodeMetadata.execute(resource.getId());
node = getNodeMetadata.execute(resource.getId().toASCIIString());
nodes.add(node);
} catch (NullPointerException e) {
logger.warn("vApp %s not yet present in vdc %s", resource.getId(), vdc.getId());
logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName());
}
}
}

View File

@ -21,6 +21,8 @@ package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -38,22 +40,21 @@ import com.google.common.base.Predicate;
@Singleton
public class VCloudRebootNodeStrategy implements RebootNodeStrategy {
private final VCloudClient client;
protected final Predicate<String> taskTester;
protected final Predicate<URI> taskTester;
protected final GetNodeMetadataStrategy getNode;
@Inject
protected VCloudRebootNodeStrategy(VCloudClient client,
Predicate<String> taskTester, GetNodeMetadataStrategy getNode) {
protected VCloudRebootNodeStrategy(VCloudClient client, Predicate<URI> taskTester, GetNodeMetadataStrategy getNode) {
this.client = client;
this.taskTester = taskTester;
this.getNode = getNode;
}
@Override
public NodeMetadata execute(String id) {
Task task = client.resetVApp(checkNotNull(id, "node.id"));
taskTester.apply(task.getId());
return getNode.execute(id);
public NodeMetadata execute(String in) {
URI id = URI.create(checkNotNull(in, "node.id"));
Task task = client.resetVApp(id);
taskTester.apply(task.getLocation());
return getNode.execute(in);
}
}

View File

@ -22,8 +22,10 @@ package org.jclouds.vcloud.config;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Iterables.get;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Maps.newLinkedHashMap;
import static com.google.common.collect.Maps.transformValues;
import static com.google.common.collect.Maps.uniqueIndex;
@ -69,14 +71,10 @@ import org.jclouds.vcloud.endpoints.Catalog;
import org.jclouds.vcloud.endpoints.Network;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.endpoints.TasksList;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.jclouds.vcloud.endpoints.VCloudLogin;
import org.jclouds.vcloud.endpoints.VDC;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
import org.jclouds.vcloud.endpoints.internal.VAppTemplateRoot;
import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog;
import org.jclouds.vcloud.functions.AllCatalogsInOrganization;
import org.jclouds.vcloud.functions.AllVDCsInOrganization;
import org.jclouds.vcloud.functions.OrganizationsForNames;
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
@ -111,6 +109,9 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
bind(new TypeLiteral<Supplier<Map<String, NamedResource>>>() {
}).annotatedWith(Org.class).to(new TypeLiteral<OrgNameToOrgSupplier>() {
});
bind(new TypeLiteral<Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>>() {
}).to(new TypeLiteral<URItoVDC>() {
});
super.configure();
}
@ -119,9 +120,9 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
@Provides
@Singleton
protected Predicate<String> successTester(TaskSuccess success,
protected Predicate<URI> successTester(TaskSuccess success,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
return new RetryablePredicate<String>(success, completed);
return new RetryablePredicate<URI>(success, completed);
}
@VCloudToken
@ -134,7 +135,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
@Org
@Singleton
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
return getLast(orgs).getLocation();
return getLast(orgs).getId();
}
@Provides
@ -165,6 +166,40 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
}
@Singleton
public static class URItoVDC implements Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> {
private final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
@Inject
URItoVDC(Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap) {
this.orgVDCMap = orgVDCMap;
}
@Override
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
return uniqueIndex(
concat(transform(
orgVDCMap.get().values(),
new Function<Map<String, ? extends org.jclouds.vcloud.domain.VDC>, Iterable<? extends org.jclouds.vcloud.domain.VDC>>() {
@Override
public Iterable<? extends org.jclouds.vcloud.domain.VDC> apply(
Map<String, ? extends org.jclouds.vcloud.domain.VDC> from) {
return from.values();
}
})), new Function<org.jclouds.vcloud.domain.VDC, URI>() {
@Override
public URI apply(org.jclouds.vcloud.domain.VDC from) {
return from.getId();
}
});
}
}
@Provides
@Org
@Singleton
@ -174,13 +209,6 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
return discovery.getOrgs().values();
}
@Provides
@VCloudApi
@Singleton
URI provideVCloudApi(@VCloudLogin URI vcloudUri) {
return URI.create(vcloudUri.toASCIIString().replace("/login", ""));
}
protected AtomicReference<AuthorizationException> authException = new AtomicReference<AuthorizationException>();
@Provides
@ -289,6 +317,49 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
});
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationVDCSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>(
authException, seconds, new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return supplier.get();
}
});
}
@Singleton
public static class OrganizationVDCSupplier implements
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> {
protected final Supplier<Map<String, ? extends Organization>> orgSupplier;
private final AllVDCsInOrganization allVDCsInOrganization;
@Inject
protected OrganizationVDCSupplier(Supplier<Map<String, ? extends Organization>> orgSupplier,
AllVDCsInOrganization allVDCsInOrganization) {
this.orgSupplier = orgSupplier;
this.allVDCsInOrganization = allVDCsInOrganization;
}
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return transformValues(
transformValues(orgSupplier.get(), allVDCsInOrganization),
new Function<Iterable<? extends org.jclouds.vcloud.domain.VDC>, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>() {
@Override
public Map<String, ? extends org.jclouds.vcloud.domain.VDC> apply(
Iterable<? extends org.jclouds.vcloud.domain.VDC> from) {
return uniqueIndex(from, name);
}
});
}
}
@Singleton
public static class OrganizationCatalogItemSupplier implements
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> {
@ -381,27 +452,6 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
return factory.create(VCloudVersionsAsyncClient.class);
}
@Provides
@CatalogItemRoot
@Singleton
String provideCatalogItemRoot(@VCloudLogin URI vcloudUri) {
return vcloudUri.toASCIIString().replace("/login", "/catalogItem");
}
@Provides
@VAppRoot
@Singleton
String provideVAppRoot(@VCloudLogin URI vcloudUri) {
return vcloudUri.toASCIIString().replace("/login", "/vapp");
}
@Provides
@VAppTemplateRoot
@Singleton
String provideVAppTemplateRoot(@VCloudLogin URI vcloudUri) {
return vcloudUri.toASCIIString().replace("/login", "/vAppTemplate");
}
@Provides
@Singleton
protected Organization provideOrganization(VCloudClient discovery) throws ExecutionException, TimeoutException,
@ -409,7 +459,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
if (authException.get() != null)
throw authException.get();
try {
return discovery.getDefaultOrganization();
return discovery.findOrganizationNamed(null);
} catch (AuthorizationException e) {
authException.set(e);
throw e;
@ -421,7 +471,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
@Singleton
protected URI provideDefaultVDC(Organization org) {
checkState(org.getVDCs().size() > 0, "No vdcs present in org: " + org.getName());
return get(org.getVDCs().values(), 0).getLocation();
return get(org.getVDCs().values(), 0).getId();
}
@Provides
@ -429,7 +479,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
@Singleton
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
checkState(org.getCatalogs().size() > 0, "No catalogs present in org: " + org.getName());
return get(org.getCatalogs().values(), 0).getLocation();
return get(org.getCatalogs().values(), 0).getId();
}
@Provides
@ -448,10 +498,10 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
if (authException.get() != null)
throw authException.get();
try {
org.jclouds.vcloud.domain.VDC vDC = client.getDefaultVDC();
org.jclouds.vcloud.domain.VDC vDC = client.findVDCInOrgNamed(null, null);
Map<String, NamedResource> networks = vDC.getAvailableNetworks();
checkState(networks.size() > 0, "No networks present in vDC: " + vDC.getName());
return get(networks.values(), 0).getLocation();
return get(networks.values(), 0).getId();
} catch (AuthorizationException e) {
authException.set(e);
throw e;
@ -477,6 +527,6 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
@Singleton
protected URI provideDefaultTasksList(Organization org) {
checkState(org.getTasksLists().size() > 0, "No tasks lists present in org: " + org.getName());
return get(org.getTasksLists().values(), 0).getLocation();
return get(org.getTasksLists().values(), 0).getId();
}
}

View File

@ -33,17 +33,10 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(NamedResourceImpl.class)
public interface NamedResource extends Comparable<NamedResource> {
/**
* name is not a safe means to identify a resource. Please use name or
* location
*/
@Deprecated
String getId();
URI getId();
String getName();
String getType();
URI getLocation();
}

View File

@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy;
*/
@ImplementedBy(TaskImpl.class)
public interface Task extends Comparable<Task> {
String getId();
URI getLocation();
@ -40,8 +39,9 @@ public interface Task extends Comparable<Task> {
Date getStartTime();
Date getEndTime();
Date getExpiryTime();
/**
* A link to the vDC in which the task was started
*/
@ -51,13 +51,15 @@ public interface Task extends Comparable<Task> {
* A link to the result of the task
*/
NamedResource getResult();
Error getError();
@ImplementedBy(TaskImpl.ErrorImpl.class)
static interface Error {
String getMessage();
String getMajorErrorCode();
String getMinorErrorCode();
String getMessage();
String getMajorErrorCode();
String getMinorErrorCode();
}
}

View File

@ -24,7 +24,6 @@ import java.util.SortedSet;
import org.jclouds.vcloud.domain.internal.TasksListImpl;
import com.google.common.collect.ListMultimap;
import com.google.inject.ImplementedBy;
/**
@ -33,14 +32,9 @@ import com.google.inject.ImplementedBy;
@org.jclouds.vcloud.endpoints.TasksList
@ImplementedBy(TasksListImpl.class)
public interface TasksList {
String getId();
URI getLocation();
SortedSet<Task> getTasks();
ListMultimap<URI, Task> getTasksByResult();
ListMultimap<URI, Task> getTasksByOwner();
}

View File

@ -24,13 +24,13 @@ import java.util.Set;
import org.jclouds.vcloud.domain.internal.VAppImpl;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.ImplementedBy;
/**
* A virtual application (vApp) is a software solution, packaged in OVF containing one or more
* virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators
* in Enterprises and Service Providers.
* A virtual application (vApp) is a software solution, packaged in OVF
* containing one or more virtual machines. A vApp can be authored by Developers
* at ISVs and VARs or by IT Administrators in Enterprises and Service
* Providers.
*
* @author Adrian Cole
*/
@ -50,6 +50,4 @@ public interface VApp extends NamedResource {
Set<ResourceAllocation> getResourceAllocations();
Multimap<ResourceType, ResourceAllocation> getResourceAllocationByType();
}

View File

@ -41,28 +41,23 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
private final String id;
private final String name;
private final String description;
private final URI location;
private final URI id;
public CatalogImpl(String id, String name, URI location, @Nullable String description,
Map<String, NamedResource> contents) {
this.id = checkNotNull(id, "id");
public CatalogImpl(String name, URI id, @Nullable String description, Map<String, NamedResource> contents) {
this.name = checkNotNull(name, "name");
this.description = description;
this.location = checkNotNull(location, "location");
this.id = checkNotNull(id, "id");
putAll(checkNotNull(contents, "contents"));
}
public URI getLocation() {
return location;
}
public String getId() {
@Override
public URI getId() {
return id;
}
@Override
public String getName() {
return name;
}
@ -72,7 +67,7 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@ -91,10 +86,10 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
return false;
} else if (!description.equals(other.description))
return false;
if (location == null) {
if (other.location != null)
if (id == null) {
if (other.id != null)
return false;
} else if (!location.equals(other.location))
} else if (!id.equals(other.id))
return false;
if (name == null) {
if (other.name != null)

View File

@ -45,9 +45,9 @@ public class CatalogItemImpl extends NamedResourceImpl implements CatalogItem {
private final NamedResource entity;
private final Map<String, String> properties = Maps.newLinkedHashMap();
public CatalogItemImpl(String id, String name, URI location, @Nullable String description, NamedResource entity,
public CatalogItemImpl(String name, URI id, @Nullable String description, NamedResource entity,
Map<String, String> properties) {
super(id, name, VCloudMediaType.CATALOGITEM_XML, location);
super(name, VCloudMediaType.CATALOGITEM_XML, id);
this.description = description;
this.entity = checkNotNull(entity, "entity");
this.properties.putAll(checkNotNull(properties, "properties"));
@ -73,9 +73,8 @@ public class CatalogItemImpl extends NamedResourceImpl implements CatalogItem {
@Override
public String toString() {
return "CatalogItemImpl [id=" + getId() + ", name=" + getName() + ", location=" + getLocation() + ", type="
+ getType() + ", description=" + getDescription() + ", entity=" + entity + ", properties=" + properties
+ "]";
return "CatalogItemImpl [id=" + getId() + ", name=" + getName() + ", type=" + getType() + ", description="
+ getDescription() + ", entity=" + entity + ", properties=" + properties + "]";
}
@Override

View File

@ -30,36 +30,34 @@ import org.jclouds.vcloud.domain.NamedResource;
*
*/
public class NamedResourceImpl implements NamedResource {
private final String id;
private final String name;
private final String type;
private final URI location;
private final URI id;
public NamedResourceImpl(String id, String name, String type, URI location) {
this.id = id;
public NamedResourceImpl(String name, String type, URI id) {
this.name = name;
this.type = type;
this.location = location;
}
public String getId() {
return id;
this.id = id;
}
@Override
public String getName() {
return name;
}
@Override
public String getType() {
return type;
}
public URI getLocation() {
return location;
@Override
public URI getId() {
return id;
}
@Override
public int compareTo(NamedResource that) {
return (this == that) ? 0 : this.id.compareTo(that.getId());
return (this == that) ? 0 : getId().compareTo(that.getId());
}
@Override
@ -67,7 +65,6 @@ public class NamedResourceImpl implements NamedResource {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
@ -87,11 +84,6 @@ public class NamedResourceImpl implements NamedResource {
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (name == null) {
if (other.name != null)
return false;
@ -107,6 +99,6 @@ public class NamedResourceImpl implements NamedResource {
@Override
public String toString() {
return "[id=" + id + ", name=" + name + ", type=" + type + ", location=" + location + "]";
return "[id=" + id + ", name=" + name + ", type=" + type + "]";
}
}

View File

@ -51,11 +51,9 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
private final Set<NatRule> natRules = Sets.newHashSet();
private final Set<FirewallRule> firewallRules = Sets.newHashSet();
public NetworkImpl(String id, String name, URI location, String description,
Set<String> dnsServers, String gateway, String netmask,
Set<String> fenceModes, Boolean dhcp, Set<NatRule> natRules,
Set<FirewallRule> firewallRules) {
super(id, name, VCloudMediaType.NETWORK_XML, location);
public NetworkImpl(String name, URI id, String description, Set<String> dnsServers, String gateway,
String netmask, Set<String> fenceModes, Boolean dhcp, Set<NatRule> natRules, Set<FirewallRule> firewallRules) {
super(name, VCloudMediaType.NETWORK_XML, id);
this.description = description;
this.dnsServers.addAll(dnsServers);
this.gateway = gateway;
@ -131,15 +129,11 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((description == null) ? 0 : description.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
result = prime * result
+ ((dnsServers == null) ? 0 : dnsServers.hashCode());
result = prime * result
+ ((fenceModes == null) ? 0 : fenceModes.hashCode());
result = prime * result
+ ((firewallRules == null) ? 0 : firewallRules.hashCode());
result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode());
result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode());
result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode());
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
@ -200,11 +194,9 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
@Override
public String toString() {
return "NetworkImpl [id=" + getId() + ", location=" + getLocation()
+ ", name=" + getName() + ", type=" + getType() + ", description="
+ description + ", dhcp=" + dhcp + ", dnsServers=" + dnsServers
+ ", fenceModes=" + fenceModes + ", firewallRules=" + firewallRules
+ ", gateway=" + gateway + ", natRules=" + natRules + ", netmask="
return "NetworkImpl [id=" + getId() + ", name=" + getName() + ", type=" + getType() + ", description="
+ description + ", dhcp=" + dhcp + ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes
+ ", firewallRules=" + firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask="
+ netmask + "]";
}

View File

@ -36,45 +36,44 @@ import org.jclouds.vcloud.endpoints.VDC;
*
*/
public class OrganizationImpl implements Organization {
private final String id;
private final String name;
private final URI location;
private final URI id;
private final Map<String, NamedResource> catalogs;
private final Map<String, NamedResource> vdcs;
private final Map<String, NamedResource> tasksLists;
public OrganizationImpl(String id, String name, URI location, Map<String, NamedResource> catalogs,
public OrganizationImpl(String name, URI id, Map<String, NamedResource> catalogs,
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
this.id = id;
this.name = name;
this.location = location;
this.id = id;
this.catalogs = catalogs;
this.vdcs = vdcs;
this.tasksLists = tasksLists;
}
public String getId() {
return id;
}
@Override
public String getName() {
return name;
}
public URI getLocation() {
return location;
@Override
public URI getId() {
return id;
}
@Catalog
@Override
public Map<String, NamedResource> getCatalogs() {
return catalogs;
}
@Override
@VDC
public Map<String, NamedResource> getVDCs() {
return vdcs;
}
@Override
@TasksList
public Map<String, NamedResource> getTasksLists() {
return tasksLists;
@ -86,7 +85,6 @@ public class OrganizationImpl implements Organization {
int result = 1;
result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((tasksLists == null) ? 0 : tasksLists.hashCode());
result = prime * result + ((vdcs == null) ? 0 : vdcs.hashCode());
@ -112,11 +110,6 @@ public class OrganizationImpl implements Organization {
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (name == null) {
if (other.name != null)
return false;
@ -140,12 +133,13 @@ public class OrganizationImpl implements Organization {
return VCloudMediaType.ORG_XML;
}
@Override
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
}
@Override
public String toString() {
return "[id=" + id + ", name=" + name + ", type=" + getType() + ", location=" + location + "]";
return "[id=" + id + ", name=" + name + ", type=" + getType() + "]";
}
}

View File

@ -42,8 +42,7 @@ public class TaskImpl implements Task {
private final String majorErrorCode;
private final String minorErrorCode;
public ErrorImpl(String message, String majorErrorCode,
String minorErrorCode) {
public ErrorImpl(String message, String majorErrorCode, String minorErrorCode) {
this.message = message;
this.majorErrorCode = majorErrorCode;
this.minorErrorCode = minorErrorCode;
@ -65,11 +64,9 @@ public class TaskImpl implements Task {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((majorErrorCode == null) ? 0 : majorErrorCode.hashCode());
result = prime * result + ((majorErrorCode == null) ? 0 : majorErrorCode.hashCode());
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result
+ ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode());
result = prime * result + ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode());
return result;
}
@ -102,13 +99,12 @@ public class TaskImpl implements Task {
@Override
public String toString() {
return "ErrorImpl [majorErrorCode=" + majorErrorCode + ", message="
+ message + ", minorErrorCode=" + minorErrorCode + "]";
return "ErrorImpl [majorErrorCode=" + majorErrorCode + ", message=" + message + ", minorErrorCode="
+ minorErrorCode + "]";
}
}
private final String id;
private final URI location;
private final URI id;
private final TaskStatus status;
private final Date startTime;
@Nullable
@ -121,11 +117,9 @@ public class TaskImpl implements Task {
@Nullable
private final Error error;
public TaskImpl(String id, URI location, TaskStatus status, Date startTime,
@Nullable Date endTime,@Nullable Date expiryTime, NamedResource owner,
@Nullable NamedResource result, Error error) {
public TaskImpl(URI id, TaskStatus status, Date startTime, @Nullable Date endTime, @Nullable Date expiryTime,
NamedResource owner, @Nullable NamedResource result, Error error) {
this.id = checkNotNull(id, "id");
this.location = checkNotNull(location, "location");
this.status = checkNotNull(status, "status");
this.startTime = startTime;
this.endTime = endTime;
@ -135,38 +129,42 @@ public class TaskImpl implements Task {
this.error = error;
}
@Override
public TaskStatus getStatus() {
return status;
}
@Override
public Date getStartTime() {
return startTime;
}
@Override
public NamedResource getOwner() {
return owner;
}
@Override
public NamedResource getResult() {
return result;
}
@Override
public Date getEndTime() {
return endTime;
}
@Override
public int compareTo(Task o) {
return (this == o) ? 0 : getId().compareTo(o.getId());
return (this == o) ? 0 : getLocation().compareTo(o.getLocation());
}
public String getId() {
@Override
public URI getLocation() {
return id;
}
public URI getLocation() {
return location;
}
@Override
public Error getError() {
return error;
}
@ -179,7 +177,6 @@ public class TaskImpl implements Task {
result = prime * result + ((error == null) ? 0 : error.hashCode());
result = prime * result + ((expiryTime == null) ? 0 : expiryTime.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
result = prime * result + ((this.result == null) ? 0 : this.result.hashCode());
result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
@ -216,11 +213,6 @@ public class TaskImpl implements Task {
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (owner == null) {
if (other.owner != null)
return false;
@ -246,9 +238,8 @@ public class TaskImpl implements Task {
@Override
public String toString() {
return "TaskImpl [endTime=" + endTime + ", error=" + error + ", id=" + id
+ ", location=" + location + ", owner=" + owner + ", result="
+ result + ", startTime=" + startTime + ", status=" + status + "]";
return "TaskImpl [endTime=" + endTime + ", error=" + error + ", id=" + id + ", owner=" + owner
+ ", result=" + result + ", startTime=" + startTime + ", status=" + status + "]";
}
public Date getExpiryTime() {

View File

@ -25,12 +25,6 @@ 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,53 +32,25 @@ import com.google.common.collect.Multimaps;
*
*/
public class TasksListImpl implements TasksList {
private final String id;
private final SortedSet<Task> tasks;
private final ListMultimap<URI, Task> tasksByResult;
private final ListMultimap<URI, Task> tasksByOwner;
private final URI location;
private final URI id;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public TasksListImpl(String id, URI location, SortedSet<Task> tasks) {
public TasksListImpl(URI id, SortedSet<Task> tasks) {
this.id = id;
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(Iterables.filter(tasks, new Predicate<Task>() {
@Override
public boolean apply(Task input) {
return input.getOwner() != null;
}
}), new Function<Task, URI>() {
public URI apply(Task in) {
return in.getOwner().getLocation();
}
});
}
@Override
public SortedSet<Task> getTasks() {
return tasks;
}
@Override
public URI getLocation() {
return location;
return id;
}
@Override
@ -92,10 +58,7 @@ public class TasksListImpl implements TasksList {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
result = prime * result + ((tasksByOwner == null) ? 0 : tasksByOwner.hashCode());
result = prime * result + ((tasksByResult == null) ? 0 : tasksByResult.hashCode());
return result;
}
@ -113,39 +76,12 @@ public class TasksListImpl implements TasksList {
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (tasks == null) {
if (other.tasks != null)
return false;
} else if (!tasks.equals(other.tasks))
return false;
if (tasksByOwner == null) {
if (other.tasksByOwner != null)
return false;
} else if (!tasksByOwner.equals(other.tasksByOwner))
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;
}
@Override
public String getId() {
return id;
}
}

View File

@ -27,15 +27,11 @@ import java.util.Set;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VirtualSystem;
import com.google.common.base.Function;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
/**
*
@ -43,9 +39,8 @@ import com.google.common.collect.Multimaps;
*
*/
public class VAppImpl implements VApp {
private final String id;
private final String name;
private final URI location;
private final URI id;
private final NamedResource vDC;
private final VAppStatus status;
private final Long size;
@ -53,61 +48,50 @@ public class VAppImpl implements VApp {
private final String operatingSystemDescription;
private final VirtualSystem system;
private final Set<ResourceAllocation> resourceAllocations;
private final ListMultimap<ResourceType, ResourceAllocation> resourceAllocationByType;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public VAppImpl(String id, String name, URI location, VAppStatus status,
Long size, NamedResource vDC,
ListMultimap<String, String> networkToAddresses,
String operatingSystemDescription, VirtualSystem system,
public VAppImpl(String name, URI id, VAppStatus status, Long size, NamedResource vDC,
ListMultimap<String, String> networkToAddresses, String operatingSystemDescription, VirtualSystem system,
Set<ResourceAllocation> resourceAllocations) {
this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name");
this.location = checkNotNull(location, "location");
this.id = checkNotNull(id, "id");
this.status = checkNotNull(status, "status");
this.size = size;// hostingdotcom
this.vDC = vDC;
this.networkToAddresses = checkNotNull(networkToAddresses,
"networkToAddresses");
this.networkToAddresses = checkNotNull(networkToAddresses, "networkToAddresses");
this.operatingSystemDescription = operatingSystemDescription;
this.system = system;
this.resourceAllocations = checkNotNull(resourceAllocations,
"resourceAllocations");
resourceAllocationByType = Multimaps.index(resourceAllocations,
new Function<ResourceAllocation, ResourceType>() {
@Override
public ResourceType apply(ResourceAllocation from) {
return from.getType();
}
});
this.resourceAllocations = checkNotNull(resourceAllocations, "resourceAllocations");
}
@Override
public VAppStatus getStatus() {
return status;
}
@Override
public ListMultimap<String, String> getNetworkToAddresses() {
return networkToAddresses;
}
@Override
public String getOperatingSystemDescription() {
return operatingSystemDescription;
}
@Override
public VirtualSystem getSystem() {
return system;
}
@Override
public Set<ResourceAllocation> getResourceAllocations() {
return resourceAllocations;
}
public Multimap<ResourceType, ResourceAllocation> getResourceAllocationByType() {
return resourceAllocationByType;
}
@Override
public NamedResource getVDC() {
return vDC;
}
@ -117,23 +101,10 @@ public class VAppImpl implements VApp {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime
* result
+ ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode());
result = prime
* result
+ ((operatingSystemDescription == null) ? 0
: operatingSystemDescription.hashCode());
result = prime
* result
+ ((resourceAllocationByType == null) ? 0
: resourceAllocationByType.hashCode());
result = prime
* result
+ ((resourceAllocations == null) ? 0 : resourceAllocations
.hashCode());
result = prime * result + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode());
result = prime * result + ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode());
result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
result = prime * result + ((size == null) ? 0 : size.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode());
@ -155,11 +126,6 @@ public class VAppImpl implements VApp {
return false;
} else if (!id.equals(other.id))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (name == null) {
if (other.name != null)
return false;
@ -173,14 +139,7 @@ public class VAppImpl implements VApp {
if (operatingSystemDescription == null) {
if (other.operatingSystemDescription != null)
return false;
} else if (!operatingSystemDescription
.equals(other.operatingSystemDescription))
return false;
if (resourceAllocationByType == null) {
if (other.resourceAllocationByType != null)
return false;
} else if (!resourceAllocationByType
.equals(other.resourceAllocationByType))
} else if (!operatingSystemDescription.equals(other.operatingSystemDescription))
return false;
if (resourceAllocations == null) {
if (other.resourceAllocations != null)
@ -210,30 +169,26 @@ public class VAppImpl implements VApp {
return true;
}
public String getId() {
return id;
}
@Override
public String getName() {
return name;
}
public URI getLocation() {
return location;
@Override
public URI getId() {
return id;
}
@Override
public Long getSize() {
return size;
}
@Override
public String toString() {
return "[id=" + id + ", location=" + location + ", name=" + name
+ ", networkToAddresses=" + networkToAddresses
+ ", operatingSystemDescription=" + operatingSystemDescription
+ ", resourceAllocationByType=" + resourceAllocationByType
+ ", resourceAllocations=" + resourceAllocations + ", size=" + size
+ ", status=" + status + ", system=" + system + ", vDC=" + vDC
return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses
+ ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType="
+ resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC
+ "]";
}

View File

@ -39,9 +39,8 @@ public class VAppTemplateImpl extends NamedResourceImpl implements VAppTemplate
private final String description;
private final VAppStatus status;
public VAppTemplateImpl(String id, String name, URI location, @Nullable String description,
@Nullable VAppStatus status) {
super(id, name, VCloudMediaType.VAPPTEMPLATE_XML, location);
public VAppTemplateImpl(String name, URI id, @Nullable String description, @Nullable VAppStatus status) {
super(name, VCloudMediaType.VAPPTEMPLATE_XML, id);
this.description = description;
this.status = status;
}

View File

@ -38,9 +38,8 @@ import org.jclouds.vcloud.domain.VDC;
*/
public class VDCImpl implements VDC {
private final String id;
private final String name;
private final URI location;
private final URI id;
private final String description;
private final Capacity storageCapacity;
private final Capacity cpuCapacity;
@ -50,14 +49,11 @@ public class VDCImpl implements VDC {
private final Map<String, NamedResource> availableNetworks;
private final Map<String, NamedResource> resourceEntities;
public VDCImpl(String id, String name, URI location, String description,
Capacity storageCapacity, Capacity cpuCapacity, Capacity memoryCapacity,
Quota instantiatedVmsQuota, Quota deployedVmsQuota,
Map<String, NamedResource> resourceEntities,
Map<String, NamedResource> availableNetworks) {
this.id = id;
public VDCImpl(String name, URI id, String description, Capacity storageCapacity, Capacity cpuCapacity,
Capacity memoryCapacity, Quota instantiatedVmsQuota, Quota deployedVmsQuota,
Map<String, NamedResource> resourceEntities, Map<String, NamedResource> availableNetworks) {
this.name = checkNotNull(name, "name");
this.location = checkNotNull(location, "location");
this.id = checkNotNull(id, "id");
this.description = description;
this.storageCapacity = storageCapacity;
this.cpuCapacity = cpuCapacity;
@ -71,22 +67,22 @@ public class VDCImpl implements VDC {
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public String getId() {
return id;
}
@Override
public String getName() {
return name;
}
public URI getLocation() {
return location;
@Override
public URI getId() {
return id;
}
@Override
public Map<String, NamedResource> getAvailableNetworks() {
return availableNetworks;
}
@Override
public Map<String, NamedResource> getResourceEntities() {
return resourceEntities;
}
@ -99,10 +95,8 @@ public class VDCImpl implements VDC {
result = prime * result + ((cpuCapacity == null) ? 0 : cpuCapacity.hashCode());
result = prime * result + ((deployedVmsQuota == null) ? 0 : deployedVmsQuota.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((instantiatedVmsQuota == null) ? 0 : instantiatedVmsQuota.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result
+ ((instantiatedVmsQuota == null) ? 0 : instantiatedVmsQuota.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((memoryCapacity == null) ? 0 : memoryCapacity.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((resourceEntities == null) ? 0 : resourceEntities.hashCode());
@ -139,20 +133,15 @@ public class VDCImpl implements VDC {
return false;
} else if (!description.equals(other.description))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (instantiatedVmsQuota == null) {
if (other.instantiatedVmsQuota != null)
return false;
} else if (!instantiatedVmsQuota.equals(other.instantiatedVmsQuota))
return false;
if (location == null) {
if (other.location != null)
if (id == null) {
if (other.id != null)
return false;
} else if (!location.equals(other.location))
} else if (!id.equals(other.id))
return false;
if (memoryCapacity == null) {
if (other.memoryCapacity != null)
@ -177,26 +166,32 @@ public class VDCImpl implements VDC {
return true;
}
@Override
public String getDescription() {
return description;
}
@Override
public Capacity getStorageCapacity() {
return storageCapacity;
}
@Override
public Capacity getCpuCapacity() {
return cpuCapacity;
}
@Override
public Capacity getMemoryCapacity() {
return memoryCapacity;
}
@Override
public Quota getInstantiatedVmsQuota() {
return instantiatedVmsQuota;
}
@Override
public Quota getDeployedVmsQuota() {
return deployedVmsQuota;
}

View File

@ -1,41 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.endpoints;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* Represents a component related to vCloud.
*
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
* @author Adrian Cole
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface VCloudApi {
}

View File

@ -1,40 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.endpoints.internal;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* Root path where all catalog items exist.
*
* @author Adrian Cole
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface CatalogItemRoot {
}

View File

@ -1,40 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.endpoints.internal;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* Root path where all vApps exist.
*
* @author Adrian Cole
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface VAppTemplateRoot {
}

View File

@ -75,10 +75,10 @@ public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? ex
@SuppressWarnings("unchecked")
@Override
public Future<CatalogItem> apply(NamedResource from) {
return (Future<CatalogItem>) aclient.getCatalogItem(from.getLocation());
return (Future<CatalogItem>) aclient.getCatalogItem(from.getId());
}
}, executor, null, logger, "catalogItems in " + from.getLocation());
}, executor, null, logger, "catalogItems in " + from.getId());
return catalogItems;
}

View File

@ -64,7 +64,7 @@ public class AllCatalogsInOrganization implements Function<Organization, Iterabl
@SuppressWarnings("unchecked")
@Override
public Future<Catalog> apply(NamedResource from) {
return (Future<Catalog>) aclient.findCatalogInOrgNamed(org.getName(), from.getName());
return (Future<Catalog>) aclient.getCatalog(from.getId());
}
}, executor, null, logger, "catalogs in " + org.getName());

View File

@ -65,10 +65,10 @@ public class AllVDCsInOrganization implements Function<Organization, Iterable<?
@SuppressWarnings("unchecked")
@Override
public Future<VDC> apply(NamedResource from) {
return (Future<VDC>) aclient.findVDCInOrgNamed(org.getName(), from.getName());
return (Future<VDC>) aclient.getVDC(from.getId());
}
}, executor, null, logger, "vdcs in " + org.getName());
}, executor, null, logger, "vdcs in org " + org.getName());
return catalogItems;
}

View File

@ -1,47 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.functions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class CatalogIdToUri implements Function<Object, String> {
@Inject
@CatalogItemRoot
private String catalogItemRoot;
public String apply(Object from) {
checkArgument(checkNotNull(from, "from") instanceof String,
"this binder is only valid for String!");
return String.format("%s/%s", catalogItemRoot, from);
}
}

View File

@ -67,9 +67,7 @@ public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
try {
Map<String, NamedResource> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();
return catalog == null ? Iterables.getLast(catalogs.values()).getLocation() : catalogs.get(catalog)
.getLocation();
return catalog == null ? Iterables.getLast(catalogs.values()).getId() : catalogs.get(catalog).getId();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get());
}

View File

@ -67,8 +67,7 @@ public class OrgNameAndTasksListNameToEndpoint implements Function<Object, URI>
try {
Map<String, NamedResource> tasksLists = checkNotNull(orgMap.get().get(org)).getTasksLists();
return tasksList == null ? Iterables.getLast(tasksLists.values()).getLocation() : tasksLists.get(tasksList)
.getLocation();
return tasksList == null ? Iterables.getLast(tasksLists.values()).getId() : tasksLists.get(tasksList).getId();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + tasksList + " not found in " + orgMap.get());
}

View File

@ -67,8 +67,7 @@ public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
try {
Map<String, NamedResource> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();
return vdc == null ? Iterables.getLast(vdcs.values()).getLocation() : vdcs.get(vdc).getLocation();
return vdc == null ? Iterables.getLast(vdcs.values()).getId() : vdcs.get(vdc).getId();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get());
}

View File

@ -66,7 +66,7 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
catalog = defaultCatalog;
try {
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getLocation();
return catalogs.get(catalog).get(catalogItem).getId();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ orgCatalogMap.get());

View File

@ -67,7 +67,7 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
catalog = defaultCatalog;
try {
Map<String, Map<String, ? extends CatalogItem>> catalogs = checkNotNull(orgCatalogItemMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getEntity().getLocation();
return catalogs.get(catalog).get(catalogItem).getEntity().getId();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ orgCatalogItemMap.get());

View File

@ -49,7 +49,7 @@ public class OrgNameToEndpoint implements Function<Object, URI> {
public URI apply(Object from) {
try {
return from == null ? defaultUri : orgNameToEndpoint.get().get(from).getLocation();
return from == null ? defaultUri : orgNameToEndpoint.get().get(from).getId();
} catch (NullPointerException e) {
throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpoint.get().keySet());
}

View File

@ -0,0 +1,75 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
@Singleton
public class OrgNameVDCNameResourceEntityNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
private final String defaultOrg;
private final String defaultVDC;
@Inject
public OrgNameVDCNameResourceEntityNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> orgVDCMap, @Org String defaultOrg,
@VDC String defaultVDC) {
this.orgVDCMap = orgVDCMap;
this.defaultOrg = defaultOrg;
this.defaultVDC = defaultVDC;
}
@SuppressWarnings("unchecked")
public URI apply(Object from) {
Iterable<Object> orgVDC = (Iterable<Object>) checkNotNull(from, "args");
Object org = Iterables.get(orgVDC, 0);
Object vDC = Iterables.get(orgVDC, 1);
Object entityName = Iterables.get(orgVDC, 2);
if (org == null)
org = defaultOrg;
if (vDC == null)
vDC = defaultVDC;
try {
Map<String, ? extends org.jclouds.vcloud.domain.VDC> vDCs = checkNotNull(orgVDCMap.get().get(org));
return vDCs.get(vDC).getResourceEntities().get(entityName).getId();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + vDC + "/" + entityName + " not found in " + orgVDCMap.get());
}
}
}

View File

@ -81,7 +81,7 @@ public class OrganizatonsForLocations implements
@Override
public URI apply(Location from) {
return VCloudLocation.class.cast(from.getParent()).getResource().getLocation();
return VCloudLocation.class.cast(from.getParent()).getResource().getId();
}
})), new Function<URI, Future<Organization>>() {

View File

@ -1,43 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.functions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Singleton;
import org.jclouds.vcloud.domain.VApp;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class VAppId implements Function<Object, String> {
public String apply(Object from) {
checkArgument(checkNotNull(from, "from") instanceof VApp,
"this binder is only valid for VApps!");
return ((VApp) from).getId();
}
}

View File

@ -1,47 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.functions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class VAppIdToUri implements Function<Object, String> {
@Inject
@VAppRoot
private String vAppRoot;
public String apply(Object from) {
checkArgument(checkNotNull(from, "from") instanceof String,
"this binder is only valid for Strings!");
return String.format("%s/%s", vAppRoot, from);
}
}

View File

@ -74,7 +74,7 @@ public class VAppTemplatesForCatalogItems implements
@SuppressWarnings("unchecked")
@Override
public Future<VAppTemplate> apply(CatalogItem from) {
return (Future<VAppTemplate>) aclient.getVAppTemplate(from.getEntity().getLocation());
return (Future<VAppTemplate>) aclient.getVAppTemplate(from.getEntity().getId());
}
}, executor, null, logger, "vappTemplates in");

View File

@ -74,7 +74,7 @@ public class VAppTemplatesForResourceEntities implements
@SuppressWarnings("unchecked")
@Override
public Future<VAppTemplate> apply(NamedResource from) {
return (Future<VAppTemplate>) aclient.getVAppTemplate(from.getLocation());
return (Future<VAppTemplate>) aclient.getVAppTemplate(from.getId());
}
}, executor, null, logger, "vappTemplates in");

View File

@ -46,7 +46,7 @@ public class VDCNameToEndpoint implements Function<Object, URI> {
public URI apply(Object from) {
try {
return from == null ? defaultVDC : org.getVDCs().get(from).getLocation();
return from == null ? defaultVDC : org.getVDCs().get(from).getId();
} catch (NullPointerException e) {
throw new IllegalArgumentException("vdc name: " + from + " not in " + org.getVDCs());
}

View File

@ -19,6 +19,8 @@
package org.jclouds.vcloud.predicates;
import java.net.URI;
import javax.annotation.Resource;
import javax.inject.Singleton;
@ -37,7 +39,7 @@ import com.google.inject.Inject;
* @author Adrian Cole
*/
@Singleton
public class TaskSuccess implements Predicate<String> {
public class TaskSuccess implements Predicate<URI> {
private final VCloudClient client;
@ -49,14 +51,14 @@ public class TaskSuccess implements Predicate<String> {
this.client = client;
}
public boolean apply(String taskId) {
public boolean apply(URI taskId) {
logger.trace("looking for status on task %s", taskId);
Task task = client.getTask(taskId);
logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task
.getStatus());
if (task.getStatus() == TaskStatus.ERROR)
throw new RuntimeException("error on task: " + task.getId() + " error: " + task.getError());
throw new RuntimeException("error on task: " + task.getLocation() + " error: " + task.getError());
return task.getStatus() == TaskStatus.SUCCESS;
}

View File

@ -17,31 +17,40 @@
* ====================================================================
*/
package org.jclouds.vcloud.functions;
package org.jclouds.vcloud.predicates;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.endpoints.internal.VAppTemplateRoot;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
/**
*
* @author Adrian Cole
*/
@Singleton
public class VAppTemplateIdToUri implements Function<Object, String> {
@Inject
@VAppTemplateRoot
private String vAppTemplateRoot;
public class VCloudPredicates {
public String apply(Object from) {
checkArgument(checkNotNull(from, "from") instanceof String,
"this binder is only valid for String!");
return String.format("%s/%s", vAppTemplateRoot, from);
/**
* Return resource allocations of the specific type.
*
* @param type
* type to match the items
* @return predicate
*/
public static Predicate<ResourceAllocation> resourceType(final ResourceType type) {
checkNotNull(type, "type");
return new Predicate<ResourceAllocation>() {
@Override
public boolean apply(ResourceAllocation in) {
return type.equals(in.getType());
}
@Override
public String toString() {
return "resourceAllocationType(" + type + ")";
}
};
}
}
}

View File

@ -36,26 +36,20 @@ public class Utils {
public static NamedResource newNamedResource(Attributes attributes) {
String uri = attributes.getValue(attributes.getIndex("href"));
String id = uri.substring(uri.lastIndexOf('/') + 1);
return new NamedResourceImpl(id, attributes.getValue(attributes
.getIndex("name")), attributes
.getValue(attributes.getIndex("type")), URI.create(uri));
return new NamedResourceImpl(attributes.getValue(attributes.getIndex("name")), attributes.getValue(attributes
.getIndex("type")), URI.create(uri));
}
public static Task.Error newError(Attributes attributes) {
return new ErrorImpl(attrOrNull(attributes, "message"), attrOrNull(
attributes, "majorErrorCode"), attrOrNull(attributes,
"minorErrorCode"));
return new ErrorImpl(attrOrNull(attributes, "message"), attrOrNull(attributes, "majorErrorCode"), attrOrNull(
attributes, "minorErrorCode"));
}
private static String attrOrNull(Attributes attributes, String attr) {
return attributes.getIndex(attr) >= 0 ? attributes.getValue(attributes
.getIndex(attr)) : null;
return attributes.getIndex(attr) >= 0 ? attributes.getValue(attributes.getIndex(attr)) : null;
}
public static void putNamedResource(Map<String, NamedResource> map,
Attributes attributes) {
map.put(attributes.getValue(attributes.getIndex("name")),
newNamedResource(attributes));
public static void putNamedResource(Map<String, NamedResource> map, Attributes attributes) {
map.put(attributes.getValue(attributes.getIndex("name")), newNamedResource(attributes));
}
}

View File

@ -43,13 +43,11 @@ public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
private String description;
public Catalog getResult() {
return new CatalogImpl(catalog.getId(), catalog.getName(), catalog.getLocation(),
description, contents);
return new CatalogImpl(catalog.getName(), catalog.getId(), description, contents);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("Catalog")) {
catalog = Utils.newNamedResource(attributes);
} else if (qName.equals("CatalogItem")) {

View File

@ -45,13 +45,11 @@ public class CatalogItemHandler extends ParseSax.HandlerWithResult<CatalogItem>
protected SortedMap<String, String> properties = Maps.newTreeMap();
public CatalogItem getResult() {
return new CatalogItemImpl(catalogItem.getId(), catalogItem.getName(), catalogItem.getLocation(),
description, entity, properties);
return new CatalogItemImpl(catalogItem.getName(), catalogItem.getId(), description, entity, properties);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("CatalogItem")) {
catalogItem = Utils.newNamedResource(attributes);
} else if (qName.equals("Entity")) {

View File

@ -71,14 +71,12 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
private String sourcePort;
public Network getResult() {
return new NetworkImpl(network.getId(), network.getName(), network
.getLocation(), description, dnsServers, gateway, netmask,
return new NetworkImpl(network.getName(), network.getId(), description, dnsServers, gateway, netmask,
fenceModes, dhcp, natRules, firewallRules);
}
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("Network")) {
network = Utils.newNamedResource(attributes);
}
@ -98,8 +96,7 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
} else if (qName.equals("Dhcp")) {
dhcp = new Boolean(currentOrNull());
} else if (qName.equals("NatRule")) {
natRules.add(new NatRule(externalIP, externalPort, internalIP,
internalPort));
natRules.add(new NatRule(externalIP, externalPort, internalIP, internalPort));
externalIP = null;
externalPort = null;
internalIP = null;
@ -113,8 +110,7 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
} else if (qName.equals("InternalPort")) {
internalPort = Integer.parseInt(currentOrNull());
} else if (qName.equals("FirewallRule")) {
firewallRules.add(new FirewallRule(policy, protocol, sourceIP,
sourcePort));
firewallRules.add(new FirewallRule(policy, protocol, sourceIP, sourcePort));
policy = null;
protocol = null;
sourceIP = null;

View File

@ -46,13 +46,11 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
protected Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
public Organization getResult() {
return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalogs, vdcs,
tasksLists);
return new OrganizationImpl(org.getName(), org.getId(), catalogs, vdcs, tasksLists);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("Org")) {
org = newNamedResource(attributes);
} else if (qName.equals("Link")) {

View File

@ -66,10 +66,10 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equalsIgnoreCase("Task")) {
if (attributes.getIndex("href") != -1)// queued tasks may not have an href yet
if (attributes.getIndex("href") != -1)// queued tasks may not have an
// href yet
taskLink = Utils.newNamedResource(attributes);
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
if (attributes.getIndex("startTime") != -1)
@ -81,7 +81,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
} else if (qName.equals("Owner")) {
owner = Utils.newNamedResource(attributes);
} else if (qName.equals("Link") && attributes.getIndex("rel") != -1
&& attributes.getValue(attributes.getIndex("rel")).equals("self")) {
&& attributes.getValue(attributes.getIndex("rel")).equals("self")) {
taskLink = Utils.newNamedResource(attributes);
} else if (qName.equals("Result")) {
result = Utils.newNamedResource(attributes);
@ -113,8 +113,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equalsIgnoreCase("Task")) {
this.task = new TaskImpl(taskLink.getId(), taskLink.getLocation(), status, startTime,
endTime, expiryTime, owner, result, error);
this.task = new TaskImpl(taskLink.getId(), status, startTime, endTime, expiryTime, owner, result, error);
taskLink = null;
status = null;
startTime = null;

View File

@ -49,16 +49,15 @@ public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
}
public TasksList getResult() {
return new TasksListImpl(resource.getId(), resource.getLocation(), tasks);
return new TasksListImpl(resource.getId(), tasks);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("TasksList")) {
resource = Utils.newNamedResource(attributes);
} else if (qName.equals("Link") && attributes.getIndex("rel") != -1
&& attributes.getValue(attributes.getIndex("rel")).equals("self")) {
&& attributes.getValue(attributes.getIndex("rel")).equals("self")) {
resource = Utils.newNamedResource(attributes);
} else {
taskHandler.startElement(uri, localName, qName, attributes);

View File

@ -53,8 +53,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
protected Logger logger = Logger.NULL;
@Inject
public VAppHandler(VirtualSystemHandler systemHandler,
ResourceAllocationHandler allocationHandler) {
public VAppHandler(VirtualSystemHandler systemHandler, ResourceAllocationHandler allocationHandler) {
this.systemHandler = systemHandler;
this.allocationHandler = allocationHandler;
}
@ -68,30 +67,26 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
protected boolean inOs;
protected String networkName;
protected String name;
protected String id;
protected URI location;
protected Long size;
protected NamedResource vDC;
public VApp getResult() {
return new VAppImpl(id, name, location, status, size, vDC, networkToAddresses,
operatingSystemDescription, system, allocations);
return new VAppImpl(name, location, status, size, vDC, networkToAddresses, operatingSystemDescription, system,
allocations);
}
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("VApp")) {
NamedResource resource = Utils.newNamedResource(attributes);
name = resource.getName();
id = resource.getId();
location = resource.getLocation();
location = resource.getId();
status = VAppStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
if (attributes.getIndex("size") != -1)
size = new Long(attributes.getValue(attributes.getIndex("size")));
} else if (qName.equals("Link")) { // type should never be missing
if (attributes.getIndex("type") != -1
&& attributes.getValue(attributes.getIndex("type")).equals(
VCloudMediaType.VDC_XML)) {
&& attributes.getValue(attributes.getIndex("type")).equals(VCloudMediaType.VDC_XML)) {
vDC = Utils.newNamedResource(attributes);
}
} else if (qName.equals("OperatingSystemSection")) {

View File

@ -39,13 +39,11 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
private VAppStatus status;
public VAppTemplate getResult() {
return new VAppTemplateImpl(catalog.getId(), catalog.getName(), catalog.getLocation(),
description, status);
return new VAppTemplateImpl(catalog.getName(), catalog.getId(), description, status);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("VAppTemplate")) {
catalog = Utils.newNamedResource(attributes);
if (attributes.getIndex("status") != -1)

View File

@ -66,14 +66,12 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
private int limit;
public VDC getResult() {
return new VDCImpl(vDC.getId(), vDC.getName(), vDC.getLocation(), description,
storageCapacity, cpuCapacity, memoryCapacity, instantiatedVmsQuota,
deployedVmsQuota, resourceEntities, availableNetworks);
return new VDCImpl(vDC.getName(), vDC.getId(), description, storageCapacity, cpuCapacity, memoryCapacity,
instantiatedVmsQuota, deployedVmsQuota, resourceEntities, availableNetworks);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("Vdc")) {
vDC = newNamedResource(attributes);
} else if (qName.equals("Network")) {

View File

@ -55,6 +55,7 @@ import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.OrganizationImpl;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
@ -242,8 +243,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getCatalog", String.class);
HttpRequest request = processor.createRequest(method, "1");
Method method = VCloudAsyncClient.class.getMethod("getCatalog", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
@ -272,8 +274,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class);
HttpRequest request = processor.createRequest(method, "2");
Method method = VCloudAsyncClient.class.getMethod("getNetwork", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/network/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/network/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
@ -454,8 +457,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getTasksList", String.class);
HttpRequest request = processor.createRequest(method, "1");
Method method = VCloudAsyncClient.class.getMethod("getTasksList", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/tasksList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
@ -484,8 +488,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("deployVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/action/deploy HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
@ -499,8 +504,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("getVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
@ -514,8 +520,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("undeployVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("undeployVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/action/undeploy HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
@ -529,8 +536,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
@ -544,8 +552,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("powerOnVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("powerOnVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1");
@ -560,8 +569,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("powerOffVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("powerOffVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1");
@ -576,8 +586,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testReset() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("resetVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("resetVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/reset HTTP/1.1");
@ -592,8 +603,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testSuspend() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("suspendVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("suspendVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/suspend HTTP/1.1");
@ -608,8 +620,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testShutdown() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("shutdownVApp", String.class);
HttpRequest request = processor.createRequest(method, 1);
Method method = VCloudAsyncClient.class.getMethod("shutdownVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/shutdown HTTP/1.1");
@ -624,8 +637,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getTask", String.class);
HttpRequest request = processor.createRequest(method, "1");
Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/task/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
@ -639,8 +653,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("cancelTask", String.class);
HttpRequest request = processor.createRequest(method, "1");
Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/task/1/action/cancel HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
@ -686,14 +701,6 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login");
}
@Override
protected void configure() {
super.configure();
bind(OrganizationMapSupplier.class).to(TestOrganizationMapSupplier.class);
bind(OrganizationCatalogSupplier.class).to(TestOrganizationCatalogItemMapSupplier.class);
bind(OrganizationCatalogItemSupplier.class).to(TestOrganizationCatalogItemSupplier.class);
}
@Override
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/org");
@ -743,7 +750,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public Map<String, NamedResource> getOrgs() {
return ImmutableMap.<String, NamedResource> of("org", new NamedResourceImpl("1", "org",
return ImmutableMap.<String, NamedResource> of("org", new NamedResourceImpl("org",
VCloudMediaType.ORG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")));
}
@ -756,6 +763,30 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
@Override
protected void configure() {
super.configure();
bind(OrganizationMapSupplier.class).to(TestOrganizationMapSupplier.class);
bind(OrganizationCatalogSupplier.class).to(TestOrganizationCatalogSupplier.class);
bind(OrganizationCatalogItemSupplier.class).to(TestOrganizationCatalogItemSupplier.class);
}
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationVDCSupplier supplier) {
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new VDCImpl("vdc", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "description", null, null, null, null,
null, ImmutableMap.<String, NamedResource> of("vapp", new NamedResourceImpl("vapp",
"application/vnd.vmware.vcloud.vApp+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), "network",
new NamedResourceImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), null))));
}
@Singleton
public static class TestOrganizationMapSupplier extends OrganizationMapSupplier {
@Inject
@ -765,22 +796,22 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public Map<String, Organization> get() {
return ImmutableMap.<String, Organization> of("org", new OrganizationImpl("1", "org", URI
return ImmutableMap.<String, Organization> of("org", new OrganizationImpl("org", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), ImmutableMap.<String, NamedResource> of(
"catalog", new NamedResourceImpl("1", "catalog", VCloudMediaType.CATALOG_XML, URI
"catalog", new NamedResourceImpl("catalog", VCloudMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<String, NamedResource> of("vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
.<String, NamedResource> of("vdc", new NamedResourceImpl("vdc", VCloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, NamedResource> of("tasksList", new NamedResourceImpl("1", "tasksList",
.<String, NamedResource> of("tasksList", new NamedResourceImpl("tasksList",
VCloudMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")))));
}
}
@Singleton
public static class TestOrganizationCatalogItemMapSupplier extends OrganizationCatalogSupplier {
public static class TestOrganizationCatalogSupplier extends OrganizationCatalogSupplier {
@Inject
protected TestOrganizationCatalogItemMapSupplier() {
protected TestOrganizationCatalogSupplier() {
super(null, null);
}
@ -788,12 +819,12 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("1", "catalog", URI
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"), "description", ImmutableMap
.<String, NamedResource> of("item", new NamedResourceImpl("1", "item",
.<String, NamedResource> of("item", new NamedResourceImpl("item",
"application/vnd.vmware.vcloud.catalogItem+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), "template",
new NamedResourceImpl("2", "template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))))));
}
}
@ -809,11 +840,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
return ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
"org", ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
"catalog", ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of("template",
new CatalogItemImpl("2", "template", URI
new CatalogItemImpl("template", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "description",
new NamedResourceImpl("2", "template",
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
ImmutableMap.<String, String> of()))));
}

View File

@ -69,9 +69,8 @@ public class VCloudClientLiveTest {
public void testCatalog() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getName());
assertNotNull(response.getLocation());
assertNotNull(response.getId());
assertEquals(connection.findCatalogInOrgNamed(null, response.getName()), response);
}
@ -95,7 +94,6 @@ public class VCloudClientLiveTest {
assertNotNull(item);
assertNotNull(item.getEntity());
assertNotNull(item.getId());
assertNotNull(item.getLocation());
assertNotNull(item.getProperties());
assertNotNull(item.getType());
}
@ -107,7 +105,7 @@ public class VCloudClientLiveTest {
Catalog response = connection.findCatalogInOrgNamed(null, null);
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getLocation());
CatalogItem item = connection.getCatalogItem(resource.getId());
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(null, null, item.getEntity().getName()));
}
@ -119,22 +117,20 @@ public class VCloudClientLiveTest {
public void testDefaultVDC() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getName());
assertNotNull(response.getLocation());
assertNotNull(response.getId());
assertNotNull(response.getResourceEntities());
assertNotNull(response.getAvailableNetworks());
assertEquals(connection.getVDC(response.getLocation()), response);
assertEquals(connection.getVDC(response.getId()), response);
}
@Test
public void testDefaultTasksList() throws Exception {
org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
assertEquals(connection.getTasksList(response.getId()).getId(), response.getId());
assertEquals(connection.getTasksList(response.getLocation()).getLocation(), response.getLocation());
}
@Test
@ -145,7 +141,7 @@ public class VCloudClientLiveTest {
assertNotNull(response.getTasks());
if (response.getTasks().size() > 0) {
Task task = response.getTasks().last();
assertEquals(connection.getTask(task.getId()).getLocation(), task.getLocation());
assertEquals(connection.getTask(task.getLocation()).getLocation(), task.getLocation());
}
}

View File

@ -20,10 +20,13 @@
package org.jclouds.vcloud.compute;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
@ -63,7 +66,7 @@ public class VCloudComputeClientLiveTest {
protected VCloudComputeClient computeClient;
protected VCloudClient client;
protected String id;
protected URI id;
protected String publicAddress;
protected String templateName;
@ -93,7 +96,7 @@ public class VCloudComputeClientLiveTest {
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024).productProperties(
ImmutableMap.of("foo", "bar"));
id = computeClient.start(null, template.getLocation(), templateName, options).get("id");
id = URI.create(computeClient.start(null, template.getId(), templateName, options).get("id"));
Expectation expectation = expectationMap.get(toTest);
VApp vApp = client.getVApp(id);
@ -117,14 +120,16 @@ public class VCloudComputeClientLiveTest {
int memory, long hardDisk) {
// assertEquals(vApp.getName(), serverName);
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
assertEquals(Iterables
.getOnlyElement(filter(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)))
.getVirtualQuantity(), processorCount);
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
.getVirtualQuantity(), 1);
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.MEMORY))
assertEquals(Iterables.getOnlyElement(
filter(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER))).getVirtualQuantity(), 1);
assertEquals(Iterables.getOnlyElement(filter(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)))
.getVirtualQuantity(), memory);
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
.getVirtualQuantity(), hardDisk);
assertEquals(Iterables.getOnlyElement(
filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))).getVirtualQuantity(),
hardDisk);
}
@AfterTest

View File

@ -45,8 +45,8 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@BeforeClass
@Override
public void setServiceDefaults() {
System.setProperty("vcloud.endpoint", checkNotNull(System
.getProperty("jclouds.test.endpoint"), "jclouds.test.endpoint"));
System.setProperty("vcloud.endpoint", checkNotNull(System.getProperty("jclouds.test.endpoint"),
"jclouds.test.endpoint"));
provider = "vcloud";
}
@ -57,9 +57,8 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<VCloudClient, VCloudAsyncClient> tmContext = new ComputeServiceContextFactory()
.createContext(provider, identity, credential)
.getProviderSpecificContext();
RestContext<VCloudClient, VCloudAsyncClient> tmContext = new ComputeServiceContextFactory().createContext(
provider, identity, credential).getProviderSpecificContext();
}
@Override
@ -69,9 +68,9 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
assert node.getLocation() != null;
assertEquals(node.getType(), ComputeType.NODE);
NodeMetadata allData = client.getNodeMetadata(node.getId());
assert allData.getExtra().get("processor/count") != null;
assert allData.getExtra().get("disk_drive/1/kb") != null;
assert allData.getExtra().get("memory/mb") != null;
assert allData.getExtra().get("processor/count") != null : allData.getExtra();
assert allData.getExtra().get("disk_drive/1/kb") != null : allData.getExtra();
assert allData.getExtra().get("memory/mb") != null : allData.getExtra();
System.out.println(allData.getExtra());
}
}

View File

@ -42,33 +42,25 @@ import com.google.common.collect.ListMultimap;
public class VCloudListNodesStrategyTest {
@SuppressWarnings("unused")
private VApp newVApp() throws UnknownHostException {
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap
.<String, String> of("Network 1", "127.0.0.1");
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Network 1",
"127.0.0.1");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family",
"SimpleVM", "vmx-07");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)",
"Number of Virtual CPUs", ResourceType.PROCESSOR, null,
null, null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size",
ResourceType.MEMORY, null, null, null, null, null,
null, 512, "byte * 2^20")).add(
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 512, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0",
"SCSI Controller", ResourceType.SCSI_CONTROLLER,
"lsilogic", null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null,
ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3,
null, 20971520, "byte * 2^20")).build();
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3, null,
20971520, "byte * 2^20")).build();
return new VAppImpl("10", "10", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/10"),
VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null,
system, resourceAllocations);
return new VAppImpl("10", URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/10"), VAppStatus.OFF,
new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
}
// TODO rewrite this test

View File

@ -51,34 +51,31 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
@Test
public void testApply() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")));
.getResourceAsStream("/orglist.xml")));
response.getPayload().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().setContentLength(307l);
response.getHeaders().put(HttpHeaders.SET_COOKIE,
"vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/");
response.getHeaders().put(HttpHeaders.SET_COOKIE, "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/");
VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl(
"48", "adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}
@Test
public void testApplyBlueLock() {
HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass()
.getResourceAsStream("/orglist.xml")));
.getResourceAsStream("/orglist.xml")));
response.getPayload().setContentType("Content-Type: application/xml; charset=utf-8");
response.getPayload().setContentLength(307l);
response.getHeaders().put(HttpHeaders.SET_COOKIE,
"vcloud-token=c9f232506df9b65d7b7d97b7499eddd7; Domain=.bluelock.com; Path=/");
"vcloud-token=c9f232506df9b65d7b7d97b7499eddd7; Domain=.bluelock.com; Path=/");
VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "c9f232506df9b65d7b7d97b7499eddd7");
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl(
"48", "adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}

View File

@ -50,15 +50,13 @@ public class CatalogHandlerTest {
Factory factory = injector.getInstance(ParseSax.Factory.class);
CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
assertEquals(result, new CatalogItemImpl("2", "Windows 2008 Datacenter 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"),
"Windows 2008 Datacenter 64 Bit", new NamedResourceImpl("2",
"Windows 2008 Datacenter 64 Bit",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
ImmutableSortedMap.of("Foo", "Bar", "Hello", "World"
assertEquals(result, new CatalogItemImpl("Windows 2008 Datacenter 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "Windows 2008 Datacenter 64 Bit",
new NamedResourceImpl("Windows 2008 Datacenter 64 Bit", "application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")), ImmutableSortedMap.of("Foo",
"Bar", "Hello", "World"
)));
)));
}
}

View File

@ -30,13 +30,10 @@ import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import org.testng.annotations.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Provides;
/**
* Tests behavior of {@code CatalogHandler}
@ -52,149 +49,100 @@ public class CatalogItemHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/catalog.xml");
injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@CatalogItemRoot
String provide() {
return "https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem";
}
});
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(
is);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1");
assert result.getDescription() == null;
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
assertEquals(result.getId(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
assertEquals(result.get("CentOS 5.3 (32-bit)"), new NamedResourceImpl(5 + "",
"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 NamedResourceImpl(6 + "",
"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 NamedResourceImpl(7 + "",
"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 NamedResourceImpl(8 + "",
"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 NamedResourceImpl(11 + "",
"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 NamedResourceImpl(12 + "",
"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 NamedResourceImpl(9 + "",
"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 NamedResourceImpl(10 + "",
"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 NamedResourceImpl(1 + "",
"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 NamedResourceImpl(2 + "",
"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 NamedResourceImpl(3 + "",
"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 NamedResourceImpl(4 + "",
"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 NamedResourceImpl(
23 + "",
"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("CentOS 5.3 (32-bit)"), new NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl("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 NamedResourceImpl(
"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 NamedResourceImpl(
"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 NamedResourceImpl(
"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 NamedResourceImpl(
"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 NamedResourceImpl(
"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 NamedResourceImpl(
13 + "", "Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
"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 NamedResourceImpl(
15 + "", "Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
"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 NamedResourceImpl(
16 + "", "Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
"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 NamedResourceImpl(
17 + "", "Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
"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 NamedResourceImpl(
18 + "", "Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
"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 NamedResourceImpl(
19 + "", "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 NamedResourceImpl(
14 + "",
"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 NamedResourceImpl(20 + "",
"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 NamedResourceImpl(21 + "",
"Windows Web Server 2008 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
"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 NamedResourceImpl(
"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 NamedResourceImpl(
"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 NamedResourceImpl(
"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 NamedResourceImpl(
22 + "", "Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
"Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
}
public void testHosting() {
InputStream is = getClass().getResourceAsStream("/catalog-hosting.xml");
injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@CatalogItemRoot
String provide() {
return "https://vcloud.safesecureweb.com/api/v0.8/catalogItem";
}
});
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(
is);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
assertEquals(result.getName(), "HMSCatalog");
assertEquals(result.getDescription(), "HMS Shared Catalog");
assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
assertEquals(result.get("Plesk (Linux) 64-bit Template"), new NamedResourceImpl(1 + "",
"Plesk (Linux) 64-bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Plesk (Linux) 64-bit Template"), new NamedResourceImpl("Plesk (Linux) 64-bit Template",
CATALOGITEM_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Windows 2008 Datacenter 64 Bit Template"), new NamedResourceImpl(
2 + "", "Windows 2008 Datacenter 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2")));
"Windows 2008 Datacenter 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2")));
assertEquals(result.get("Cent OS 64 Bit Template"), new NamedResourceImpl(3 + "",
"Cent OS 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("Cent OS 64 Bit Template"), new NamedResourceImpl("Cent OS 64 Bit Template",
CATALOGITEM_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("cPanel (Linux) 64 Bit Template"), new NamedResourceImpl(4 + "",
"cPanel (Linux) 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4")));
assertEquals(result.get("cPanel (Linux) 64 Bit Template"), new NamedResourceImpl(
"cPanel (Linux) 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4")));
}
}

View File

@ -55,33 +55,22 @@ public class NetworkHandlerTest {
InputStream is = getClass().getResourceAsStream("/network-terremark.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Network result = factory.create(
injector.getInstance(NetworkHandler.class)).parse(is);
assertEquals(
result,
new NetworkImpl(
"1708",
"10.114.34.128/26",
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"),
null, ImmutableSet.<String> of(), "10.114.34.129",
"255.255.255.192", ImmutableSet
.<String> of(FenceMode.ISOLATED), null, ImmutableSet
.<NatRule> of(), ImmutableSet.<FirewallRule> of()));
Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
assertEquals(result, new NetworkImpl("10.114.34.128/26", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"), null, ImmutableSet
.<String> of(), "10.114.34.129", "255.255.255.192", ImmutableSet.<String> of(FenceMode.ISOLATED), null,
ImmutableSet.<NatRule> of(), ImmutableSet.<FirewallRule> of()));
}
public void testHosting() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/network-hosting.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Network result = (Network) factory.create(
injector.getInstance(NetworkHandler.class)).parse(is);
assertEquals(result, new NetworkImpl("1183", "188849 trust", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/network/1183"),
"188849 trust", ImmutableSet.<String> of("76.12.32.110",
"208.112.89.187"), "204.12.53.89", "255.255.255.248",
ImmutableSet.<String> of(), null, ImmutableSet.<NatRule> of(),
ImmutableSet.<FirewallRule> of()));
Network result = (Network) factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
assertEquals(result, new NetworkImpl("188849 trust", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/network/1183"), "188849 trust", ImmutableSet
.<String> of("76.12.32.110", "208.112.89.187"), "204.12.53.89", "255.255.255.248", ImmutableSet
.<String> of(), null, ImmutableSet.<NatRule> of(), ImmutableSet.<FirewallRule> of()));
}
}

View File

@ -26,22 +26,17 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.net.URI;
import javax.inject.Singleton;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Provides;
/**
* Tests behavior of {@code OrgHandler}
@ -54,82 +49,37 @@ public class OrgHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/org.xml");
Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Singleton
@VCloudApi
URI provide() {
return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
}
});
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class))
.parse(is);
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
assertEquals(result.getName(), "adrian@jclouds.org");
assertEquals(result.getId(), 48 + "");
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog",new NamedResourceImpl("catalog",
"Miami Environment 1 Catalog", CATALOG_XML,
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))));
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog", new NamedResourceImpl(
"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 NamedResourceImpl(
"32", "Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
assertEquals(
result.getTasksLists(),
ImmutableMap
.of(
"Miami Environment 1 Tasks List",
new NamedResourceImpl(
"32",
"Miami Environment 1 Tasks List",
TASKSLIST_XML,
URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32"))));
"Miami Environment 1", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
assertEquals(result.getTasksLists(), ImmutableMap.of("Miami Environment 1 Tasks List", new NamedResourceImpl(
"Miami Environment 1 Tasks List", TASKSLIST_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32"))));
}
public void testHosting() {
InputStream is = getClass().getResourceAsStream("/org-hosting.xml");
Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Singleton
@VCloudApi
URI provide() {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8");
}
});
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class))
.parse(is);
Organization result = (Organization) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
assertEquals(result.getName(), "Customer 188849");
assertEquals(result.getId(), 188849 + "");
assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
assertEquals(result.getCatalogs(), ImmutableMap.of( "HMS Shared Catalog", new NamedResourceImpl("1", "HMS Shared Catalog",
CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter",
new NamedResourceImpl("188849", "188849 Virtual DataCenter",
VCloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
assertEquals(result.getCatalogs(), ImmutableMap.of("HMS Shared Catalog", new NamedResourceImpl(
"HMS Shared Catalog", CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", new NamedResourceImpl(
"188849 Virtual DataCenter", VCloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List",
new NamedResourceImpl("188849", "188849 Task List", TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"))));
new NamedResourceImpl("188849 Task List", TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"))));
}
}

View File

@ -29,7 +29,6 @@ import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@ -42,19 +41,11 @@ import com.google.common.collect.ImmutableMap;
@Test(groups = "unit", testName = "vcloud.OrgListHandlerTest")
public class OrgListHandlerTest extends BaseHandlerTest {
@BeforeTest
@Override
protected void setUpInjector() {
super.setUpInjector();
}
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/orglist.xml");
Map<String, NamedResource> result = factory.create(injector.getInstance(OrgListHandler.class))
.parse(is);
assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl("48",
"adrian@jclouds.org", VCloudMediaType.ORG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
Map<String, NamedResource> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new NamedResourceImpl("adrian@jclouds.org",
VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}
}

View File

@ -57,16 +57,14 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl("3299", 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"), null,
new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
Task expects = new TaskImpl(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"), null, new NamedResourceImpl("VDC Name",
VCloudMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
), null
), null
);
assertEquals(result, expects);
@ -84,9 +82,8 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl("d188849-78", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
TaskStatus.QUEUED, null, null, null, null, null, null);
Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
TaskStatus.QUEUED, null, null, null, null, null, null);
assertEquals(result, expects);
}
@ -96,15 +93,13 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl("97806", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), TaskStatus.SUCCESS,
dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
.iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
.iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"),
TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
.iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
.iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
new NamedResourceImpl("188849-96", "188849-96", VCloudMediaType.VAPP_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null,
null);
new NamedResourceImpl("188849-96", VCloudMediaType.VAPP_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null, null);
assertEquals(result, expects);
}
@ -113,15 +108,13 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl("23", URI.create("http://10.150.4.49/api/v0.8/task/23"),
TaskStatus.ERROR, dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null,
new NamedResourceImpl("1", "APIOrg", VCloudMediaType.ORG_XML, URI
.create("http://10.150.4.49/api/v0.8/org/1")), new NamedResourceImpl("1",
"testapp1", VCloudMediaType.VAPP_XML, URI
.create("http://10.150.4.49/api/v0.8/vapp/1")),
new TaskImpl.ErrorImpl("Error processing job", "500",
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00"));
Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), TaskStatus.ERROR, dateService
.iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService
.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new NamedResourceImpl("APIOrg",
VCloudMediaType.ORG_XML, URI.create("http://10.150.4.49/api/v0.8/org/1")), new NamedResourceImpl(
"testapp1", VCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")),
new TaskImpl.ErrorImpl("Error processing job", "500",
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00"));
assertEquals(result, expects);
}

View File

@ -35,7 +35,6 @@ 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;
/**
@ -60,53 +59,29 @@ 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"));
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
Task task1 = new TaskImpl(
"3300",
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"),
null,
new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")),
null);
Task task2 = new TaskImpl(
"3299",
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"),
null,
new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")),
null);
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"),
null, new NamedResourceImpl("VDC Name", VCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), new NamedResourceImpl(
"Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
Task task2 = new TaskImpl(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"), null, new NamedResourceImpl("VDC Name",
VCloudMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("Server1", VCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
assertEquals(
result.getTasksByResult(),
ImmutableListMultimap
.of(
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));
}
public void testApplyInputStreamHosting() {
InputStream is = getClass().getResourceAsStream("/taskslist-hosting.xml");
TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"));
assertEquals(result.getLocation(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"));
}

View File

@ -54,31 +54,25 @@ public class VAppHandlerTest extends BaseHandlerTest {
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of(
"Network 1", "204.12.11.167");
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Network 1",
"204.12.11.167");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
"hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size",
ResourceType.MEMORY, null, null, null, null, null, null, 512,
"byte * 2^20")).add(
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 512, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
null, 1, null)).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
null, "20971520", null, 0, 3, null, 20971520, "byte * 2^20"))
.build();
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3, null,
20971520, "byte * 2^20")).build();
VApp expects = new VAppImpl("188849-96", "188849-96", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"), VAppStatus.OFF,
new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
VApp expects = new VAppImpl("188849-96", URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"),
VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
assertEquals(result, expects);
}
@ -88,11 +82,10 @@ public class VAppHandlerTest extends BaseHandlerTest {
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
VApp expects = new VAppImpl("10", "centos53", URI
.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.RESOLVED, 123456789l,
new NamedResourceImpl("4", null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap
.<String, String> of(), null, null, ImmutableSet.<ResourceAllocation> of());
VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.RESOLVED,
123456789l, new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap.<String, String> of(), null,
null, ImmutableSet.<ResourceAllocation> of());
assertEquals(result, expects);
}
@ -101,39 +94,30 @@ public class VAppHandlerTest extends BaseHandlerTest {
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of(
"Public Network", "10.150.4.93");
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
"10.150.4.93");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "centos53", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
"hertz * 10^6"),
new ResourceAllocation(2, "16MB of memory", "Memory Size",
ResourceType.MEMORY, null, null, null, null, null, null, 16,
"byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1",
"PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null,
true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
null, "104857", null, 0, 3, null, 104857, "byte * 2^20")).build();
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "16MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 16, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1", "PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null, true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "104857", null, 0, 3, null,
104857, "byte * 2^20")).build();
VApp expects = new VAppImpl("10", "centos53", URI
.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.ON, new Long(104857),
new NamedResourceImpl("4", null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses,
"Other Linux (32-bit)", system, resourceAllocations);
VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.ON,
new Long(104857), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses, "Other Linux (32-bit)", system,
resourceAllocations);
assertEquals(result.getId(), expects.getId());
assertEquals(result.getLocation(), expects.getLocation());
assertEquals(result.getName(), expects.getName());
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
assertEquals(result.getResourceAllocationByType(), expects.getResourceAllocationByType());
assertEquals(result.getResourceAllocations(), expects.getResourceAllocations());
assertEquals(result.getSize(), expects.getSize());
assertEquals(result.getStatus(), expects.getStatus());
@ -147,41 +131,30 @@ public class VAppHandlerTest extends BaseHandlerTest {
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of(
"Public Network", "10.23.119.221");
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
"10.23.119.221");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "m1", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
"hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size",
ResourceType.MEMORY, null, null, null, null, null, null, 512,
"byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1",
"PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null,
true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
null, "10485760", null, 0, 3, null, 10485760, "byte * 2^20"))
.build();
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> naturalOrder().add(
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null,
null, null, null, null, 1, "hertz * 10^6"),
new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null,
null, null, 512, "byte * 2^20")).add(
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic",
null, 0, null, null, null, 1, null)).add(
new ResourceAllocation(8, "Network Adapter 1", "PCNet32 ethernet adapter on \"Internal\" network",
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null, true, 1, null)).add(
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "10485760", null, 0, 3, null,
10485760, "byte * 2^20")).build();
VApp expects = new VAppImpl("80", "m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"),
VAppStatus.ON, new Long(10485760), new NamedResourceImpl("28", null,
"application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://localhost:8000/api/v0.8/vdc/28")),
networkToAddresses, "Microsoft Windows XP Professional (32-bit)", system,
resourceAllocations);
VApp expects = new VAppImpl("m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"), VAppStatus.ON, new Long(
10485760), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses,
"Microsoft Windows XP Professional (32-bit)", system, resourceAllocations);
assertEquals(result.getId(), expects.getId());
assertEquals(result.getLocation(), expects.getLocation());
assertEquals(result.getName(), expects.getName());
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
assertEquals(result.getResourceAllocationByType(), expects.getResourceAllocationByType());
assertEquals(result.getResourceAllocations(), expects.getResourceAllocations());
assertEquals(result.getSize(), expects.getSize());
assertEquals(result.getStatus(), expects.getStatus());

View File

@ -51,21 +51,19 @@ public class VAppTemplateHandlerTest {
InputStream is = getClass().getResourceAsStream("/vAppTemplate-trmk.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(
is);
assertEquals(result, new VAppTemplateImpl("5", "CentOS 5.3 (32-bit)", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/5"),
"description of CentOS 5.3 (32-bit)", null));
VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
assertEquals(result, new VAppTemplateImpl("CentOS 5.3 (32-bit)", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/5"),
"description of CentOS 5.3 (32-bit)", null));
}
public void testHosting() {
InputStream is = getClass().getResourceAsStream("/vAppTemplate-hosting.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
VAppTemplate result = (VAppTemplate) factory.create(
injector.getInstance(VAppTemplateHandler.class)).parse(is);
assertEquals(result, new VAppTemplateImpl("4", "cPanel (Linux) 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"),
"cPanel (Linux) 64 Bit", VAppStatus.RESOLVED));
VAppTemplate result = (VAppTemplate) factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
assertEquals(result, new VAppTemplateImpl("cPanel (Linux) 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"), "cPanel (Linux) 64 Bit",
VAppStatus.RESOLVED));
}
}

View File

@ -32,14 +32,11 @@ import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.endpoints.VCloudApi;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Provides;
/**
* Tests behavior of {@code VDCHandler}
@ -51,25 +48,11 @@ public class VDCHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/vdc.xml");
Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@VCloudApi
URI provide() {
return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
}
});
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1");
assertEquals(result.getLocation(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
assertEquals(result.getDescription(), null);
assertEquals(result.getStorageCapacity(), null);
assertEquals(result.getCpuCapacity(), null);
@ -77,99 +60,45 @@ public class VDCHandlerTest {
assertEquals(result.getInstantiatedVmsQuota(), null);
assertEquals(result.getDeployedVmsQuota(), null);
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedResource> of());
assertEquals(
result.getAvailableNetworks(),
ImmutableMap
.of(
"10.114.34.128/26",
new NamedResourceImpl(
"1708",
"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.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new NamedResourceImpl(
"10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
}
public void testApplyHosting() {
InputStream is = getClass().getResourceAsStream("/vdc-hosting.xml");
Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@VCloudApi
URI provide() {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8");
}
});
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
assertEquals(result.getName(), "vDC Name");
assertEquals(result.getLocation(), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"));
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"));
assertEquals(result.getDescription(), "vDC Name");
assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 0, 40960));
assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 0, 2400));
assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 10^9", 0, 2));
assertEquals(result.getInstantiatedVmsQuota(), new Quota(0, 2));
assertEquals(result.getDeployedVmsQuota(), new Quota(0, 2));
assertEquals(
result.getResourceEntities(),
new ImmutableMap.Builder<String, NamedResource>()
.put(
"Plesk (Linux) 64-bit Template",
new NamedResourceImpl(
"1",
"Plesk (Linux) 64-bit Template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1")))
.put(
assertEquals(result.getResourceEntities(), new ImmutableMap.Builder<String, NamedResource>().put(
"Plesk (Linux) 64-bit Template",
new NamedResourceImpl("Plesk (Linux) 64-bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1"))).put(
"Windows 2008 Datacenter 64 Bit Template",
new NamedResourceImpl(
"2",
"Windows 2008 Datacenter 64 Bit Template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")))
.put(
"Cent OS 64 Bit Template",
new NamedResourceImpl(
"3",
"Cent OS 64 Bit Template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3")))
.put(
"cPanel (Linux) 64 Bit Template",
new NamedResourceImpl(
"4",
"cPanel (Linux) 64 Bit Template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4")))
.put(
"188849-1",
new NamedResourceImpl(
"188849-1",
"188849-1",
"application/vnd.vmware.vcloud.vApp+xml",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")))
.put(
"188849-2",
new NamedResourceImpl(
"188849-2",
"188849-2",
"application/vnd.vmware.vcloud.vApp+xml",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2")))
.build());
"Windows 2008 Datacenter 64 Bit Template",
new NamedResourceImpl("Windows 2008 Datacenter 64 Bit Template",
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"))).put(
"Cent OS 64 Bit Template",
new NamedResourceImpl("Cent OS 64 Bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"))).put(
"cPanel (Linux) 64 Bit Template",
new NamedResourceImpl("cPanel (Linux) 64 Bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4"))).put(
"188849-1",
new NamedResourceImpl("188849-1", "application/vnd.vmware.vcloud.vApp+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1"))).put(
"188849-2",
new NamedResourceImpl("188849-2", "application/vnd.vmware.vcloud.vApp+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"))).build());
assertEquals(result.getAvailableNetworks(), ImmutableMap.<String, NamedResource> of());
}

View File

@ -28,7 +28,6 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.predicates.validators.DnsNameValidator;
@ -74,12 +73,10 @@ public interface HostingDotComVCloudAsyncClient extends VCloudAsyncClient {
@GET
@Consumes(VAPP_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vapp/{vAppId}")
@XMLResponseParser(HostingDotComVAppHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Override
ListenableFuture<? extends HostingDotComVApp> getVApp(@PathParam("vAppId") String appId);
ListenableFuture<? extends HostingDotComVApp> getVApp(@EndpointParam URI appId);
@POST
@Path("/action/instantiateVAppTemplate")

View File

@ -45,6 +45,6 @@ public interface HostingDotComVCloudClient extends VCloudClient {
@Override
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
HostingDotComVApp getVApp(String vAppId);
HostingDotComVApp getVApp(URI vAppId);
}

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.hostingdotcom.compute;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableMap;
public class HostingDotComVCloudComputeClient extends BaseVCloudComputeClient {
@Inject
protected HostingDotComVCloudComputeClient(VCloudClient client, Predicate<String> successTester,
protected HostingDotComVCloudComputeClient(VCloudClient client, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState);
}
@ -50,8 +51,8 @@ public class HostingDotComVCloudComputeClient extends BaseVCloudComputeClient {
@Override
protected Map<String, String> parseResponse(VAppTemplate template, VApp vAppResponse) {
HostingDotComVApp hVApp = HostingDotComVApp.class.cast(vAppResponse);
return ImmutableMap.<String, String> of("id", vAppResponse.getId(), "username", hVApp.getUsername(), "password",
hVApp.getPassword());
return ImmutableMap.<String, String> of("id", vAppResponse.getId().toASCIIString(), "username", hVApp
.getUsername(), "password", hVApp.getPassword());
}
}

View File

@ -45,12 +45,11 @@ public class HostingDotComVAppImpl extends VAppImpl implements HostingDotComVApp
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public HostingDotComVAppImpl(String id, String name, URI location, VAppStatus status, Long size,
NamedResource vDC, ListMultimap<String, String> networkToAddresses,
String operatingSystemDescription, VirtualSystem system,
Set<ResourceAllocation> resourceAllocations, String username, String password) {
super(id, name, location, status, size, vDC, networkToAddresses, operatingSystemDescription,
system, resourceAllocations);
public HostingDotComVAppImpl(String name, URI location, VAppStatus status, Long size, NamedResource vDC,
ListMultimap<String, String> networkToAddresses, String operatingSystemDescription, VirtualSystem system,
Set<ResourceAllocation> resourceAllocations, String username, String password) {
super(name, location, status, size, vDC, networkToAddresses, operatingSystemDescription, system,
resourceAllocations);
this.username = username;
this.password = password;

View File

@ -38,19 +38,17 @@ public class HostingDotComVAppHandler extends VAppHandler {
private String password;
@Inject
public HostingDotComVAppHandler(VirtualSystemHandler systemHandler,
ResourceAllocationHandler allocationHandler) {
public HostingDotComVAppHandler(VirtualSystemHandler systemHandler, ResourceAllocationHandler allocationHandler) {
super(systemHandler, allocationHandler);
}
public HostingDotComVApp getResult() {
return new HostingDotComVAppImpl(id, name, location, status, size, vDC, networkToAddresses,
operatingSystemDescription, system, allocations, username, password);
return new HostingDotComVAppImpl(name, location, status, size, vDC, networkToAddresses,
operatingSystemDescription, system, allocations, username, password);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
super.startElement(uri, localName, qName, attributes);
if (attributes.getIndex("key") != -1) {
String key = attributes.getValue(attributes.getIndex("key"));

View File

@ -48,15 +48,14 @@ public class HostingDotComVAppHandlerTest extends BaseHandlerTest {
InputStream is = getClass().getResourceAsStream("/hostingdotcom/instantiatevapp.xml");
HostingDotComVApp result = (HostingDotComVApp) factory.create(
injector.getInstance(HostingDotComVAppHandler.class)).parse(is);
injector.getInstance(HostingDotComVAppHandler.class)).parse(is);
HostingDotComVApp expects = new HostingDotComVAppImpl("188849-33", "188849-33", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-33"),
VAppStatus.RESOLVED, null, new NamedResourceImpl("188849", null,
"application/vnd.vmware.vcloud.vdc+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")),
ImmutableListMultimap.<String, String> of(), null, null, ImmutableSortedSet
.<ResourceAllocation> of(), "root", "meatisyummy");
HostingDotComVApp expects = new HostingDotComVAppImpl("188849-33", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-33"), VAppStatus.RESOLVED, null,
new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")), ImmutableListMultimap
.<String, String> of(), null, null, ImmutableSortedSet.<ResourceAllocation> of(), "root",
"meatisyummy");
assertEquals(result, expects);
}

View File

@ -23,16 +23,16 @@ import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERV
import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERVICE_XML;
import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.PUBLICIP_XML;
import java.net.URI;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.MapPayloadParam;
@ -45,6 +45,8 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.Protocol;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint;
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
@ -68,37 +70,34 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
* @see TerremarkVCloudExpressClient#getAllInternetServices
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/vdc/{vDCId}/internetServices")
@Consumes(INTERNETSERVICESLIST_XML)
@XMLResponseParser(InternetServicesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
@Override
ListenableFuture<? extends Set<InternetService>> getAllInternetServicesInVDC(@PathParam("vDCId") String vDCId);
ListenableFuture<? extends Set<InternetService>> getAllInternetServicesInVDC(
@EndpointParam(parser = VDCURIToInternetServicesEndpoint.class) URI vDCId);
/**
* @see TerremarkVCloudExpressClient#activatePublicIpInVDC
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/vdc/{vDCId}/publicIps")
@Consumes(PUBLICIP_XML)
@XMLResponseParser(PublicIpAddressesHandler.class)
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<PublicIpAddress> activatePublicIpInVDC(@PathParam("vDCId") String vDCId);
ListenableFuture<PublicIpAddress> activatePublicIpInVDC(
@EndpointParam(parser = VDCURIToPublicIPsEndpoint.class) URI vDCId);
/**
* @see TerremarkVCloudExpressClient#addInternetServiceToExistingIp
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/publicIp/{ipId}/internetServices")
@Path("/internetServices")
@Produces(INTERNETSERVICE_XML)
@Consumes(INTERNETSERVICE_XML)
@XMLResponseParser(InternetServiceHandler.class)
@MapBinder(AddInternetServiceOptions.class)
@Override
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@PathParam("ipId") int existingIpId,
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@EndpointParam URI existingIpId,
@MapPayloadParam("name") String serviceName, @MapPayloadParam("protocol") Protocol protocol,
@MapPayloadParam("port") int port, AddInternetServiceOptions... options);
@ -106,24 +105,21 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
* @see TerremarkVCloudExpressClient#getInternetServicesOnPublicIP
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/publicIp/{ipId}/internetServices")
@Path("/internetServices")
@Consumes(INTERNETSERVICESLIST_XML)
@XMLResponseParser(InternetServicesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
@Override
ListenableFuture<? extends Set<InternetService>> getInternetServicesOnPublicIp(@PathParam("ipId") int ipId);
ListenableFuture<? extends Set<InternetService>> getInternetServicesOnPublicIp(@EndpointParam URI ipId);
/**
* @see TerremarkVCloudExpressClient#getInternetService
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/internetService/{internetServiceId}")
@Consumes(INTERNETSERVICESLIST_XML)
@XMLResponseParser(InternetServiceHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Override
ListenableFuture<? extends InternetService> getInternetService(@PathParam("internetServiceId") int internetServiceId);
ListenableFuture<? extends InternetService> getInternetService(@EndpointParam URI internetServiceId);
}

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.terremark;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
@ -42,5 +43,5 @@ public interface TerremarkECloudClient extends TerremarkVCloudClient {
* @param vDCId
* @return
*/
PublicIpAddress activatePublicIpInVDC(String vDCId);
PublicIpAddress activatePublicIpInVDC(URI vDCId);
}

View File

@ -41,7 +41,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.predicates.validators.DnsNameValidator;
@ -50,7 +49,6 @@ import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.MapPayloadParam;
import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
@ -69,7 +67,6 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
import org.jclouds.vcloud.functions.VAppId;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.binders.BindNodeConfigurationToXmlPayload;
import org.jclouds.vcloud.terremark.binders.BindVAppConfigurationToXmlPayload;
@ -85,6 +82,8 @@ import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
import org.jclouds.vcloud.terremark.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.terremark.functions.ReturnVoidOnDeleteDefaultIp;
import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint;
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
import org.jclouds.vcloud.terremark.xml.CustomizationParametersHandler;
@ -114,6 +113,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
/**
* @see VCloudClient#getCatalogItemInOrg
*/
@Override
@GET
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(TerremarkCatalogItemHandler.class)
@ -133,6 +133,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends TerremarkCatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
@Override
@GET
@Deprecated
@Endpoint(Org.class)
@ -140,6 +141,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
@XMLResponseParser(TerremarkOrgHandler.class)
ListenableFuture<? extends TerremarkOrganization> getDefaultOrganization();
@Override
@GET
@XMLResponseParser(TerremarkOrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ -160,6 +162,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
/**
* @see TerremarkVCloudExpressClient#getDefaultVDC
*/
@Override
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@XMLResponseParser(TerremarkVDCHandler.class)
@ -169,14 +172,12 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
/**
* Terremark does not have multiple catalogs, so we ignore this parameter.
*/
@Deprecated
@GET
@Override
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
@XMLResponseParser(CatalogHandler.class)
@Consumes(CATALOG_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Catalog> getCatalog(String catalogId);
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
/**
* @see TerremarkVCloudExpressClient#getVDC
@ -203,6 +204,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
/**
* @see VCloudClient#instantiateVAppTemplateInVDC
*/
@Override
@POST
@Path("action/instantiateVAppTemplate")
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
@ -215,27 +217,25 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
InstantiateVAppTemplateOptions... options);
/**
* @see TerremarkVCloudExpressClient#getAllInternetServices
* @see TerremarkVCloudExpressClient#getAllInternetServicesInVDC
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/vdc/{vDCId}/internetServices")
@Consumes(INTERNETSERVICESLIST_XML)
@XMLResponseParser(InternetServicesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<InternetService>> getAllInternetServicesInVDC(@PathParam("vDCId") String vDCId);
ListenableFuture<? extends Set<InternetService>> getAllInternetServicesInVDC(
@EndpointParam(parser = VDCURIToInternetServicesEndpoint.class) URI vDCId);
/**
* @see TerremarkVCloudExpressClient#addInternetServiceToExistingIp
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/publicIp/{ipId}/internetServices")
@Path("/internetServices")
@Produces(INTERNETSERVICE_XML)
@Consumes(INTERNETSERVICE_XML)
@XMLResponseParser(InternetServiceHandler.class)
@MapBinder(AddInternetServiceOptions.class)
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@PathParam("ipId") int existingIpId,
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@EndpointParam URI publicIpId,
@MapPayloadParam("name") String serviceName, @MapPayloadParam("protocol") Protocol protocol,
@MapPayloadParam("port") int port, AddInternetServiceOptions... options);
@ -243,75 +243,65 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
* @see TerremarkVCloudExpressClient#deletePublicIp
*/
@DELETE
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/publicIp/{ipId}")
@ExceptionParser(ReturnVoidOnDeleteDefaultIp.class)
ListenableFuture<Void> deletePublicIp(@PathParam("ipId") int ipId);
ListenableFuture<Void> deletePublicIp(@EndpointParam URI ipId);
/**
* @see TerremarkVCloudExpressClient#getInternetServicesOnPublicIP
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/publicIp/{ipId}/internetServices")
@Path("/internetServices")
@Consumes(INTERNETSERVICESLIST_XML)
@XMLResponseParser(InternetServicesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<InternetService>> getInternetServicesOnPublicIp(@PathParam("ipId") int ipId);
ListenableFuture<? extends Set<InternetService>> getInternetServicesOnPublicIp(@EndpointParam URI ipId);
/**
* @see TerremarkVCloudExpressClient#getPublicIp
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/publicIp/{ipId}")
@Consumes(PUBLICIP_XML)
@XMLResponseParser(InternetServicesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<InternetService>> getPublicIp(@PathParam("ipId") int ipId);
ListenableFuture<? extends Set<InternetService>> getPublicIp(@EndpointParam URI ipId);
/**
* @see TerremarkVCloudExpressClient#getPublicIpsAssociatedWithVDC
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/vdc/{vDCId}/publicIps")
@Path("/publicIps")
@Consumes(PUBLICIPSLIST_XML)
@XMLResponseParser(PublicIpAddressesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<PublicIpAddress>> getPublicIpsAssociatedWithVDC(@PathParam("vDCId") String vDCId);
ListenableFuture<? extends Set<PublicIpAddress>> getPublicIpsAssociatedWithVDC(
@EndpointParam(parser = VDCURIToPublicIPsEndpoint.class) URI vDCId);
/**
* @see TerremarkVCloudExpressClient#deleteInternetService
*/
@DELETE
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/internetService/{internetServiceId}")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> deleteInternetService(@PathParam("internetServiceId") int internetServiceId);
ListenableFuture<Void> deleteInternetService(@EndpointParam URI internetServiceId);
/**
* @see TerremarkVCloudExpressClient#getInternetService
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/internetService/{internetServiceId}")
@Consumes(INTERNETSERVICESLIST_XML)
@XMLResponseParser(InternetServiceHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends InternetService> getInternetService(@PathParam("internetServiceId") int internetServiceId);
ListenableFuture<? extends InternetService> getInternetService(@EndpointParam URI internetServiceId);
/**
* @see TerremarkVCloudExpressClient#addNode
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/internetService/{internetServiceId}/nodeServices")
@Path("/nodeServices")
@Produces(NODESERVICE_XML)
@Consumes(NODESERVICE_XML)
@XMLResponseParser(NodeHandler.class)
@MapBinder(AddNodeOptions.class)
ListenableFuture<? extends Node> addNode(@PathParam("internetServiceId") int internetServiceId,
ListenableFuture<? extends Node> addNode(@EndpointParam URI internetServiceId,
@MapPayloadParam("ipAddress") String ipAddress, @MapPayloadParam("name") String name,
@MapPayloadParam("port") int port, AddNodeOptions... options);
@ -319,71 +309,49 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
* @see TerremarkVCloudExpressClient#getNodes
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/internetService/{internetServiceId}/nodeServices")
@Path("/nodeServices")
@XMLResponseParser(NodesHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
@Consumes(NODESERVICE_XML)
ListenableFuture<? extends Set<Node>> getNodes(@PathParam("internetServiceId") int internetServiceId);
ListenableFuture<? extends Set<Node>> getNodes(@EndpointParam URI internetServiceId);
/**
* @see TerremarkVCloudExpressClient#getNode
*/
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/nodeService/{nodeId}")
@XMLResponseParser(NodeHandler.class)
@Consumes(NODESERVICE_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Node> getNode(@PathParam("nodeId") int nodeId);
ListenableFuture<? extends Node> getNode(@EndpointParam URI nodeId);
/**
* @see TerremarkVCloudExpressClient#configureNode
*/
@PUT
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/nodeService/{nodeId}")
@Produces(NODESERVICE_XML)
@Consumes(NODESERVICE_XML)
@XMLResponseParser(NodeHandler.class)
@MapBinder(BindNodeConfigurationToXmlPayload.class)
ListenableFuture<? extends Node> configureNode(@PathParam("nodeId") int nodeId,
@MapPayloadParam("name") String name, @MapPayloadParam("enabled") boolean enabled,
@Nullable @MapPayloadParam("description") String description);
ListenableFuture<? extends Node> configureNode(@EndpointParam URI nodeId, @MapPayloadParam("name") String name,
@MapPayloadParam("enabled") boolean enabled, @Nullable @MapPayloadParam("description") String description);
/**
* @see TerremarkVCloudExpressClient#deleteNode
*/
@DELETE
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/nodeService/{nodeId}")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> deleteNode(@PathParam("nodeId") int nodeId);
ListenableFuture<Void> deleteNode(@EndpointParam URI nodeId);
/**
* @see TerremarkVCloudExpressClient#configureVApp
*/
@PUT
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vapp/{vAppId}")
@Produces(VAPP_XML)
@Consumes(VAPP_XML)
@MapBinder(BindVAppConfigurationToXmlPayload.class)
@ResponseParser(ParseTaskFromLocationHeader.class)
ListenableFuture<? extends Task> configureVApp(@PathParam("vAppId") @ParamParser(VAppId.class) VApp vApp,
VAppConfiguration configuration);
/**
* @see TerremarkVCloudClient#getCustomizationOptionsOfCatalogItem
*/
@Deprecated
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/template/{catalogItemId}/options/customization")
@XMLResponseParser(CustomizationParametersHandler.class)
@Consumes(CATALOGITEMCUSTOMIZATIONPARAMETERS_XML)
ListenableFuture<? extends CustomizationParameters> getCustomizationOptionsOfCatalogItem(
@PathParam("catalogItemId") String catalogItemId);
ListenableFuture<? extends Task> configureVApp(
@EndpointParam(parser = BindVAppConfigurationToXmlPayload.class) VApp vApp, VAppConfiguration configuration);
/**
* @see TerremarkVCloudClient#getCustomizationOptions

View File

@ -71,17 +71,14 @@ public interface TerremarkVCloudClient extends VCloudClient {
@Override
TerremarkOrganization findOrganizationNamed(String orgName);
@Deprecated
CustomizationParameters getCustomizationOptionsOfCatalogItem(String catalogItemId);
CustomizationParameters getCustomizationOptions(URI customizationOptions);
/**
* This call returns a list of public IP addresses.
*/
Set<PublicIpAddress> getPublicIpsAssociatedWithVDC(String vDCId);
Set<PublicIpAddress> getPublicIpsAssociatedWithVDC(URI vDCId);
void deletePublicIp(int ipId);
void deletePublicIp(URI ipId);
/**
* This call adds an internet service to a known, existing public IP. This
@ -89,21 +86,21 @@ public interface TerremarkVCloudClient extends VCloudClient {
* in the request.
*
*/
InternetService addInternetServiceToExistingIp(int existingIpId, String serviceName, Protocol protocol, int port,
InternetService addInternetServiceToExistingIp(URI existingIpId, String serviceName, Protocol protocol, int port,
AddInternetServiceOptions... options);
void deleteInternetService(int internetServiceId);
void deleteInternetService(URI internetServiceId);
InternetService getInternetService(int internetServiceId);
InternetService getInternetService(URI internetServiceId);
Set<InternetService> getAllInternetServicesInVDC(String vDCId);
Set<InternetService> getAllInternetServicesInVDC(URI vDCId);
/**
* This call returns information about the internet service on a public IP.
*/
Set<InternetService> getInternetServicesOnPublicIp(int ipId);
Set<InternetService> getInternetServicesOnPublicIp(URI ipId);
Set<InternetService> getPublicIp(int ipId);
Set<InternetService> getPublicIp(URI ipId);
/**
* This call adds a node to an existing internet service.
@ -120,15 +117,15 @@ public interface TerremarkVCloudClient extends VCloudClient {
* @param options
* @return
*/
Node addNode(int internetServiceId, String ipAddress, String name, int port, AddNodeOptions... options);
Node addNode(URI internetServiceId, String ipAddress, String name, int port, AddNodeOptions... options);
Node getNode(int nodeId);
Node getNode(URI nodeId);
Node configureNode(int nodeId, String name, boolean enabled, @Nullable String description);
Node configureNode(URI nodeId, String name, boolean enabled, @Nullable String description);
void deleteNode(int nodeId);
void deleteNode(URI nodeId);
Set<Node> getNodes(int internetServiceId);
Set<Node> getNodes(URI internetServiceId);
/**
* This call configures the settings of an existing vApp by passing the new
@ -146,7 +143,7 @@ public interface TerremarkVCloudClient extends VCloudClient {
* can increase the number of virtual CPUs and the amount of virtual memory
* in the same request.
*
* @param vApp
* @param VApp
* vApp to change in power state off
* @param configuration
* (s) to change

View File

@ -31,11 +31,8 @@ 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 javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder;
@ -50,7 +47,8 @@ import org.jclouds.vcloud.terremark.binders.BindCreateKeyToXmlPayload;
import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.KeyPair;
import org.jclouds.vcloud.terremark.domain.Protocol;
import org.jclouds.vcloud.terremark.functions.OrgNameToKeysListEndpoint;
import org.jclouds.vcloud.terremark.functions.OrgURIToKeysListEndpoint;
import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
import org.jclouds.vcloud.terremark.xml.KeyPairByNameHandler;
@ -73,25 +71,43 @@ public interface TerremarkVCloudExpressAsyncClient extends TerremarkVCloudAsyncC
* @see TerremarkVCloudExpressClient#addInternetServiceToVDC
*/
@POST
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/extensions/vdc/{vDCId}/internetServices")
@Produces(INTERNETSERVICE_XML)
@Consumes(INTERNETSERVICE_XML)
@XMLResponseParser(InternetServiceHandler.class)
@MapBinder(AddInternetServiceOptions.class)
ListenableFuture<? extends InternetService> addInternetServiceToVDC(@PathParam("vDCId") String vDCId,
ListenableFuture<? extends InternetService> addInternetServiceToVDC(
@EndpointParam(parser = VDCURIToInternetServicesEndpoint.class) URI vDCId,
@MapPayloadParam("name") String serviceName, @MapPayloadParam("protocol") Protocol protocol,
@MapPayloadParam("port") int port, AddInternetServiceOptions... options);
/**
* @see TerremarkVCloudExpressClient#listKeyPairsInOrg
* @see TerremarkVCloudExpressClient#findKeyPairInOrgNamed
*/
@GET
@XMLResponseParser(KeyPairByNameHandler.class)
@Consumes(KEYSLIST_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends KeyPair> findKeyPairInOrg(
@Nullable @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, String keyName);
/**
* @see TerremarkVCloudExpressClient#listKeyPairsInOrgNamed
*/
@GET
@Consumes(KEYSLIST_XML)
@XMLResponseParser(KeyPairsHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<KeyPair>> listKeyPairsInOrg(
@Nullable @EndpointParam(parser = OrgNameToKeysListEndpoint.class) String orgName);
@Nullable @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org);
/**
* @see TerremarkVCloudExpressClient#listKeyPairs
*/
@GET
@Consumes(KEYSLIST_XML)
@XMLResponseParser(KeyPairsHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<KeyPair>> listKeyPairs(@EndpointParam URI keysList);
/**
* @see TerremarkVCloudExpressClient#generateKeyPairInOrg
@ -102,8 +118,8 @@ public interface TerremarkVCloudExpressAsyncClient extends TerremarkVCloudAsyncC
@XMLResponseParser(KeyPairHandler.class)
@MapBinder(BindCreateKeyToXmlPayload.class)
ListenableFuture<? extends KeyPair> generateKeyPairInOrg(
@Nullable @EndpointParam(parser = OrgNameToKeysListEndpoint.class) String orgName,
@MapPayloadParam("name") String name, @MapPayloadParam("isDefault") boolean makeDefault);
@EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, @MapPayloadParam("name") String name,
@MapPayloadParam("isDefault") boolean makeDefault);
/**
* @see TerremarkVCloudExpressClient#getKeyPair
@ -114,16 +130,6 @@ public interface TerremarkVCloudExpressAsyncClient extends TerremarkVCloudAsyncC
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends KeyPair> getKeyPair(@EndpointParam URI keyId);
/**
* @see TerremarkVCloudExpressClient#getKeyPairInOrg
*/
@GET
@XMLResponseParser(KeyPairByNameHandler.class)
@Consumes(KEYSLIST_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends KeyPair> getKeyPairInOrg(
@Nullable @EndpointParam(parser = OrgNameToKeysListEndpoint.class) String orgName, String keyName);
// TODO
// /**
// * @see TerremarkVCloudClient#configureKeyPair

View File

@ -23,10 +23,7 @@ import java.net.URI;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.KeyPair;
import org.jclouds.vcloud.terremark.domain.Protocol;
@ -44,30 +41,19 @@ import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
public interface TerremarkVCloudExpressClient extends TerremarkVCloudClient {
/**
* @param orgName
* null if use the default org
* @throws ResourceNotFoundException
* if the orgName is not a valid organization
*/
Set<KeyPair> listKeyPairsInOrg(@Nullable String orgName);
Set<KeyPair> listKeyPairsInOrg(URI org);
/**
* @param orgName
* null if use the default org
* @throws ResourceNotFoundException
* if the orgName is not a valid organization
* @throws IllegalStateException
* if a key of the same name already exists
*/
KeyPair generateKeyPairInOrg(@Nullable String orgName, String name, boolean makeDefault);
KeyPair generateKeyPairInOrg(URI org, String name, boolean makeDefault);
/**
* @param orgName
* null if use the default org
* @throws ResourceNotFoundException
* if the orgName is not a valid organization
*/
KeyPair getKeyPairInOrg(@Nullable String orgName, String keyPairName);
KeyPair findKeyPairInOrg(URI org, String keyPairName);
KeyPair getKeyPair(URI keyPair);
@ -77,6 +63,6 @@ public interface TerremarkVCloudExpressClient extends TerremarkVCloudClient {
void deleteKeyPair(URI keyPair);
InternetService addInternetServiceToVDC(String vDCId, String serviceName, Protocol protocol, int port,
InternetService addInternetServiceToVDC(URI vDCId, String serviceName, Protocol protocol, int port,
AddInternetServiceOptions... options);
}

View File

@ -22,9 +22,13 @@ package org.jclouds.vcloud.terremark.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
@ -44,7 +48,7 @@ import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
import com.google.common.collect.Iterables;
import com.google.common.base.Function;
import com.google.inject.Inject;
import com.jamesmurty.utils.XMLBuilder;
@ -54,7 +58,7 @@ import com.jamesmurty.utils.XMLBuilder;
*
*/
@Singleton
public class BindVAppConfigurationToXmlPayload implements MapBinder {
public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Object, URI> {
private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
@ -64,8 +68,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder {
@Inject
public BindVAppConfigurationToXmlPayload(BindToStringPayload stringBinder,
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
this.ns = ns;
this.schema = schema;
this.stringBinder = stringBinder;
@ -74,7 +77,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder {
@SuppressWarnings("unchecked")
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
"this binder is only valid for GeneratedHttpRequests!");
"this binder is only valid for GeneratedHttpRequests!");
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
@ -94,16 +97,14 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder {
}
protected String generateXml(VApp vApp, VAppConfiguration configuration)
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
protected String generateXml(VApp vApp, VAppConfiguration configuration) throws ParserConfigurationException,
FactoryConfigurationError, TransformerException {
String name = configuration.getName() != null ? configuration.getName() : vApp.getName();
XMLBuilder rootBuilder = buildRoot(vApp, name);
XMLBuilder sectionBuilder = rootBuilder.e("Section").a("xsi:type",
"VirtualHardwareSection_Type").a("xmlns",
"http://schemas.dmtf.org/ovf/envelope/1").a("xmlns:q2",
"http://www.vmware.com/vcloud/v1");
XMLBuilder sectionBuilder = rootBuilder.e("Section").a("xsi:type", "VirtualHardwareSection_Type").a("xmlns",
"http://schemas.dmtf.org/ovf/envelope/1").a("xmlns:q2", "http://www.vmware.com/vcloud/v1");
sectionBuilder.e("Info").t("Virtual Hardware");
addProcessorItem(sectionBuilder, vApp, configuration);
@ -115,40 +116,32 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder {
return rootBuilder.asString(outputProperties);
}
private void addProcessorItem(XMLBuilder sectionBuilder, VApp vApp,
VAppConfiguration configuration) {
ResourceAllocation cpu = Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(
ResourceType.PROCESSOR));
long quantity = configuration.getProcessorCount() != null ? configuration.getProcessorCount()
: cpu.getVirtualQuantity();
private void addProcessorItem(XMLBuilder sectionBuilder, VApp vApp, VAppConfiguration configuration) {
ResourceAllocation cpu = find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR));
long quantity = configuration.getProcessorCount() != null ? configuration.getProcessorCount() : cpu
.getVirtualQuantity();
addResourceWithQuantity(sectionBuilder, cpu, quantity);
}
private void addMemoryItem(XMLBuilder sectionBuilder, VApp vApp,
VAppConfiguration configuration) {
ResourceAllocation memory = Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(
ResourceType.MEMORY));
long quantity = configuration.getMemory() != null ? configuration.getMemory() : memory
.getVirtualQuantity();
private void addMemoryItem(XMLBuilder sectionBuilder, VApp vApp, VAppConfiguration configuration) {
ResourceAllocation memory = find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY));
long quantity = configuration.getMemory() != null ? configuration.getMemory() : memory.getVirtualQuantity();
addResourceWithQuantity(sectionBuilder, memory, quantity);
}
private void addDiskItems(XMLBuilder sectionBuilder, VApp vApp,
VAppConfiguration configuration) {
for (ResourceAllocation disk : vApp.getResourceAllocationByType()
.get(ResourceType.DISK_DRIVE)) {
private void addDiskItems(XMLBuilder sectionBuilder, VApp vApp, VAppConfiguration configuration) {
for (ResourceAllocation disk : filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))) {
if (!configuration.getDisksToDelete().contains(disk.getAddressOnParent()))
addDiskWithQuantity(sectionBuilder, disk);
}
for (Long quantity : configuration.getDisks()) {
ResourceAllocation disk = new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE,
null, "1048576", null, -1, null, null, quantity, null);
ResourceAllocation disk = new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576",
null, -1, null, null, quantity, null);
addDiskWithQuantity(sectionBuilder, disk);
}
}
private XMLBuilder addResourceWithQuantity(XMLBuilder sectionBuilder,
ResourceAllocation resource, long quantity) {
private XMLBuilder addResourceWithQuantity(XMLBuilder sectionBuilder, ResourceAllocation resource, long quantity) {
XMLBuilder itemBuilder = sectionBuilder.e("Item");
addCommonElements(itemBuilder, resource, quantity);
return itemBuilder;
@ -156,26 +149,23 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder {
private void addCommonElements(XMLBuilder itemBuilder, ResourceAllocation resource, long quantity) {
itemBuilder.e("InstanceID").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getId() + "");
itemBuilder.e("ResourceType").a("xmlns", RESOURCE_ALLOCATION_NS)
.t(resource.getType().value());
itemBuilder.e("ResourceType").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getType().value());
itemBuilder.e("VirtualQuantity").a("xmlns", RESOURCE_ALLOCATION_NS).t(quantity + "");
}
private XMLBuilder addDiskWithQuantity(XMLBuilder sectionBuilder, ResourceAllocation disk) {
XMLBuilder itemBuilder = sectionBuilder.e("Item");
itemBuilder.e("AddressOnParent").a("xmlns", RESOURCE_ALLOCATION_NS).t(
disk.getAddressOnParent() + "");
itemBuilder.e("AddressOnParent").a("xmlns", RESOURCE_ALLOCATION_NS).t(disk.getAddressOnParent() + "");
itemBuilder.e("HostResource").a("xmlns", RESOURCE_ALLOCATION_NS).t(disk.getHostResource());
addCommonElements(itemBuilder, disk, disk.getVirtualQuantity());
return itemBuilder;
}
protected XMLBuilder buildRoot(VApp vApp, String name)
throws ParserConfigurationException, FactoryConfigurationError {
XMLBuilder rootBuilder = XMLBuilder.create("VApp").a("type", vApp.getType()).a("name", name)
.a("status", vApp.getStatus().value()).a("size", vApp.getSize()+"").a(
"xmlns", ns).a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a(
"xsi:schemaLocation", ns + " " + schema);
protected XMLBuilder buildRoot(VApp vApp, String name) throws ParserConfigurationException,
FactoryConfigurationError {
XMLBuilder rootBuilder = XMLBuilder.create("VApp").a("type", vApp.getType()).a("name", name).a("status",
vApp.getStatus().value()).a("size", vApp.getSize() + "").a("xmlns", ns).a("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema);
return rootBuilder;
}
@ -210,4 +200,9 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder {
protected String ifNullDefaultTo(String value, String defaultValue) {
return value != null ? value : checkNotNull(defaultValue, "defaultValue");
}
@Override
public URI apply(Object from) {
return VApp.class.cast(checkNotNull(from, "from")).getId();
}
}

View File

@ -70,7 +70,7 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
@Inject
protected TerremarkVCloudComputeClient(TerremarkVCloudExpressClient client,
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<String> successTester,
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState);
this.client = client;
@ -108,11 +108,11 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
response.put("password", password);
}
if (portsToOpen.length > 0)
createPublicAddressMappedToPorts(response.get("id"), portsToOpen);
createPublicAddressMappedToPorts(URI.create(response.get("id")), portsToOpen);
return response;
}
public String createPublicAddressMappedToPorts(String vAppId, int... ports) {
public String createPublicAddressMappedToPorts(URI vAppId, int... ports) {
VApp vApp = client.getVApp(vAppId);
PublicIpAddress ip = null;
String privateAddress = getLast(vApp.getNetworkToAddresses().values());
@ -141,28 +141,28 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
vApp.getName() + "-" + port,
protocol,
port,
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
.getName())));
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
vApp.getName())));
ip = is.getPublicIpAddress();
} else {
logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getName(), protocol, port);
ip = TerremarkECloudClient.class.cast(client).activatePublicIpInVDC(vApp.getVDC().getId());
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port,
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
.getName())));
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol,
port, withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp
.getName(), vApp.getName())));
}
} else {
logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port);
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port,
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), vApp
.getName())));
}
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getId(), is.getPublicIpAddress().getAddress(), is
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(), is
.getProtocol(), is.getPort());
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
privateAddress, port);
Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
logger.debug("<< added Node(%s)", node.getId());
logger.debug("<< added Node(%s)", node.getName());
}
return ip != null ? ip.getAddress() : null;
}
@ -173,16 +173,16 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
for (Node node : client.getNodes(service.getId())) {
if (vApp.getNetworkToAddresses().containsValue(node.getIpAddress())) {
ipAddresses.add(service.getPublicIpAddress());
logger.debug(">> deleting Node(%s) %s:%d -> %s:%d", node.getId(), service.getPublicIpAddress()
logger.debug(">> deleting Node(%s) %s:%d -> %s:%d", node.getName(), service.getPublicIpAddress()
.getAddress(), service.getPort(), node.getIpAddress(), node.getPort());
client.deleteNode(node.getId());
logger.debug("<< deleted Node(%s)", node.getId());
logger.debug("<< deleted Node(%s)", node.getName());
Set<Node> nodes = client.getNodes(service.getId());
if (nodes.size() == 0) {
logger.debug(">> deleting InternetService(%s) %s:%d", service.getId(), service.getPublicIpAddress()
logger.debug(">> deleting InternetService(%s) %s:%d", service.getName(), service.getPublicIpAddress()
.getAddress(), service.getPort());
client.deleteInternetService(service.getId());
logger.debug("<< deleted InternetService(%s)", service.getId());
logger.debug("<< deleted InternetService(%s)", service.getName());
continue SERVICE;
}
}
@ -210,7 +210,7 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
* not support the command.
*/
@Override
public void stop(String id) {
public void stop(URI id) {
VApp vApp = client.getVApp(id);
Set<PublicIpAddress> ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp);
deletePublicIpAddressesWithNoServicesAttached(ipAddresses);
@ -218,27 +218,27 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
try {
powerOffAndWait(vApp);
} catch (IllegalStateException e) {
logger.warn("<< %s vApp(%s)", e.getMessage(), vApp.getId());
logger.warn("<< %s vApp(%s)", e.getMessage(), vApp.getName());
blockOnLastTask(vApp);
powerOffAndWait(vApp);
}
vApp = client.getVApp(id);
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getId());
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
}
logger.debug(">> deleting vApp(%s)", vApp.getId());
logger.debug(">> deleting vApp(%s)", vApp.getName());
client.deleteVApp(id);
logger.debug("<< deleted vApp(%s))", vApp.getId());
logger.debug("<< deleted vApp(%s))", vApp.getName());
}
private void powerOffAndWait(VApp vApp) {
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getId(), vApp.getStatus());
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
Task task = client.powerOffVApp(vApp.getId());
if (!taskTester.apply(task.getId()))
if (!taskTester.apply(task.getLocation()))
throw new TaskException("powerOff", vApp, task);
}
void blockOnLastTask(VApp vApp) {
TasksList list = client.getDefaultTasksList();
TasksList list = client.getTasksList(vApp.getVDC());
try {
Task lastTask = getLast(filter(list.getTasks(), new Predicate<Task>() {
@ -248,7 +248,7 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
}
}));
if (!taskTester.apply(lastTask.getId()))
if (!taskTester.apply(lastTask.getLocation()))
throw new TaskException("powerOff", vApp, lastTask);
} catch (NoSuchElementException ex) {
@ -259,7 +259,7 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
* @returns empty set if the node is not found
*/
@Override
public Set<String> getPrivateAddresses(String id) {
public Set<String> getPrivateAddresses(URI id) {
VApp vApp = client.getVApp(id);
if (vApp != null)
return Sets.newHashSet(vApp.getNetworkToAddresses().values());
@ -271,7 +271,7 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
* @returns empty set if the node is not found
*/
@Override
public Set<String> getPublicAddresses(String id) {
public Set<String> getPublicAddresses(URI id) {
VApp vApp = client.getVApp(id);
if (vApp != null) {
Set<String> ipAddresses = Sets.newHashSet();

View File

@ -43,11 +43,11 @@ import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
import org.jclouds.compute.util.ComputeUtils;
import org.jclouds.domain.Location;
import org.jclouds.vcloud.terremark.compute.domain.KeyPairCredentials;
import org.jclouds.vcloud.terremark.compute.domain.OrgAndName;
import org.jclouds.vcloud.terremark.compute.functions.NodeMetadataToOrgAndName;
import org.jclouds.vcloud.terremark.compute.options.TerremarkVCloudTemplateOptions;
import org.jclouds.vcloud.terremark.compute.strategy.CleanupOrphanKeys;
import org.jclouds.vcloud.terremark.domain.KeyPair;
import com.google.common.base.Predicate;
@ -59,29 +59,18 @@ public class TerremarkVCloudComputeService extends BaseComputeService {
private final CleanupOrphanKeys cleanupOrphanKeys;
@Inject
protected TerremarkVCloudComputeService(ComputeServiceContext context,
Provider<Set<? extends Image>> images,
Provider<Set<? extends Size>> sizes,
Provider<Set<? extends Location>> locations,
ListNodesStrategy listNodesStrategy,
GetNodeMetadataStrategy getNodeMetadataStrategy,
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy,
RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy,
Provider<TemplateBuilder> templateBuilderProvider,
Provider<TemplateOptions> templateOptionsProvider,
@Named("NODE_RUNNING") Predicate<NodeMetadata> nodeRunning,
@Named("NODE_TERMINATED") Predicate<NodeMetadata> nodeTerminated,
ComputeUtils utils,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
CleanupOrphanKeys cleanupOrphanKeys,
ConcurrentMap<OrgAndName, KeyPair> credentialsMap,
NodeMetadataToOrgAndName nodeToOrgAndName) {
super(context, images, sizes, locations, listNodesStrategy,
getNodeMetadataStrategy, runNodesAndAddToSetStrategy,
rebootNodeStrategy, destroyNodeStrategy, templateBuilderProvider,
templateOptionsProvider, nodeRunning, nodeTerminated, utils,
executor);
protected TerremarkVCloudComputeService(ComputeServiceContext context, Provider<Set<? extends Image>> images,
Provider<Set<? extends Size>> sizes, Provider<Set<? extends Location>> locations,
ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
RunNodesAndAddToSetStrategy runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
Provider<TemplateOptions> templateOptionsProvider, @Named("NODE_RUNNING") Predicate<NodeMetadata> nodeRunning,
@Named("NODE_TERMINATED") Predicate<NodeMetadata> nodeTerminated, ComputeUtils utils,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, CleanupOrphanKeys cleanupOrphanKeys,
ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap, NodeMetadataToOrgAndName nodeToOrgAndName) {
super(context, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy, runNodesAndAddToSetStrategy,
rebootNodeStrategy, destroyNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
nodeTerminated, utils, executor);
this.cleanupOrphanKeys = cleanupOrphanKeys;
}
@ -90,8 +79,7 @@ public class TerremarkVCloudComputeService extends BaseComputeService {
* clean implicit keypairs.
*/
@Override
public Set<? extends NodeMetadata> destroyNodesMatching(
Predicate<NodeMetadata> filter) {
public Set<? extends NodeMetadata> destroyNodesMatching(Predicate<NodeMetadata> filter) {
Set<? extends NodeMetadata> deadOnes = super.destroyNodesMatching(filter);
cleanupOrphanKeys.execute(deadOnes);
return deadOnes;

Some files were not shown because too many files have changed in this diff Show More