Issue 976:update to support eucalyptus 3

This commit is contained in:
Adrian Cole 2012-06-15 19:13:38 -04:00
parent a6528c1074
commit 5123195eec
18 changed files with 246 additions and 49 deletions

View File

@ -55,7 +55,7 @@ public class DescribeRegionsResponseHandler extends ParseSax.HandlerWithResult<M
String pending = currentText.toString().trim();
if (pending.indexOf("Walrus") == -1)
regionEndpoint = URI.create(pending.startsWith("http") ? pending : String.format("https://%s", pending));
} else if (qName.equals("item") && region != null) {
} else if (qName.equals("item") && region != null && regionEndpoint != null) {
regionEndpoints.put(region, regionEndpoint);
this.region = null;
this.regionEndpoint = null;

View File

@ -134,7 +134,7 @@ public class EC2RestClientModuleExpectTest extends BaseEC2ExpectTest<Injector> {
assertEquals(injector.getInstance(RegionToEndpointOrProviderIfNull.class).apply("us-west-2"),
URI.create("https://ec2.us-west-2.amazonaws.com"));
}
@Override
public Injector createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props);

View File

@ -34,7 +34,7 @@
<packaging>bundle</packaging>
<properties>
<test.eucalyptus.endpoint>http://ecc.eucalyptus.com:8773/services/Eucalyptus</test.eucalyptus.endpoint>
<test.eucalyptus.endpoint>http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/</test.eucalyptus.endpoint>
<test.eucalyptus.api-version>2010-06-15</test.eucalyptus.api-version>
<test.eucalyptus.build-version />
<test.eucalyptus.identity>FIXME_IDENTITY</test.eucalyptus.identity>

View File

@ -20,7 +20,6 @@ package org.jclouds.eucalyptus;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_PORT_OPEN;
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties;
@ -36,9 +35,9 @@ public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ENDPOINT, "http://173.205.188.130:8773/services/Eucalyptus");
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin");
properties.setProperty(PROPERTY_ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/");
// in version 3, lowecase 'e' version 2, uppercase 'E'
properties.setProperty(PROPERTY_REGIONS, "eucalyptus");
properties.setProperty(PROPERTY_TIMEOUT_PORT_OPEN, 5 * 60 * 1000 + "");
return properties;
}

View File

@ -0,0 +1,106 @@
/**
* 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.eucalyptus.config;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.jclouds.eucalyptus.internal.BaseEucalyptusExpectTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.location.Region;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "EucalyptusRestClientModuleExpectTest")
public class EucalyptusRestClientModuleExpectTest extends BaseEucalyptusExpectTest<Injector> {
private Injector injector;
public EucalyptusRestClientModuleExpectTest() {
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder();
builder.put(describeRegionsRequest, describeRegionsResponse);
builder.put(describeAZRequest, describeAZResponse);
injector = requestsSendResponses(builder.build());
}
public void testLocationIdAndURIBindings() {
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
}, Region.class)).get(), ImmutableSet.<String> of("eucalyptus"));
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
}, Zone.class)).get(), ImmutableSet.<String> of("partner01"));
Map<String, Supplier<URI>> regionToURISupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
}, Region.class)).get();
assertEquals(regionToURISupplier.get("eucalyptus").get(), URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
Map<String, Supplier<Set<String>>> regionToZoneIdSupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<Set<String>>>>>() {
}, Zone.class)).get();
assertEquals(regionToZoneIdSupplier.get("eucalyptus").get(), ImmutableSet.of("partner01"));
Map<String, Supplier<URI>> zoneToURISupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
}, Zone.class)).get();
assertEquals(zoneToURISupplier.get("partner01").get(), URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
}
public void testZoneToEndpoint() {
assertEquals(injector.getInstance(ZoneToEndpoint.class).apply("partner01"),
URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
}
public void testRegionToEndpointOrProviderIfNull() {
assertEquals(injector.getInstance(RegionToEndpointOrProviderIfNull.class).apply("eucalyptus"),
URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
}
@Override
public Injector createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props);
}
}

View File

@ -0,0 +1,97 @@
/**
* 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.eucalyptus.internal;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.config.EC2RestClientModule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.BaseRestClientExpectTest;
import org.jclouds.rest.ConfiguresRestClient;
import com.google.common.collect.ImmutableMultimap;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public abstract class BaseEucalyptusExpectTest<T> extends BaseRestClientExpectTest<T> {
protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z";
protected DateService dateService = new SimpleDateFormatDateService();
protected HttpRequest describeRegionsRequest = HttpRequest
.builder()
.method("POST")
.endpoint(URI.create("http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/"))
.headers(ImmutableMultimap.of("Host", "partnercloud.eucalyptus.com:8773"))
.payload(payloadFromStringWithContentType(
"Action=DescribeRegions&Signature=tp9WpT8503JdxIXYu6Eu2Dmu%2Bd%2FpqviST7N7Fvr%2FyQo%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
MediaType.APPLICATION_FORM_URLENCODED)).build();
protected HttpResponse describeRegionsResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/regionEndpoints-euca.xml", MediaType.APPLICATION_XML))
.build();
protected HttpRequest describeAZRequest = HttpRequest.builder()
.method("POST")
.endpoint(URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus/"))
.headers(ImmutableMultimap.of("Host", "eucalyptus.partner.eucalyptus.com:8773"))
.payload(payloadFromStringWithContentType(
"Action=DescribeAvailabilityZones&Signature=i4OkMed1sqQV7hlF%2Fl1KdbQwmwJ4Fh4o9W32eVGayPk%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
MediaType.APPLICATION_FORM_URLENCODED)).build();
protected HttpResponse describeAZResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType(
"/availabilityZones-eucalyptus.xml", MediaType.APPLICATION_XML)).build();
public BaseEucalyptusExpectTest() {
provider = "eucalyptus";
}
@RequiresHttp
@ConfiguresRestClient
public static class StubEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
public StubEC2RestClientModule() {
super(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
}
@Override
protected String provideTimeStamp(DateService dateService) {
return CONSTANT_DATE;
}
}
@Override
protected Module createModule() {
return new StubEC2RestClientModule();
}
}

View File

@ -0,0 +1,11 @@
<DescribeAvailabilityZonesResponse
xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
<availabilityZoneInfo>
<item>
<zoneName>partner01</zoneName>
<zoneState>173.205.188.7 arn:euca:eucalyptus:partner01:cluster:cc_01/</zoneState>
<regionName />
<messageSet />
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,12 @@
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
<regionInfo>
<item>
<regionName>eucalyptus</regionName>
<regionEndpoint>http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus</regionEndpoint>
</item>
<item>
<regionName>walrus</regionName>
<regionEndpoint>http://walrus.partner.eucalyptus.com:8773/services/Walrus</regionEndpoint>
</item>
</regionInfo>
</DescribeRegionsResponse>

View File

@ -35,7 +35,7 @@
<properties>
<test.initializer>org.jclouds.walrus.blobstore.WalrusTestInitializer</test.initializer>
<test.walrus.endpoint>http://ecc.eucalyptus.com:8773/services/Walrus</test.walrus.endpoint>
<test.walrus.endpoint>http://walrus.partner.eucalyptus.com:8773/services/Walrus</test.walrus.endpoint>
<test.walrus.api-version>2006-03-01</test.walrus.api-version>
<test.walrus.build-version />
<test.walrus.identity>${test.eucalyptus.identity}</test.walrus.identity>

View File

@ -19,6 +19,7 @@
package org.jclouds.walrus;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH;
import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS;
@ -36,6 +37,7 @@ public class WalrusPropertiesBuilder extends S3PropertiesBuilder {
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, "Walrus-1.6");
properties.setProperty(PROPERTY_ENDPOINT, "http://walrus.partner.eucalyptus.com:8773/services/Walrus");
properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
return properties;

View File

@ -34,14 +34,12 @@
<packaging>bundle</packaging>
<properties>
<test.eucalyptus-partnercloud-ec2.endpoint>http://partnercloud.eucalyptus.com:8773/services/Eucalyptus</test.eucalyptus-partnercloud-ec2.endpoint>
<test.eucalyptus-partnercloud-ec2.endpoint>http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/</test.eucalyptus-partnercloud-ec2.endpoint>
<test.eucalyptus-partnercloud-ec2.api-version>2010-06-15</test.eucalyptus-partnercloud-ec2.api-version>
<test.eucalyptus-partnercloud-ec2.build-version />
<test.eucalyptus-partnercloud-ec2.identity>FIXME_IDENTITY</test.eucalyptus-partnercloud-ec2.identity>
<test.eucalyptus-partnercloud-ec2.credential>FIXME_CREDENTIAL</test.eucalyptus-partnercloud-ec2.credential>
<test.eucalyptus-partnercloud-ec2.image-id />
<!-- corresponds to image manifest and also virt + "-cluster" zone -->
<test.eucalyptus-partnercloud-ec2.virtualization-type>kvm</test.eucalyptus-partnercloud-ec2.virtualization-type>
</properties>
<dependencies>
@ -121,7 +119,6 @@
<test.eucalyptus-partnercloud-ec2.identity>${test.eucalyptus-partnercloud-ec2.identity}</test.eucalyptus-partnercloud-ec2.identity>
<test.eucalyptus-partnercloud-ec2.credential>${test.eucalyptus-partnercloud-ec2.credential}</test.eucalyptus-partnercloud-ec2.credential>
<test.eucalyptus-partnercloud-ec2.image-id>${test.eucalyptus-partnercloud-ec2.image-id}</test.eucalyptus-partnercloud-ec2.image-id>
<test.eucalyptus-partnercloud-ec2.virtualization-type>${test.eucalyptus-partnercloud-ec2.virtualization-type}</test.eucalyptus-partnercloud-ec2.virtualization-type>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -86,7 +86,7 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad
*/
@Override
public URI getConsole() {
return URI.create("https://partnercloud.eucalyptus.com:8443");
return URI.create("https://eucalyptus.partner.eucalyptus.com");
}
/**

View File

@ -38,11 +38,10 @@ public class EucalyptusPartnerCloudPropertiesBuilder extends EucalyptusPropertie
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
properties.setProperty(PROPERTY_REGIONS, "eucalyptus");
properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA");
properties.setProperty("eucalyptus-partnercloud-ec2.virtualization-type", "kvm");
properties.setProperty(PROPERTY_ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Eucalyptus");
properties.setProperty(PROPERTY_REGION + ".eucalyptus." + ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/");
return properties;
}

View File

@ -18,30 +18,16 @@
*/
package org.jclouds.epc.config;
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
import org.jclouds.epc.strategy.EucalyptusPartnerCloudReviseParsedImage;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;
/**
*
* @author Adrian Cole
*/
public class EucalyptusPartnerCloudComputeServiceContextModule extends EC2ComputeServiceContextModule {
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
String virt = injector.getInstance(Key.get(String.class, Names
.named("eucalyptus-partnercloud-ec2.virtualization-type")));
return template.osFamily(UBUNTU).locationId(virt + "-cluster");
}
@Override
protected void configure() {
super.configure();

View File

@ -18,8 +18,6 @@
*/
package org.jclouds.epc.compute;
import java.util.Properties;
import org.jclouds.eucalyptus.compute.EucalyptusComputeServiceLiveTest;
import org.testng.annotations.Test;
@ -35,14 +33,4 @@ public class EucalyptusPartnerCloudEucalyptusComputeServiceLiveTest extends Euca
// security groups must be <30 characters
group = "eu";
}
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
if (System.getProperties().containsKey("test.eucalyptus-partnercloud-ec2.virtualization-type"))
overrides.setProperty("eucalyptus-partnercloud-ec2.virtualization-type", System
.getProperty("test.eucalyptus-partnercloud-ec2.virtualization-type"));
return overrides;
}
}

