Issue 280: separated out VCloudExpress specific classes from the 1.0 stuff

This commit is contained in:
Adrian Cole 2010-08-19 16:04:11 -07:00
parent 0d06623dcf
commit 3657e066f4
136 changed files with 5255 additions and 1120 deletions

View File

@ -74,6 +74,9 @@ opscodeplatform.propertiesbuilder=org.jclouds.opscodeplatform.OpscodePlatformPro
vcloud.contextbuilder=org.jclouds.vcloud.VCloudContextBuilder
vcloud.propertiesbuilder=org.jclouds.vcloud.VCloudPropertiesBuilder
vcloudexpress.contextbuilder=org.jclouds.vcloud.VCloudExpressContextBuilder
vcloudexpress.propertiesbuilder=org.jclouds.vcloud.VCloudExpressPropertiesBuilder
eucalyptus.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder
eucalyptus.propertiesbuilder=org.jclouds.aws.ec2.EucalyptusPropertiesBuilder

View File

@ -25,8 +25,8 @@ import java.util.Properties;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.vcloud.VCloudContextBuilder;
import org.jclouds.vcloud.bluelock.compute.config.BlueLockVCloudExpressComputeServiceContextModule;
import org.jclouds.vcloud.bluelock.config.BlueLockVCloudExpressRestClientModule;
import org.jclouds.vcloud.bluelock.compute.config.BlueLockVCloudDirectorComputeServiceContextModule;
import org.jclouds.vcloud.bluelock.config.BlueLockVCloudDirectorRestClientModule;
import com.google.inject.Injector;
import com.google.inject.Module;
@ -52,12 +52,12 @@ public class BlueLockVCloudDirectorContextBuilder extends VCloudContextBuilder {
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new BlueLockVCloudExpressComputeServiceContextModule());
modules.add(new BlueLockVCloudDirectorComputeServiceContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new BlueLockVCloudExpressRestClientModule());
modules.add(new BlueLockVCloudDirectorRestClientModule());
}
}

View File

@ -19,9 +19,7 @@
package org.jclouds.vcloud.bluelock;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
import java.util.Properties;
@ -36,8 +34,6 @@ public class BlueLockVCloudDirectorPropertiesBuilder extends VCloudPropertiesBui
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, "1.0");
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1.0");
properties.setProperty(PROPERTY_ENDPOINT, "https://vcenterprise.bluelock.com/api");
return properties;
}

View File

@ -24,7 +24,7 @@ import java.util.Properties;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.vcloud.VCloudContextBuilder;
import org.jclouds.vcloud.VCloudExpressContextBuilder;
import org.jclouds.vcloud.bluelock.compute.config.BlueLockVCloudExpressComputeServiceContextModule;
import org.jclouds.vcloud.bluelock.config.BlueLockVCloudExpressRestClientModule;
@ -44,7 +44,7 @@ import com.google.inject.Module;
* @author Adrian Cole
* @see BlueLockVCloudComputeServiceContext
*/
public class BlueLockVCloudExpressContextBuilder extends VCloudContextBuilder {
public class BlueLockVCloudExpressContextBuilder extends VCloudExpressContextBuilder {
public BlueLockVCloudExpressContextBuilder(Properties props) {
super(props);

View File

@ -23,14 +23,14 @@ import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import java.util.Properties;
import org.jclouds.vcloud.VCloudPropertiesBuilder;
import org.jclouds.vcloud.VCloudExpressPropertiesBuilder;
/**
* Builds properties used in bluelock VCloud Clients
*
* @author Adrian Cole
*/
public class BlueLockVCloudExpressPropertiesBuilder extends VCloudPropertiesBuilder {
public class BlueLockVCloudExpressPropertiesBuilder extends VCloudExpressPropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();

View File

@ -0,0 +1,62 @@
/**
*
* 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.bluelock.compute;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.base.Predicate;
/**
* @author Adrian Cole
*/
@Singleton
public class BlueLockVCloudDirectorComputeClient extends BaseVCloudComputeClient {
private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
@Inject
protected BlueLockVCloudDirectorComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
VCloudClient client, Predicate<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState);
this.credentialsProvider = credentialsProvider;
}
@Override
protected Map<String, String> parseAndValidateResponse(VAppTemplate template, VApp vAppResponse) {
Credentials credentials = credentialsProvider.execute(template);
Map<String, String> toReturn = super.parseResponse(template, vAppResponse);
toReturn.put("username", credentials.identity);
toReturn.put("password", credentials.credential);
return toReturn;
}
}

View File

@ -28,8 +28,8 @@ import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.BaseVCloudExpressComputeClient;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VAppTemplate;
@ -40,12 +40,12 @@ import com.google.common.base.Predicate;
* @author Adrian Cole
*/
@Singleton
public class BlueLockVCloudExpressComputeClient extends BaseVCloudComputeClient {
public class BlueLockVCloudExpressComputeClient extends BaseVCloudExpressComputeClient {
private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
@Inject
protected BlueLockVCloudExpressComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
VCloudClient client, Predicate<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
VCloudExpressClient client, Predicate<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState);
this.credentialsProvider = credentialsProvider;
}

View File

@ -0,0 +1,57 @@
/**
*
* 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.bluelock.compute.config;
import java.util.Set;
import org.jclouds.compute.domain.Size;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.vcloud.bluelock.compute.BlueLockVCloudDirectorComputeClient;
import org.jclouds.vcloud.bluelock.compute.config.suppliers.ParseSizeFromImageSupplier;
import org.jclouds.vcloud.bluelock.compute.functions.BlueLockVCloudImageForVAppTemplate;
import org.jclouds.vcloud.bluelock.compute.strategy.DefaultLoginCredentialsFromBlueLockFAQ;
import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
import com.google.common.base.Supplier;
import com.google.inject.Injector;
/**
* Configures the {@link BlueLockVCloudComputeServiceContext}; requires
* {@link BlueLockVCloudComputeClient} bound.
*
* @author Adrian Cole
*/
public class BlueLockVCloudDirectorComputeServiceContextModule extends VCloudComputeServiceContextModule {
@Override
protected void configure() {
super.configure();
bind(ImageForVAppTemplate.class).to(BlueLockVCloudImageForVAppTemplate.class);
bind(VCloudComputeClient.class).to(BlueLockVCloudDirectorComputeClient.class);
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(DefaultLoginCredentialsFromBlueLockFAQ.class);
}
@Override
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
return injector.getInstance(ParseSizeFromImageSupplier.class);
}
}

View File

@ -25,10 +25,10 @@ import org.jclouds.compute.domain.Size;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.vcloud.bluelock.compute.BlueLockVCloudExpressComputeClient;
import org.jclouds.vcloud.bluelock.compute.config.suppliers.ParseSizeFromImageSupplier;
import org.jclouds.vcloud.bluelock.compute.functions.BlueLockVCloudExpressImageForVAppTemplate;
import org.jclouds.vcloud.bluelock.compute.functions.BlueLockVCloudImageForVAppTemplate;
import org.jclouds.vcloud.bluelock.compute.strategy.DefaultLoginCredentialsFromBlueLockFAQ;
import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule;
import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
import com.google.common.base.Supplier;
@ -40,13 +40,13 @@ import com.google.inject.Injector;
*
* @author Adrian Cole
*/
public class BlueLockVCloudExpressComputeServiceContextModule extends VCloudComputeServiceContextModule {
public class BlueLockVCloudExpressComputeServiceContextModule extends VCloudExpressComputeServiceContextModule {
@Override
protected void configure() {
super.configure();
bind(ImageForVAppTemplate.class).to(BlueLockVCloudExpressImageForVAppTemplate.class);
bind(VCloudComputeClient.class).to(BlueLockVCloudExpressComputeClient.class);
bind(ImageForVAppTemplate.class).to(BlueLockVCloudImageForVAppTemplate.class);
bind(VCloudExpressComputeClient.class).to(BlueLockVCloudExpressComputeClient.class);
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(DefaultLoginCredentialsFromBlueLockFAQ.class);
}

View File

@ -31,10 +31,10 @@ import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
* @author Adrian Cole
*/
@Singleton
public class BlueLockVCloudExpressImageForVAppTemplate extends ImageForVAppTemplate {
public class BlueLockVCloudImageForVAppTemplate extends ImageForVAppTemplate {
@Inject
protected BlueLockVCloudExpressImageForVAppTemplate(FindLocationForResource findLocationForResource,
protected BlueLockVCloudImageForVAppTemplate(FindLocationForResource findLocationForResource,
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) {
super(findLocationForResource, credentialsProvider);
}

View File

@ -0,0 +1,35 @@
/**
*
* 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.bluelock.config;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.vcloud.config.VCloudRestClientModule;
/**
* Configures the VCloud authentication service connection, including logging and http transport.
*
* @author Adrian Cole
*/
@RequiresHttp
@ConfiguresRestClient
public class BlueLockVCloudDirectorRestClientModule extends VCloudRestClientModule {
}

View File

@ -24,15 +24,13 @@ import static org.jclouds.Constants.PROPERTY_IDENTITY;
import java.net.URI;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import javax.inject.Named;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.config.VCloudRestClientModule;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
@ -40,18 +38,16 @@ 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
*/
@RequiresHttp
@ConfiguresRestClient
public class BlueLockVCloudExpressRestClientModule extends VCloudRestClientModule {
public class BlueLockVCloudExpressRestClientModule extends VCloudExpressRestClientModule {
@Override
protected URI provideDefaultNetwork(VCloudClient client) throws InterruptedException, ExecutionException,
TimeoutException {
protected URI provideDefaultNetwork(VCloudExpressClient client) {
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());

View File

@ -25,7 +25,7 @@ import java.util.Properties;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.VCloudClientLiveTest;
import org.jclouds.vcloud.VCloudExpressClientLiveTest;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@ -38,7 +38,7 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", sequential = true, testName = "vcloud.BlueLockVCloudClientLiveTest")
public class BlueLockVCloudExpressClientLiveTest extends VCloudClientLiveTest {
public class BlueLockVCloudExpressClientLiveTest extends VCloudExpressClientLiveTest {
@BeforeGroups(groups = { "live" })
@Override

View File

@ -34,7 +34,7 @@ import org.testng.annotations.Test;
*
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true, testName = "bluelock.BlueLockVCloudExpressComputeServiceLiveTest")
@Test(groups = "live", enabled = true, sequential = true, testName = "bluelock.BlueLockVCloudComputeServiceLiveTest")
public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
@Override
public void setServiceDefaults() {

View File

@ -26,7 +26,7 @@ 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.vcloud.compute.VCloudComputeServiceLiveTest;
import org.jclouds.vcloud.compute.VCloudExpressComputeServiceLiveTest;
import org.testng.annotations.Test;
/**
@ -35,7 +35,7 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true, testName = "bluelock.BlueLockVCloudExpressComputeServiceLiveTest")
public class BlueLockVCloudExpressComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
public class BlueLockVCloudExpressComputeServiceLiveTest extends VCloudExpressComputeServiceLiveTest {
@Override
public void setServiceDefaults() {
provider = "bluelock-vcloudexpress";

View File

@ -19,15 +19,15 @@
package org.jclouds.vcloud;
import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOGITEM_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.NETWORK_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.TASK_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VAPPTEMPLATE_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VAPP_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VDC_XML;
import java.net.URI;
@ -95,7 +95,7 @@ import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(SetVCloudTokenCookie.class)
public interface VCloudAsyncClient {
/**
* @see VCloudClient#getDefaultOrganization
* @see VCloudExpressClient#getDefaultOrganization
*/
@Deprecated
@GET
@ -105,7 +105,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Organization> getDefaultOrganization();
/**
* @see VCloudClient#getOrganization
* @see VCloudExpressClient#getOrganization
*/
@GET
@XMLResponseParser(OrgHandler.class)
@ -114,7 +114,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Organization> getOrganization(@EndpointParam URI orgId);
/**
* @see VCloudClient#getOrganizationNamed
* @see VCloudExpressClient#getOrganizationNamed
*/
@GET
@XMLResponseParser(OrgHandler.class)
@ -124,7 +124,7 @@ public interface VCloudAsyncClient {
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
/**
* @see VCloudClient#getDefaultCatalog
* @see VCloudExpressClient#getDefaultCatalog
*/
@Deprecated
@GET
@ -134,7 +134,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Catalog> getDefaultCatalog();
/**
* @see VCloudClient#getCatalog
* @see VCloudExpressClient#getCatalog
*/
@GET
@XMLResponseParser(CatalogHandler.class)
@ -143,7 +143,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
/**
* @see VCloudClient#findCatalogInOrgNamed
* @see VCloudExpressClient#findCatalogInOrgNamed
*/
@GET
@XMLResponseParser(CatalogHandler.class)
@ -154,7 +154,7 @@ public interface VCloudAsyncClient {
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
/**
* @see VCloudClient#getVAppTemplate
* @see VCloudExpressClient#getVAppTemplate
*/
@GET
@Consumes(VAPPTEMPLATE_XML)
@ -163,7 +163,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
/**
* @see VCloudClient#findVAppTemplateInOrgCatalogNameds
* @see VCloudExpressClient#findVAppTemplateInOrgCatalogNameds
*/
@GET
@Consumes(VAPPTEMPLATE_XML)
@ -175,7 +175,7 @@ public interface VCloudAsyncClient {
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
/**
* @see VCloudClient#getCatalogItem
* @see VCloudExpressClient#getCatalogItem
*/
@GET
@Consumes(CATALOGITEM_XML)
@ -184,7 +184,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
/**
* @see VCloudClient#getCatalogItemInOrg
* @see VCloudExpressClient#getCatalogItemInOrg
*/
@GET
@Consumes(CATALOGITEM_XML)
@ -196,7 +196,7 @@ public interface VCloudAsyncClient {
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
/**
* @see VCloudClient#findNetworkInOrgVDCNamed
* @see VCloudExpressClient#findNetworkInOrgVDCNamed
*/
@GET
@Consumes(NETWORK_XML)
@ -208,7 +208,7 @@ public interface VCloudAsyncClient {
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
/**
* @see VCloudClient#getNetwork
* @see VCloudExpressClient#getNetwork
*/
@GET
@Consumes(NETWORK_XML)
@ -217,7 +217,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Network> getNetwork(@EndpointParam URI network);
/**
* @see VCloudClient#getDefaultVDC
* @see VCloudExpressClient#getDefaultVDC
*/
@Deprecated
@GET
@ -227,7 +227,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends VDC> getDefaultVDC();
/**
* @see VCloudClient#getVDC(URI)
* @see VCloudExpressClient#getVDC(URI)
*/
@GET
@XMLResponseParser(VDCHandler.class)
@ -236,7 +236,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
/**
* @see VCloudClient#findVDCInOrgNamed(String, String)
* @see VCloudExpressClient#findVDCInOrgNamed(String, String)
*/
@GET
@XMLResponseParser(VDCHandler.class)
@ -247,7 +247,7 @@ public interface VCloudAsyncClient {
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
/**
* @see VCloudClient#getTasksList
* @see VCloudExpressClient#getTasksList
*/
@GET
@Consumes(TASKSLIST_XML)
@ -256,7 +256,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
/**
* @see VCloudClient#getTasksListInOrg
* @see VCloudExpressClient#getTasksListInOrg
*/
@GET
@Consumes(TASKSLIST_XML)
@ -267,7 +267,7 @@ public interface VCloudAsyncClient {
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName);
/**
* @see VCloudClient#getDefaultTasksList
* @see VCloudExpressClient#getDefaultTasksList
*/
@Deprecated
@GET
@ -277,7 +277,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends TasksList> getDefaultTasksList();
/**
* @see VCloudClient#deployVApp
* @see VCloudExpressClient#deployVApp
*/
@POST
@Consumes(TASK_XML)
@ -286,14 +286,14 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#deleteVApp
* @see VCloudExpressClient#deleteVApp
*/
@DELETE
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> deleteVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#undeployVApp
* @see VCloudExpressClient#undeployVApp
*/
@POST
@Consumes(TASK_XML)
@ -302,7 +302,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#powerOnVApp
* @see VCloudExpressClient#powerOnVApp
*/
@POST
@Consumes(TASK_XML)
@ -311,7 +311,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#powerOffVApp
* @see VCloudExpressClient#powerOffVApp
*/
@POST
@Consumes(TASK_XML)
@ -320,14 +320,14 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#shutdownVApp
* @see VCloudExpressClient#shutdownVApp
*/
@POST
@Path("/power/action/shutdown")
ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#resetVApp
* @see VCloudExpressClient#resetVApp
*/
@POST
@Consumes(TASK_XML)
@ -336,7 +336,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#suspendVApp
* @see VCloudExpressClient#suspendVApp
*/
@POST
@Consumes(TASK_XML)
@ -345,7 +345,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
/**
* @see VCloudClient#getTask
* @see VCloudExpressClient#getTask
*/
@GET
@Consumes(TASK_XML)
@ -354,14 +354,14 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
/**
* @see VCloudClient#cancelTask
* @see VCloudExpressClient#cancelTask
*/
@POST
@Path("/action/cancel")
ListenableFuture<Void> cancelTask(@EndpointParam URI taskId);
/**
* @see VCloudClient#findVAppInOrgVDCNamed
* @see VCloudExpressClient#findVAppInOrgVDCNamed
*/
@GET
@Consumes(VAPP_XML)
@ -373,7 +373,7 @@ public interface VCloudAsyncClient {
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
/**
* @see VCloudClient#getVApp
* @see VCloudExpressClient#getVApp
*/
@GET
@Consumes(VAPP_XML)
@ -382,7 +382,7 @@ public interface VCloudAsyncClient {
ListenableFuture<? extends VApp> getVApp(@EndpointParam URI vApp);
/**
* @see VCloudClient#instantiateVAppTemplateInVDC
* @see VCloudExpressClient#instantiateVAppTemplateInVDC
*/
@POST
@Path("action/instantiateVAppTemplate")
@ -396,7 +396,7 @@ public interface VCloudAsyncClient {
InstantiateVAppTemplateOptions... options);
/**
* @see VCloudClient#cloneVAppInVDC
* @see VCloudExpressClient#cloneVAppInVDC
*/
@POST
@Path("/action/cloneVApp")

View File

@ -48,8 +48,7 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole
* @see VCloudComputeServiceContext
*/
public class VCloudContextBuilder extends
ComputeServiceContextBuilder<VCloudClient, VCloudAsyncClient> {
public class VCloudContextBuilder extends ComputeServiceContextBuilder<VCloudClient, VCloudAsyncClient> {
public VCloudContextBuilder(Properties props) {
super(VCloudClient.class, VCloudAsyncClient.class, props);
@ -68,11 +67,8 @@ public class VCloudContextBuilder extends
@Override
public ComputeServiceContext buildComputeServiceContext() {
// need the generic type information
return (ComputeServiceContext) this
.buildInjector()
.getInstance(
Key
.get(new TypeLiteral<ComputeServiceContextImpl<VCloudClient, VCloudAsyncClient>>() {
}));
return (ComputeServiceContext) this.buildInjector().getInstance(
Key.get(new TypeLiteral<ComputeServiceContextImpl<VCloudClient, VCloudAsyncClient>>() {
}));
}
}

View File

@ -0,0 +1,411 @@
/**
*
* 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;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOGITEM_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.NETWORK_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.TASK_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VAPPTEMPLATE_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VAPP_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VDC_XML;
import java.net.URI;
import javax.annotation.Nullable;
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.Produces;
import org.jclouds.predicates.validators.DnsNameValidator;
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;
import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.Network;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameAndTasksListNameToEndpoint;
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;
import org.jclouds.vcloud.xml.CatalogItemHandler;
import org.jclouds.vcloud.xml.NetworkHandler;
import org.jclouds.vcloud.xml.OrgHandler;
import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.TasksListHandler;
import org.jclouds.vcloud.xml.VAppHandler;
import org.jclouds.vcloud.xml.VAppTemplateHandler;
import org.jclouds.vcloud.xml.VDCHandler;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides access to VCloud resources via their REST API.
* <p/>
*
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
* />
* @author Adrian Cole
*/
@RequestFilters(SetVCloudTokenCookie.class)
public interface VCloudExpressAsyncClient {
/**
* @see VCloudExpressClient#getDefaultOrganization
*/
@Deprecated
@GET
@Endpoint(Org.class)
@Consumes(ORG_XML)
@XMLResponseParser(OrgHandler.class)
ListenableFuture<? extends Organization> getDefaultOrganization();
/**
* @see VCloudExpressClient#getOrganization
*/
@GET
@XMLResponseParser(OrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(ORG_XML)
ListenableFuture<? extends Organization> getOrganization(@EndpointParam URI orgId);
/**
* @see VCloudExpressClient#getOrganizationNamed
*/
@GET
@XMLResponseParser(OrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(ORG_XML)
ListenableFuture<? extends Organization> findOrganizationNamed(
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
/**
* @see VCloudExpressClient#getDefaultCatalog
*/
@Deprecated
@GET
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
@Consumes(CATALOG_XML)
@XMLResponseParser(CatalogHandler.class)
ListenableFuture<? extends Catalog> getDefaultCatalog();
/**
* @see VCloudExpressClient#getCatalog
*/
@GET
@XMLResponseParser(CatalogHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
/**
* @see VCloudExpressClient#findCatalogInOrgNamed
*/
@GET
@XMLResponseParser(CatalogHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(CATALOG_XML)
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
/**
* @see VCloudExpressClient#getVAppTemplate
*/
@GET
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
/**
* @see VCloudExpressClient#findVAppTemplateInOrgCatalogNameds
*/
@GET
@Consumes(VAPPTEMPLATE_XML)
@XMLResponseParser(VAppTemplateHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VAppTemplate> findVAppTemplateInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
/**
* @see VCloudExpressClient#getCatalogItem
*/
@GET
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(CatalogItemHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
/**
* @see VCloudExpressClient#getCatalogItemInOrg
*/
@GET
@Consumes(CATALOGITEM_XML)
@XMLResponseParser(CatalogItemHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
/**
* @see VCloudExpressClient#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 VCloudExpressClient#getNetwork
*/
@GET
@Consumes(NETWORK_XML)
@XMLResponseParser(NetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Network> getNetwork(@EndpointParam URI network);
/**
* @see VCloudExpressClient#getDefaultVDC
*/
@Deprecated
@GET
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
ListenableFuture<? extends VDC> getDefaultVDC();
/**
* @see VCloudExpressClient#getVDC(URI)
*/
@GET
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
/**
* @see VCloudExpressClient#findVDCInOrgNamed(String, String)
*/
@GET
@XMLResponseParser(VDCHandler.class)
@Consumes(VDC_XML)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> findVDCInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
/**
* @see VCloudExpressClient#getTasksList
*/
@GET
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
/**
* @see VCloudExpressClient#getTasksListInOrg
*/
@GET
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends TasksList> findTasksListInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndTasksListNameToEndpoint.class) String tasksListName);
/**
* @see VCloudExpressClient#getDefaultTasksList
*/
@Deprecated
@GET
@Endpoint(org.jclouds.vcloud.endpoints.TasksList.class)
@Consumes(TASKSLIST_XML)
@XMLResponseParser(TasksListHandler.class)
ListenableFuture<? extends TasksList> getDefaultTasksList();
/**
* @see VCloudExpressClient#deployVApp
*/
@POST
@Consumes(TASK_XML)
@Path("/action/deploy")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#deleteVApp
*/
@DELETE
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> deleteVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#undeployVApp
*/
@POST
@Consumes(TASK_XML)
@Path("/action/undeploy")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#powerOnVApp
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/powerOn")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#powerOffVApp
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/powerOff")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#shutdownVApp
*/
@POST
@Path("/power/action/shutdown")
ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#resetVApp
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/reset")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#suspendVApp
*/
@POST
@Consumes(TASK_XML)
@Path("/power/action/suspend")
@XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
/**
* @see VCloudExpressClient#getTask
*/
@GET
@Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
/**
* @see VCloudExpressClient#cancelTask
*/
@POST
@Path("/action/cancel")
ListenableFuture<Void> cancelTask(@EndpointParam URI taskId);
/**
* @see VCloudExpressClient#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 VCloudExpressClient#getVApp
*/
@GET
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VApp> getVApp(@EndpointParam URI vApp);
/**
* @see VCloudExpressClient#instantiateVAppTemplateInVDC
*/
@POST
@Path("action/instantiateVAppTemplate")
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
@Consumes(VAPP_XML)
@XMLResponseParser(VAppHandler.class)
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends VApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc,
@MapPayloadParam("template") URI template,
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
InstantiateVAppTemplateOptions... options);
/**
* @see VCloudExpressClient#cloneVAppInVDC
*/
@POST
@Path("/action/cloneVApp")
@Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
@Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class)
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @MapPayloadParam("vApp") URI toClone,
@MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppOptions... options);
}

View File

@ -0,0 +1,213 @@
/**
*
* 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;
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;
import org.jclouds.vcloud.domain.Network;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
/**
* Provides access to VCloud resources via their REST API.
* <p/>
*
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
* />
* @author Adrian Cole
*/
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
public interface VCloudExpressClient {
/**
* Please use {@link #findOrganizationNamed(String)} passing null
*/
@Deprecated
Organization getDefaultOrganization();
Organization getOrganization(URI orgId);
/**
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and
* task lists within the organization.
*
* @param name
* organization name, or null for the default
* @throws NoSuchElementException
* if you specified an org name that isn't present
*/
Organization findOrganizationNamed(@Nullable String name);
/**
* Please use #findCatalogInOrgNamed(null, null)
*/
@Deprecated
Catalog getDefaultCatalog();
Catalog getCatalog(URI catalogId);
/**
* 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);
/**
* 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);
/**
* 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 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);
/**
* Please use #findVDCInOrgNamed
*/
@Deprecated
VDC getDefaultVDC();
TasksList getTasksList(URI tasksListId);
TasksList findTasksListInOrgNamed(String orgName, String tasksListName);
/**
* Please use #getTasksListInOrg(null, null)
*/
@Deprecated
TasksList getDefaultTasksList();
Task deployVApp(URI vAppId);
void deleteVApp(URI vAppId);
Task undeployVApp(URI vAppId);
/**
* This call powers on the vApp, as specified in the vApp's ovf:Startup
* element.
*/
Task powerOnVApp(URI vAppId);
/**
* This call powers off the vApp, as specified in the vApp's ovf:Startup
* element.
*/
Task powerOffVApp(URI vAppId);
/**
* This call shuts down the vApp.
*/
void shutdownVApp(URI vAppId);
/**
* This call resets the vApp.
*/
Task resetVApp(URI vAppId);
/**
* This call suspends the vApp.
*/
Task suspendVApp(URI vAppId);
Task getTask(URI taskId);
void cancelTask(URI taskId);
VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName);
VApp getVApp(URI vApp);
VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options);
Task cloneVAppInVDC(URI vDC, URI toClone, String newName, CloneVAppOptions... options);
}

View File

@ -0,0 +1,74 @@
/**
*
* 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;
import java.util.List;
import java.util.Properties;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextBuilder;
import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule;
import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* Creates {@link VCloudComputeServiceContext} or {@link Injector} instances based on the most
* commonly requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole
* @see VCloudComputeServiceContext
*/
public class VCloudExpressContextBuilder extends ComputeServiceContextBuilder<VCloudExpressClient, VCloudExpressAsyncClient> {
public VCloudExpressContextBuilder(Properties props) {
super(VCloudExpressClient.class, VCloudExpressAsyncClient.class, props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new VCloudExpressComputeServiceContextModule());
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new VCloudExpressRestClientModule());
}
@Override
public ComputeServiceContext buildComputeServiceContext() {
// need the generic type information
return (ComputeServiceContext) this.buildInjector().getInstance(
Key.get(new TypeLiteral<ComputeServiceContextImpl<VCloudExpressClient, VCloudExpressAsyncClient>>() {
}));
}
}

View File

@ -0,0 +1,42 @@
/**
*
* 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;
import javax.ws.rs.core.MediaType;
/**
* Resource Types used in VCloud express
*
* @see MediaType
*/
public interface VCloudExpressMediaType extends VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.organizationList+xml"
*/
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.organizationList+xml";
/**
* "application/vnd.vmware.vcloud.organizationList+xml"
*/
public final static MediaType ORGLIST_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.organizationList+xml");
}

View File

@ -0,0 +1,90 @@
/**
*
* 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;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
import java.util.Properties;
import org.jclouds.PropertiesBuilder;
import org.jclouds.vcloud.domain.FenceMode;
/**
* Builds properties used in VCloud Clients
*
* @author Adrian Cole
*/
public class VCloudExpressPropertiesBuilder extends PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, "0.8");
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
properties.setProperty("jclouds.dns_name_length_min", "1");
properties.setProperty("jclouds.dns_name_length_max", "80");
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 180l * 1000l + "");
return properties;
}
public VCloudExpressPropertiesBuilder(Properties properties) {
super(properties);
}
protected void setNs() {
if (properties.getProperty(PROPERTY_VCLOUD_XML_NAMESPACE) == null)
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v"
+ properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA));
}
protected void setFenceMode() {
if (properties.getProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) == null) {
if (properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA).startsWith("0.8"))
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut");
else
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED);
}
}
public VCloudExpressPropertiesBuilder withApiVersion(String version) {
properties.setProperty(PROPERTY_API_VERSION, "0.8");
return this;
}
public VCloudExpressPropertiesBuilder withSchemaVersion(String version) {
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
return this;
}
@Override
public Properties build() {
setNs();
setFenceMode();
return super.build();
}
}

View File

@ -22,31 +22,29 @@ package org.jclouds.vcloud;
import javax.ws.rs.core.MediaType;
/**
* Resource Types used in VCloud express
* Resource Types used in VCloud
*
* @see MediaType
*/
public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.organizationList+xml"
* "application/vnd.vmware.vcloud.vcloud+xml"
*/
public final static String VCLOUD_XML = "application/vnd.vmware.vcloud.vcloud+xml";
/**
* "application/vnd.vmware.vcloud.organizationList+xml"
* "application/vnd.vmware.vcloud.vcloud+xml"
*/
public final static MediaType VCLOUD_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.vcloud+xml");
public final static MediaType VCLOUD_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vcloud+xml");
/**
* "application/vnd.vmware.vcloud.organizationList+xml"
* "application/vnd.vmware.vcloud.orgList+xml"
*/
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.organizationList+xml";
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml";
/**
* "application/vnd.vmware.vcloud.organizationList+xml"
* "application/vnd.vmware.vcloud.orgList+xml"
*/
public final static MediaType ORGLIST_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.organizationList+xml");
public final static MediaType ORGLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.orgList+xml");
/**
* "application/vnd.vmware.vcloud.org+xml"
*/
@ -54,8 +52,7 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.org+xml"
*/
public final static MediaType ORG_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.org+xml");
public final static MediaType ORG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.org+xml");
/**
* "application/vnd.vmware.vcloud.vdc+xml"
@ -64,8 +61,7 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.vdc+xml"
*/
public final static MediaType VDC_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.vdc+xml");
public final static MediaType VDC_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vdc+xml");
/**
* "application/vnd.vmware.vcloud.catalog+xml"
@ -74,8 +70,7 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.catalog+xml"
*/
public final static MediaType CATALOG_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.catalog+xml");
public final static MediaType CATALOG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.catalog+xml");
/**
* "application/vnd.vmware.vcloud.tasksList+xml"
@ -84,8 +79,7 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.tasksList+xml"
*/
public final static MediaType TASKSLIST_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.tasksList+xml");
public final static MediaType TASKSLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.tasksList+xml");
/**
* "application/vnd.vmware.vcloud.catalogItem+xml"
@ -104,8 +98,7 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.task+xml"
*/
public final static MediaType TASK_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.task+xml");
public final static MediaType TASK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.task+xml");
/**
* "application/vnd.vmware.vcloud.vApp+xml"
@ -114,8 +107,7 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.vApp+xml"
*/
public final static MediaType VAPP_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.vApp+xml");
public final static MediaType VAPP_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vApp+xml");
/**
* "application/vnd.vmware.vcloud.vAppTemplate+xml"
@ -134,7 +126,6 @@ public interface VCloudMediaType {
/**
* "application/vnd.vmware.vcloud.network+xml"
*/
public final static MediaType NETWORK_XML_TYPE = new MediaType("application",
"vnd.vmware.vcloud.network+xml");
public final static MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml");
}

View File

@ -41,13 +41,14 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, "0.8");
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
properties.setProperty(PROPERTY_API_VERSION, "1.0");
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1.0");
properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
properties.setProperty("jclouds.dns_name_length_min", "1");
properties.setProperty("jclouds.dns_name_length_max", "80");
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED);
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 180l * 1000l + "");
return properties;
}
@ -62,29 +63,20 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
+ properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA));
}
protected void setFenceMode() {
if (properties.getProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) == null) {
if (properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA).startsWith("0.8"))
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut");
else
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED);
}
}
public VCloudPropertiesBuilder withApiVersion(String version) {
properties.setProperty(PROPERTY_API_VERSION, "0.8");
properties.setProperty(PROPERTY_API_VERSION, "1.0");
return this;
}
public VCloudPropertiesBuilder withSchemaVersion(String version) {
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1.0");
return this;
}
@Override
public Properties build() {
setNs();
setFenceMode();
return super.build();
}
}

