From 37e6424040513dac7ba9350ea47e0d9e278edfbd Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 17:03:32 -0700 Subject: [PATCH] Issue 557:support Virtacore vCloud Express --- core/src/main/resources/rest.properties | 3 + .../virtacore-vcloudexpress/pom.xml | 142 +++++++++++++++ .../VirtacoreVCloudExpressContextBuilder.java | 51 ++++++ ...rtacoreVCloudExpressPropertiesBuilder.java | 46 +++++ ...irtacoreVCloudExpressProviderMetadata.java | 116 ++++++++++++ ...oudExpressComputeServiceContextModule.java | 38 ++++ ...irtacoreVCloudExpressRestClientModule.java | 41 +++++ ...loudTokenCookieAndAuthorizationHeader.java | 53 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../VirtacoreVCloudExpressProviderTest.java | 36 ++++ ...reVCloudExpressComputeServiceLiveTest.java | 40 +++++ ...eVCloudExpressTemplateBuilderLiveTest.java | 79 ++++++++ .../src/test/resources/log4j.xml | 170 ++++++++++++++++++ 13 files changed, 816 insertions(+) create mode 100644 sandbox-providers/virtacore-vcloudexpress/pom.xml create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 21fa5249d3..b1c4f1ffea 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -144,6 +144,9 @@ cloudsigma-zrh.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder ibm-smartcloud.propertiesbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudPropertiesBuilder ibm-smartcloud.contextbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudContextBuilder +virtacore-vcloudexpress.propertiesbuilder=org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressPropertiesBuilder +virtacore-vcloudexpress.contextbuilder=org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressContextBuilder + stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder # example of where to change your endpoint # bluelock.endpoint=https://express3.bluelock.com/api diff --git a/sandbox-providers/virtacore-vcloudexpress/pom.xml b/sandbox-providers/virtacore-vcloudexpress/pom.xml new file mode 100644 index 0000000000..24d8120cac --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/pom.xml @@ -0,0 +1,142 @@ + + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.1.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.provider + virtacore-vcloudexpress + jclouds Virtacore vCloud Express provider + vCloud implementation targeted to Virtacore + + + https://vcloud.virtacore.com/api + 1.0 + FIXME_IDENTITY + FIXME_CREDENTIAL + + + + + org.jclouds.api + vcloud + ${project.version} + + + org.jclouds.common + vcloud-common + ${project.version} + test-jar + test + + + org.jclouds.api + vcloud + ${project.version} + test-jar + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds.driver + jclouds-jsch + ${project.version} + test + + + com.jcraft + jsch + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.virtacore-vcloudexpress.endpoint + ${test.virtacore-vcloudexpress.endpoint} + + + test.virtacore-vcloudexpress.apiversion + ${test.virtacore-vcloudexpress.apiversion} + + + test.virtacore-vcloudexpress.identity + ${test.virtacore-vcloudexpress.identity} + + + test.virtacore-vcloudexpress.credential + ${test.virtacore-vcloudexpress.credential} + + + + + + + + + + + + + + diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java new file mode 100644 index 0000000000..9aa36ef305 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.vcloud.VCloudContextBuilder; +import org.jclouds.virtacore.vcloudexpress.config.VirtacoreVCloudExpressComputeServiceContextModule; +import org.jclouds.virtacore.vcloudexpress.config.VirtacoreVCloudExpressRestClientModule; + +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + * + */ +public class VirtacoreVCloudExpressContextBuilder extends VCloudContextBuilder { + + public VirtacoreVCloudExpressContextBuilder(Properties props) { + super(props); + } + + @Override + protected void addContextModule(List modules) { + modules.add(new VirtacoreVCloudExpressComputeServiceContextModule()); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new VirtacoreVCloudExpressRestClientModule()); + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java new file mode 100644 index 0000000000..4d5b5b9ed4 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java @@ -0,0 +1,46 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress; + +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; + +import java.util.Properties; + +import org.jclouds.vcloud.VCloudPropertiesBuilder; + +/** + * + * @author Adrian Cole + */ +public class VirtacoreVCloudExpressPropertiesBuilder extends VCloudPropertiesBuilder { + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA"); + properties.setProperty(PROPERTY_ENDPOINT, "https://vcloud.virtacore.com/api"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, ".*-Public"); + return properties; + } + + public VirtacoreVCloudExpressPropertiesBuilder(Properties properties) { + super(properties); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java new file mode 100644 index 0000000000..6ecbfc7596 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Virtacore vCloud Express + * + * @author Adrian Cole + */ +public class VirtacoreVCloudExpressProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "virtacore-vcloudexpress"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Virtacore vCloud Express"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "User at Organization (user@org)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.virtacore.com/vcloud_express.cfm"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://www.virtacore.com/vcloudlogin.cfm"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://kb.virtacore.com/categories/vCloud+Express/"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("virtacore-vcloudexpress"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-VA","US-CA"); + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java new file mode 100644 index 0000000000..effc224048 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java @@ -0,0 +1,38 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress.config; + +import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; +import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; +import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; + +import com.google.inject.Injector; + +/** + * + * @author Adrian Cole + */ +public class VirtacoreVCloudExpressComputeServiceContextModule extends VCloudComputeServiceContextModule { + + @Override + protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { + return options.as(VCloudTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java new file mode 100644 index 0000000000..319aa7b884 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress.config; + +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.virtacore.vcloudexpress.filters.SetVCloudTokenCookieAndAuthorizationHeader; + +/** + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class VirtacoreVCloudExpressRestClientModule extends VCloudRestClientModule { + + @Override + protected void configure() { + super.configure(); + bind(SetVCloudTokenCookie.class).to(SetVCloudTokenCookieAndAuthorizationHeader.class); + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java new file mode 100644 index 0000000000..361e0905ce --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java @@ -0,0 +1,53 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress.filters; + +import javax.inject.Inject; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.jclouds.http.HttpException; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.vcloud.VCloudToken; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; + +/** + * Adds the VCloud Token to the request as a cookie + * + * @author Adrian Cole + * + */ +@Singleton +public class SetVCloudTokenCookieAndAuthorizationHeader extends SetVCloudTokenCookie { + + private final Provider vcloudTokenProvider; + + @Inject + public SetVCloudTokenCookieAndAuthorizationHeader(@VCloudToken Provider authTokenProvider) { + super(authTokenProvider); + this.vcloudTokenProvider = authTokenProvider; + } + + @Override + public HttpRequest filter(HttpRequest request) throws HttpException { + return ModifyRequest.replaceHeader(super.filter(request), "x-vcloud-authorization", vcloudTokenProvider.get()); + } + +} \ No newline at end of file diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..8505807ce7 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressProviderMetadata diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java new file mode 100644 index 0000000000..4ad921231a --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java @@ -0,0 +1,36 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "VirtacoreVCloudExpressProviderTest") +public class VirtacoreVCloudExpressProviderTest extends BaseProviderMetadataTest { + + public VirtacoreVCloudExpressProviderTest() { + super(new VirtacoreVCloudExpressProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java new file mode 100644 index 0000000000..d58ac26dde --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress.compute; + +import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true) +public class VirtacoreVCloudExpressComputeServiceLiveTest extends VCloudComputeServiceLiveTest { + public VirtacoreVCloudExpressComputeServiceLiveTest() { + provider = "virtacore-vcloudexpress"; + } + + @Override + public void setServiceDefaults() { + group = "director"; + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..d18e566546 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java @@ -0,0 +1,79 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.virtacore.vcloudexpress.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class VirtacoreVCloudExpressTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public VirtacoreVCloudExpressTemplateBuilderLiveTest() { + provider = "virtacore-vcloudexpress"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return !input.version.equals(""); + case RHEL: + return !input.version.equals(""); + default: + return true; + } + } + + }; + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = context.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-VA", "US-CA"); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml b/sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml new file mode 100644 index 0000000000..7343ec00e2 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file