View File

@ -35,7 +35,7 @@
<properties>
<test.initializer>org.jclouds.epc.blobstore.EucalyptusPartnerCloudWalrusTestInitializer</test.initializer>
<test.eucalyptus-partnercloud-s3.endpoint>http://partnercloud.eucalyptus.com:8773/services/Walrus</test.eucalyptus-partnercloud-s3.endpoint>
<test.eucalyptus-partnercloud-s3.endpoint>http://walrus.partner.eucalyptus.com:8773/services/Walrus</test.eucalyptus-partnercloud-s3.endpoint>
<test.eucalyptus-partnercloud-s3.api-version>2006-03-01</test.eucalyptus-partnercloud-s3.api-version>
<test.eucalyptus-partnercloud-s3.build-version />
<test.eucalyptus-partnercloud-s3.identity>FIXME_IDENTITY</test.eucalyptus-partnercloud-s3.identity>

View File

@ -86,7 +86,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada
*/
@Override
public URI getConsole() {
return URI.create("https://partnercloud.eucalyptus.com:8443");
return URI.create("https://walrus.partner.eucalyptus.com");
}
/**

View File

@ -38,11 +38,11 @@ public class EucalyptusPartnerCloudWalrusPropertiesBuilder extends WalrusPropert
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "Walrus");
properties.setProperty(PROPERTY_REGIONS, "walrus");
properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_REGION + ".Walrus." + ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Walrus");
properties.setProperty(PROPERTY_REGION + "." + "Walrus" + "." + ENDPOINT, "http://partnercloud.eucalyptus.com:8773/services/Walrus");
properties.setProperty(PROPERTY_REGION + ".walrus." + ISO3166_CODES, "US-CA");
properties.setProperty(PROPERTY_ENDPOINT, "http://walrus.partner.eucalyptus.com:8773/services/Walrus");
properties.setProperty(PROPERTY_REGION + "." + "Walrus" + "." + ENDPOINT, "http://walrus.partner.eucalyptus.com:8773/services/Walrus");
return properties;
}