From fa42041b42140fe63e2e3c6d47b84c8aed884b4a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 25 Sep 2011 19:44:28 -0700 Subject: [PATCH] Issue 699:Add support for Dunkel vCloud into sandbox --- core/src/main/resources/rest.properties | 3 + sandbox-providers/dunkel-vcd/pom.xml | 128 +++++++++++++++ .../DunkelVCloudDirectorContextBuilder.java | 51 ++++++ ...DunkelVCloudDirectorPropertiesBuilder.java | 46 ++++++ .../DunkelVCloudDirectorProviderMetadata.java | 116 ++++++++++++++ ...udDirectorComputeServiceContextModule.java | 47 ++++++ .../DunkelVCloudDirectorRestClientModule.java | 41 +++++ ...loudTokenCookieAndAuthorizationHeader.java | 53 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../vcd/DunkelVCloudDirectorProviderTest.java | 36 +++++ ...lVCloudDirectorComputeServiceLiveTest.java | 40 +++++ ...VCloudDirectorTemplateBuilderLiveTest.java | 77 +++++++++ .../dunkel-vcd/src/test/resources/log4j.xml | 151 ++++++++++++++++++ 13 files changed, 790 insertions(+) create mode 100644 sandbox-providers/dunkel-vcd/pom.xml create mode 100644 sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java create mode 100644 sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java create mode 100644 sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java create mode 100644 sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java create mode 100644 sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java create mode 100644 sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/filters/SetVCloudTokenCookieAndAuthorizationHeader.java create mode 100644 sandbox-providers/dunkel-vcd/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java create mode 100644 sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java create mode 100644 sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java create mode 100644 sandbox-providers/dunkel-vcd/src/test/resources/log4j.xml diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index bde0a446cd..70116a85e5 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -132,6 +132,9 @@ ibm-smartcloud.contextbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudContextBui virtacore-vcloudexpress.propertiesbuilder=org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressPropertiesBuilder virtacore-vcloudexpress.contextbuilder=org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressContextBuilder +dunkel-vcd.propertiesbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorPropertiesBuilder +dunkel-vcd.contextbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorContextBuilder + 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/dunkel-vcd/pom.xml b/sandbox-providers/dunkel-vcd/pom.xml new file mode 100644 index 0000000000..7ca420f8a5 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/pom.xml @@ -0,0 +1,128 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.2.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.provider + dunkel-vcd + jclouds Dunkel vCloud provider + vCloud implementation targeted to Dunkel + + + https://vdc.dunkel.de/api + 1.0 + FIXME_IDENTITY + FIXME_CREDENTIAL + + + + + org.jclouds.api + vcloud + ${project.version} + + + 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-sshj + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.dunkel-vcd.endpoint + ${test.dunkel-vcd.endpoint} + + + test.dunkel-vcd.apiversion + ${test.dunkel-vcd.apiversion} + + + test.dunkel-vcd.identity + ${test.dunkel-vcd.identity} + + + test.dunkel-vcd.credential + ${test.dunkel-vcd.credential} + + + + + + + + + + + + + + diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java new file mode 100644 index 0000000000..350cb0fcf9 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java @@ -0,0 +1,51 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.vcloud.VCloudContextBuilder; +import org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorComputeServiceContextModule; +import org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorRestClientModule; + +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + * + */ +public class DunkelVCloudDirectorContextBuilder extends VCloudContextBuilder { + + public DunkelVCloudDirectorContextBuilder(Properties props) { + super(props); + } + + @Override + protected void addContextModule(List modules) { + modules.add(new DunkelVCloudDirectorComputeServiceContextModule()); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new DunkelVCloudDirectorRestClientModule()); + } + +} diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java new file mode 100644 index 0000000000..fcd3773452 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd; + +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 DunkelVCloudDirectorPropertiesBuilder extends VCloudPropertiesBuilder { + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "DE"); + properties.setProperty(PROPERTY_ENDPOINT, "https://vcd.dunkel.de/api"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, ".*-intranet"); + return properties; + } + + public DunkelVCloudDirectorPropertiesBuilder(Properties properties) { + super(properties); + } +} diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java new file mode 100644 index 0000000000..3fa940cfeb --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd; + +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 Dunkel vCloud Director + * + * @author Adrian Cole + */ +public class DunkelVCloudDirectorProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "dunkel-vcd"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Dunkel vCloud Director"; + } + + /** + * {@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.dunkel.de/vcloud/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://vcd.dunkel.de/cloud"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.dunkel.de/vcloud/"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("dunkel-vcd"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("DE"); + } + +} diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java new file mode 100644 index 0000000000..f73cd4c0a4 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java @@ -0,0 +1,47 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd.config; + +import static org.jclouds.compute.domain.OsFamily.RHEL; + +import org.jclouds.compute.domain.TemplateBuilder; +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 DunkelVCloudDirectorComputeServiceContextModule extends VCloudComputeServiceContextModule { + + @Override + protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { + return options.as(VCloudTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL); + } + + //CIM ostype does not include version info + @Override + protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { + return template.osFamily(RHEL).os64Bit(true); + } +} diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java new file mode 100644 index 0000000000..9a1e1ed607 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java @@ -0,0 +1,41 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd.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.dunkel.vcd.filters.SetVCloudTokenCookieAndAuthorizationHeader; + +/** + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class DunkelVCloudDirectorRestClientModule extends VCloudRestClientModule { + + @Override + protected void configure() { + super.configure(); + bind(SetVCloudTokenCookie.class).to(SetVCloudTokenCookieAndAuthorizationHeader.class); + } + +} diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/filters/SetVCloudTokenCookieAndAuthorizationHeader.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/filters/SetVCloudTokenCookieAndAuthorizationHeader.java new file mode 100644 index 0000000000..746d0d51b1 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/filters/SetVCloudTokenCookieAndAuthorizationHeader.java @@ -0,0 +1,53 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd.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()); + } + +} diff --git a/sandbox-providers/dunkel-vcd/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/dunkel-vcd/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..217f305590 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.dunkel.vcd.DunkelVCloudDirectorProviderMetadata diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java new file mode 100644 index 0000000000..ad1043bff2 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java @@ -0,0 +1,36 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.dunkel.vcd.DunkelVCloudDirectorProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "DunkelVCloudDirectorProviderTest") +public class DunkelVCloudDirectorProviderTest extends BaseProviderMetadataTest { + + public DunkelVCloudDirectorProviderTest() { + super(new DunkelVCloudDirectorProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java new file mode 100644 index 0000000000..2657004a8b --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java @@ -0,0 +1,40 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd.compute; + +import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true) +public class DunkelVCloudDirectorComputeServiceLiveTest extends VCloudComputeServiceLiveTest { + public DunkelVCloudDirectorComputeServiceLiveTest() { + provider = "dunkel-vcd"; + } + + @Override + public void setServiceDefaults() { + group = "director"; + } + +} diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..fc67f05871 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java @@ -0,0 +1,77 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.dunkel.vcd.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", testName = "DunkelVCloudDirectorTemplateBuilderLiveTest") +public class DunkelVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public DunkelVCloudDirectorTemplateBuilderLiveTest() { + provider = "dunkel-vcd"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case RHEL: + return !(input.version.equals("") && input.is64Bit); + 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.RHEL); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("DE"); + } +} diff --git a/sandbox-providers/dunkel-vcd/src/test/resources/log4j.xml b/sandbox-providers/dunkel-vcd/src/test/resources/log4j.xml new file mode 100644 index 0000000000..63810d3ca0 --- /dev/null +++ b/sandbox-providers/dunkel-vcd/src/test/resources/log4j.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +