Issue 972:add greenqloud-compute as org.jclouds.labs/greenqloud-compute

This commit is contained in:
Adrian Cole 2012-06-12 22:50:36 -07:00
parent 73ddd9095c
commit 46edf40d40
11 changed files with 1009 additions and 0 deletions

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.5.0-SNAPSHOT</version>
<relativePath>../../project/pom.xml</relativePath>
</parent>
<groupId>org.jclouds.labs</groupId>
<artifactId>greenqloud-compute</artifactId>
<name>jclouds Greenqloud compute provider</name>
<description>Compute implementation targeted to Greenqloud Web Services</description>
<packaging>bundle</packaging>
<properties>
<test.greenqloud-compute.endpoint>https://api.greenqloud.com</test.greenqloud-compute.endpoint>
<test.greenqloud-compute.api-version>2010-06-15</test.greenqloud-compute.api-version>
<test.greenqloud-compute.build-version></test.greenqloud-compute.build-version>
<test.greenqloud-compute.identity>${test.greenqloud.identity}</test.greenqloud-compute.identity>
<test.greenqloud-compute.credential>${test.greenqloud.credential}</test.greenqloud-compute.credential>
<test.greenqloud-compute.image-id></test.greenqloud-compute.image-id>
<jclouds.osgi.export>org.jclouds.greenqloud.compute*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
org.jclouds.rest.internal;version="${project.version}",
org.jclouds*;version="${project.version}",
*
</jclouds.osgi.import>
</properties>
<dependencies>
<dependency>
<groupId>org.jclouds.api</groupId>
<artifactId>ec2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.api</groupId>
<artifactId>ec2</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-sshj</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<threadCount>1</threadCount>
<systemPropertyVariables>
<test.greenqloud-compute.endpoint>${test.greenqloud-compute.endpoint}</test.greenqloud-compute.endpoint>
<test.greenqloud-compute.api-version>${test.greenqloud-compute.api-version}</test.greenqloud-compute.api-version>
<test.greenqloud-compute.build-version>${test.greenqloud-compute.build-version}</test.greenqloud-compute.build-version>
<test.greenqloud-compute.identity>${test.greenqloud-compute.identity}</test.greenqloud-compute.identity>
<test.greenqloud-compute.credential>${test.greenqloud-compute.credential}</test.greenqloud-compute.credential>
<test.greenqloud-compute.image-id>${test.greenqloud-compute.image-id}</test.greenqloud-compute.image-id>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,101 @@
/**
* 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.greenqloud.compute;
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.net.URI;
import java.util.Properties;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.compute.config.EC2ResolveImagesModule;
import org.jclouds.ec2.config.EC2RestClientModule;
import org.jclouds.greenqloud.compute.config.GreenQloudComputeComputeServiceContextModule;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/**
* Implementation of {@link org.jclouds.providers.ProviderMetadata} for Greenqloud Compute Cloud.
*
* @author Adrian Cole
*/
public class GreenQloudComputeProviderMetadata extends BaseProviderMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 7625722444851538962L;
public static Builder builder() {
return new Builder();
}
@Override
public Builder toBuilder() {
return builder().fromProviderMetadata(this);
}
public GreenQloudComputeProviderMetadata() {
super(builder());
}
public GreenQloudComputeProviderMetadata(Builder builder) {
super(builder);
}
public static Properties defaultProperties() {
Properties properties = new Properties();
properties.setProperty(PROPERTY_REGIONS, "is-1");
properties.setProperty(PROPERTY_REGION + ".is-1." + ISO3166_CODES, "IS-1");
return properties;
}
public static class Builder extends BaseProviderMetadata.Builder {
protected Builder(){
id("greenqloud-compute")
.name("Greenqloud Compute Cloud")
.apiMetadata(
new EC2ApiMetadata().toBuilder()
.defaultModules(ImmutableSet.<Class<? extends Module>>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, GreenQloudComputeComputeServiceContextModule.class))
.build())
.homepage(URI.create("http://www.greenqloud.com"))
.console(URI.create("https://manage.greenqloud.com"))
.linkedServices("greenqloud-compute", "greenqloud-storage")
.iso3166Codes("IS-1")
.endpoint("https://api.greenqloud.com")
.defaultProperties(GreenQloudComputeProviderMetadata.defaultProperties());
}
@Override
public GreenQloudComputeProviderMetadata build() {
return new GreenQloudComputeProviderMetadata(this);
}
@Override
public Builder fromProviderMetadata(
ProviderMetadata in) {
super.fromProviderMetadata(in);
return this;
}
}
}

View File

@ -0,0 +1,37 @@
/**
* 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.greenqloud.compute.config;
import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
import org.jclouds.greenqloud.compute.strategy.GreenQloudComputeReviseParsedImage;
/**
*
* @author Adrian Cole
*/
public class GreenQloudComputeComputeServiceContextModule extends EC2ComputeServiceContextModule {
@Override
protected void configure() {
super.configure();
bind(ReviseParsedImage.class).to(GreenQloudComputeReviseParsedImage.class);
}
}

View File

@ -0,0 +1,65 @@
/**
* 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.greenqloud.compute.strategy;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
import org.jclouds.logging.Logger;
/**
* @author Adrian Cole
*/
@Singleton
public class GreenQloudComputeReviseParsedImage implements ReviseParsedImage {
public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
@javax.annotation.Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
private final Map<OsFamily, Map<String, String>> osVersionMap;
@Inject
public GreenQloudComputeReviseParsedImage(Map<OsFamily, Map<String, String>> osVersionMap) {
this.osVersionMap = osVersionMap;
}
public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
OperatingSystem.Builder osBuilder) {
if (from.getDescription() != null)
osBuilder.is64Bit(from.getDescription().contains("64-bit"));
Matcher matcher = DEFAULT_PATTERN.matcher(from.getDescription());
if (matcher.find() && matcher.groupCount() >= 3) {
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(3), osVersionMap));
}
}
}

View File

@ -0,0 +1 @@
org.jclouds.greenqloud.compute.GreenQloudComputeProviderMetadata

View File

@ -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.greenqloud.compute;
import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "GreenQloudComputeComputeServiceLiveTest")
public class GreenQloudComputeComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
public GreenQloudComputeComputeServiceLiveTest() {
provider = "greenqloud-compute";
}
}

View File

@ -0,0 +1,32 @@
/**
* 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.greenqloud.compute;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.providers.internal.BaseProviderMetadataTest;
import org.testng.annotations.Test;
@Test(groups = "unit", testName = "GreenQloudComputeProviderTest")
public class GreenQloudComputeProviderTest extends BaseProviderMetadataTest {
public GreenQloudComputeProviderTest() {
super(new GreenQloudComputeProviderMetadata(), new EC2ApiMetadata());
}
}

View File

@ -0,0 +1,96 @@
/**
* 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.greenqloud.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.aws.util.AWSUtils;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
import org.jclouds.domain.LocationScope;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", testName = "GreenQloudComputeTemplateBuilderLiveTest")
public class GreenQloudComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public GreenQloudComputeTemplateBuilderLiveTest() {
provider = "greenqloud-compute";
}
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return Predicates.not(new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
switch (input.family) {
case UBUNTU:
return (input.version.equals("") || input.version.equals("10.04") || input.version.equals("11.04") || input.version
.equals("11.10"))
&& input.is64Bit;
case DEBIAN:
return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit;
case CENTOS:
return (input.version.equals("") || input.version.equals("5.5") || input.version.equals("5.6") || input.version
.equals("6.0"))
&& input.is64Bit;
case FEDORA:
return input.version.equals("") && input.is64Bit;
default:
return false;
}
}
});
}
@Test
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = view.getComputeService().templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("qmi-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
assertEquals(defaultTemplate.getHardware().getId(), "m1.small");
assertEquals(defaultTemplate.getLocation().getId(), "is-1");
assertEquals(defaultTemplate.getLocation().getScope(), LocationScope.REGION);
assertEquals(AWSUtils.getRegionFromLocationOrNull(defaultTemplate.getLocation()), "is-1");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
@Override
protected Set<String> getIso3166Codes() {
return ImmutableSet.<String> of("IS-1");
}
}

View File

@ -0,0 +1,256 @@
/**
* 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.greenqloud.compute.strategy;
import static org.testng.Assert.assertEquals;
import java.util.Map;
import java.util.Set;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule;
import org.jclouds.ec2.compute.functions.EC2ImageParser;
import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.xml.DescribeImagesResponseHandlerTest;
import org.jclouds.greenqloud.compute.strategy.GreenQloudComputeReviseParsedImage;
import org.jclouds.json.Json;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.inject.Guice;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "GreenQloudComputeReviseParsedImageTest")
public class GreenQloudComputeReviseParsedImageTest {
public void testParseGreenQloudImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/greenqloud_images.xml");
assertEquals(result.size(), 9);
assertEquals(
Iterables.get(result, 0).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.UBUNTU).version("10.04")
.description("Ubuntu Server 10.04 (64-bit)").is64Bit(true)
.arch("paravirtual").build())
.description("Ubuntu Server 10.04 (64-bit)")
.name("Ubuntu Server 10.04.3")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-4e5b842f")
.providerId("qmi-4e5b842f")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 1).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.UBUNTU).version("11.10")
.description("Ubuntu Server 11.10 (64-bit)").is64Bit(true)
.arch("paravirtual").build())
.description("Ubuntu Server 11.10 (64-bit)")
.name("Ubuntu Server 11.10")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-9ac92558")
.providerId("qmi-9ac92558")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 1).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 2).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.CENTOS).version("5.5")
.description("CentOS 5.5 Server 64-bit").is64Bit(true)
.arch("paravirtual").build())
.description("CentOS 5.5 Server 64-bit")
.name("CentOS 5.5 Server")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-33a467aa")
.providerId("qmi-33a467aa")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 2).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 3).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.DEBIAN).version("6.0")
.description("Debian 6.0 (64-bit)").is64Bit(true)
.arch("paravirtual").build())
.description("Debian 6.0 (64-bit)")
.name("Debian 6.0")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-f2a9d2ba")
.providerId("qmi-f2a9d2ba")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 3).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 4).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.CENTOS).version("6.0")
.description("CentOS 6.0 (64-bit)").is64Bit(true)
.arch("paravirtual").build())
.description("CentOS 6.0 (64-bit)")
.name("CentOS 6.0")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-96f82145")
.providerId("qmi-96f82145")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 4).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 5).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.CENTOS).version("6.0")
.description("CentOS 6.0 GUI (64-bit)").is64Bit(true)
.arch("paravirtual").build())
.description("CentOS 6.0 GUI (64-bit)")
.name("CentOS 6.0 GUI")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-42e877f6")
.providerId("qmi-42e877f6")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 5).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 6).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.UBUNTU).version("11.04")
.description("Ubuntu Server 11.04 (64-bit)").is64Bit(true)
.arch("paravirtual").build())
.description("Ubuntu Server 11.04 (64-bit)")
.name("Ubuntu Server 11.04")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-eed8cea7")
.providerId("qmi-eed8cea7")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 6).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 7).toString(),
new ImageBuilder()
.operatingSystem(
// fedora is not in the image version map, yet
OperatingSystem.builder().family(OsFamily.FEDORA).version("")
.description("Fedora 16 Server").is64Bit(false)
.arch("paravirtual").build())
.description("Fedora 16 Server")
.name("Fedora 16 Server")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-fa4bdae0")
.providerId("qmi-fa4bdae0")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 7).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
assertEquals(
Iterables.get(result, 8).toString(),
new ImageBuilder()
.operatingSystem(
OperatingSystem.builder().family(OsFamily.CENTOS).version("5.6")
.description("CentOS 5.6 Server GUI 64-bit").is64Bit(true)
.arch("paravirtual").build())
.description("CentOS 5.6 Server GUI 64-bit")
.name("CentOS 5.6 GUI")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/qmi-93271d32")
.providerId("qmi-93271d32")
.location(defaultLocation)
.userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
"paravirtual", "hypervisor", "xen"))
.status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
assertEquals(Iterables.get(result, 8).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
}
static Location defaultLocation = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description(
"us-east-1").build();
public static Set<org.jclouds.compute.domain.Image> convertImages(String resource) {
Map<OsFamily, Map<String, String>> map = new BaseComputeServiceContextModule() {
}.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
.getInstance(Json.class));
// note this method is what mandates the location id as us-east-1
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
EC2ImageParser parser = new EC2ImageParser(EC2ComputeServiceDependenciesModule.toPortableImageStatus,
new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map, Suppliers
.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation), new GreenQloudComputeReviseParsedImage(map));
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
}
}

View File

@ -0,0 +1,257 @@
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
<requestId>1c016525-12ae-4fc6-8d4e-754692412bbc</requestId>
<imagesSet>
<item>
<imageId>qmi-4e5b842f</imageId>
<imageLocation>Ubuntu Server 10.04 (64-bit)</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>Ubuntu Server 10.04.3</name>
<description>Ubuntu Server 10.04 (64-bit)</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-9ac92558</imageId>
<imageLocation>Ubuntu Server 11.10 (64-bit)</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>Ubuntu Server 11.10</name>
<description>Ubuntu Server 11.10 (64-bit)</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-33a467aa</imageId>
<imageLocation>CentOS 5.5 Server 64-bit</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>CentOS 5.5 Server</name>
<description>CentOS 5.5 Server 64-bit</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-f2a9d2ba</imageId>
<imageLocation>Debian 6.0 (64-bit)</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>Debian 6.0</name>
<description>Debian 6.0 (64-bit)</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-96f82145</imageId>
<imageLocation>CentOS 6.0 (64-bit)</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>CentOS 6.0</name>
<description>CentOS 6.0 (64-bit)</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-42e877f6</imageId>
<imageLocation>CentOS 6.0 GUI (64-bit)</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>CentOS 6.0 GUI</name>
<description>CentOS 6.0 GUI (64-bit)</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-eed8cea7</imageId>
<imageLocation>Ubuntu Server 11.04 (64-bit)</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>Ubuntu Server 11.04</name>
<description>Ubuntu Server 11.04 (64-bit)</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-fa4bdae0</imageId>
<imageLocation>Fedora 16 Server</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>Fedora 16 Server</name>
<description>Fedora 16 Server</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
<item>
<imageId>qmi-93271d32</imageId>
<imageLocation>CentOS 5.6 Server GUI 64-bit</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes>
<item>
<productCode></productCode>
</item>
</productCodes>
<architecture></architecture>
<imageType>machine</imageType>
<kernelId></kernelId>
<ramdiskId></ramdiskId>
<platform></platform>
<stateReason>
<code></code>
<message></message>
</stateReason>
<imageOwnerAlias></imageOwnerAlias>
<name>CentOS 5.6 GUI</name>
<description>CentOS 5.6 Server GUI 64-bit</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName></rootDeviceName>
<blockDeviceMapping />
<hypervisor>xen</hypervisor>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -49,5 +49,6 @@
<module>openstack-quantum</module>
<module>rackspace-cloudidentity</module>
<module>rackspace-cloudservers-us</module>
<module>greenqloud-compute</module>
</modules>
</project>