View File

@ -38,7 +38,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToStringPayload;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.options.CloneVAppOptions;
import com.google.inject.Inject;
@ -95,7 +95,7 @@ public class BindCloneVAppParamsToXmlPayload implements MapBinder {
XMLBuilder rootBuilder = buildRoot(newName, options.isDeploy(), options.isPowerOn());
if (options.getDescription() != null)
rootBuilder.e("Description").text(options.getDescription());
rootBuilder.e("VApp").a("href", vApp).a("type", VCloudMediaType.VAPP_XML);
rootBuilder.e("VApp").a("href", vApp).a("type", VCloudExpressMediaType.VAPP_XML);
Properties outputProperties = new Properties();
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
return rootBuilder.asString(outputProperties);

View File

@ -63,7 +63,7 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
@Inject
public BaseVCloudComputeClient(VCloudClient client, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
this.client = client;
this.taskTester = successTester;
this.vAppStatusToNodeState = vAppStatusToNodeState;
@ -71,7 +71,7 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
@Override
public Map<String, String> start(@Nullable URI VDC, URI templateId, String name,
InstantiateVAppTemplateOptions options, int... portsToOpen) {
InstantiateVAppTemplateOptions options, int... portsToOpen) {
checkNotNull(options, "options");
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
@ -175,7 +175,7 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
public TaskException(String type, VApp vApp, Task task) {
super(String.format("failed to %s vApp %s status %s;task %s status %s", type, vApp.getName(),
vApp.getStatus(), task.getLocation(), task.getStatus()), vApp);
vApp.getStatus(), task.getLocation(), task.getStatus()), vApp);
this.task = task;
}

View File

@ -0,0 +1,216 @@
/**
*
* 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.compute;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.annotation.Resource;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
/**
* @author Adrian Cole
*/
@Singleton
public class BaseVCloudExpressComputeClient implements VCloudExpressComputeClient {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final VCloudExpressClient client;
protected final Predicate<URI> taskTester;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
@Inject
public BaseVCloudExpressComputeClient(VCloudExpressClient client, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
this.client = client;
this.taskTester = successTester;
this.vAppStatusToNodeState = vAppStatusToNodeState;
}
@Override
public Map<String, String> start(@Nullable URI VDC, URI templateId, String name,
InstantiateVAppTemplateOptions options, int... portsToOpen) {
checkNotNull(options, "options");
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
VDC vdc = client.getVDC(VDC);
VAppTemplate template = client.getVAppTemplate(templateId);
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vdc.getId(), template.getId(), name, options);
logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
logger.debug(">> deploying vApp(%s)", vAppResponse.getName());
Task task = client.deployVApp(vAppResponse.getId());
if (options.shouldBlockOnDeploy()) {
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("deploy", vAppResponse, task);
}
logger.debug("<< deployed vApp(%s)", vAppResponse.getName());
logger.debug(">> powering vApp(%s)", vAppResponse.getName());
task = client.powerOnVApp(vAppResponse.getId());
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("powerOn", vAppResponse, task);
}
logger.debug("<< on vApp(%s)", vAppResponse.getName());
}
return parseAndValidateResponse(template, vAppResponse);
}
protected Map<String, String> parseAndValidateResponse(VAppTemplate template, VApp vAppResponse) {
Map<String, String> response = parseResponse(template, vAppResponse);
checkState(response.containsKey("id"), "bad configuration: [id] should be in response");
checkState(response.containsKey("username"), "bad configuration: [username] should be in response");
checkState(response.containsKey("password"), "bad configuration: [password] should be in response");
return response;
}
protected Map<String, String> parseResponse(VAppTemplate template, VApp vAppResponse) {
Map<String, String> config = Maps.newLinkedHashMap();// Allows nulls
config.put("id", vAppResponse.getId().toASCIIString());
config.put("username", null);
config.put("password", null);
return config;
}
@Override
public void reboot(URI id) {
VApp vApp = client.getVApp(id);
logger.debug(">> resetting vApp(%s)", vApp.getName());
Task task = client.resetVApp(vApp.getId());
if (!taskTester.apply(task.getLocation())) {
throw new TaskException("resetVApp", vApp, task);
}
logger.debug("<< on vApp(%s)", vApp.getName());
}
@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.getName());
}
private void deleteVApp(VApp vApp) {
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.getName(), vApp.getStatus());
Task task = client.undeployVApp(vApp.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.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.getName(), vApp.getStatus());
Task task = client.powerOffVApp(vApp.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.getName());
}
return vApp;
}
public static class TaskException extends VAppException {
private final Task task;
/** The serialVersionUID */
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.getName(),
vApp.getStatus(), task.getLocation(), task.getStatus()), vApp);
this.task = task;
}
public Task getTask() {
return task;
}
}
public static class VAppException extends RuntimeException {
private final VApp vApp;
/** The serialVersionUID */
private static final long serialVersionUID = 251801929573211256L;
public VAppException(String message, VApp vApp) {
super(message);
this.vApp = vApp;
}
public VApp getvApp() {
return vApp;
}
}
@Override
public Set<String> getPrivateAddresses(URI id) {
return ImmutableSet.of();
}
@Override
public Set<String> getPublicAddresses(URI id) {
VApp vApp = client.getVApp(id);
return Sets.newHashSet(vApp.getNetworkToAddresses().values());
}
}

View File

@ -0,0 +1,101 @@
/**
*
* 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.compute;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.inject.ImplementedBy;
/**
*
* @author Adrian Cole
*/
@ImplementedBy(BaseVCloudExpressComputeClient.class)
public interface VCloudExpressComputeClient {
/**
* Runs through all commands necessary to startup a vApp, opening at least
* one ip address to the public network. These are the steps:
* <p/>
* instantiate -> deploy -> powerOn
* <p/>
* This command blocks until the vApp is in state {@code VAppStatus#ON}
*
* @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
* amount of ram in megabytes
* @param options
* options for instantiating the vApp; null is ok
* @param portsToOpen
* opens the following ports on the public ip address
* @return map contains at least the following properties
* <ol>
* <li>id - vApp id</li> <li>username - console login user</li> <li>
* password - console login password</li>
* </ol>
*/
Map<String, String> start(@Nullable URI VDC, URI templateId, String name, InstantiateVAppTemplateOptions options,
int... portsToOpen);
/**
* returns a set of addresses that are only visible to the private network.
*/
Set<String> getPrivateAddresses(URI vAppId);
/**
* returns a set of addresses that are publically visible
*/
Set<String> getPublicAddresses(URI vAppId);
/**
* reboots the vApp, blocking until the following state transition is
* complete:
* <p/>
* current -> {@code VAppStatus#OFF} -> {@code VAppStatus#ON}
*
* @param vAppId
* vApp to reboot
*/
void reboot(URI vAppId);
/**
* Destroys dependent resources, powers off and deletes the vApp, blocking
* until the following state transition is complete:
* <p/>
* current -> {@code VAppStatus#OFF} -> deleted
*
* @param vAppId
* vApp to stop
*/
void stop(URI vAppId);
}

View File

@ -0,0 +1,92 @@
/**
*
* 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.compute.config;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.Size;
import org.jclouds.domain.Location;
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier;
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
import org.jclouds.vcloud.domain.VAppStatus;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.util.Providers;
/**
* Configures the {@link VCloudComputeServiceContext}; requires {@link BaseVCloudComputeClient}
* bound.
*
* @author Adrian Cole
*/
public class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
@VisibleForTesting
static final Map<VAppStatus, NodeState> vAppStatusToNodeState = ImmutableMap.<VAppStatus, NodeState> builder().put(
VAppStatus.OFF, NodeState.SUSPENDED).put(VAppStatus.ON, NodeState.RUNNING).put(VAppStatus.RESOLVED,
NodeState.PENDING).put(VAppStatus.SUSPENDED, NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED,
NodeState.PENDING).build();
@Singleton
@Provides
Map<VAppStatus, NodeState> provideVAppStatusToNodeState() {
return vAppStatusToNodeState;
}
@Override
protected void configure() {
install(new ComputeServiceTimeoutsModule());
bindLoadBalancer();
}
protected void bindLoadBalancer() {
bind(LoadBalancerService.class).toProvider(Providers.<LoadBalancerService> of(null));
}
@Override
protected Supplier<Set<? extends Image>> getSourceImageSupplier(Injector injector) {
return injector.getInstance(VCloudImageSupplier.class);
}
@Override
protected Supplier<Set<? extends Location>> getSourceLocationSupplier(Injector injector) {
return injector.getInstance(OrgAndVDCToLocationSupplier.class);
}
@Override
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
return injector.getInstance(StaticSizeSupplier.class);
}
}

View File

@ -19,18 +19,7 @@
package org.jclouds.vcloud.compute.config;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.LoadBalancerService;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.Size;
import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
import org.jclouds.compute.strategy.DestroyNodeStrategy;
@ -39,10 +28,8 @@ import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
import org.jclouds.domain.Location;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.compute.strategy.VCloudAddNodeWithTagStrategy;
@ -50,19 +37,9 @@ import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier;
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
import org.jclouds.vcloud.domain.VAppStatus;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
import com.google.inject.util.Providers;
/**
* Configures the {@link VCloudComputeServiceContext}; requires {@link BaseVCloudComputeClient}
@ -70,55 +47,22 @@ import com.google.inject.util.Providers;
*
* @author Adrian Cole
*/
public class VCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
@VisibleForTesting
static final Map<VAppStatus, NodeState> vAppStatusToNodeState = ImmutableMap.<VAppStatus, NodeState> builder().put(
VAppStatus.OFF, NodeState.SUSPENDED).put(VAppStatus.ON, NodeState.RUNNING).put(VAppStatus.RESOLVED,
NodeState.PENDING).put(VAppStatus.SUSPENDED, NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED,
NodeState.PENDING).build();
@Singleton
@Provides
Map<VAppStatus, NodeState> provideVAppStatusToNodeState() {
return vAppStatusToNodeState;
}
public class VCloudComputeServiceContextModule extends CommonVCloudComputeServiceContextModule {
@Override
protected void configure() {
install(new ComputeServiceTimeoutsModule());
bind(AddNodeWithTagStrategy.class).to(VCloudAddNodeWithTagStrategy.class);
super.configure();
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<VCloudClient, VCloudAsyncClient>>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<VCloudClient, VCloudClient>>() {
}).in(Scopes.SINGLETON);
bind(new TypeLiteral<RestContext<VCloudClient, VCloudAsyncClient>>() {
}).to(new TypeLiteral<RestContextImpl<VCloudClient, VCloudAsyncClient>>() {
bind(new TypeLiteral<RestContext<VCloudClient, VCloudClient>>() {
}).to(new TypeLiteral<RestContextImpl<VCloudClient, VCloudClient>>() {
}).in(Scopes.SINGLETON);
bind(AddNodeWithTagStrategy.class).to(VCloudAddNodeWithTagStrategy.class);
bind(DestroyNodeStrategy.class).to(VCloudDestroyNodeStrategy.class);
bind(RunNodesAndAddToSetStrategy.class).to(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class);
bind(ListNodesStrategy.class).to(VCloudListNodesStrategy.class);
bind(GetNodeMetadataStrategy.class).to(VCloudGetNodeMetadataStrategy.class);
bind(RebootNodeStrategy.class).to(VCloudRebootNodeStrategy.class);
bind(DestroyNodeStrategy.class).to(VCloudDestroyNodeStrategy.class);
bindLoadBalancer();
}
protected void bindLoadBalancer() {
bind(LoadBalancerService.class).toProvider(Providers.<LoadBalancerService> of(null));
}
@Override
protected Supplier<Set<? extends Image>> getSourceImageSupplier(Injector injector) {
return injector.getInstance(VCloudImageSupplier.class);
}
@Override
protected Supplier<Set<? extends Location>> getSourceLocationSupplier(Injector injector) {
return injector.getInstance(OrgAndVDCToLocationSupplier.class);
}
@Override
protected Supplier<Set<? extends Size>> getSourceSizeSupplier(Injector injector) {
return injector.getInstance(StaticSizeSupplier.class);
}
}

View File

@ -0,0 +1,69 @@
/**
*
* 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.compute.config;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
import org.jclouds.compute.strategy.DestroyNodeStrategy;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.BaseVCloudExpressComputeClient;
import org.jclouds.vcloud.compute.strategy.VCloudExpressAddNodeWithTagStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudExpressDestroyNodeStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudExpressGetNodeMetadataStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy;
import org.jclouds.vcloud.compute.strategy.VCloudExpressRebootNodeStrategy;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/**
* Configures the {@link VCloudComputeServiceContext}; requires
* {@link BaseVCloudExpressComputeClient} bound.
*
* @author Adrian Cole
*/
public class VCloudExpressComputeServiceContextModule extends CommonVCloudComputeServiceContextModule {
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<VCloudExpressClient, VCloudExpressClient>>() {
}).in(Scopes.SINGLETON);
bind(new TypeLiteral<RestContext<VCloudExpressClient, VCloudExpressClient>>() {
}).to(new TypeLiteral<RestContextImpl<VCloudExpressClient, VCloudExpressClient>>() {
}).in(Scopes.SINGLETON);
bind(AddNodeWithTagStrategy.class).to(VCloudExpressAddNodeWithTagStrategy.class);
bind(DestroyNodeStrategy.class).to(VCloudExpressDestroyNodeStrategy.class);
bind(RunNodesAndAddToSetStrategy.class).to(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class);
bind(ListNodesStrategy.class).to(VCloudExpressListNodesStrategy.class);
bind(GetNodeMetadataStrategy.class).to(VCloudExpressGetNodeMetadataStrategy.class);
bind(RebootNodeStrategy.class).to(VCloudExpressRebootNodeStrategy.class);
}
}

View File

@ -31,7 +31,7 @@ import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.compute.BaseVCloudExpressComputeClient;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp;
@ -40,7 +40,7 @@ import com.google.common.base.Function;
/**
* Configures the {@link VCloudComputeServiceContext}; requires
* {@link BaseVCloudComputeClient} bound.
* {@link BaseVCloudExpressComputeClient} bound.
*
* @author Adrian Cole
*/

View File

@ -28,7 +28,6 @@ import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.functions.AllCatalogItemsInOrganization;
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
@ -40,13 +39,13 @@ import com.google.common.collect.Iterables;
public class ImagesInOrganization implements Function<Organization, Iterable<? extends Image>> {
private final AllCatalogItemsInOrganization allCatalogItemsInOrganization;
private final VAppTemplatesForCatalogItems vAppTemplatesForCatalogItems;
private final Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems;
private final Provider<ImageForVAppTemplate> imageForVAppTemplateProvider;
@Inject
ImagesInOrganization(AllCatalogItemsInOrganization allCatalogItemsInOrganization,
Provider<ImageForVAppTemplate> imageForVAppTemplateProvider,
VAppTemplatesForCatalogItems vAppTemplatesForCatalogItems) {
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> vAppTemplatesForCatalogItems) {
this.imageForVAppTemplateProvider = imageForVAppTemplateProvider;
this.allCatalogItemsInOrganization = allCatalogItemsInOrganization;
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;

View File

@ -0,0 +1,89 @@
/**
*
* 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.compute.strategy;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.collect.ImmutableMap;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
protected final VCloudExpressClient client;
protected final VCloudExpressComputeClient computeClient;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
@Inject
protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
this.client = client;
this.computeClient = computeClient;
this.vAppStatusToNodeState = vAppStatusToNodeState;
}
@Override
public NodeMetadata execute(String tag, String name, Template template) {
InstantiateVAppTemplateOptions options = processorCount(Double.valueOf(template.getSize().getCores()).intValue())
.memory(template.getSize().getRam()).disk(template.getSize().getDisk() * 1024 * 1024l);
if (!template.getOptions().shouldBlockUntilRunning())
options.blockOnDeploy(false);
Map<String, String> metaMap = computeClient.start(URI.create(template.getLocation().getId()), URI.create(template
.getImage().getId()), name, options, template.getOptions().getInboundPorts());
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().toASCIIString(), vApp.getName(), vApp.getId().toASCIIString(), template
.getLocation(), vApp.getId(), ImmutableMap.<String, String> of(), tag, template.getImage().getId(),
getOperatingSystemForVAppOrDefaultTo(vApp, template.getImage().getOperatingSystem()),
vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getId()),
computeClient.getPrivateAddresses(vApp.getId()), ImmutableMap.<String, String> of(), new Credentials(
metaMap.get("username"), metaMap.get("password")));
}
private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) {
return vApp.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()),
null, null, vApp.getOperatingSystemDescription()) : operatingSystem;
}
}

View File

@ -0,0 +1,55 @@
/**
*
* 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.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.strategy.DestroyNodeStrategy;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressDestroyNodeStrategy implements DestroyNodeStrategy {
protected final VCloudExpressComputeClient computeClient;
protected final GetNodeMetadataStrategy getNode;
@Inject
protected VCloudExpressDestroyNodeStrategy(VCloudExpressComputeClient computeClient, GetNodeMetadataStrategy getNode) {
this.computeClient = computeClient;
this.getNode = getNode;
}
@Override
public NodeMetadata execute(String id) {
computeClient.stop(URI.create(checkNotNull(id, "node.id")));
return getNode.execute(id);
}
}

View File

@ -17,7 +17,7 @@
* ====================================================================
*/
package org.jclouds.vcloud.compute.functions;
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName;
@ -37,11 +37,13 @@ import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.GetExtra;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
@ -49,26 +51,23 @@ import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
/**
* Configures the {@link VCloudComputeServiceContext}; requires {@link BaseVCloudComputeClient}
* bound.
*
* @author Adrian Cole
*/
@Singleton
public class VCloudGetNodeMetadata {
public class VCloudExpressGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
protected final VCloudClient client;
protected final VCloudComputeClient computeClient;
protected final VCloudExpressClient client;
protected final VCloudExpressComputeClient computeClient;
protected final Supplier<Set<? extends Image>> images;
protected final FindLocationForResource findLocationForResourceInVDC;
protected final GetExtra getExtra;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
@Inject
VCloudGetNodeMetadata(VCloudClient client, VCloudComputeClient computeClient,
protected VCloudExpressGetNodeMetadataStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images) {
this.client = checkNotNull(client, "client");

View File

@ -0,0 +1,141 @@
/**
*
* 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.compute.strategy;
import static org.jclouds.compute.reference.ComputeServiceConstants.COMPUTE_LOGGER;
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_BLACKLIST_NODES;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.internal.ComputeMetadataImpl;
import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.internal.util.ImmutableSet;
/**
* @author Adrian Cole
*/
// TODO REFACTOR!!! needs to be parallel
@Singleton
public class VCloudExpressListNodesStrategy implements ListNodesStrategy {
@Resource
@Named(COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
protected final VCloudExpressGetNodeMetadataStrategy getNodeMetadata;
protected final VCloudExpressClient client;
protected final FindLocationForResource findLocationForResourceInVDC;
Set<String> blackListVAppNames = ImmutableSet.<String> of();
@Inject(optional = true)
void setBlackList(@Named(PROPERTY_BLACKLIST_NODES) String blackListNodes) {
if (blackListNodes != null && !"".equals(blackListNodes))
this.blackListVAppNames = ImmutableSet.copyOf(Splitter.on(',').split(blackListNodes));
}
private final Supplier<Map<String, NamedResource>> orgNameToEndpoint;
@Inject
protected VCloudExpressListNodesStrategy(VCloudExpressClient client,
@Org Supplier<Map<String, NamedResource>> orgNameToEndpoint,
VCloudExpressGetNodeMetadataStrategy getNodeMetadata, FindLocationForResource findLocationForResourceInVDC) {
this.client = client;
this.orgNameToEndpoint = orgNameToEndpoint;
this.getNodeMetadata = getNodeMetadata;
this.findLocationForResourceInVDC = findLocationForResourceInVDC;
}
@Override
public Iterable<ComputeMetadata> list() {
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.getId()).getResourceEntities().values()) {
if (validVApp(resource)) {
nodes.add(convertVAppToComputeMetadata(vdc, resource));
}
}
}
}
return nodes;
}
private boolean validVApp(NamedResource resource) {
return resource.getType().equals(VCloudExpressMediaType.VAPP_XML)
&& !blackListVAppNames.contains(resource.getName());
}
private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc, NamedResource resource) {
Location location = findLocationForResourceInVDC.apply(vdc);
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId().toASCIIString(), resource.getName(), resource
.getId().toASCIIString(), location, null, ImmutableMap.<String, String> of());
}
@Override
public Iterable<NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) {
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.getId()).getResourceEntities().values()) {
if (validVApp(resource) && filter.apply(convertVAppToComputeMetadata(vdc, resource))) {
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
}
}
}
}
return nodes;
}
@VisibleForTesting
void addVAppToSetRetryingIfNotYetPresent(Set<NodeMetadata> nodes, NamedResource vdc, NamedResource resource) {
NodeMetadata node = null;
int i = 0;
while (node == null && i++ < 3) {
try {
node = getNodeMetadata.execute(resource.getId().toASCIIString());
nodes.add(node);
} catch (NullPointerException e) {
logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName());
}
}
}
}

View File

@ -0,0 +1,60 @@
/**
*
* 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.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.Task;
import com.google.common.base.Predicate;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressRebootNodeStrategy implements RebootNodeStrategy {
private final VCloudExpressClient client;
protected final Predicate<URI> taskTester;
protected final GetNodeMetadataStrategy getNode;
@Inject
protected VCloudExpressRebootNodeStrategy(VCloudExpressClient client, Predicate<URI> taskTester, GetNodeMetadataStrategy getNode) {
this.client = client;
this.taskTester = taskTester;
this.getNode = getNode;
}
@Override
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

@ -20,30 +20,75 @@
package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.GetExtra;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
protected final VCloudGetNodeMetadata getNodeMetadata;
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
protected final VCloudClient client;
protected final VCloudComputeClient computeClient;
protected final Supplier<Set<? extends Image>> images;
protected final FindLocationForResource findLocationForResourceInVDC;
protected final GetExtra getExtra;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
@Inject
protected VCloudGetNodeMetadataStrategy(VCloudGetNodeMetadata getNodeMetadata) {
this.getNodeMetadata = getNodeMetadata;
VCloudGetNodeMetadataStrategy(VCloudClient client, VCloudComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images) {
this.client = checkNotNull(client, "client");
this.images = checkNotNull(images, "images");
this.getExtra = checkNotNull(getExtra, "getExtra");
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
this.computeClient = checkNotNull(computeClient, "computeClient");
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
}
@Override
public NodeMetadata execute(String id) {
return getNodeMetadata.execute(checkNotNull(id, "node.id"));
public NodeMetadata execute(String in) {
URI id = URI.create(in);
VApp from = client.getVApp(id);
if (from == null)
return null;
String tag = parseTagFromName(from.getName());
Location location = findLocationForResourceInVDC.apply(from.getVDC());
return new NodeMetadataImpl(in, from.getName(), in, location, from.getId(), ImmutableMap.<String, String> of(),
tag, null, from.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(from
.getOsType()), null, null, from.getOperatingSystemDescription()) : null, vAppStatusToNodeState
.get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient
.getPrivateAddresses(id), getExtra.apply(from), null);
}
}

View File

@ -39,7 +39,6 @@ import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org;
@ -55,13 +54,13 @@ import com.google.inject.internal.util.ImmutableSet;
/**
* @author Adrian Cole
*/
//TODO REFACTOR!!! needs to be parallel
// TODO REFACTOR!!! needs to be parallel
@Singleton
public class VCloudListNodesStrategy implements ListNodesStrategy {
@Resource
@Named(COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
protected final VCloudGetNodeMetadata getNodeMetadata;
protected final VCloudGetNodeMetadataStrategy getNodeMetadata;
protected final VCloudClient client;
protected final FindLocationForResource findLocationForResourceInVDC;
Set<String> blackListVAppNames = ImmutableSet.<String> of();
@ -76,7 +75,7 @@ public class VCloudListNodesStrategy implements ListNodesStrategy {
@Inject
protected VCloudListNodesStrategy(VCloudClient client, @Org Supplier<Map<String, NamedResource>> orgNameToEndpoint,
VCloudGetNodeMetadata getNodeMetadata, FindLocationForResource findLocationForResourceInVDC) {
VCloudGetNodeMetadataStrategy getNodeMetadata, FindLocationForResource findLocationForResourceInVDC) {
this.client = client;
this.orgNameToEndpoint = orgNameToEndpoint;
this.getNodeMetadata = getNodeMetadata;
@ -104,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().toASCIIString(), resource.getName(),
resource.getId().toASCIIString(), 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

View File

@ -0,0 +1,126 @@
/**
*
* 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.config;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.get;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
import java.net.URI;
import java.util.Map;
import javax.inject.Named;
import org.jclouds.domain.Location;
import org.jclouds.http.RequiresHttp;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.functions.VCloudExpressAllCatalogItemsInCatalog;
import org.jclouds.vcloud.functions.VCloudExpressAllCatalogsInOrganization;
import org.jclouds.vcloud.functions.VCloudExpressAllVDCsInOrganization;
import org.jclouds.vcloud.functions.VCloudExpressOrganizationsForNames;
import org.jclouds.vcloud.functions.VCloudExpressOrganizatonsForLocations;
import org.jclouds.vcloud.functions.VCloudExpressVAppTemplatesForCatalogItems;
import org.jclouds.vcloud.predicates.VCloudExpressTaskSuccess;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
/**
* Configures the VCloud authentication service connection, including logging and http transport.
*
* @author Adrian Cole
*/
@RequiresHttp
@ConfiguresRestClient
public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressClient, A extends VCloudExpressAsyncClient>
extends CommonVCloudRestClientModule<S, A> {
public BaseVCloudExpressRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
super(syncClientType, asyncClientType);
}
@Override
protected void configure() {
super.configure();
bind(new TypeLiteral<Function<Catalog, Iterable<? extends CatalogItem>>>() {
}).to(new TypeLiteral<VCloudExpressAllCatalogItemsInCatalog>() {
});
bind(new TypeLiteral<Function<Organization, Iterable<? extends Catalog>>>() {
}).to(new TypeLiteral<VCloudExpressAllCatalogsInOrganization>() {
});
bind(new TypeLiteral<Function<Organization, Iterable<? extends VDC>>>() {
}).to(new TypeLiteral<VCloudExpressAllVDCsInOrganization>() {
});
bind(new TypeLiteral<Function<Iterable<String>, Iterable<? extends Organization>>>() {
}).to(new TypeLiteral<VCloudExpressOrganizationsForNames>() {
});
bind(new TypeLiteral<Function<Iterable<? extends Location>, Iterable<? extends Organization>>>() {
}).to(new TypeLiteral<VCloudExpressOrganizatonsForLocations>() {
});
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>>>() {
}).to(new TypeLiteral<VCloudExpressVAppTemplatesForCatalogItems>() {
});
}
@Override
protected Organization provideOrganization(VCloudExpressClient discovery) {
if (authException.get() != null)
throw authException.get();
try {
return discovery.findOrganizationNamed(null);
} catch (AuthorizationException e) {
authException.set(e);
throw e;
}
}
@Override
protected URI provideDefaultNetwork(VCloudExpressClient client) {
if (authException.get() != null)
throw authException.get();
try {
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).getId();
} catch (AuthorizationException e) {
authException.set(e);
throw e;
}
}
@Override
protected Predicate<URI> successTester(Injector injector,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
return new RetryablePredicate<URI>(injector.getInstance(VCloudExpressTaskSuccess.class), completed);
}
}

View File

@ -19,84 +19,50 @@
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;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_IDENTITY;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
import java.net.URI;
import java.util.Map;
import java.util.SortedMap;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.domain.Location;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.logging.Logger;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.AsyncClientFactory;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
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.VDC;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog;
import org.jclouds.vcloud.functions.AllCatalogsInOrganization;
import org.jclouds.vcloud.functions.AllVDCsInOrganization;
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
import org.jclouds.vcloud.functions.OrganizatonsForLocations;
import org.jclouds.vcloud.functions.OrganizationsForNames;
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.jclouds.vcloud.predicates.TaskSuccess;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.inject.Provides;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
/**
* 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
*/
@RequiresHttp
@ConfiguresRestClient
public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A extends VCloudAsyncClient> extends
RestClientModule<S, A> {
CommonVCloudRestClientModule<S, A> {
public BaseVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
super(syncClientType, asyncClientType);
@ -104,378 +70,29 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
@Override
protected void configure() {
requestInjection(this);
super.configure();
bind(new TypeLiteral<Function<Catalog, Iterable<? extends CatalogItem>>>() {
}).to(new TypeLiteral<AllCatalogItemsInCatalog>() {
});
bind(new TypeLiteral<Function<Organization, Iterable<? extends Catalog>>>() {
}).to(new TypeLiteral<AllCatalogsInOrganization>() {
});
bind(new TypeLiteral<Function<Organization, Iterable<? extends VDC>>>() {
}).to(new TypeLiteral<AllVDCsInOrganization>() {
});
bind(new TypeLiteral<Function<Iterable<String>, Iterable<? extends Organization>>>() {
}).to(new TypeLiteral<OrganizationsForNames>() {
});
bind(new TypeLiteral<Function<Iterable<? extends Location>, Iterable<? extends Organization>>>() {
}).to(new TypeLiteral<OrganizatonsForLocations>() {
});
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>>>() {
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
});
}
@Resource
protected Logger logger = Logger.NULL;
@Provides
@Singleton
protected Predicate<URI> successTester(TaskSuccess success,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
return new RetryablePredicate<URI>(success, completed);
}
@VCloudToken
@Provides
String provideVCloudToken(Supplier<VCloudSession> cache) {
return checkNotNull(cache.get().getVCloudToken(), "No token present in session");
}
@Provides
@Org
@Singleton
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
return getLast(orgs).getId();
}
@Provides
@Org
@Singleton
protected String provideOrgName(@Org Iterable<NamedResource> orgs) {
return getLast(orgs).getName();
}
@Provides
@Org
@Singleton
protected Supplier<Map<String, NamedResource>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final OrgNameToOrgSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, NamedResource>>(authException,
seconds, new Supplier<Map<String, NamedResource>>() {
@Override
public Map<String, NamedResource> get() {
return supplier.get();
}
});
}
@Provides
@Singleton
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>(
authException, seconds, new Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>() {
@Override
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
return supplier.get();
}
});
}
@Provides
@Singleton
@VDC
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final Supplier<Map<String, ? extends Organization>> orgToVDCSupplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, String>>(authException, seconds,
new Supplier<Map<String, String>>() {
@Override
public Map<String, String> get() {
Map<String, String> returnVal = newLinkedHashMap();
for (Entry<String, ? extends Organization> orgr : orgToVDCSupplier.get().entrySet()) {
for (String vdc : orgr.getValue().getVDCs().keySet()) {
returnVal.put(vdc, orgr.getKey());
}
}
return returnVal;
}
});
}
@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
protected Iterable<NamedResource> provideOrgs(Supplier<VCloudSession> cache, @Named(PROPERTY_IDENTITY) String user) {
VCloudSession discovery = cache.get();
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user);
return discovery.getOrgs().values();
}
protected AtomicReference<AuthorizationException> authException = new AtomicReference<AuthorizationException>();
@Provides
@Singleton
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final VCloudLoginAsyncClient login) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
new Supplier<VCloudSession>() {
@Override
public VCloudSession get() {
try {
return login.login().get(10, TimeUnit.SECONDS);
} catch (Exception e) {
propagate(e);
assert false : e;
return null;
}
}
});
}
@Provides
@Singleton
protected Supplier<Map<String, ? extends Organization>> provideOrgMapCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationMapSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ? extends Organization>>(
authException, seconds, new Supplier<Map<String, ? extends Organization>>() {
@Override
public Map<String, ? extends Organization> get() {
return supplier.get();
}
});
}
private final static Function<NamedResource, String> name = new Function<NamedResource, String>() {
@Override
public String apply(NamedResource from) {
return from.getName();
}
};
@Singleton
public static class OrganizationMapSupplier implements Supplier<Map<String, ? extends Organization>> {
protected final Supplier<VCloudSession> sessionSupplier;
private final OrganizationsForNames organizationsForNames;
@Inject
protected OrganizationMapSupplier(Supplier<VCloudSession> sessionSupplier,
OrganizationsForNames organizationsForNames) {
this.sessionSupplier = sessionSupplier;
this.organizationsForNames = organizationsForNames;
}
@Override
public Map<String, ? extends Organization> get() {
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
}
}
@Singleton
public static class OrganizationCatalogSupplier implements
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
protected final Supplier<Map<String, ? extends Organization>> orgSupplier;
private final AllCatalogsInOrganization allCatalogsInOrganization;
@Inject
protected OrganizationCatalogSupplier(Supplier<Map<String, ? extends Organization>> orgSupplier,
AllCatalogsInOrganization allCatalogsInOrganization) {
this.orgSupplier = orgSupplier;
this.allCatalogsInOrganization = allCatalogsInOrganization;
}
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return transformValues(
transformValues(orgSupplier.get(), allCatalogsInOrganization),
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
@Override
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
return uniqueIndex(from, name);
}
});
}
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> provideOrganizationCatalogItemMapSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>(
authException, seconds,
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>() {
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return supplier.get();
}
});
}
@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>>>> {
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
private final AllCatalogItemsInCatalog allCatalogItemsInCatalog;
@Inject
protected OrganizationCatalogItemSupplier(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
AllCatalogItemsInCatalog allCatalogItemsInCatalog) {
this.catalogSupplier = catalogSupplier;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
}
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
return transformValues(
catalogSupplier.get(),
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
@Override
public Map<String, Map<String, ? extends CatalogItem>> apply(
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
return transformValues(
from,
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
@Override
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
}
});
}
});
}
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> provideOrganizationCatalogItemSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogItemSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>(
authException, seconds,
new Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>() {
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
return supplier.get();
}
});
}
@Provides
@Singleton
@org.jclouds.vcloud.endpoints.VCloudLogin
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException, TimeoutException {
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
checkState(versions.size() > 0, "No versions present");
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
return versions.get(version);
}
@Singleton
private static class OrgNameToOrgSupplier implements Supplier<Map<String, NamedResource>> {
private final Supplier<VCloudSession> sessionSupplier;
@SuppressWarnings("unused")
@Inject
OrgNameToOrgSupplier(Supplier<VCloudSession> sessionSupplier) {
this.sessionSupplier = sessionSupplier;
}
@Override
public Map<String, NamedResource> get() {
return sessionSupplier.get().getOrgs();
}
}
@Provides
@Singleton
protected VCloudLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
return factory.create(VCloudLoginAsyncClient.class);
}
@Provides
@Singleton
protected VCloudVersionsAsyncClient provideVCloudVersions(AsyncClientFactory factory) {
return factory.create(VCloudVersionsAsyncClient.class);
}
@Provides
@Singleton
protected Organization provideOrganization(VCloudClient discovery) throws ExecutionException, TimeoutException,
InterruptedException {
@Override
protected Organization provideOrganization(VCloudClient discovery) {
if (authException.get() != null)
throw authException.get();
try {
@ -486,35 +103,8 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
}
}
@Provides
@VDC
@Singleton
protected URI provideDefaultVDC(Organization org) {
checkState(org.getVDCs().size() > 0, "No vdcs present in org: " + org.getName());
return get(org.getVDCs().values(), 0).getId();
}
@Provides
@Catalog
@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).getId();
}
@Provides
@Catalog
@Singleton
protected String provideCatalogName(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogs) {
return getLast(getLast(catalogs.get().values()).keySet());
}
@Provides
@Network
@Singleton
protected URI provideDefaultNetwork(VCloudClient client) throws InterruptedException, ExecutionException,
TimeoutException {
@Override
protected URI provideDefaultNetwork(VCloudClient client) {
if (authException.get() != null)
throw authException.get();
try {
@ -526,27 +116,10 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
authException.set(e);
throw e;
}
}
@Provides
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK)
@Singleton
String provideDefaultNetworkString(@Network URI network) {
return network.toASCIIString();
}
}
@Override
protected void bindErrorHandlers() {
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseVCloudErrorFromHttpResponse.class);
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
}
@Provides
@TasksList
@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).getId();
protected Predicate<URI> successTester(Injector injector,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
return new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), completed);
}
}

View File

@ -0,0 +1,521 @@
/**
*
* 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.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;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_IDENTITY;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
import java.net.URI;
import java.util.Map;
import java.util.SortedMap;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.logging.Logger;
import org.jclouds.rest.AsyncClientFactory;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
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.VDC;
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.inject.Injector;
import com.google.inject.Provides;
/**
* Configures the VCloud authentication service connection, including logging and http transport.
*
* @author Adrian Cole
*/
@RequiresHttp
@ConfiguresRestClient
public abstract class CommonVCloudRestClientModule<S, A> extends RestClientModule<S, A> {
public CommonVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
super(syncClientType, asyncClientType);
}
@Override
protected void configure() {
requestInjection(this);
super.configure();
}
@Resource
protected Logger logger = Logger.NULL;
@Provides
@Singleton
protected abstract Predicate<URI> successTester(Injector injector,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed);
@VCloudToken
@Provides
String provideVCloudToken(Supplier<VCloudSession> cache) {
return checkNotNull(cache.get().getVCloudToken(), "No token present in session");
}
@Provides
@Org
@Singleton
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
return getLast(orgs).getId();
}
@Provides
@Org
@Singleton
protected String provideOrgName(@Org Iterable<NamedResource> orgs) {
return getLast(orgs).getName();
}
@Provides
@Org
@Singleton
protected Supplier<Map<String, NamedResource>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final OrgNameToOrgSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, NamedResource>>(authException,
seconds, new Supplier<Map<String, NamedResource>>() {
@Override
public Map<String, NamedResource> get() {
return supplier.get();
}
});
}
@Provides
@Singleton
protected Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>> provideURIToVDC(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>(
authException, seconds, new Supplier<Map<URI, ? extends org.jclouds.vcloud.domain.VDC>>() {
@Override
public Map<URI, ? extends org.jclouds.vcloud.domain.VDC> get() {
return supplier.get();
}
});
}
@Provides
@Singleton
@VDC
protected Supplier<Map<String, String>> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final Supplier<Map<String, ? extends Organization>> orgToVDCSupplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, String>>(authException, seconds,
new Supplier<Map<String, String>>() {
@Override
public Map<String, String> get() {
Map<String, String> returnVal = newLinkedHashMap();
for (Entry<String, ? extends Organization> orgr : orgToVDCSupplier.get().entrySet()) {
for (String vdc : orgr.getValue().getVDCs().keySet()) {
returnVal.put(vdc, orgr.getKey());
}
}
return returnVal;
}
});
}
@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
protected Iterable<NamedResource> provideOrgs(Supplier<VCloudSession> cache, @Named(PROPERTY_IDENTITY) String user) {
VCloudSession discovery = cache.get();
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user);
return discovery.getOrgs().values();
}
protected AtomicReference<AuthorizationException> authException = new AtomicReference<AuthorizationException>();
@Provides
@Singleton
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final VCloudLoginAsyncClient login) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
new Supplier<VCloudSession>() {
@Override
public VCloudSession get() {
try {
return login.login().get(10, TimeUnit.SECONDS);
} catch (Exception e) {
propagate(e);
assert false : e;
return null;
}
}
});
}
@Provides
@Singleton
protected Supplier<Map<String, ? extends Organization>> provideOrgMapCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationMapSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ? extends Organization>>(
authException, seconds, new Supplier<Map<String, ? extends Organization>>() {
@Override
public Map<String, ? extends Organization> get() {
return supplier.get();
}
});
}
private final static Function<NamedResource, String> name = new Function<NamedResource, String>() {
@Override
public String apply(NamedResource from) {
return from.getName();
}
};
@Singleton
public static class OrganizationMapSupplier implements Supplier<Map<String, ? extends Organization>> {
protected final Supplier<VCloudSession> sessionSupplier;
private final Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames;
@Inject
protected OrganizationMapSupplier(Supplier<VCloudSession> sessionSupplier,
Function<Iterable<String>, Iterable<? extends Organization>> organizationsForNames) {
this.sessionSupplier = sessionSupplier;
this.organizationsForNames = organizationsForNames;
}
@Override
public Map<String, ? extends Organization> get() {
return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name);
}
}
@Singleton
public static class OrganizationCatalogSupplier implements
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> {
protected final Supplier<Map<String, ? extends Organization>> orgSupplier;
private final Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrganization;
@Inject
protected OrganizationCatalogSupplier(Supplier<Map<String, ? extends Organization>> orgSupplier,
Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.Catalog>> allCatalogsInOrganization) {
this.orgSupplier = orgSupplier;
this.allCatalogsInOrganization = allCatalogsInOrganization;
}
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return transformValues(
transformValues(orgSupplier.get(), allCatalogsInOrganization),
new Function<Iterable<? extends org.jclouds.vcloud.domain.Catalog>, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>() {
@Override
public Map<String, ? extends org.jclouds.vcloud.domain.Catalog> apply(
Iterable<? extends org.jclouds.vcloud.domain.Catalog> from) {
return uniqueIndex(from, name);
}
});
}
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> provideOrganizationCatalogItemMapSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>(
authException, seconds,
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>>() {
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return supplier.get();
}
});
}
@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 Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.VDC>> allVDCsInOrganization;
@Inject
protected OrganizationVDCSupplier(Supplier<Map<String, ? extends Organization>> orgSupplier,
Function<Organization, Iterable<? extends org.jclouds.vcloud.domain.VDC>> 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>>>> {
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier;
private final Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
@Inject
protected OrganizationCatalogItemSupplier(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogSupplier,
Function<org.jclouds.vcloud.domain.Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
this.catalogSupplier = catalogSupplier;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
}
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
return transformValues(
catalogSupplier.get(),
new Function<Map<String, ? extends org.jclouds.vcloud.domain.Catalog>, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>() {
@Override
public Map<String, Map<String, ? extends CatalogItem>> apply(
Map<String, ? extends org.jclouds.vcloud.domain.Catalog> from) {
return transformValues(
from,
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
@Override
public Map<String, ? extends CatalogItem> apply(
org.jclouds.vcloud.domain.Catalog from) {
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
}
});
}
});
}
}
@Provides
@Singleton
protected Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> provideOrganizationCatalogItemSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationCatalogItemSupplier supplier) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>(
authException, seconds,
new Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>>() {
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
return supplier.get();
}
});
}
@Provides
@Singleton
@org.jclouds.vcloud.endpoints.VCloudLogin
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
TimeoutException {
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
checkState(versions.size() > 0, "No versions present");
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
return versions.get(version);
}
@Singleton
private static class OrgNameToOrgSupplier implements Supplier<Map<String, NamedResource>> {
private final Supplier<VCloudSession> sessionSupplier;
@SuppressWarnings("unused")
@Inject
OrgNameToOrgSupplier(Supplier<VCloudSession> sessionSupplier) {
this.sessionSupplier = sessionSupplier;
}
@Override
public Map<String, NamedResource> get() {
return sessionSupplier.get().getOrgs();
}
}
@Provides
@Singleton
protected VCloudLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
return factory.create(VCloudLoginAsyncClient.class);
}
@Provides
@Singleton
protected VCloudVersionsAsyncClient provideVCloudVersions(AsyncClientFactory factory) {
return factory.create(VCloudVersionsAsyncClient.class);
}
@Provides
@Singleton
protected abstract Organization provideOrganization(S client);
@Provides
@VDC
@Singleton
protected URI provideDefaultVDC(Organization org) {
checkState(org.getVDCs().size() > 0, "No vdcs present in org: " + org.getName());
return get(org.getVDCs().values(), 0).getId();
}
@Provides
@Catalog
@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).getId();
}
@Provides
@Catalog
@Singleton
protected String provideCatalogName(
Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>>> catalogs) {
return getLast(getLast(catalogs.get().values()).keySet());
}
@Provides
@Network
@Singleton
protected abstract URI provideDefaultNetwork(S client);
@Provides
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK)
@Singleton
String provideDefaultNetworkString(@Network URI network) {
return network.toASCIIString();
}
@Override
protected void bindErrorHandlers() {
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseVCloudErrorFromHttpResponse.class);
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
}
@Provides
@TasksList
@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).getId();
}
}

View File

@ -0,0 +1,41 @@
/**
*
* 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.config;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressClient;
/**
* Configures the VCloud authentication service connection, including logging and http transport.
*
* @author Adrian Cole
*/
@RequiresHttp
@ConfiguresRestClient
public class VCloudExpressRestClientModule extends
BaseVCloudExpressRestClientModule<VCloudExpressClient, VCloudExpressAsyncClient> {
public VCloudExpressRestClientModule() {
super(VCloudExpressClient.class, VCloudExpressAsyncClient.class);
}
}

View File

@ -25,8 +25,7 @@ import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudClient;
/**
* 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
*/

View File

@ -21,14 +21,14 @@ package org.jclouds.vcloud.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
/**
*
* VirtualResource such as disks or CPU
*
* @author Adrian Cole
* @see VCloudAsyncClient#getVApp
* @see VCloudExpressAsyncClient#getVApp
* @see <a href="http://blogs.vmware.com/vapp/2009/11/index.html"/>
*
*/

View File

@ -25,7 +25,7 @@ import java.net.URI;
import java.util.LinkedHashMap;
import java.util.Map;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
@ -105,7 +105,7 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
@Override
public String getType() {
return VCloudMediaType.CATALOG_XML;
return VCloudExpressMediaType.CATALOG_XML;
}
@Override

View File

