From db17dadb439df0ea754f61183ff5840b163c5636 Mon Sep 17 00:00:00 2001 From: Don Tran Date: Wed, 21 Dec 2011 20:12:53 +0000 Subject: [PATCH] Issue 789: add los angeles elastichost provider --- core/src/main/resources/rest.properties | 3 + providers/elastichosts-lax-p/README.txt | 27 ++++ providers/elastichosts-lax-p/pom.xml | 134 ++++++++++++++++++ ...HostsPeer1LosAngelesPropertiesBuilder.java | 46 ++++++ ...cHostsPeer1LosAngelesProviderMetadata.java | 114 +++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../preinstalled_images.json | 65 +++++++++ ...ticHostsPeer1LosAngelesClientLiveTest.java | 34 +++++ ...asticHostsPeer1LosAngelesProviderTest.java | 35 +++++ ...Peer1LosAngelesComputeServiceLiveTest.java | 36 +++++ ...eer1LosAngelesTemplateBuilderLiveTest.java | 84 +++++++++++ providers/pom.xml | 1 + 12 files changed, 580 insertions(+) create mode 100644 providers/elastichosts-lax-p/README.txt create mode 100644 providers/elastichosts-lax-p/pom.xml create mode 100644 providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java create mode 100644 providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java create mode 100644 providers/elastichosts-lax-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json create mode 100644 providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java create mode 100644 providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java create mode 100644 providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesComputeServiceLiveTest.java create mode 100644 providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 3ff7c3d7cd..42e60c4a3c 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -117,6 +117,9 @@ elastichosts-sat-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBu elastichosts-tor-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1TorontoPropertiesBuilder elastichosts-tor-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder +elastichosts-lax-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1LosAngelesPropertiesBuilder +elastichosts-lax-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder + skalicloud-sdg-my.propertiesbuilder=org.jclouds.skalicloud.SkaliCloudMalaysiaPropertiesBuilder skalicloud-sdg-my.contextbuilder=org.jclouds.skalicloud.SkaliCloudMalaysiaContextBuilder diff --git a/providers/elastichosts-lax-p/README.txt b/providers/elastichosts-lax-p/README.txt new file mode 100644 index 0000000000..d561817819 --- /dev/null +++ b/providers/elastichosts-lax-p/README.txt @@ -0,0 +1,27 @@ +==== + 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. +==== + +# +# The jclouds provider for ElasticHosts' Peer1 Los Angeles ElasticStack (http://www.elastichosts.com/). +# +# Expects the jclouds elasticstack API to be present on your application's classpath. +# +# TODO: Implementation status. +# TODO: Supported features. +# TODO: Usage example. diff --git a/providers/elastichosts-lax-p/pom.xml b/providers/elastichosts-lax-p/pom.xml new file mode 100644 index 0000000000..96ebd24ae2 --- /dev/null +++ b/providers/elastichosts-lax-p/pom.xml @@ -0,0 +1,134 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.3.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.provider + elastichosts-lax-p + jclouds ElasticHosts Peer1 Los Angeles provider + ElasticHosts implementation targeted to Peer1 Toronto + bundle + + + https://api.lax-p.elastichosts.com + 2.0 + FIXME_IDENTITY + FIXME_CREDENTIAL + + + + + + org.jclouds.api + elasticstack + ${project.version} + + + org.jclouds.api + elasticstack + ${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.elastichosts-lax-p.endpoint} + ${test.elastichosts-lax-p.apiversion} + ${test.elastichosts-lax-p.identity} + ${test.elastichosts-lax-p.credential} + ${test.elastichosts-lax-p.image-id} + + + + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jclouds.elastichosts.*;version="${project.version}" + org.jclouds.*;version="${project.version}",* + + + + + + + + diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.java new file mode 100644 index 0000000000..89cab71919 --- /dev/null +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesPropertiesBuilder.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.elastichosts; + +import org.jclouds.elasticstack.ElasticStackPropertiesBuilder; + +import java.util.Properties; + +import static org.jclouds.Constants.*; + +/** + * + * @author Adrian Cole + */ +public class ElasticHostsPeer1LosAngelesPropertiesBuilder extends ElasticStackPropertiesBuilder { + + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); + properties.setProperty(PROPERTY_ENDPOINT, "https://api.lax-p.elastichosts.com"); + properties.setProperty(PROPERTY_API_VERSION, "2.0"); + return properties; + } + + public ElasticHostsPeer1LosAngelesPropertiesBuilder(Properties properties) { + super(properties); + } + +} diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java new file mode 100644 index 0000000000..82a277c28f --- /dev/null +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -0,0 +1,114 @@ +/** + * 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.elastichosts; + +import com.google.common.collect.ImmutableSet; +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +import java.net.URI; +import java.util.Set; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Toronto Peer 1. + * + * @author Adrian Cole + */ +public class ElasticHostsPeer1LosAngelesProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "elastichosts-lax-p"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "ElasticHosts Los Angeles Peer 1"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("https://lax-p.elastichosts.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://lax-p.elastichosts.com/accounts"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.elastichosts.com/cloud-hosting/api"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("elastichosts-lax-p"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-CA"); + } + +} diff --git a/providers/elastichosts-lax-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-lax-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..f659bfab9a --- /dev/null +++ b/providers/elastichosts-lax-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsPeer1LosAngelesProviderMetadata diff --git a/providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json b/providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json new file mode 100644 index 0000000000..2e40589519 --- /dev/null +++ b/providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json @@ -0,0 +1,65 @@ +[ + { + "uuid": "73f7cc6a-1c48-418a-80de-886b28a56a4d", + "description": "CentOS Linux 6.0", + "osFamily": "CENTOS", + "osVersion": "6.0", + "size": "3" + }, + { + "uuid": "9405cddf-8d01-472c-b7e3-e8c062dcde51", + "description": "Debian Linux 6.0", + "osFamily": "DEBIAN", + "osVersion": "6.0", + "size": "1" + }, + { + "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", + "description": "Ubuntu Linux 10.04", + "osFamily": "UBUNTU", + "osVersion": "10.04", + "size": "1" + }, + { + "uuid": "8d8aee18-8744-452c-94b2-69a2a34b8460", + "description": "Ubuntu Linux 11.10", + "osFamily": "UBUNTU", + "osVersion": "11.10", + "size": "1" + }, + { + "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", + "description": "Windows Web Server 2008", + "osFamily": "WINDOWS", + "osVersion": "2008", + "size": "13" + }, + { + "uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34", + "description": "Windows Web Server 2008 R2", + "osFamily": "WINDOWS", + "osVersion": "2008 R2", + "size": "13" + }, + { + "uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927", + "description": "Windows Web Server 2008 R2 + SQL Server", + "osFamily": "WINDOWS", + "osVersion": "2008 R2", + "size": "13" + }, + { + "uuid": "b17ebce6-61b4-4dcc-9654-41c9fc847e01", + "description": "Windows Server 2008 Standard R2", + "osFamily": "WINDOWS", + "osVersion": "2008 R2", + "size": "13" + }, + { + "uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf", + "description": "Windows Server 2008 Standard R2 + SQL Server", + "osFamily": "WINDOWS", + "osVersion": "2008 R2", + "size": "13" + } +] diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java new file mode 100644 index 0000000000..53e80469d1 --- /dev/null +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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.elastichosts; + +import org.jclouds.elasticstack.ElasticStackClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", sequential = true) +public class ElasticHostsPeer1LosAngelesClientLiveTest extends ElasticStackClientLiveTest { + public ElasticHostsPeer1LosAngelesClientLiveTest() { + provider = "elastichosts-lax-p"; + bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d"; + } +} diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java new file mode 100644 index 0000000000..f5a34fc642 --- /dev/null +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java @@ -0,0 +1,35 @@ +/** + * 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.elastichosts; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ElasticHostsPeer1LosAngelesProviderTest") +public class ElasticHostsPeer1LosAngelesProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsPeer1LosAngelesProviderTest() { + super(new ElasticHostsPeer1LosAngelesProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesComputeServiceLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesComputeServiceLiveTest.java new file mode 100644 index 0000000000..6c4bdc843a --- /dev/null +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesComputeServiceLiveTest.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.elastichosts.compute; + +import org.jclouds.elasticstack.compute.ElasticStackComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", sequential = true, testName = "ElasticHostsPeer1LosAngelesComputeServiceLiveTest") +public class ElasticHostsPeer1LosAngelesComputeServiceLiveTest extends ElasticStackComputeServiceLiveTest { + + public ElasticHostsPeer1LosAngelesComputeServiceLiveTest() { + provider = "elastichosts-lax-p"; + group = "elastichosts"; + } + +} diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..ef3a59f41d --- /dev/null +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java @@ -0,0 +1,84 @@ +/** + * 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.elastichosts.compute; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; +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 java.util.Set; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest() { + provider = "elastichosts-lax-p"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return (input.version.equals("") || ImmutableSet.of("11.10", "10.04").contains(input.version)) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) + && input.is64Bit; + default: + return false; + } + } + + }); + } + + @Test + public void testTemplateBuilder() { + Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getLocation().getId(), "elastichosts-lax-p"); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-CA"); + } +} diff --git a/providers/pom.xml b/providers/pom.xml index 8dbcc79e72..d487de2b16 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -58,6 +58,7 @@ elastichosts-sat-p elastichosts-lon-b elastichosts-tor-p + elastichosts-lax-p rimuhosting openhosting-east1 serverlove-z1-man