@ -26,7 +26,7 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.NamedResource;
@ -47,7 +47,7 @@ public class CatalogItemImpl extends NamedResourceImpl implements CatalogItem {
public CatalogItemImpl(String name, URI id, @Nullable String description, NamedResource entity,
Map<String, String> properties) {
super(name, VCloudMediaType.CATALOGITEM_XML, id);
super(name, VCloudExpressMediaType.CATALOGITEM_XML, id);
this.description = description;
this.entity = checkNotNull(entity, "entity");
this.properties.putAll(checkNotNull(properties, "properties"));
@ -55,7 +55,7 @@ public class CatalogItemImpl extends NamedResourceImpl implements CatalogItem {
@Override
public String getType() {
return VCloudMediaType.CATALOGITEM_XML;
return VCloudExpressMediaType.CATALOGITEM_XML;
}
public NamedResource getEntity() {

View File

@ -22,7 +22,7 @@ package org.jclouds.vcloud.domain.internal;
import java.net.URI;
import java.util.Set;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.FirewallRule;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.NatRule;
@ -53,7 +53,7 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
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);
super(name, VCloudExpressMediaType.NETWORK_XML, id);
this.description = description;
this.dnsServers.addAll(dnsServers);
this.gateway = gateway;

View File

@ -22,7 +22,7 @@ package org.jclouds.vcloud.domain.internal;
import java.net.URI;
import java.util.Map;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.endpoints.Catalog;
@ -130,7 +130,7 @@ public class OrganizationImpl implements Organization {
@Override
public String getType() {
return VCloudMediaType.ORG_XML;
return VCloudExpressMediaType.ORG_XML;
}
@Override

View File

@ -24,7 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VApp;
@ -207,7 +207,7 @@ public class VAppImpl implements VApp {
@Override
public String getType() {
return VCloudMediaType.VAPP_XML;
return VCloudExpressMediaType.VAPP_XML;
}
@Override

View File

@ -23,7 +23,7 @@ import java.net.URI;
import javax.annotation.Nullable;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VAppTemplate;
@ -40,7 +40,7 @@ public class VAppTemplateImpl extends NamedResourceImpl implements VAppTemplate
private final VAppStatus status;
public VAppTemplateImpl(String name, URI id, @Nullable String description, @Nullable VAppStatus status) {
super(name, VCloudMediaType.VAPPTEMPLATE_XML, id);
super(name, VCloudExpressMediaType.VAPPTEMPLATE_XML, id);
this.description = description;
this.status = status;
}

View File

@ -24,7 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Quota;
@ -198,7 +198,7 @@ public class VDCImpl implements VDC {
@Override
public String getType() {
return VCloudMediaType.VDC_XML;
return VCloudExpressMediaType.VDC_XML;
}
@Override

View File

@ -55,7 +55,8 @@ public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? ex
private final ExecutorService executor;
@Inject
AllCatalogItemsInCatalog(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
AllCatalogItemsInCatalog(VCloudAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}

View File

@ -43,13 +43,13 @@ public class AllCatalogItemsInOrganization implements Function<Organization, Ite
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final AllCatalogsInOrganization allCatalogsInOrganization;
private final Function<Organization, Iterable<? extends Catalog>> allCatalogsInOrganization;
private final AllCatalogItemsInCatalog allCatalogItemsInCatalog;
private final Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog;
@Inject
AllCatalogItemsInOrganization(AllCatalogsInOrganization allCatalogsInOrganization,
AllCatalogItemsInCatalog allCatalogItemsInCatalog) {
AllCatalogItemsInOrganization(Function<Organization, Iterable<? extends Catalog>> allCatalogsInOrganization,
Function<Catalog, Iterable<? extends CatalogItem>> allCatalogItemsInCatalog) {
this.allCatalogsInOrganization = allCatalogsInOrganization;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
}

View File

@ -52,7 +52,8 @@ public class AllCatalogsInOrganization implements Function<Organization, Iterabl
private final ExecutorService executor;
@Inject
AllCatalogsInOrganization(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
AllCatalogsInOrganization(VCloudAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@ -60,14 +61,14 @@ public class AllCatalogsInOrganization implements Function<Organization, Iterabl
@Override
public Iterable<? extends Catalog> apply(final Organization org) {
Iterable<Catalog> catalogs = transformParallel(org.getCatalogs().values(),
new Function<NamedResource, Future<Catalog>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Catalog> apply(NamedResource from) {
return (Future<Catalog>) aclient.getCatalog(from.getId());
}
new Function<NamedResource, Future<Catalog>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Catalog> apply(NamedResource from) {
return (Future<Catalog>) aclient.getCatalog(from.getId());
}
}, executor, null, logger, "catalogs in " + org.getName());
}, executor, null, logger, "catalogs in " + org.getName());
return catalogs;
}
}

View File

@ -52,7 +52,8 @@ public class AllVDCsInOrganization implements Function<Organization, Iterable<?
private final ExecutorService executor;
@Inject
AllVDCsInOrganization(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
AllVDCsInOrganization(VCloudAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@ -61,14 +62,14 @@ public class AllVDCsInOrganization implements Function<Organization, Iterable<?
public Iterable<? extends VDC> apply(final Organization org) {
Iterable<VDC> catalogItems = transformParallel(org.getVDCs().values(),
new Function<NamedResource, Future<VDC>>() {
@SuppressWarnings("unchecked")
@Override
public Future<VDC> apply(NamedResource from) {
return (Future<VDC>) aclient.getVDC(from.getId());
}
new Function<NamedResource, Future<VDC>>() {
@SuppressWarnings("unchecked")
@Override
public Future<VDC> apply(NamedResource from) {
return (Future<VDC>) aclient.getVDC(from.getId());
}
}, executor, null, logger, "vdcs in org " + org.getName());
}, executor, null, logger, "vdcs in org " + org.getName());
return catalogItems;
}

View File

@ -46,7 +46,7 @@ import com.google.common.base.Predicate;
*/
@Singleton
public class VAppTemplatesForCatalogItems implements
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> {
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
@ -55,7 +55,7 @@ public class VAppTemplatesForCatalogItems implements
@Inject
VAppTemplatesForCatalogItems(VCloudAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}

View File

@ -34,8 +34,8 @@ import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.VAppTemplate;
@ -51,11 +51,11 @@ public class VAppTemplatesForResourceEntities implements
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudAsyncClient aclient;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VAppTemplatesForResourceEntities(VCloudAsyncClient aclient,
VAppTemplatesForResourceEntities(VCloudExpressAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
@ -67,7 +67,7 @@ public class VAppTemplatesForResourceEntities implements
@Override
public boolean apply(NamedResource input) {
return input.getType().equals(VCloudMediaType.VAPPTEMPLATE_XML);
return input.getType().equals(VCloudExpressMediaType.VAPPTEMPLATE_XML);
}
}), new Function<NamedResource, Future<VAppTemplate>>() {

View File

@ -0,0 +1,85 @@
/**
*
* 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.collect.Iterables.filter;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.NamedResource;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressAllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VCloudExpressAllCatalogItemsInCatalog(VCloudExpressAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<? extends CatalogItem> apply(Catalog from) {
Iterable<CatalogItem> catalogItems = transformParallel(filter(from.values(), new Predicate<NamedResource>() {
@Override
public boolean apply(NamedResource input) {
return input.getType().equals(VCloudExpressMediaType.CATALOGITEM_XML);
}
}), new Function<NamedResource, Future<CatalogItem>>() {
@SuppressWarnings("unchecked")
@Override
public Future<CatalogItem> apply(NamedResource from) {
return (Future<CatalogItem>) aclient.getCatalogItem(from.getId());
}
}, executor, null, logger, "catalogItems in " + from.getId());
return catalogItems;
}
}

View File

@ -0,0 +1,73 @@
/**
*
* 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 org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressAllCatalogsInOrganization implements Function<Organization, Iterable<? extends Catalog>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VCloudExpressAllCatalogsInOrganization(VCloudExpressAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<? extends Catalog> apply(final Organization org) {
Iterable<Catalog> catalogs = transformParallel(org.getCatalogs().values(),
new Function<NamedResource, Future<Catalog>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Catalog> apply(NamedResource from) {
return (Future<Catalog>) aclient.getCatalog(from.getId());
}
}, executor, null, logger, "catalogs in " + org.getName());
return catalogs;
}
}

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 org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.VDC;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressAllVDCsInOrganization implements Function<Organization, Iterable<? extends VDC>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VCloudExpressAllVDCsInOrganization(VCloudExpressAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<? extends VDC> apply(final Organization org) {
Iterable<VDC> catalogItems = transformParallel(org.getVDCs().values(),
new Function<NamedResource, Future<VDC>>() {
@SuppressWarnings("unchecked")
@Override
public Future<VDC> apply(NamedResource from) {
return (Future<VDC>) aclient.getVDC(from.getId());
}
}, executor, null, logger, "vdcs in org " + org.getName());
return catalogItems;
}
}

View File

@ -0,0 +1,70 @@
/**
*
* 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 org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.domain.Organization;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressOrganizationsForNames implements Function<Iterable<String>, Iterable<? extends Organization>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VCloudExpressOrganizationsForNames(VCloudExpressAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<? extends Organization> apply(Iterable<String> from) {
return transformParallel(from, new Function<String, Future<Organization>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Organization> apply(String from) {
return (Future<Organization>) aclient.findOrganizationNamed(from);
}
}, executor, null, logger, "organizations for names");
}
}

View File

@ -0,0 +1,98 @@
/**
*
* 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.collect.Iterables.filter;
import static com.google.common.collect.Iterables.transform;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.net.URI;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.compute.domain.VCloudLocation;
import org.jclouds.vcloud.domain.Organization;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Sets;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressOrganizatonsForLocations implements
Function<Iterable<? extends Location>, Iterable<? extends Organization>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VCloudExpressOrganizatonsForLocations(VCloudExpressAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
/**
* Zones are assignable, but we want regions. so we look for zones, whose
* parent is region. then, we use a set to extract the unique set.
*/
@Override
public Iterable<? extends Organization> apply(Iterable<? extends Location> from) {
return transformParallel(Sets.newLinkedHashSet(transform(filter(from, new Predicate<Location>() {
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.ZONE;
}
}), new Function<Location, URI>() {
@Override
public URI apply(Location from) {
return VCloudLocation.class.cast(from.getParent()).getResource().getId();
}
})), new Function<URI, Future<Organization>>() {
@SuppressWarnings("unchecked")
@Override
public Future<Organization> apply(URI from) {
return (Future<Organization>) aclient.getOrganization(from);
}
}, executor, null, logger, "organizations for uris");
}
}

View File

@ -0,0 +1,83 @@
/**
*
* 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.collect.Iterables.filter;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
/**
* @author Adrian Cole
*/
@Singleton
public class VCloudExpressVAppTemplatesForCatalogItems implements
Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
public Logger logger = Logger.NULL;
private final VCloudExpressAsyncClient aclient;
private final ExecutorService executor;
@Inject
VCloudExpressVAppTemplatesForCatalogItems(VCloudExpressAsyncClient aclient,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<? extends VAppTemplate> apply(Iterable<? extends CatalogItem> from) {
return transformParallel(filter(from, new Predicate<CatalogItem>() {
@Override
public boolean apply(CatalogItem input) {
return input.getEntity().getType().equals(VCloudExpressMediaType.VAPPTEMPLATE_XML);
}
}), new Function<CatalogItem, Future<VAppTemplate>>() {
@SuppressWarnings("unchecked")
@Override
public Future<VAppTemplate> apply(CatalogItem from) {
return (Future<VAppTemplate>) aclient.getVAppTemplate(from.getEntity().getId());
}
}, executor, null, logger, "vappTemplates in");
}
}

View File

@ -28,7 +28,7 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.endpoints.Org;
@ -61,6 +61,6 @@ public interface VCloudLoginAsyncClient {
*/
@POST
@ResponseParser(ParseLoginResponseFromHeaders.class)
@Consumes(VCloudMediaType.ORGLIST_XML)
@Consumes(VCloudExpressMediaType.ORGLIST_XML)
ListenableFuture<VCloudSession> login();
}

View File

@ -54,14 +54,12 @@ public class InstantiateVAppTemplateOptions {
return this;
}
public InstantiateVAppTemplateOptions productProperty(String key,
String value) {
public InstantiateVAppTemplateOptions productProperty(String key, String value) {
properties.put(checkNotNull(key, "key"), checkNotNull(value, "value"));
return this;
}
public InstantiateVAppTemplateOptions productProperties(
Map<String, String> properties) {
public InstantiateVAppTemplateOptions productProperties(Map<String, String> properties) {
this.properties.putAll(checkNotNull(properties, "properties"));
return this;
}
@ -95,8 +93,7 @@ public class InstantiateVAppTemplateOptions {
}
public InstantiateVAppTemplateOptions inNetwork(URI networkLocation) {
this.network = checkNotNull(networkLocation, "networkLocation")
.toASCIIString();
this.network = checkNotNull(networkLocation, "networkLocation").toASCIIString();
return this;
}
@ -133,8 +130,7 @@ public class InstantiateVAppTemplateOptions {
/**
* @see InstantiateVAppTemplateOptions#blockOnDeploy
*/
public static InstantiateVAppTemplateOptions blockOnDeploy(
boolean blockOnDeploy) {
public static InstantiateVAppTemplateOptions blockOnDeploy(boolean blockOnDeploy) {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
return options.blockOnDeploy(blockOnDeploy);
}
@ -182,8 +178,7 @@ public class InstantiateVAppTemplateOptions {
/**
* @see InstantiateVAppTemplateOptions#networkName(String)
*/
public static InstantiateVAppTemplateOptions networkName(
String networkName) {
public static InstantiateVAppTemplateOptions networkName(String networkName) {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
return options.networkName(networkName);
}
@ -191,8 +186,7 @@ public class InstantiateVAppTemplateOptions {
/**
* @see InstantiateVAppTemplateOptions#productProperty(String,String)
*/
public static InstantiateVAppTemplateOptions productProperty(String key,
String value) {
public static InstantiateVAppTemplateOptions productProperty(String key, String value) {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
return options.productProperty(key, value);
}
@ -200,8 +194,7 @@ public class InstantiateVAppTemplateOptions {
/**
* @see InstantiateVAppTemplateOptions#setProperties(Map<String, String>)
*/
public static InstantiateVAppTemplateOptions productProperties(
Map<String, String> properties) {
public static InstantiateVAppTemplateOptions productProperties(Map<String, String> properties) {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
return options.productProperties(properties);
}
@ -209,11 +202,9 @@ public class InstantiateVAppTemplateOptions {
@Override
public String toString() {
return "InstantiateVAppTemplateOptions [cpuCount=" + cpuCount
+ ", memorySizeMegabytes=" + memorySizeMegabytes
+ ", diskSizeKilobytes=" + diskSizeKilobytes + ", network="
+ network + ", networkName=" + networkName + ", fenceMode="
+ fenceMode + ", properties=" + properties + "]";
return "InstantiateVAppTemplateOptions [cpuCount=" + cpuCount + ", memorySizeMegabytes=" + memorySizeMegabytes
+ ", diskSizeKilobytes=" + diskSizeKilobytes + ", network=" + network + ", networkName=" + networkName
+ ", fenceMode=" + fenceMode + ", properties=" + properties + "]";
}
@Override
@ -221,19 +212,12 @@ public class InstantiateVAppTemplateOptions {
final int prime = 31;
int result = 1;
result = prime * result + ((cpuCount == null) ? 0 : cpuCount.hashCode());
result = prime * result
+ ((diskSizeKilobytes == null) ? 0 : diskSizeKilobytes.hashCode());
result = prime * result
+ ((fenceMode == null) ? 0 : fenceMode.hashCode());
result = prime
* result
+ ((memorySizeMegabytes == null) ? 0 : memorySizeMegabytes
.hashCode());
result = prime * result + ((diskSizeKilobytes == null) ? 0 : diskSizeKilobytes.hashCode());
result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
result = prime * result + ((memorySizeMegabytes == null) ? 0 : memorySizeMegabytes.hashCode());
result = prime * result + ((network == null) ? 0 : network.hashCode());
result = prime * result
+ ((networkName == null) ? 0 : networkName.hashCode());
result = prime * result
+ ((properties == null) ? 0 : properties.hashCode());
result = prime * result + ((networkName == null) ? 0 : networkName.hashCode());
result = prime * result + ((properties == null) ? 0 : properties.hashCode());
return result;
}

View File

@ -19,13 +19,15 @@
package org.jclouds.vcloud.predicates;
import java.net.URI;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.logging.Logger;
import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
@ -37,23 +39,27 @@ import com.google.inject.Inject;
* @author Adrian Cole
*/
@Singleton
public class VAppNotFound implements Predicate<VApp> {
public class VCloudExpressTaskSuccess implements Predicate<URI> {
private final VCloudClient client;
private final VCloudExpressClient client;
@Resource
protected Logger logger = Logger.NULL;
@Inject
public VAppNotFound(VCloudClient client) {
public VCloudExpressTaskSuccess(VCloudExpressClient client) {
this.client = client;
}
public boolean apply(VApp vApp) {
try {
return client.getVApp(vApp.getId()) == null;
} catch (ResourceNotFoundException e) {
return true;
}
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.getLocation() + " error: " + task.getError());
return task.getStatus() == TaskStatus.SUCCESS;
}
}

View File

@ -19,9 +19,9 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.VDC_XML;
import static org.jclouds.vcloud.util.Utils.newNamedResource;
import static org.jclouds.vcloud.util.Utils.putNamedResource;

View File

@ -19,7 +19,7 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.ORG_XML;
import static org.jclouds.vcloud.util.Utils.putNamedResource;
import java.util.Map;

View File

@ -27,7 +27,7 @@ import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VApp;
@ -87,7 +87,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
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(VCloudExpressMediaType.VDC_XML)) {
vDC = Utils.newNamedResource(attributes);
}
} else if (qName.equals("OperatingSystemSection")) {

View File

@ -37,12 +37,14 @@ public class ProvidersInPropertiesTest {
public void testSupportedProviders() {
Iterable<String> providers = Utils.getSupportedProviders();
assert Iterables.contains(providers, "vcloud") : providers;
assert Iterables.contains(providers, "vcloudexpress") : providers;
}
@Test
public void testSupportedComputeServiceProviders() {
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
assert Iterables.contains(providers, "vcloud") : providers;
assert Iterables.contains(providers, "vcloudexpress") : providers;
}
}

View File

@ -90,16 +90,16 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class);
String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp");
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp");
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp-hosting.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppHandler.class);
@ -109,21 +109,20 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException,
IOException {
IOException {
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp", processorCount(1).memory(
512).disk(1024).fenceMode("allowInOut").inNetwork(
URI.create("https://vcloud.safesecureweb.com/network/1990")));
String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor
.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp",
processorCount(1).memory(512).disk(1024).inNetwork(
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream(
"/newvapp-hostingcpumemdisk.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
false);
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp-cpumemdisk.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppHandler.class);
@ -134,25 +133,26 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException,
IOException {
IOException {
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class);
processor.createRequest(method, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "CentOS 01", processorCount(1).memory(512)
.disk(1024).inNetwork(URI.create("https://vcloud.safesecureweb.com/network/1990")));
String.class, InstantiateVAppTemplateOptions[].class);
processor.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512)
.disk(1024).inNetwork(URI.create("https://vcenterprise.bluelock.com/network/1990")));
}
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
CloneVAppOptions[].class);
CloneVAppOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/4181"), "my-vapp");
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp");
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
assertRequestLineEquals(request,
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")),
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
@ -163,16 +163,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
CloneVAppOptions[].class);
CloneVAppOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/201"), "new-linux-server", new CloneVAppOptions()
.deploy().powerOn().withDescription("The description of the new vApp"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server",
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
assertRequestLineEquals(request,
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")),
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
@ -185,7 +186,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("getDefaultOrganization");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(request, null, null, false);
@ -199,9 +200,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testOrganization() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getOrganization", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(request, null, null, false);
@ -216,7 +217,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("findOrganizationNamed", String.class);
HttpRequest request = processor.createRequest(method, "org");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(request, null, null, false);
@ -231,7 +232,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("getDefaultCatalog");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertPayloadEquals(request, null, null, false);
@ -245,9 +246,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getCatalog", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertPayloadEquals(request, null, null, false);
@ -262,7 +263,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "catalog");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertPayloadEquals(request, null, null, false);
@ -276,9 +277,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getNetwork", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/network/2"));
.create("https://vcenterprise.bluelock.com/api/v1.0/network/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/network/2 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
assertPayloadEquals(request, null, null, false);
@ -292,9 +293,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getCatalogItem", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"));
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
assertPayloadEquals(request, null, null, false);
@ -307,10 +308,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, String.class,
String.class);
String.class);
HttpRequest request = processor.createRequest(method, "org", "catalog", "item");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
assertPayloadEquals(request, null, null, false);
@ -323,10 +324,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
String.class, String.class);
String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "catalog", "template");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
assertPayloadEquals(request, null, null, false);
@ -340,9 +341,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
assertPayloadEquals(request, null, null, false);
@ -357,7 +358,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("getDefaultVDC");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
@ -372,7 +373,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "vdc");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
@ -399,7 +400,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, null, "vdc");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
@ -414,7 +415,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, null, null);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
@ -428,9 +429,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
@ -445,7 +446,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/taskslist HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/taskslist HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertPayloadEquals(request, null, null, false);
@ -459,9 +460,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getTasksList", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/tasksList/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertPayloadEquals(request, null, null, false);
@ -476,7 +477,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
Method method = VCloudAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "tasksList");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/tasksList/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertPayloadEquals(request, null, null, false);
@ -490,9 +491,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("deployVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/action/deploy HTTP/1.1");
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -506,9 +507,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, null, null, false);
@ -522,9 +523,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("undeployVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/action/undeploy HTTP/1.1");
assertRequestLineEquals(request,
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -538,9 +540,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
@ -554,10 +556,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("powerOnVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -571,10 +573,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("powerOffVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -588,10 +590,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testReset() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("resetVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/reset HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -605,10 +607,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testSuspend() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("suspendVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/suspend HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -622,10 +624,10 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testShutdown() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("shutdownVApp", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/shutdown HTTP/1.1");
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
@ -639,9 +641,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/task/1 HTTP/1.1");
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
@ -655,9 +657,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/task/1/action/cancel HTTP/1.1");
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
@ -688,7 +690,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public ContextSpec<?, ?> createContextSpec() {
Properties overrides = new Properties();
overrides.setProperty("vcloud.endpoint", "https://vcloud.safesecureweb.com/api/v0.8");
overrides.setProperty("vcloud.endpoint", "https://vcenterprise.bluelock.com/api/v1.0");
return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides);
}
@ -697,13 +699,13 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
public static class VCloudRestClientModuleExtension extends VCloudRestClientModule {
@Override
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
@Named(PROPERTY_API_VERSION) String version) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login");
@Named(PROPERTY_API_VERSION) String version) {
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login");
}
@Override
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/org");
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/org");
}
@ -714,7 +716,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog");
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog");
}
@ -730,28 +732,28 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
protected URI provideDefaultTasksList(Organization org) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/taskslist");
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/taskslist");
}
@Override
protected URI provideDefaultVDC(Organization org) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1");
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1");
}
@Override
protected URI provideDefaultNetwork(VCloudClient client) {
return URI.create("https://vcloud.safesecureweb.com/network/1990");
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990");
}
@Override
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final VCloudLoginAsyncClient login) {
final VCloudLoginAsyncClient login) {
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
@Override
public Map<String, NamedResource> getOrgs() {
return ImmutableMap.<String, NamedResource> of("org", new NamedResourceImpl("org",
VCloudMediaType.ORG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")));
VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")));
}
@Override
@ -772,18 +774,41 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
}
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrganizationVDCSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrganizationVDCSupplier supplier) {
@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",
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))));
ImmutableMap
.<String, org.jclouds.vcloud.domain.VDC> of(
"vdc",
new VDCImpl(
"vdc",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/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://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")),
"network",
new NamedResourceImpl(
"network",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))),
null))));
}
@ -797,14 +822,15 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public Map<String, Organization> get() {
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("catalog", VCloudMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<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("tasksList",
VCloudMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")))));
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), ImmutableMap
.<String, NamedResource> of("catalog", new NamedResourceImpl("catalog",
VCloudMediaType.CATALOG_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
.<String, NamedResource> of("vdc", new NamedResourceImpl("vdc", VCloudMediaType.VDC_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap
.<String, NamedResource> of("tasksList", new NamedResourceImpl("tasksList",
VCloudMediaType.TASKSLIST_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")))));
}
}
@ -817,15 +843,32 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
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",
return ImmutableMap
.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of(
"org",
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("item",
"application/vnd.vmware.vcloud.catalogItem+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), "template",
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))))));
ImmutableMap
.<String, org.jclouds.vcloud.domain.Catalog> of(
"catalog",
new CatalogImpl(
"catalog",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"),
"description",
ImmutableMap
.<String, NamedResource> of(
"item",
new NamedResourceImpl(
"item",
"application/vnd.vmware.vcloud.catalogItem+xml",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
"template",
new NamedResourceImpl(
"template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))))));
}
}
@ -837,14 +880,26 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
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("template", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "description",
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
ImmutableMap.<String, String> of()))));
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(
"template",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"),
"description",
new NamedResourceImpl(
"template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
ImmutableMap.<String, String> of()))));
}
}

View File

@ -53,6 +53,7 @@ public class VCloudClientLiveTest {
protected VCloudClient connection;
protected String identity;
protected RestContext<VCloudClient, VCloudAsyncClient> context;
private String credential;
@Test
public void testOrganization() throws Exception {
@ -156,16 +157,17 @@ public class VCloudClientLiveTest {
}
}
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("vcloud.identity"), "vcloud.identity");
credential = checkNotNull(System.getProperty("vcloud.credential"), "vcloud.credential");
}
@BeforeGroups(groups = { "live" })
public void setupClient() {
String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), "jclouds.test.endpoint");
identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
setupCredentials();
Properties props = new Properties();
props.setProperty("vcloud.endpoint", endpoint);
context = new RestContextFactory().createContext("vcloud", identity, credential, ImmutableSet
.<Module> of(new Log4JLoggingModule()), props);
.<Module> of(new Log4JLoggingModule()), props);
connection = context.getApi();
}

View File

@ -0,0 +1,870 @@
/**
*
* 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;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_IDENTITY;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Utils;
import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Organization;
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;
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.xml.CatalogHandler;
import org.jclouds.vcloud.xml.CatalogItemHandler;
import org.jclouds.vcloud.xml.NetworkHandler;
import org.jclouds.vcloud.xml.OrgHandler;
import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.TasksListHandler;
import org.jclouds.vcloud.xml.VAppHandler;
import org.jclouds.vcloud.xml.VAppTemplateHandler;
import org.jclouds.vcloud.xml.VDCHandler;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* Tests behavior of {@code VCloudExpressAsyncClient}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.VCloudExpressAsyncClientTest")
public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAsyncClient> {
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp");
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass()
.getResourceAsStream("/express/newvapp-hosting.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException,
IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp", processorCount(1)
.memory(512).disk(1024).fenceMode("allowInOut").inNetwork(
URI.create("https://vcloud.safesecureweb.com/network/1990")));
assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream(
"/express/newvapp-hostingcpumemdisk.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException,
IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class);
processor.createRequest(method, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "CentOS 01", processorCount(1).memory(512)
.disk(1024).inNetwork(URI.create("https://vcloud.safesecureweb.com/network/1990")));
}
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
CloneVAppOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/4181"), "my-vapp");
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream(
"/express/cloneVApp-default.xml")), "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
CloneVAppOptions[].class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/201"), "new-linux-server",
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp.xml")),
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testDefaultOrganization() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getDefaultOrganization");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, OrgHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testOrganization() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getOrganization", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, OrgHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindOrganizationNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findOrganizationNamed", String.class);
HttpRequest request = processor.createRequest(method, "org");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, OrgHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testDefaultCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getDefaultCatalog");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "catalog");
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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NetworkHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class,
String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "catalog", "item");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "catalog", "template");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getVAppTemplate", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testGetDefaultVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getDefaultVDC");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "vdc");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
@Test(expectedExceptions = NoSuchElementException.class)
public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
processor.createRequest(method, "org", "vdc1");
}
@Test(expectedExceptions = NoSuchElementException.class)
public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
processor.createRequest(method, "org1", "vdc");
}
public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, null, "vdc");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, null, null);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getVDC", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("getDefaultTasksList");
HttpRequest request = processor.createRequest(method);
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/taskslist HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "tasksList");
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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VAppHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
checkFilters(request);
}
public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testReset() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testSuspend() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testShutdown() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, TaskHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.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, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
@Override
protected void checkFilters(HttpRequest request) {
assertEquals(request.getFilters().size(), 1);
assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<VCloudExpressAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<VCloudExpressAsyncClient>>() {
};
}
@Override
protected Module createModule() {
return new VCloudRestClientModuleExtension();
}
@Override
public ContextSpec<?, ?> createContextSpec() {
Properties overrides = new Properties();
overrides.setProperty("vcloudexpress.endpoint", "https://vcloud.safesecureweb.com/api/v0.8");
return new RestContextFactory().createContextSpec("vcloudexpress", "identity", "credential", overrides);
}
@RequiresHttp
@ConfiguresRestClient
public static class VCloudRestClientModuleExtension extends VCloudExpressRestClientModule {
@Override
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
@Named(PROPERTY_API_VERSION) String version) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login");
}
@Override
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/org");
}
@Override
protected String provideOrgName(@Org Iterable<NamedResource> orgs) {
return "org";
}
@Override
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog");
}
@Override
protected Organization provideOrganization(VCloudExpressClient discovery) {
return null;
}
@Override
protected Iterable<NamedResource> provideOrgs(Supplier<VCloudSession> cache, @Named(PROPERTY_IDENTITY) String user) {
return null;
}
@Override
protected URI provideDefaultTasksList(Organization org) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/taskslist");
}
@Override
protected URI provideDefaultVDC(Organization org) {
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1");
}
@Override
protected URI provideDefaultNetwork(VCloudExpressClient client) {
return URI.create("https://vcloud.safesecureweb.com/network/1990");
}
@Override
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final VCloudLoginAsyncClient login) {
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
@Override
public Map<String, NamedResource> getOrgs() {
return ImmutableMap.<String, NamedResource> of("org", new NamedResourceImpl("org",
VCloudExpressMediaType.ORG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")));
}
@Override
public String getVCloudToken() {
return "token";
}
});
}
@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
protected TestOrganizationMapSupplier() {
super(null, null);
}
@Override
public Map<String, Organization> get() {
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("catalog",
VCloudExpressMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<String, NamedResource> of("vdc", new NamedResourceImpl("vdc", VCloudExpressMediaType.VDC_XML,
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, NamedResource> of("tasksList", new NamedResourceImpl("tasksList",
VCloudExpressMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")))));
}
}
@Singleton
public static class TestOrganizationCatalogSupplier extends OrganizationCatalogSupplier {
@Inject
protected TestOrganizationCatalogSupplier() {
super(null, null);
}
@Override
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("catalog", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"), "description", ImmutableMap
.<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("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))))));
}
}
@Singleton
public static class TestOrganizationCatalogItemSupplier extends OrganizationCatalogItemSupplier {
protected TestOrganizationCatalogItemSupplier() {
super(null, null);
}
@Override
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
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(
"template",
URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"),
"description",
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

@ -0,0 +1,175 @@
/**
*
* 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;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.util.Properties;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Network;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VDC;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/**
* Tests behavior of {@code VCloudClient}
*
* @author Adrian Cole
*/
@Test(groups = "live", sequential = true, testName = "vcloud.VCloudClientLiveTest")
public class VCloudExpressClientLiveTest {
protected VCloudExpressClient connection;
protected String identity;
protected RestContext<VCloudExpressClient, VCloudExpressAsyncClient> context;
private String credential;
@Test
public void testOrganization() throws Exception {
Organization response = connection.findOrganizationNamed(null);
assertNotNull(response);
assertNotNull(response.getName());
assert response.getCatalogs().size() >= 1;
assert response.getTasksLists().size() >= 1;
assert response.getVDCs().size() >= 1;
assertEquals(connection.findOrganizationNamed(response.getName()), response);
}
@Test
public void testCatalog() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getId());
assertEquals(connection.findCatalogInOrgNamed(null, response.getName()), response);
}
@Test
public void testGetNetwork() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
for (NamedResource resource : response.getAvailableNetworks().values()) {
if (resource.getType().equals(VCloudExpressMediaType.NETWORK_XML)) {
Network item = connection.getNetwork(resource.getId());
assertNotNull(item);
}
}
}
@Test
public void testGetCatalogItem() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudExpressMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, resource.getName());
assertNotNull(item);
assertNotNull(item.getEntity());
assertNotNull(item.getId());
assertNotNull(item.getProperties());
assertNotNull(item.getType());
}
}
}
@Test
public void testGetVAppTemplate() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudExpressMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getId());
if (item.getEntity().getType().equals(VCloudExpressMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(null, null, item.getEntity().getName()));
}
}
}
}
@Test
public void testDefaultVDC() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getId());
assertNotNull(response.getResourceEntities());
assertNotNull(response.getAvailableNetworks());
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.getLocation());
assertNotNull(response.getTasks());
assertEquals(connection.getTasksList(response.getLocation()).getLocation(), response.getLocation());
}
@Test
public void testGetTask() throws Exception {
org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
if (response.getTasks().size() > 0) {
Task task = response.getTasks().last();
assertEquals(connection.getTask(task.getLocation()).getLocation(), task.getLocation());
}
}
@Test
public void testGetVApp() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
for (NamedResource item : response.getResourceEntities().values()) {
if (item.getType().equals(VCloudExpressMediaType.VAPP_XML)) {
VApp app = connection.getVApp(item.getId());
assertNotNull(app);
}
}
}
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("vcloudexpress.identity"), "vcloudexpress.identity");
credential = checkNotNull(System.getProperty("vcloudexpress.credential"), "vcloudexpress.credential");
}
@BeforeGroups(groups = { "live" })
public void setupClient() {
setupCredentials();
Properties props = new Properties();
context = new RestContextFactory().createContext("vcloudexpress", identity, credential, ImmutableSet
.<Module> of(new Log4JLoggingModule()), props);
connection = context.getApi();
}
}

View File

@ -54,8 +54,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
@Override
protected void configure() {
Properties props = new Properties();
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(),
"properties"));
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
}
});
@ -70,19 +69,17 @@ public class BindCloneVAppParamsToXmlPayloadTest {
request.setPayload(expected);
replay(request);
BindCloneVAppParamsToXmlPayload binder = injector
.getInstance(BindCloneVAppParamsToXmlPayload.class);
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("newName", "new-linux-server");
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/201");
map.put("vApp", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201");
binder.bindToRequest(request, map);
verify(request);
}
public void testDefault() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
"/cloneVApp-default.xml"));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
@ -90,12 +87,11 @@ public class BindCloneVAppParamsToXmlPayloadTest {
request.setPayload(expected);
replay(request);
BindCloneVAppParamsToXmlPayload binder = injector
.getInstance(BindCloneVAppParamsToXmlPayload.class);
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("newName", "my-vapp");
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181");
map.put("vApp", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181");
binder.bindToRequest(request, map);
verify(request);
}

View File

@ -56,17 +56,13 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
@Override
protected void configure() {
Properties props = new Properties();
props
.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
"https://vcloud.safesecureweb.com/network/1990");
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(),
"properties"));
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK, "https://vcenterprise.bluelock.com/api/v1.0/network/1990");
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
}
});
public void testDefault() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
"/newvapp-hosting.xml"));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
@ -78,7 +74,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
binder.bindToRequest(request, map);
verify(request);
@ -88,8 +84,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
options.processorCount(1).memory(512).disk(1024);
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
"/newvapp-hostingcpumemdisk.xml"));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp-cpumemdisk.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] { options }).atLeastOnce();
@ -101,8 +96,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
map.put("network", "https://vcenterprise.bluelock.com/api/v1.0/network/1990");
binder.bindToRequest(request, map);
verify(request);
@ -110,8 +105,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
}
public void testWithNetworkNameDhcpFenceMode() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
"/newvapp-hostingnetworknamedhcpfencemode.xml"));
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp-networknamedhcpfencemode.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
@ -124,8 +118,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
map.put("network", "https://vcenterprise.bluelock.com/api/v1.0/network/1990");
map.put("networkName", "aloha");
map.put("fenceMode", FenceMode.BRIDGED);

View File

@ -0,0 +1,98 @@
/**
*
* 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.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.easymock.EasyMock.expect;
import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay;
import static org.easymock.classextension.EasyMock.verify;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Utils;
import org.jclouds.vcloud.VCloudExpressPropertiesBuilder;
import org.jclouds.vcloud.options.CloneVAppOptions;
import org.testng.annotations.Test;
import com.google.common.collect.Maps;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.name.Names;
/**
* Tests behavior of {@code BindCloneVAppParamsToXmlPayload}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.BindCloneVAppParamsToXmlPayloadTest")
public class VCloudExpressBindCloneVAppParamsToXmlPayloadTest {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
Properties props = new Properties();
Names.bindProperties(binder(), checkNotNull(new VCloudExpressPropertiesBuilder(props).build(), "properties"));
}
});
public void testWithDescriptionDeployOn() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp.xml"));
CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().withDescription(
"The description of the new vApp");
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] { options }).atLeastOnce();
request.setPayload(expected);
replay(request);
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("newName", "new-linux-server");
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/201");
binder.bindToRequest(request, map);
verify(request);
}
public void testDefault() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp-default.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
request.setPayload(expected);
replay(request);
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("newName", "my-vapp");
map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181");
binder.bindToRequest(request, map);
verify(request);
}
}

View File

@ -0,0 +1,132 @@
/**
*
* 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.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.easymock.EasyMock.expect;
import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay;
import static org.easymock.classextension.EasyMock.verify;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Utils;
import org.jclouds.vcloud.VCloudExpressPropertiesBuilder;
import org.jclouds.vcloud.domain.FenceMode;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.testng.annotations.Test;
import com.google.common.collect.Maps;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.name.Names;
/**
* Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.BindInstantiateVAppTemplateParamsToXmlPayloadTest")
public class VCloudExpressBindInstantiateVAppTemplateParamsToXmlPayloadTest {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
Properties props = new Properties();
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK, "https://vcloud.safesecureweb.com/network/1990");
Names.bindProperties(binder(), checkNotNull(new VCloudExpressPropertiesBuilder(props).build(), "properties"));
}
});
public void testDefault() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hosting.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
request.setPayload(expected);
replay(request);
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
binder.bindToRequest(request, map);
verify(request);
}
public void testWithProcessorMemoryDisk() throws IOException {
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
options.processorCount(1).memory(512).disk(1024);
String expected = Utils
.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hostingcpumemdisk.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] { options }).atLeastOnce();
request.setPayload(expected);
replay(request);
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
binder.bindToRequest(request, map);
verify(request);
}
public void testWithNetworkNameDhcpFenceMode() throws IOException {
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
"/express/newvapp-hostingnetworknamedhcpfencemode.xml"));
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
request.setPayload(expected);
replay(request);
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
Map<String, String> map = Maps.newHashMap();
map.put("name", "my-vapp");
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
map.put("networkName", "aloha");
map.put("fenceMode", FenceMode.BRIDGED);
binder.bindToRequest(request, map);
verify(request);
}
}

View File

@ -28,7 +28,6 @@ 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;
import java.util.concurrent.TimeoutException;
@ -83,6 +82,8 @@ public class VCloudComputeClientLiveTest {
protected Map<OsFamily, Expectation> expectationMap;
protected Predicate<String> addressTester;
private String identity;
private String credential;
@Test(enabled = true)
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException, IOException {
@ -94,7 +95,7 @@ public class VCloudComputeClientLiveTest {
VAppTemplate template = client.findVAppTemplateInOrgCatalogNamed(null, null, templateName);
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024).productProperties(
ImmutableMap.of("foo", "bar"));
ImmutableMap.of("foo", "bar"));
id = URI.create(computeClient.start(null, template.getId(), templateName, options).get("id"));
Expectation expectation = expectationMap.get(toTest);
@ -106,7 +107,7 @@ public class VCloudComputeClientLiveTest {
private String getCompatibleServerName(OsFamily toTest) {
String serverName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, toTest.toString()).substring(0,
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
return serverName;
}
@ -117,19 +118,20 @@ public class VCloudComputeClientLiveTest {
}
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
int memory, long hardDisk) {
int memory, long hardDisk) {
// assertEquals(vApp.getName(), serverName);
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
assertEquals(Iterables
.getOnlyElement(filter(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)))
.getVirtualQuantity(), processorCount);
.getOnlyElement(filter(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)))
.getVirtualQuantity(), processorCount);
assertEquals(Iterables.getOnlyElement(
filter(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER))).getVirtualQuantity(), 1);
filter(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER))).getVirtualQuantity(),
1);
assertEquals(Iterables.getOnlyElement(filter(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)))
.getVirtualQuantity(), memory);
.getVirtualQuantity(), memory);
assertEquals(Iterables.getOnlyElement(
filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))).getVirtualQuantity(),
hardDisk);
filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))).getVirtualQuantity(),
hardDisk);
}
@AfterTest
@ -138,23 +140,23 @@ public class VCloudComputeClientLiveTest {
computeClient.stop(id);
}
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("vcloud.identity"), "vcloud.identity");
credential = checkNotNull(System.getProperty("vcloud.credential"), "vcloud.credential");
}
@BeforeGroups(groups = { "live" })
public void setupClient() {
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), "jclouds.test.endpoint");
Properties props = new Properties();
props.setProperty("vcloud.endpoint", endpoint);
setupCredentials();
Injector injector = new RestContextFactory().createContextBuilder("vcloud", identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule()), props).buildInjector();
ImmutableSet.<Module> of(new Log4JLoggingModule())).buildInjector();
computeClient = injector.getInstance(VCloudComputeClient.class);
client = injector.getInstance(VCloudClient.class);
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() {
}));
expectationMap = ImmutableMap.<OsFamily, Expectation> builder().put(OsFamily.CENTOS,
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
provider = "vcloudtest";
templateName = "Ubuntu JeOS 9.10 (32-bit)";
}

View File

@ -43,11 +43,15 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@Override
public void setServiceDefaults() {
System.setProperty("vcloud.endpoint", checkNotNull(System.getProperty("jclouds.test.endpoint"),
"jclouds.test.endpoint"));
provider = "vcloud";
}
@Override
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("vcloud.identity"), "vcloud.identity");
credential = checkNotNull(System.getProperty("vcloud.credential"), "vcloud.credential");
}
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
@ -56,7 +60,7 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<VCloudClient, VCloudAsyncClient> tmContext = new ComputeServiceContextFactory().createContext(
provider, identity, credential).getProviderSpecificContext();
provider, identity, credential).getProviderSpecificContext();
}
@Override

View File

@ -0,0 +1,164 @@
/**
*
* 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.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.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import com.google.common.base.CaseFormat;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* Tests behavior of {@code VCloudClient}
*
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true, testName = "vcloud.VCloudClientLiveTest")
public class VCloudExpressComputeClientLiveTest {
protected String provider;
protected VCloudExpressComputeClient computeClient;
protected VCloudExpressClient client;
protected URI id;
protected String publicAddress;
protected String templateName;
public static class Expectation {
final long hardDisk;
final String os;
public Expectation(long hardDisk, String os) {
this.hardDisk = hardDisk;
this.os = os;
}
}
protected Map<OsFamily, Expectation> expectationMap;
protected Predicate<String> addressTester;
private String identity;
private String credential;
@Test(enabled = true)
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException, IOException {
OsFamily toTest = OsFamily.CENTOS;
String serverName = getCompatibleServerName(toTest);
int processorCount = 1;
int memory = 512;
VAppTemplate template = client.findVAppTemplateInOrgCatalogNamed(null, null, templateName);
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024).productProperties(
ImmutableMap.of("foo", "bar"));
id = URI.create(computeClient.start(null, template.getId(), templateName, options).get("id"));
Expectation expectation = expectationMap.get(toTest);
VApp vApp = client.getVApp(id);
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
assertEquals(vApp.getStatus(), VAppStatus.ON);
}
private String getCompatibleServerName(OsFamily toTest) {
String serverName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, toTest.toString()).substring(0,
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
return serverName;
}
@Test(dependsOnMethods = "testPowerOn", enabled = true)
public void testGetPublicAddresses() {
publicAddress = Iterables.getLast(computeClient.getPublicAddresses(id));
assert !addressTester.apply(publicAddress);
}
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
int memory, long hardDisk) {
// assertEquals(vApp.getName(), serverName);
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
assertEquals(Iterables
.getOnlyElement(filter(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)))
.getVirtualQuantity(), processorCount);
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(
filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))).getVirtualQuantity(),
hardDisk);
}
@AfterTest
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
if (id != null)
computeClient.stop(id);
}
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("vcloudexpress.identity"), "vcloudexpress.identity");
credential = checkNotNull(System.getProperty("vcloudexpress.credential"), "vcloudexpress.credential");
}
@BeforeGroups(groups = { "live" })
public void setupClient() {
setupCredentials();
Injector injector = new RestContextFactory().createContextBuilder("vcloudexpress", identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule())).buildInjector();
computeClient = injector.getInstance(VCloudExpressComputeClient.class);
client = injector.getInstance(VCloudExpressClient.class);
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() {
}));
expectationMap = ImmutableMap.<OsFamily, Expectation> builder().put(OsFamily.CENTOS,
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
provider = "vcloudtest";
templateName = "Ubuntu JeOS 9.10 (32-bit)";
}
}

View File

@ -0,0 +1,80 @@
/**
*
* 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.compute;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressClient;
import org.testng.annotations.Test;
/**
*
*
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true, testName = "vcloud.VCloudExpressComputeServiceLiveTest")
public class VCloudExpressComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@Override
public void setServiceDefaults() {
provider = "vcloudexpress";
}
@Override
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("vcloudexpress.identity"), "vcloudexpress.identity");
credential = checkNotNull(System.getProperty("vcloudexpress.credential"), "vcloudexpress.credential");
}
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
}
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<VCloudExpressClient, VCloudExpressAsyncClient> tmContext = new ComputeServiceContextFactory()
.createContext(provider, identity, credential).getProviderSpecificContext();
}
@Override
public void testListNodes() throws Exception {
for (ComputeMetadata node : client.listNodes()) {
assert node.getProviderId() != null;
assert node.getLocation() != null;
assertEquals(node.getType(), ComputeType.NODE);
NodeMetadata allData = client.getNodeMetadata(node.getId());
assert allData.getExtra().get("processor/count") != null : allData.getExtra();
assert allData.getExtra().get("disk_drive/0/kb") != null : allData.getExtra();
assert allData.getExtra().get("memory/mb") != null : allData.getExtra();
System.out.println(allData.getExtra());
}
}
}

View File

@ -0,0 +1,38 @@
/**
*
* 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.compute.config;
import org.jclouds.vcloud.domain.VAppStatus;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.VCloudExpressComputeServiceContextModuleTest")
public class VCloudExpressComputeServiceContextModuleTest {
public void testAllStatusCovered() {
for (VAppStatus state : VAppStatus.values()) {
assert VCloudExpressComputeServiceContextModule.vAppStatusToNodeState.containsKey(state) : state;
}
}
}

View File

@ -28,7 +28,7 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.io.Payloads;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
import org.testng.annotations.BeforeTest;
@ -59,7 +59,7 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
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"))));
VCloudExpressMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}
@ -75,7 +75,7 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
VCloudSession reply = parser.apply(response);
assertEquals(reply.getVCloudToken(), "c9f232506df9b65d7b7d97b7499eddd7");
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"))));
VCloudExpressMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}

View File

@ -19,7 +19,7 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOGITEM_XML;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;

View File

@ -19,8 +19,8 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOG_XML;
import static org.jclouds.vcloud.VCloudExpressMediaType.TASKSLIST_XML;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
@ -29,7 +29,7 @@ import java.net.URI;
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.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Organization;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.Test;
@ -59,7 +59,7 @@ public class OrgHandlerTest {
"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(
"Miami Environment 1", VCloudMediaType.VDC_XML, URI
"Miami Environment 1", VCloudExpressMediaType.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
@ -76,7 +76,7 @@ public class OrgHandlerTest {
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
"188849 Virtual DataCenter", VCloudExpressMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
assertEquals(result.getTasksLists(), ImmutableMap.of("188849 Task List",
new NamedResourceImpl("188849 Task List", TASKSLIST_XML, URI

View File

@ -26,7 +26,7 @@ import java.net.URI;
import java.util.Map;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.Test;
@ -46,6 +46,6 @@ public class OrgListHandlerTest extends BaseHandlerTest {
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"))));
VCloudExpressMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
}
}

View File

@ -26,7 +26,7 @@ import java.net.URI;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.VAppStatus;
@ -60,8 +60,8 @@ public class TaskHandlerTest extends BaseHandlerTest {
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
VCloudExpressMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("Server1", VCloudExpressMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
), null
@ -98,7 +98,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
.iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
.iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
new NamedResourceImpl("188849-96", VCloudMediaType.VAPP_XML, URI
new NamedResourceImpl("188849-96", VCloudExpressMediaType.VAPP_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null, null);
assertEquals(result, expects);
}
@ -111,8 +111,8 @@ public class TaskHandlerTest extends BaseHandlerTest {
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")),
VCloudExpressMediaType.ORG_XML, URI.create("http://10.150.4.49/api/v0.8/org/1")), new NamedResourceImpl(
"testapp1", VCloudExpressMediaType.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

@ -26,7 +26,7 @@ import java.net.URI;
import org.jclouds.date.DateService;
import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.TasksList;
@ -64,15 +64,15 @@ public class TasksListHandlerTest extends BaseHandlerTest {
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
null, new NamedResourceImpl("VDC Name", VCloudExpressMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), new NamedResourceImpl(
"Server1", VCloudMediaType.VAPP_XML, URI
"Server1", VCloudExpressMediaType.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
VCloudExpressMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
new NamedResourceImpl("Server1", VCloudExpressMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
}

View File

@ -1 +1 @@
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="false" name="my-vapp" powerOn="false" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="false" name="my-vapp" powerOn="false" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.0 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><VApp href="https://vcenterprise.bluelock.com/api/v1.0/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>

View File

@ -1 +1 @@
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.0 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><VApp href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>

View File

@ -0,0 +1 @@
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="false" name="my-vapp" powerOn="false" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>

View File

@ -0,0 +1 @@
<CloneVAppParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" deploy="true" name="new-linux-server" powerOn="true" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp</Description><VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CloneVAppParams>

View File

@ -0,0 +1 @@
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1.0" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.0 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><VAppTemplate href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"/><InstantiationParams><VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v1.0"><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</VirtualQuantity></Item><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512</VirtualQuantity></Item><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1024</VirtualQuantity></Item></VirtualHardwareSection><NetworkConfigSection><NetworkConfig name="my-vapp"><Features><FenceMode>bridged</FenceMode></Features><NetworkAssociation href="https://vcenterprise.bluelock.com/api/v1.0/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>

View File

@ -0,0 +1 @@
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1.0" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.0 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><VAppTemplate href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"/><InstantiationParams><NetworkConfigSection><NetworkConfig name="my-vapp"><Features><FenceMode>bridged</FenceMode></Features><NetworkAssociation href="https://vcenterprise.bluelock.com/api/v1.0/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>

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