Merge remote branch 'upstream/master'

This commit is contained in:
Carlos 2011-01-27 11:22:06 -08:00
commit 9254305248
152 changed files with 2147 additions and 1949 deletions

View File

@ -44,14 +44,15 @@ our compute api supports: aws-ec2, gogrid, cloudservers (generic), cloudservers-
our blobstore api supports: aws-s3, cloudfiles (generic), cloudfiles-us, cloudfiles-uk,
azureblob, atmos (generic), synaptic-storage,
cloudonestorage, s3 (generic), walrus(generic), googlestorage,
scaleup-storage, eucalyptus-partnercloud-s3, swift (generic),
transient (in-mem), filesystem (on-disk)
eucalyptus-partnercloud-s3, swift (generic), transient (in-mem),
filesystem (on-disk)
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
to all of these providers
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, openstack nova,
azurequeue, simpledb as well a number of features the sandbox
azurequeue, simpledb, scaleup-storage as well as a async-http-client
driver in the sandbox
If you want access to all jclouds components, include the maven dependency org.jclouds/jclouds-all

View File

@ -49,11 +49,6 @@
<artifactId>synaptic-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>scaleup-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudonestorage</artifactId>

View File

@ -179,7 +179,7 @@ public class SignRequest implements HttpRequestFilter {
for (String header : new String[] { "Range" })
toSign.append(utils.valueOrEmpty(request.getHeaders().get(header)).toLowerCase()).append("\n");
// Standard HTTP header, in UTC format. Only the date value is used, not the header name.
toSign.append(request.getHeaders().get(HttpHeaders.DATE).iterator().next()).append("\n");
toSign.append(request.getFirstHeaderOrNull(HttpHeaders.DATE)).append("\n");
}
@VisibleForTesting

View File

@ -47,6 +47,7 @@ import org.jclouds.cloudservers.domain.ServerStatus;
import org.jclouds.cloudservers.domain.SharedIpGroup;
import org.jclouds.cloudservers.domain.WeeklyBackup;
import org.jclouds.cloudservers.options.RebuildServerOptions;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload;
@ -55,7 +56,6 @@ import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.ssh.jsch.config.JschSshClientModule;

View File

@ -20,8 +20,6 @@
package org.jclouds.ec2.compute.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
import static org.jclouds.compute.domain.OsFamily.CENTOS;
import java.util.Map;
@ -31,16 +29,12 @@ import javax.inject.Singleton;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.ec2.compute.EC2ComputeService;
import org.jclouds.ec2.compute.domain.RegionAndName;
import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
import org.jclouds.location.Provider;
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import com.google.common.base.Supplier;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Provides;
/**
@ -57,18 +51,6 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
super.configure();
}
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
// TODO: move this into the dependent modules
String provider = injector.getInstance(Key.get(String.class, Provider.class));
if ("aws-ec2".equals(provider))
return template.osFamily(AMZN_LINUX).os64Bit(true);
else if ("nova-ec2".equals(provider))
return super.provideTemplate(injector, template);
else
return template.osFamily(CENTOS);
}
@Provides
@Singleton
protected Supplier<Map<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(

View File

@ -20,25 +20,21 @@
package org.jclouds.ec2.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrUnrecognized;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.ec2.domain.Image.Architecture;
import org.jclouds.ec2.domain.Image.ImageType;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
@ -46,6 +42,9 @@ import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl;
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
import org.jclouds.ec2.domain.Image.Architecture;
import org.jclouds.ec2.domain.Image.ImageType;
import org.jclouds.location.Provider;
import org.jclouds.logging.Logger;
@ -59,49 +58,29 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
@Singleton
public class ImageParser implements Function<org.jclouds.ec2.domain.Image, Image> {
public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Image> {
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
// nebula/ubuntu-karmic
// nebula/karmic-large
public static final Pattern NEBULA_PATTERN = Pattern.compile("nebula/(ubuntu-)?(.*)(-.*)?");
// 137112412989/amzn-ami-0.9.7-beta.i386-ebs
// 137112412989/amzn-ami-0.9.7-beta.x86_64-ebs
// amzn-ami-us-east-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml
// amzn-ami-us-east-1/amzn-ami-0.9.7-beta.i386.manifest.xml
public static final Pattern AMZN_PATTERN = Pattern
.compile(".*/amzn-ami-(.*)\\.(i386|x86_64)(-ebs|\\.manifest.xml)?");
public static final Pattern CANONICAL_PATTERN = Pattern.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?");
// ex rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml
public static final Pattern RIGHTSCALE_PATTERN = Pattern
.compile("[^/]*/([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
// ex 411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha
// 411009282317/RightImage_Windows_2008_x64_v5.5.5
public static final Pattern RIGHTIMAGE_PATTERN = Pattern
.compile("[^/]*/RightImage[_ ]([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
private final Supplier<Set<? extends Location>> locations;
private final Supplier<Location> defaultLocation;
private final String provider;
private final Map<OsFamily, Map<String, String>> osVersionMap;
private final ReviseParsedImage reviseParsedImage;
@Inject
ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
Map<OsFamily, Map<String, String>> osVersionMap, @Memoized Supplier<Set<? extends Location>> locations,
Supplier<Location> defaultLocation, @Provider String provider) {
public
EC2ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
Map<OsFamily, Map<String, String>> osVersionMap, @Memoized Supplier<Set<? extends Location>> locations,
Supplier<Location> defaultLocation, @Provider String provider, ReviseParsedImage reviseParsedImage) {
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
this.locations = checkNotNull(locations, "locations");
this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
this.provider = checkNotNull(provider, "provider");
this.osVersionMap = checkNotNull(osVersionMap, "utils");
this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
this.reviseParsedImage = checkNotNull(reviseParsedImage, "reviseParsedImage");
}
@Override
@ -115,33 +94,18 @@ public class ImageParser implements Function<org.jclouds.ec2.domain.Image, Image
builder.id(from.getRegion() + "/" + from.getId());
builder.description(from.getDescription() != null ? from.getDescription() : from.getImageLocation());
builder.userMetadata(ImmutableMap.<String, String> of("owner", from.getImageOwnerId(), "rootDeviceType", from
.getRootDeviceType().toString()));
.getRootDeviceType().toString()));
OsFamily osFamily = parseOsFamilyOrNull(provider, from.getImageLocation());
String osName = null;
String osArch = from.getVirtualizationType();
String osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, from.getImageLocation(),
osVersionMap);
String osDescription = from.getImageLocation();
boolean is64Bit = from.getArchitecture() == Architecture.X86_64;
try {
Matcher matcher = getMatcherAndFind(from.getImageLocation());
if (matcher.pattern() == AMZN_PATTERN) {
osFamily = OsFamily.AMZN_LINUX;
osVersion = matcher.group(1);
builder.version(osVersion);
} else if (matcher.pattern() == NEBULA_PATTERN) {
osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(2), osVersionMap);
} else {
osFamily = OsFamily.fromValue(matcher.group(1));
osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(2), osVersionMap);
builder.version(matcher.group(3).replace(".manifest.xml", ""));
}
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", from.getImageLocation());
} catch (NoSuchElementException e) {
logger.debug("<< didn't match at all(%s)", from.getImageLocation());
}
OperatingSystemBuilder osBuilder = new OperatingSystemBuilder();
osBuilder.is64Bit(from.getArchitecture() == Architecture.X86_64);
OsFamily family = parseOsFamilyOrUnrecognized(provider, from.getImageLocation());
osBuilder.family(family);
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, from.getImageLocation(),
osVersionMap));
osBuilder.description(from.getImageLocation());
osBuilder.arch(from.getVirtualizationType());
reviseParsedImage.reviseParsedImage(from, builder, family, osBuilder);
builder.defaultCredentials(credentialProvider.execute(from));
@ -157,24 +121,10 @@ public class ImageParser implements Function<org.jclouds.ec2.domain.Image, Image
} catch (NoSuchElementException e) {
System.err.printf("unknown region %s for image %s; not in %s", from.getRegion(), from.getId(), locations);
builder.location(new LocationImpl(LocationScope.REGION, from.getRegion(), from.getRegion(), defaultLocation
.get().getParent()));
.get().getParent()));
}
builder.operatingSystem(new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit));
builder.operatingSystem(osBuilder.build());
return builder.build();
}
/**
*
* @throws NoSuchElementException
* if no configured matcher matches the manifest.
*/
private Matcher getMatcherAndFind(String manifest) {
for (Pattern pattern : new Pattern[] { AMZN_PATTERN, NEBULA_PATTERN, CANONICAL_PATTERN, RIGHTIMAGE_PATTERN,
RIGHTSCALE_PATTERN }) {
Matcher matcher = pattern.matcher(manifest);
if (matcher.find())
return matcher;
}
throw new NoSuchElementException(manifest);
}
}

View File

@ -45,11 +45,11 @@ public final class RegionAndIdToImage implements Function<RegionAndName, Image>
@Resource
protected Logger logger = Logger.NULL;
private final ImageParser parser;
private final EC2ImageParser parser;
private final EC2Client sync;
@Inject
public RegionAndIdToImage(ImageParser parser, EC2Client sync) {
public RegionAndIdToImage(EC2ImageParser parser, EC2Client sync) {
this.parser = parser;
this.sync = sync;
}

View File

@ -0,0 +1,49 @@
/**
*
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.ec2.compute.strategy;
import javax.inject.Singleton;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import com.google.inject.ImplementedBy;
/**
*
* @author Adrian Cole
*/
@ImplementedBy(ReviseParsedImage.NoopReviseParsedImage.class)
public interface ReviseParsedImage {
void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
OperatingSystemBuilder osBuilder);
@Singleton
public static class NoopReviseParsedImage implements ReviseParsedImage {
@Override
public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
OperatingSystemBuilder osBuilder) {
}
}
}

View File

@ -58,7 +58,7 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.ec2.compute.domain.RegionAndName;
import org.jclouds.ec2.compute.functions.ImageParser;
import org.jclouds.ec2.compute.functions.EC2ImageParser;
import org.jclouds.ec2.compute.strategy.DescribeImagesParallel;
import org.jclouds.ec2.options.DescribeImagesOptions;
import org.jclouds.compute.domain.Image;
@ -86,13 +86,13 @@ public class RegionAndNameToImageSupplier implements Supplier<Map<RegionAndName,
private final DescribeImagesParallel describer;
private final String[] ccAmis;
private final String[] amiOwners;
private final ImageParser parser;
private final EC2ImageParser parser;
private final Map<RegionAndName, Image> images;
@Inject
RegionAndNameToImageSupplier(@Region Set<String> regions, DescribeImagesParallel describer,
@Named(PROPERTY_EC2_CC_AMIs) String[] ccAmis, @Named(PROPERTY_EC2_AMI_OWNERS) final String[] amiOwners,
final ImageParser parser, final Map<RegionAndName, Image> images) {
final EC2ImageParser parser, final Map<RegionAndName, Image> images) {
this.regions = regions;
this.describer = describer;
this.ccAmis = ccAmis;

View File

@ -37,6 +37,7 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.Constants;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Image.EbsBlockDevice;
@ -58,7 +59,6 @@ import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.scriptbuilder.ScriptBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.testng.annotations.AfterTest;

View File

@ -37,6 +37,7 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.Constants;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.BlockDevice;
@ -70,7 +71,6 @@ import org.jclouds.scriptbuilder.InitBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.testng.annotations.AfterTest;

View File

@ -0,0 +1,92 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.ec2.compute.functions;
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.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl;
import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.xml.DescribeImagesResponseHandlerTest;
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")
public class EC2ImageParserTest {
public void testParseAmznImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/amzn_images.xml");
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description(
"137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).description("Amazon")
.defaultCredentials(new Credentials("ec2-user", null)).id("us-east-1/ami-82e4b5c7").providerId(
"ami-82e4b5c7").location(defaultLocation).userMetadata(
ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build());
assertEquals(Iterables.get(result, 3), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description(
"amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml").is64Bit(true).build())
.description("Amazon Linux AMI x86_64 S3").defaultCredentials(new Credentials("ec2-user", null)).id(
"us-east-1/ami-f2e4b5b7").providerId("ami-f2e4b5b7").location(defaultLocation).userMetadata(
ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build());
}
static Location defaultLocation = new LocationImpl(LocationScope.REGION, "us-east-1", "us-east-1", null);
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));
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation), "ec2", new ReviseParsedImage.NoopReviseParsedImage());
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
}
}

View File

@ -1,233 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.ec2.compute.functions;
import static org.testng.Assert.assertEquals;
import java.util.Map;
import java.util.Set;
import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.xml.DescribeImagesResponseHandlerTest;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl;
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.gson.Gson;
import com.google.inject.Guice;
/**
* @author Adrian Cole
*/
@Test(groups = "unit")
public class ImageParserTest {
public void testParseAlesticCanonicalImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/alestic_canonical.xml");
assertEquals(
Iterables.get(result, 0),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UBUNTU).arch("paravirtual").version("8.04")
.description("ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml")
.is64Bit(false).build())
.description("ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml")
.defaultCredentials(new Credentials("ubuntu", null)).id("us-east-1/ami-7e28ca17")
.providerId("ami-7e28ca17").location(defaultLocation).version("20091130")
.userMetadata(ImmutableMap.of("owner", "099720109477", "rootDeviceType", "instance-store")).build());
assertEquals(
Iterables.get(result, 4),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UBUNTU).arch("paravirtual").version("8.04")
.description("alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml").is64Bit(false)
.build()).description("alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml")
.defaultCredentials(new Credentials("ubuntu", null)).id("us-east-1/ami-c0fa1ea9")
.providerId("ami-c0fa1ea9").location(defaultLocation).version("20080905")
.userMetadata(ImmutableMap.of("owner", "063491364108", "rootDeviceType", "instance-store")).build());
assertEquals(
Iterables.get(result, 6),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UBUNTU).arch("paravirtual").version("10.04")
.description("099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827")
.is64Bit(false).build())
.description("099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827")
.defaultCredentials(new Credentials("ubuntu", null)).id("us-east-1/ami-10f3a255")
.providerId("ami-10f3a255").location(defaultLocation).version("20100827")
.userMetadata(ImmutableMap.of("owner", "099720109477", "rootDeviceType", "ebs")).build());
}
public void testParseVostokImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/vostok.xml");
assertEquals(
Iterables.get(result, 0),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("")
.description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml")
.is64Bit(false).build())
.description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml")
.defaultCredentials(new Credentials("root", null)).id("us-east-1/ami-870de2ee")
.providerId("ami-870de2ee").location(defaultLocation).version("5622")
.userMetadata(ImmutableMap.of("owner", "133804938231", "rootDeviceType", "instance-store")).build());
}
public void testParseCCImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/describe_images_cc.xml");
assertEquals(
Iterables.get(result, 0),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("hvm").version("5.4")
.description("amazon/EC2 CentOS 5.4 HVM AMI").is64Bit(true).build())
.description("EC2 CentOS 5.4 HVM AMI").defaultCredentials(new Credentials("root", null))
.id("us-east-1/ami-7ea24a17").providerId("ami-7ea24a17").location(defaultLocation)
.userMetadata(ImmutableMap.of("owner", "206029621532", "rootDeviceType", "ebs")).build());
}
public void testParseRightScaleImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/rightscale_images.xml");
assertEquals(
Iterables.get(result, 0),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("paravirtual").version("5.4")
.description("rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml").is64Bit(true)
.build()).description("rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml")
.defaultCredentials(new Credentials("root", null)).id("us-east-1/ami-ccb35ea5")
.providerId("ami-ccb35ea5").location(defaultLocation).version("4.4.10")
.userMetadata(ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build());
assertEquals(
new Gson().toJson(Iterables.get(result, 1)),
"{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"providerId\":\"ami-c19db6b5\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\"}}");
assertEquals(
new Gson().toJson(Iterables.get(result, 2)),
"{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"providerId\":\"ami-710c2605\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\"}}");
}
public void testParseEucalyptusImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/eucalyptus_images.xml");
assertEquals(
Iterables.get(result, 0),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("paravirtual").version("5.3")
.description("centos-5.3-x86_64/centos.5-3.x86-64.img.manifest.xml").is64Bit(true)
.build()).description("centos-5.3-x86_64/centos.5-3.x86-64.img.manifest.xml")
.defaultCredentials(new Credentials("root", null)).id("us-east-1/emi-9ACB1363")
.providerId("emi-9ACB1363").location(defaultLocation)
.userMetadata(ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build());
}
public void testParseAmznImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/amzn_images.xml");
assertEquals(
Iterables.get(result, 0),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.AMZN_LINUX).arch("paravirtual")
.version("0.9.7-beta").description("137112412989/amzn-ami-0.9.7-beta.i386-ebs")
.is64Bit(false).build()).description("Amazon")
.defaultCredentials(new Credentials("ec2-user", null)).id("us-east-1/ami-82e4b5c7")
.providerId("ami-82e4b5c7").location(defaultLocation).version("0.9.7-beta")
.userMetadata(ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build());
assertEquals(
Iterables.get(result, 3),
new ImageBuilder()
.operatingSystem(
new OperatingSystemBuilder().family(OsFamily.AMZN_LINUX).arch("paravirtual")
.version("0.9.7-beta")
.description("amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml").is64Bit(true)
.build()).description("Amazon Linux AMI x86_64 S3")
.defaultCredentials(new Credentials("ec2-user", null)).id("us-east-1/ami-f2e4b5b7")
.providerId("ami-f2e4b5b7").location(defaultLocation).version("0.9.7-beta")
.userMetadata(ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build());
}
public void testParseNovaImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/nova_images.xml");
assertEquals(
new Gson().toJson(Iterables.get(result, 0)),
"{\"operatingSystem\":{\"arch\":\"paravirtual\",\"version\":\"\",\"description\":\"nasacms/image.manifest.xml\",\"is64Bit\":true},\"description\":\"nasacms/image.manifest.xml\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-h30p5im0\",\"type\":\"IMAGE\",\"providerId\":\"ami-h30p5im0\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"foo\",\"rootDeviceType\":\"instance-store\"}}");
assertEquals(
new Gson().toJson(Iterables.get(result, 1)),
"{\"operatingSystem\":{\"arch\":\"paravirtual\",\"version\":\"\",\"description\":\"nebula/tiny\",\"is64Bit\":true},\"description\":\"nebula/tiny\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-tiny\",\"type\":\"IMAGE\",\"providerId\":\"ami-tiny\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"vishvananda\",\"rootDeviceType\":\"instance-store\"}}");
assertEquals(
new Gson().toJson(Iterables.get(result, 2)),
"{\"operatingSystem\":{\"arch\":\"paravirtual\",\"version\":\"\",\"description\":\"demos/mediawiki\",\"is64Bit\":true},\"description\":\"demos/mediawiki\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-630A130F\",\"type\":\"IMAGE\",\"providerId\":\"ami-630A130F\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"admin\",\"rootDeviceType\":\"instance-store\"}}");
assertEquals(
new Gson().toJson(Iterables.get(result, 3)),
"{\"operatingSystem\":{\"arch\":\"paravirtual\",\"version\":\"\",\"description\":\"pinglet/instances\",\"is64Bit\":true},\"description\":\"pinglet/instances\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-pinginst\",\"type\":\"IMAGE\",\"providerId\":\"ami-pinginst\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"admin\",\"rootDeviceType\":\"instance-store\"}}");
}
static Location defaultLocation = new LocationImpl(LocationScope.REGION, "us-east-1", "us-east-1", null);
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));
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)),
Suppliers.ofInstance(defaultLocation), "ec2");
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
}
}

View File

@ -49,7 +49,7 @@ public class RegionAndIdToImageTest {
@Test
public void testApply() {
ImageParser parser = createMock(ImageParser.class);
EC2ImageParser parser = createMock(EC2ImageParser.class);
EC2Client caller = createMock(EC2Client.class);
AMIClient client = createMock(AMIClient.class);
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
@ -80,7 +80,7 @@ public class RegionAndIdToImageTest {
@Test
public void testApplyNotFound() {
ImageParser parser = createMock(ImageParser.class);
EC2ImageParser parser = createMock(EC2ImageParser.class);
EC2Client caller = createMock(EC2Client.class);
AMIClient client = createMock(AMIClient.class);
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
@ -111,7 +111,7 @@ public class RegionAndIdToImageTest {
@Test
public void testApplyNoSuchElementException() {
ImageParser parser = createMock(ImageParser.class);
EC2ImageParser parser = createMock(EC2ImageParser.class);
EC2Client caller = createMock(EC2Client.class);
AMIClient client = createMock(AMIClient.class);
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);

View File

@ -24,7 +24,7 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream;
import java.util.Set;
import org.jclouds.ec2.compute.functions.ImageParserTest;
import org.jclouds.ec2.compute.functions.EC2ImageParserTest;
import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.domain.Image.Architecture;
import org.jclouds.ec2.domain.Image.EbsBlockDevice;
@ -100,7 +100,7 @@ public class DescribeImagesResponseHandlerTest {
}
public static Set<Image> parseImages(String resource) {
InputStream is = ImageParserTest.class.getResourceAsStream(resource);
InputStream is = EC2ImageParserTest.class.getResourceAsStream(resource);
return createParser().parse(is);
}
}

View File

@ -134,7 +134,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
Set<Reservation<? extends RunningInstance>> contents = Sets.newLinkedHashSet();
contents.add(new Reservation<RunningInstance>(defaultRegion, ImmutableSet.of("default"), ImmutableSet
.of(new RunningInstance(defaultRegion, ImmutableSet.<String> of(), "0", null, "ami-25CB1213", "i-9slweygo",
.of(new RunningInstance(defaultRegion, ImmutableSet.<String> of(), "0", null, "ami-82e4b5c7", "i-9slweygo",
InstanceState.TERMINATED, InstanceType.M1_SMALL, null, null, "nebulatanimislam", dateService
.iso8601SecondsDateParse("2010-09-09T18:09:42Z"), null, null, null, "paravirtual", null, null,
"10.128.207.5", ImmutableSet.<String> of("None"), null, null, null, null, null,

View File

@ -11,7 +11,7 @@
<dnsName />
<launchTime>2010-09-09T18:09:42Z</launchTime>
<instanceId>i-9slweygo</instanceId>
<imageId>ami-25CB1213</imageId>
<imageId>ami-82e4b5c7</imageId>
<instanceState>
<code>1</code>
<name>shutdown</name>

View File

@ -1,49 +0,0 @@
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
<requestId>2564fc86-9a73-4727-9298-f0b9eb9b57c8</requestId>
<imagesSet>
<item>
<imageId>emi-9ACB1363</imageId>
<imageLocation>centos-5.3-x86_64/centos.5-3.x86-64.img.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes />
<architecture>x86_64</architecture>
<imageType>machine</imageType>
<kernelId>eki-6CBD12F2</kernelId>
<ramdiskId>eri-A97113E4</ramdiskId>
</item>
<item>
<imageId>eri-A97113E4</imageId>
<imageLocation>initrd-64/initrd.img-2.6.28-11-generic.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes />
<architecture>x86_64</architecture>
<imageType>ramdisk</imageType>
</item>
<item>
<imageId>eki-6CBD12F2</imageId>
<imageLocation>kernel-64/vmlinuz-2.6.28-11-generic.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes />
<architecture>x86_64</architecture>
<imageType>kernel</imageType>
</item>
<item>
<imageId>emi-B5C5103A</imageId>
<imageLocation>shashi-test/RTestSmall.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<productCodes />
<architecture>x86_64</architecture>
<imageType>machine</imageType>
<kernelId>eki-6CBD12F2</kernelId>
<ramdiskId>eri-A97113E4</ramdiskId>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -1,179 +0,0 @@
<?xml version="1.0" ?>
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
<requestId>RX9NL9IWKIR11XL8ZLFR</requestId>
<imagesSet>
<item>
<imageOwnerId>foo</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-h30p5im0</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nasacms/image.manifest.xml</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ari-lucid</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid-ramdisk</imageLocation>
<type>ramdisk</type>
</item>
<item>
<imageOwnerId>vishvananda</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-tiny</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/tiny</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-630A130F</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>demos/mediawiki</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>aki-edge</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/bleeding-edge-kernel</imageLocation>
<type>kernel</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ari-edge</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/bleeding-edge-ramdisk</imageLocation>
<type>ramdisk</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>aki-lucid</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid-kernel</imageLocation>
<type>kernel</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-pinginst</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>pinglet/instances</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>rkumar2</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-alqbihe2</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>bucket/testbuntu.manifest.xml</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>ykliu</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-i0aemtfp</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>gfortran-bucket/gfortran.manifest.xml
</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ari-22F211EF</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/ramdisk</imageLocation>
<type>ramdisk</type>
</item>
<item>
<imageOwnerId>foo</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-2ig7w1bh</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>grinder/grinder-analyzer.manifest.xml
</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>aki-EAB510D9</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/kernel</imageLocation>
<type>kernel</type>
</item>
<item>
<imageOwnerId>vishvananda</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-lucid</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-karmiclg</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/karmic-large</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>jyothi</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-8jen8kdn</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>jo/qa-grinder.manifest.xml</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>vishvananda</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-lucidlg</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/lucid-large</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-6CD61336</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>demos/wordpress</imageLocation>
<type>machine</type>
</item>
<item>
<imageOwnerId>admin</imageOwnerId>
<isPublic>true</isPublic>
<imageId>ami-25CB1213</imageId>
<imageState>available</imageState>
<architecture>x86_64</architecture>
<imageLocation>nebula/ubuntu-karmic</imageLocation>
<type>machine</type>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -31,6 +31,7 @@ import java.util.logging.Logger;
import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.elasticstack.domain.ClaimType;
import org.jclouds.elasticstack.domain.CreateDriveRequest;
@ -51,7 +52,6 @@ import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.util.Strings2;

View File

@ -23,6 +23,7 @@ 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.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties;
@ -39,9 +40,7 @@ public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ENDPOINT,
"http://173.205.188.130:8773/services/Eucalyptus");
// TODO
// properties.setProperty(PROPERTY_ELB_ENDPOINT,
// "https://elasticloadbalancing.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin");
// amis that work with the cluster instances
properties.setProperty(PROPERTY_EC2_CC_AMIs, "");

View File

@ -53,7 +53,7 @@ import org.jclouds.s3.functions.ObjectKey;
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseIfNotEmpty;
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseOnIllegalState;
import org.jclouds.s3.options.CopyObjectOptions;
import org.jclouds.s3.options.ListBucketOptions;
import org.jclouds.s3.options.PutBucketOptions;
@ -182,7 +182,7 @@ public interface S3AsyncClient {
*/
@DELETE
@Path("/")
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseIfNotEmpty.class)
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseOnIllegalState.class)
ListenableFuture<Boolean> deleteBucketIfEmpty(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);

View File

@ -20,18 +20,12 @@
package org.jclouds.s3.functions;
import static com.google.common.base.Predicates.equalTo;
import static com.google.common.base.Throwables.getCausalChain;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.get;
import static com.google.common.collect.Iterables.size;
import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import static org.jclouds.util.Throwables2.propagateOrNull;
import java.util.List;
import javax.inject.Singleton;
import org.jclouds.aws.AWSResponseException;
import org.jclouds.blobstore.ContainerNotFoundException;
import com.google.common.base.Function;
@ -41,20 +35,13 @@ import com.google.common.base.Function;
* @author Adrian Cole
*/
@Singleton
public class ReturnTrueOn404OrNotFoundFalseIfNotEmpty implements Function<Exception, Boolean> {
public class ReturnTrueOn404OrNotFoundFalseOnIllegalState implements Function<Exception, Boolean> {
public Boolean apply(Exception from) {
List<Throwable> throwables = getCausalChain(from);
Iterable<AWSResponseException> matchingAWSResponseException = filter(throwables, AWSResponseException.class);
if (size(matchingAWSResponseException) >= 1 && get(matchingAWSResponseException, 0).getError() != null) {
if (get(matchingAWSResponseException, 0).getError().getCode().equals("BucketNotEmpty"))
return false;
if (getFirstThrowableOfType(from, IllegalStateException.class) != null) {
return false;
}
Iterable<ContainerNotFoundException> matchingContainerNotFoundException = filter(throwables,
ContainerNotFoundException.class);
if (size(matchingContainerNotFoundException) >= 1) {
if (getFirstThrowableOfType(from, ContainerNotFoundException.class) != null) {
return true;
}
if (returnValueOnCodeOrNull(from, true, equalTo(404)) != null)

View File

@ -38,7 +38,7 @@ import org.jclouds.s3.domain.AccessControlList.Permission;
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseIfNotEmpty;
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseOnIllegalState;
import org.jclouds.s3.options.CopyObjectOptions;
import org.jclouds.s3.options.ListBucketOptions;
import org.jclouds.s3.options.PutBucketOptions;
@ -231,7 +231,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnTrueOn404OrNotFoundFalseIfNotEmpty.class);
assertExceptionParserClassEquals(method, ReturnTrueOn404OrNotFoundFalseOnIllegalState.class);
checkFilters(request);
}

View File

@ -117,8 +117,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
validateContent(destinationContainer, destinationKey);
URL url = new URL(String.format("http://%1$s.s3.amazonaws.com/%2$s", destinationContainer,
destinationKey));
URL url = new URL(String.format("http://%1$s.s3.amazonaws.com/%2$s", destinationContainer, destinationKey));
Strings2.toStringAndClose(url.openStream());
} finally {
@ -130,8 +129,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
String sourceKey = "apples";
String destinationKey = "pears";
public void testPublicWriteOnObject() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testPublicWriteOnObject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
final String publicReadWriteObjectKey = "public-read-write-acl";
final String containerName = getContainerName();
try {
@ -139,14 +137,14 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
object.getMetadata().setKey(publicReadWriteObjectKey);
object.setPayload("");
// Public Read-Write object
getApi().putObject(containerName, object,
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE));
getApi()
.putObject(containerName, object,
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE));
assertConsistencyAware(new Runnable() {
public void run() {
try {
AccessControlList acl = getApi().getObjectACL(containerName,
publicReadWriteObjectKey);
AccessControlList acl = getApi().getObjectACL(containerName, publicReadWriteObjectKey);
assertEquals(acl.getGrants().size(), 3);
assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 2);
assertTrue(acl.getOwner() != null);
@ -168,8 +166,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
public void testUpdateObjectACL() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testUpdateObjectACL() throws InterruptedException, ExecutionException, TimeoutException, IOException {
String containerName = getContainerName();
try {
String objectKey = "private-acl";
@ -214,8 +211,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
public void testPrivateAclIsDefaultForObject() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testPrivateAclIsDefaultForObject() throws InterruptedException, ExecutionException, TimeoutException,
IOException {
String privateObjectKey = "private-acl";
String containerName = getContainerName();
try {
@ -233,16 +230,14 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
public void testPublicReadOnObject() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testPublicReadOnObject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
final String publicReadObjectKey = "public-read-acl";
final String containerName = getContainerName();
try {
S3Object object = getApi().newS3Object();
object.getMetadata().setKey(publicReadObjectKey);
object.setPayload("");
getApi().putObject(containerName, object,
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ));
getApi().putObject(containerName, object, new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ));
assertConsistencyAware(new Runnable() {
public void run() {
@ -275,8 +270,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
return getApi().putObject(sourceContainer, sourceObject);
}
protected S3Object validateObject(String sourceContainer, String key)
throws InterruptedException, ExecutionException, TimeoutException, IOException {
protected S3Object validateObject(String sourceContainer, String key) throws InterruptedException,
ExecutionException, TimeoutException, IOException {
assertConsistencyAwareContainerSize(sourceContainer, 1);
S3Object newObject = getApi().getObject(sourceContainer, key);
assert newObject != null;
@ -298,7 +293,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
S3Object newObject = validateObject(containerName, key);
assertEquals(newObject.getMetadata().getCacheControl(), "no-cache");
assert (newObject.getMetadata().getCacheControl().indexOf("no-cache") != -1) : newObject.getMetadata()
.getCacheControl();
assertEquals(newObject.getMetadata().getContentMetadata().getContentDisposition(),
"attachment; filename=hello.txt");
} finally {
@ -342,16 +338,15 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
}
protected String addToContainerAndValidate(String containerName, String sourceKey)
throws InterruptedException, ExecutionException, TimeoutException, IOException {
protected String addToContainerAndValidate(String containerName, String sourceKey) throws InterruptedException,
ExecutionException, TimeoutException, IOException {
String etag = addBlobToContainer(containerName, sourceKey);
validateContent(containerName, sourceKey);
return etag;
}
// TODO: fails on linux and windows
public void testCopyIfModifiedSince() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testCopyIfModifiedSince() throws InterruptedException, ExecutionException, TimeoutException, IOException {
String containerName = getContainerName();
String destinationContainer = getContainerName();
try {
@ -359,13 +354,13 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
addToContainerAndValidate(containerName, sourceKey + "mod");
Date after = new Date(System.currentTimeMillis() + 1000);
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer,
destinationKey, ifSourceModifiedSince(before));
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer, destinationKey,
ifSourceModifiedSince(before));
validateContent(destinationContainer, destinationKey);
try {
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer,
destinationKey, ifSourceModifiedSince(after));
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer, destinationKey,
ifSourceModifiedSince(after));
} catch (HttpResponseException ex) {
assertEquals(ex.getResponse().getStatusCode(), 412);
}
@ -377,8 +372,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
// TODO: fails on linux and windows
public void testCopyIfUnmodifiedSince() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testCopyIfUnmodifiedSince() throws InterruptedException, ExecutionException, TimeoutException,
IOException {
String containerName = getContainerName();
String destinationContainer = getContainerName();
try {
@ -391,8 +386,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
validateContent(destinationContainer, destinationKey);
try {
getApi().copyObject(containerName, sourceKey + "un", destinationContainer,
destinationKey, ifSourceModifiedSince(before));
getApi().copyObject(containerName, sourceKey + "un", destinationContainer, destinationKey,
ifSourceModifiedSince(before));
} catch (HttpResponseException ex) {
assertEquals(ex.getResponse().getStatusCode(), 412);
}
@ -402,8 +397,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
}
public void testCopyIfMatch() throws InterruptedException, ExecutionException, TimeoutException,
IOException {
public void testCopyIfMatch() throws InterruptedException, ExecutionException, TimeoutException, IOException {
String containerName = getContainerName();
String destinationContainer = getContainerName();
try {
@ -425,8 +419,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
}
public void testCopyIfNoneMatch() throws IOException, InterruptedException, ExecutionException,
TimeoutException {
public void testCopyIfNoneMatch() throws IOException, InterruptedException, ExecutionException, TimeoutException {
String containerName = getContainerName();
String destinationContainer = getContainerName();
try {
@ -448,8 +441,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
}
}
public void testCopyWithMetadata() throws InterruptedException, ExecutionException,
TimeoutException, IOException {
public void testCopyWithMetadata() throws InterruptedException, ExecutionException, TimeoutException, IOException {
String containerName = getContainerName();
String destinationContainer = getContainerName();
try {

View File

@ -34,17 +34,17 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
@Override
@Test(enabled = false)
public void testGetTwoRanges() {
// not supported in cloud files
// not supported in swift
}
// not supported
// not supported in swift
@Override
protected void checkContentDisposition(Blob blob, String contentDisposition) {
assert blob.getPayload().getContentMetadata().getContentDisposition() == null;
assert blob.getMetadata().getContentMetadata().getContentDisposition() == null;
}
// not supported
// not supported in swift
@Override
protected void checkContentLanguage(Blob blob, String contentLanguage) {
assert blob.getPayload().getContentMetadata().getContentLanguage() == null;

View File

@ -106,15 +106,18 @@
<appender-ref ref="ASYNCWIRE" />
</category>
<category name="jclouds.wire">
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
<!--
NOTE!! enabling this logger will cause the following test to
fail BaseBlobIntegrationTest.testPutObjectStream <category
name="jclouds.wire"> <priority value="DEBUG" /> <appender-ref
ref="ASYNCWIRE" /> </category>
-->
<category name="jclouds.blobstore">
<priority value="DEBUG" />
<appender-ref ref="ASYNCBLOBSTORE" />
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->

View File

@ -20,7 +20,7 @@
package org.jclouds.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrUnrecognized;
import java.util.Map;
import java.util.regex.Matcher;
@ -81,7 +81,7 @@ public class ImageForVCloudExpressVAppTemplate implements Function<VCloudExpress
protected OperatingSystem parseOs(VCloudExpressVAppTemplate from) {
OperatingSystemBuilder builder = new OperatingSystemBuilder();
OsFamily osFamily = parseOsFamilyOrNull("vcloudexpress", checkNotNull(from, "vapp template").getName());
OsFamily osFamily = parseOsFamilyOrUnrecognized("vcloudexpress", checkNotNull(from, "vapp template").getName());
builder.family(osFamily);
builder.description(from.getName());
builder.is64Bit(from.getName().indexOf("64") != -1);

View File

@ -22,7 +22,6 @@ package org.jclouds.blobstore.functions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
import static org.jclouds.blobstore.util.BlobStoreUtils.getNameFor;
@ -49,21 +48,19 @@ import com.google.common.base.Function;
* @author Adrian Cole
*/
public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpResponse, MutableBlobMetadata>,
InvocationContext<ParseSystemAndUserMetadataFromHeaders> {
InvocationContext<ParseSystemAndUserMetadataFromHeaders> {
private final String metadataPrefix;
private final DateService dateParser;
private final Provider<MutableBlobMetadata> metadataFactory;
private final String apiVersion;
private String key;
@Inject
public ParseSystemAndUserMetadataFromHeaders(Provider<MutableBlobMetadata> metadataFactory, DateService dateParser,
@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix, @Named(PROPERTY_API_VERSION) String apiVersion) {
@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix) {
this.metadataFactory = checkNotNull(metadataFactory, "metadataFactory");
this.dateParser = checkNotNull(dateParser, "dateParser");
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix");
this.apiVersion = checkNotNull(metadataPrefix, "metadataPrefix");
}
public MutableBlobMetadata apply(HttpResponse from) {
@ -84,7 +81,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
for (Entry<String, String> header : from.getHeaders().entries()) {
if (header.getKey() != null && header.getKey().startsWith(metadataPrefix))
metadata.getUserMetadata().put((header.getKey().substring(metadataPrefix.length())).toLowerCase(),
header.getValue());
header.getValue());
}
}
@ -95,11 +92,12 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
// scaleup-storage uses the wrong case for the last modified header
if ((lastModified = from.getFirstHeaderOrNull("Last-modified")) == null)
throw new HttpException(HttpHeaders.LAST_MODIFIED + " header not present in response: "
+ from.getStatusLine());
+ from.getStatusLine());
}
// Eucalyptus 1.6 returns iso8601 dates
if (apiVersion.indexOf("Walrus-1.6") != -1) {
metadata.setLastModified(dateParser.iso8601DateParse(lastModified.replace("+0000", "Z")));
// Walrus
if (lastModified.startsWith("20")) {
metadata.setLastModified(dateParser.iso8601DateParse(lastModified));
} else {
metadata.setLastModified(dateParser.rfc822DateParse(lastModified));
}

View File

@ -55,14 +55,14 @@ public class ParseSystemAndUserMetadataFromHeadersTest {
@BeforeTest
void setUp() {
parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider, new SimpleDateFormatDateService(),
"prefix", "default");
"prefix");
parser.setName("key");
}
@Test
public void testApplySetsName() {
HttpResponse from = new HttpResponse(200, "ok", Payloads.newStringPayload(""), ImmutableMultimap.of(
HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"));
HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"));
from.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
from.getPayload().getContentMetadata().setContentLength(100l);
BlobMetadata metadata = parser.apply(from);
@ -72,18 +72,18 @@ public class ParseSystemAndUserMetadataFromHeadersTest {
@Test
public void testNoContentOn204IsOk() {
HttpResponse from = new HttpResponse(204, "ok", Payloads.newStringPayload(""), ImmutableMultimap.of(
HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"));
HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"));
parser.apply(from);
}
@Test
public void testSetLastModified() {
HttpResponse from = new HttpResponse(200, "ok", Payloads.newStringPayload(""), ImmutableMultimap.of(
HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"));
HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"));
MutableBlobMetadata metadata = blobMetadataProvider.get();
parser.parseLastModifiedOrThrowException(from, metadata);
assertEquals(metadata.getLastModified(),
new SimpleDateFormatDateService().rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT"));
assertEquals(metadata.getLastModified(), new SimpleDateFormatDateService()
.rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT"));
}
@Test(expectedExceptions = HttpException.class)
@ -96,7 +96,7 @@ public class ParseSystemAndUserMetadataFromHeadersTest {
@Test
public void testAddETagTo() {
HttpResponse from = new HttpResponse(200, "ok", Payloads.newStringPayload(""), ImmutableMultimap.of(
HttpHeaders.ETAG, "0xfeb"));
HttpHeaders.ETAG, "0xfeb"));
MutableBlobMetadata metadata = blobMetadataProvider.get();
parser.addETagTo(from, metadata);
assertEquals(metadata.getETag(), "0xfeb");
@ -105,7 +105,7 @@ public class ParseSystemAndUserMetadataFromHeadersTest {
@Test
public void testAddUserMetadataTo() {
HttpResponse from = new HttpResponse(200, "ok", Payloads.newStringPayload(""), ImmutableMultimap.of("prefix"
+ "key", "value"));
+ "key", "value"));
MutableBlobMetadata metadata = blobMetadataProvider.get();
parser.addUserMetadataTo(from, metadata);
assertEquals(metadata.getUserMetadata().get("key"), "value");

View File

@ -513,7 +513,6 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
.getPayload().getContentMetadata().getContentLanguage();
assert blob.getMetadata().getContentMetadata().getContentLanguage().startsWith(contentLanguage) : blob
.getMetadata().getContentMetadata().getContentLanguage();
}
protected volatile static Crypto crypto;

View File

@ -19,6 +19,7 @@
package org.jclouds.blobstore.integration.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
import static org.jclouds.blobstore.util.BlobStoreUtils.getContentAsStringOrNullAndClose;
import static org.testng.Assert.assertEquals;
@ -68,8 +69,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
blobsAsString.add(getContentAsStringOrNullAndClose(blob));
}
blobsAsString.removeAll(fiveStrings.values());
assert blobsAsString.size() == 0 : blobsAsString.size() + ": " + blobs + ": "
+ blobsAsString;
assert blobsAsString.size() == 0 : blobsAsString.size() + ": " + blobs + ": " + blobsAsString;
} finally {
returnContainer(bucketName);
}
@ -91,8 +91,8 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
}
}
private void assertConsistencyAwareContentEquals(final Map<String, Blob> map, final String key,
final String blob) throws InterruptedException {
private void assertConsistencyAwareContentEquals(final Map<String, Blob> map, final String key, final String blob)
throws InterruptedException {
assertConsistencyAware(new Runnable() {
public void run() {
Blob old = map.remove(key);
@ -116,8 +116,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
Set<Entry<String, Blob>> entries = map.entrySet();
assertEquals(entries.size(), 5);
for (Entry<String, Blob> entry : entries) {
assertEquals(fiveStrings.get(entry.getKey()), getContentAsStringOrNullAndClose(entry
.getValue()));
assertEquals(fiveStrings.get(entry.getKey()), getContentAsStringOrNullAndClose(entry.getValue()));
Blob blob = entry.getValue();
blob.setPayload("");
Payloads.calculateMD5(blob);
@ -155,16 +154,15 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
}
}
void getOneReturnsAppleAndOldValueIsNull(Map<String, Blob> map, Blob old) throws IOException,
InterruptedException {
void getOneReturnsAppleAndOldValueIsNull(Map<String, Blob> map, Blob old) throws IOException, InterruptedException {
assert old == null;
assertEquals(getContentAsStringOrNullAndClose(map.get("one")), "apple");
assertConsistencyAwareMapSize(map, 1);
}
void getOneReturnsBearAndOldValueIsApple(Map<String, Blob> map, Blob oldValue)
throws IOException, InterruptedException {
assertEquals(getContentAsStringOrNullAndClose(map.get("one")), "bear");
void getOneReturnsBearAndOldValueIsApple(Map<String, Blob> map, Blob oldValue) throws IOException,
InterruptedException {
assertEquals(getContentAsStringOrNullAndClose(checkNotNull(map.get("one"), "one")), "bear");
assertEquals(getContentAsStringOrNullAndClose(oldValue), "apple");
assertConsistencyAwareMapSize(map, 1);
}
@ -210,8 +208,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
}
@Test(groups = { "integration", "live" })
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException,
TimeoutException {
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException {
if (maxResultsForTestListings() == 0)
return;
String bucketName = getContainerName();

View File

@ -19,6 +19,7 @@
package org.jclouds.blobstore.integration.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
@ -65,16 +66,14 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
valuesAsString.add(Strings2.toStringAndClose(stream));
}
valuesAsString.removeAll(fiveStrings.values());
assert valuesAsString.size() == 0 : valuesAsString.size() + ": " + values + ": "
+ valuesAsString;
assert valuesAsString.size() == 0 : valuesAsString.size() + ": " + values + ": " + valuesAsString;
} finally {
returnContainer(containerName);
}
}
@Test(groups = { "integration", "live" })
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException,
TimeoutException {
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException {
String containerName = getContainerName();
try {
InputStreamMap map = createMap(context, containerName);
@ -134,8 +133,8 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
entry.setValue(Strings2.toInputStream(""));
}
assertConsistencyAwareMapSize(map, 5);
for (InputStream value : map.values()) {
assertEquals(Strings2.toStringAndClose(value), "");
for (Entry<String, InputStream> entry : map.entrySet()) {
assertEquals(Strings2.toStringAndClose(checkNotNull(entry.getValue(), entry.getKey())), "");
}
} finally {
returnContainer(containerName);
@ -143,8 +142,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
}
@Test(groups = { "integration", "live" })
public void testContainsStringValue() throws InterruptedException, ExecutionException,
TimeoutException {
public void testContainsStringValue() throws InterruptedException, ExecutionException, TimeoutException {
String containerName = getContainerName();
try {
Map<String, InputStream> map = createMap(context, containerName);
@ -156,8 +154,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
}
@Test(groups = { "integration", "live" })
public void testContainsFileValue() throws InterruptedException, ExecutionException,
TimeoutException {
public void testContainsFileValue() throws InterruptedException, ExecutionException, TimeoutException {
String containerName = getContainerName();
try {
Map<String, InputStream> map = createMap(context, containerName);
@ -169,8 +166,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
}
@Test(groups = { "integration", "live" })
public void testContainsInputStreamValue() throws InterruptedException, ExecutionException,
TimeoutException {
public void testContainsInputStreamValue() throws InterruptedException, ExecutionException, TimeoutException {
String containerName = getContainerName();
try {
Map<String, InputStream> map = createMap(context, containerName);
@ -182,8 +178,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
}
@Test(groups = { "integration", "live" })
public void testContainsBytesValue() throws InterruptedException, ExecutionException,
TimeoutException {
public void testContainsBytesValue() throws InterruptedException, ExecutionException, TimeoutException {
String containerName = getContainerName();
try {
Map<String, InputStream> map = createMap(context, containerName);
@ -269,16 +264,15 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
}
}
void getOneReturnsAppleAndOldValueIsNull(Map<String, InputStream> map, InputStream old)
throws IOException, InterruptedException {
void getOneReturnsAppleAndOldValueIsNull(Map<String, InputStream> map, InputStream old) throws IOException,
InterruptedException {
assert old == null;
assertEquals(Strings2.toStringAndClose(map.get("one")), String
.format(XML_STRING_FORMAT, "apple"));
assertEquals(Strings2.toStringAndClose(map.get("one")), String.format(XML_STRING_FORMAT, "apple"));
assertConsistencyAwareMapSize(map, 1);
}
void getOneReturnsBearAndOldValueIsApple(Map<String, InputStream> map, InputStream oldValue)
throws IOException, InterruptedException {
void getOneReturnsBearAndOldValueIsApple(Map<String, InputStream> map, InputStream oldValue) throws IOException,
InterruptedException {
assertEquals(Strings2.toStringAndClose(map.get("one")), String.format(XML_STRING_FORMAT, "bear"));
assertEquals(Strings2.toStringAndClose(oldValue), String.format(XML_STRING_FORMAT, "apple"));
assertConsistencyAwareMapSize(map, 1);
@ -330,8 +324,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
}
@Override
protected void putStringWithMD5(Map<String, InputStream> map, String key, String value)
throws InterruptedException {
protected void putStringWithMD5(Map<String, InputStream> map, String key, String value) throws InterruptedException {
((InputStreamMap) map).putString(key, value);
}
@ -343,8 +336,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
return createMap(context, bucket, maxResults(maxResultsForTestListings()));
}
protected InputStreamMap createMap(BlobStoreContext context, String bucket,
ListContainerOptions options) {
protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) {
return context.createInputStreamMap(bucket, options);
}
}

View File

@ -33,7 +33,6 @@ import static org.testng.Assert.assertNotNull;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
@ -41,7 +40,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jclouds.Constants;
import org.jclouds.http.HttpResponseException;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
@ -83,13 +81,6 @@ import com.google.inject.Module;
public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTest {
// Terremark service call 695,490
@Override
@Test(expectedExceptions = NoSuchElementException.class)
public void testCatalog() throws Exception {
super.testCatalog();
}
protected String expectedOs = "Ubuntu Linux (64-bit)";
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
@ -149,7 +140,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
prepare();
StringBuffer name = new StringBuffer();
for (int i = 0; i < 15; i++)
name.append("a");
name.append("c");
String serverName = name.toString();// "adriantest";
long hardDisk = 4194304;
@ -166,6 +157,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
TerremarkCatalogItem item = tmClient.findCatalogItemInOrgCatalogNamed(null, null, itemName);
assert item != null;
// if this template supports setting the root password, let's add it to
// our options
CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions()
@ -175,6 +168,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
VCloudExpressVAppTemplate vAppTemplate = tmClient.getVAppTemplate(item.getEntity().getHref());
assert vAppTemplate != null;
// instantiate, noting vApp returned has minimal details
vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
instantiateOptions);
@ -196,8 +191,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
try {// per docs, this is not supported
tmClient.cancelTask(deployTask.getHref());
} catch (HttpResponseException e) {
assertEquals(e.getResponse().getStatusCode(), 501);
} catch (UnsupportedOperationException e) {
}
assert successTester.apply(deployTask.getHref());
@ -302,14 +296,14 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
try {// per docs, this is not supported
tmClient.undeployVApp(vApp.getHref());
} catch (HttpResponseException e) {
assertEquals(e.getResponse().getStatusCode(), 501);
assert false;
} catch (UnsupportedOperationException e) {
}
try {// per docs, this is not supported
tmClient.suspendVApp(vApp.getHref());
} catch (HttpResponseException e) {
assertEquals(e.getResponse().getStatusCode(), 501);
assert false;
} catch (UnsupportedOperationException e) {
}
assert successTester.apply(tmClient.resetVApp(vApp.getHref()).getHref());

View File

@ -48,8 +48,8 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
@Inject
public OrgNameCatalogNameVAppTemplateNameToEndpoint(
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> orgCatalogItemMap,
@Org String defaultOrg, @Catalog String defaultCatalog) {
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>>> orgCatalogItemMap,
@Org String defaultOrg, @Catalog String defaultCatalog) {
this.orgCatalogItemMap = orgCatalogItemMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -65,13 +65,23 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
org = defaultOrg;
if (catalog == null)
catalog = defaultCatalog;
try {
Map<String, Map<String, ? extends CatalogItem>> catalogs = checkNotNull(orgCatalogItemMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getEntity().getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
+ orgCatalogItemMap.get());
}
Map<String, Map<String, Map<String, ? extends CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
if (!orgCatalogItemMap.containsKey(org))
throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet());
Map<String, Map<String, ? extends CatalogItem>> catalogs = orgCatalogItemMap.get(org);
if (!catalogs.containsKey(catalog))
throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet());
Map<String, ? extends CatalogItem> catalogMap = catalogs.get(catalog);
if (!catalogMap.containsKey(catalogItem))
throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in "
+ catalogMap.keySet());
CatalogItem item = catalogMap.get(catalogItem);
return checkNotNull(item.getEntity(), "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity")
.getHref();
}
}

View File

@ -20,7 +20,8 @@
(:require
[clojure.contrib.logging :as logging])
(:import
[org.jclouds.ssh SshClient ExecResponse]
org.jclouds.ssh.SshClient
org.jclouds.compute.domain.ExecResponse
com.google.inject.Module
com.google.common.collect.ImmutableSet
org.jclouds.domain.Credentials

View File

@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
@ -34,7 +35,6 @@ import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.Location;
import org.jclouds.io.Payload;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
import com.google.common.base.Predicate;
import com.google.inject.ImplementedBy;

View File

@ -26,10 +26,10 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
/**
*

View File

@ -21,10 +21,10 @@ package org.jclouds.compute.callables;
import java.util.concurrent.Callable;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
import com.google.common.annotations.Beta;

View File

@ -27,6 +27,7 @@ import java.util.Collections;
import javax.annotation.Resource;
import javax.inject.Named;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.compute.reference.ComputeServiceConstants;
@ -34,7 +35,6 @@ import org.jclouds.logging.Logger;
import org.jclouds.scriptbuilder.InitBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import com.google.common.annotations.VisibleForTesting;

View File

@ -24,11 +24,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import com.google.common.base.Function;

View File

@ -25,13 +25,13 @@ import static com.google.common.base.Preconditions.checkState;
import javax.annotation.Resource;
import javax.inject.Named;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import com.google.common.annotations.VisibleForTesting;

View File

@ -17,7 +17,7 @@
* ====================================================================
*/
package org.jclouds.ssh;
package org.jclouds.compute.domain;
import org.jclouds.compute.config.CustomizationResponse;

View File

@ -59,6 +59,7 @@ import org.jclouds.compute.RunScriptOnNodesException;
import org.jclouds.compute.callables.RunScriptOnNode;
import org.jclouds.compute.config.CustomizationResponse;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
@ -85,7 +86,6 @@ import org.jclouds.logging.Logger;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.util.Strings2;
import com.google.common.base.Function;

View File

@ -22,8 +22,8 @@ package org.jclouds.compute.predicates;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.logging.Logger;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import com.google.common.base.Predicate;

View File

@ -34,6 +34,7 @@ import javax.inject.Named;
import org.jclouds.compute.callables.RunScriptOnNode;
import org.jclouds.compute.config.CustomizationResponse;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.predicates.RetryIfSocketNotYetOpen;
@ -41,7 +42,6 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.logging.Logger;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.ssh.ExecResponse;
import com.google.common.base.Function;
import com.google.common.base.Predicate;

View File

@ -30,10 +30,10 @@ import javax.annotation.Resource;
import javax.inject.Named;
import org.jclouds.compute.callables.RunScriptOnNode;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.ssh.ExecResponse;
import com.google.common.base.Objects;
import com.google.inject.assistedinject.AssistedInject;

View File

@ -132,7 +132,7 @@ public class ComputeServiceUtils {
return total;
}
public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrNull(String provider, String in) {
public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String provider, String in) {
org.jclouds.compute.domain.OsFamily myOs = null;
for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
@ -142,7 +142,7 @@ public class ComputeServiceUtils {
if (myOs == null && provider.indexOf("nebula") != -1) {
myOs = OsFamily.UBUNTU;
}
return myOs;
return OsFamily.UNRECOGNIZED;
}
public static String createExecutionErrorMessage(Map<?, Exception> executionExceptions) {

View File

@ -22,6 +22,7 @@ package org.jclouds.ssh;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.io.Payload;
import org.jclouds.net.IPSocket;

View File

@ -21,7 +21,8 @@
[clojure.contrib.logging :as logging]
[org.jclouds.modules :as modules])
(:import
[org.jclouds.ssh SshClient ExecResponse]
org.jclouds.ssh.SshClient
org.jclouds.compute.domain.ExecResponse
org.jclouds.io.Payload
org.jclouds.net.IPSocket))

View File

@ -58,6 +58,7 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.Constants;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
@ -78,7 +79,6 @@ import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.testng.annotations.AfterTest;
@ -239,11 +239,11 @@ public abstract class BaseComputeServiceLiveTest {
}
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
runningWithTag(tag), Statements.exec("echo hello"), overrideCredentialsWith(good).wrapInInitScript(false))
.entrySet())
runningWithTag(tag), Statements.exec("echo hello"),
overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet())
assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": "
+ response.getValue();
runScriptWithCreds(tag, os, good);
checkNodes(nodes, tag);

View File

@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.easymock.IArgumentMatcher;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.Credentials;
import org.jclouds.io.Payload;
@ -43,7 +44,6 @@ import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.util.Strings2;

View File

@ -62,7 +62,7 @@ aws-s3.propertiesbuilder=org.jclouds.aws.s3.AWSS3PropertiesBuilder
ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
ec2.propertiesbuilder=org.jclouds.ec2.EC2PropertiesBuilder
aws-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
aws-ec2.contextbuilder=org.jclouds.aws.ec2.AWSEC2ContextBuilder
aws-ec2.propertiesbuilder=org.jclouds.aws.ec2.AWSEC2PropertiesBuilder
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
@ -95,8 +95,8 @@ vcloudexpress.propertiesbuilder=org.jclouds.vcloud.VCloudExpressPropertiesBuilde
eucalyptus.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
eucalyptus.propertiesbuilder=org.jclouds.eucalyptus.EucalyptusPropertiesBuilder
eucalyptus-partnercloud-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
eucalyptus-partnercloud-ec2.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudEucalyptusPropertiesBuilder
eucalyptus-partnercloud-ec2.contextbuilder=org.jclouds.epc.EucalyptusPartnerCloudContextBuilder
eucalyptus-partnercloud-ec2.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudPropertiesBuilder
nova-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
nova-ec2.propertiesbuilder=org.jclouds.nova.ec2.NovaEC2PropertiesBuilder

View File

@ -40,12 +40,12 @@ import javax.inject.Named;
import org.apache.commons.io.input.ProxyInputStream;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.logging.Logger;
import org.jclouds.net.IPSocket;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.util.Strings2;

View File

@ -26,11 +26,11 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.net.IPSocket;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.util.Strings2;

View File

@ -0,0 +1,45 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2;
import java.util.List;
import java.util.Properties;
import org.jclouds.aws.ec2.config.AWSEC2ComputeServiceContextModule;
import org.jclouds.ec2.EC2ContextBuilder;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class AWSEC2ContextBuilder extends EC2ContextBuilder {
public AWSEC2ContextBuilder(Properties props) {
super(props);
}
@Override
protected void addContextModule(List<Module> modules) {
modules.add(new AWSEC2ComputeServiceContextModule());
}
}

View File

@ -0,0 +1,48 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.config;
import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
import org.jclouds.aws.ec2.strategy.AWSEC2ReviseParsedImage;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
import com.google.inject.Injector;
/**
*
* @author Adrian Cole
*/
public class AWSEC2ComputeServiceContextModule extends EC2ComputeServiceContextModule {
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
return template.osFamily(AMZN_LINUX).os64Bit(true);
}
@Override
protected void configure() {
super.configure();
bind(ReviseParsedImage.class).to(AWSEC2ReviseParsedImage.class);
}
}

View File

@ -0,0 +1,121 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystemBuilder;
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 AWSEC2ReviseParsedImage implements ReviseParsedImage {
// 137112412989/amzn-ami-0.9.7-beta.i386-ebs
// 137112412989/amzn-ami-0.9.7-beta.x86_64-ebs
// amzn-ami-us-east-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml
// amzn-ami-us-east-1/amzn-ami-0.9.7-beta.i386.manifest.xml
public static final Pattern AMZN_PATTERN = Pattern
.compile(".*/amzn-ami-(.*)\\.(i386|x86_64)(-ebs|\\.manifest.xml)?");
// amazon/EC2 CentOS 5.4 HVM AMI
public static final Pattern AMAZON_PATTERN = Pattern.compile("amazon/EC2 ([^ ]+) ([^ ]+).*");
public static final Pattern CANONICAL_PATTERN = Pattern.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?");
// ex rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml
public static final Pattern RIGHTSCALE_PATTERN = Pattern
.compile("[^/]*/([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
// ex 411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha
// 411009282317/RightImage_Windows_2008_x64_v5.5.5
public static final Pattern RIGHTIMAGE_PATTERN = Pattern
.compile("[^/]*/RightImage[_ ]([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
private final Map<OsFamily, Map<String, String>> osVersionMap;
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
@Inject
public AWSEC2ReviseParsedImage(Map<OsFamily, Map<String, String>> osVersionMap) {
this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
}
@Override
public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
OperatingSystemBuilder osBuilder) {
try {
Matcher matcher = getMatcherAndFind(from.getImageLocation());
if (matcher.pattern() == AMZN_PATTERN) {
osBuilder.family(OsFamily.AMZN_LINUX);
osBuilder.version(matcher.group(1));
builder.version(matcher.group(1));
} else if (matcher.pattern() == AMAZON_PATTERN) {
family = OsFamily.fromValue(matcher.group(1));
osBuilder.family(family);
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2),
osVersionMap));
} else {
family = OsFamily.fromValue(matcher.group(1));
osBuilder.family(family);
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2),
osVersionMap));
builder.version(matcher.group(3).replace(".manifest.xml", ""));
}
} catch (IllegalArgumentException e) {
logger.debug("<< didn't match os(%s)", from.getImageLocation());
} catch (NoSuchElementException e) {
logger.debug("<< didn't match at all(%s)", from.getImageLocation());
}
}
/**
*
* @throws NoSuchElementException
* if no configured matcher matches the manifest.
*/
private Matcher getMatcherAndFind(String manifest) {
for (Pattern pattern : new Pattern[] { AMZN_PATTERN, AMAZON_PATTERN, CANONICAL_PATTERN, RIGHTIMAGE_PATTERN,
RIGHTSCALE_PATTERN }) {
Matcher matcher = pattern.matcher(manifest);
if (matcher.find())
return matcher;
}
throw new NoSuchElementException(manifest);
}
}

View File

@ -0,0 +1,170 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.aws.ec2.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.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.internal.LocationImpl;
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.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.gson.Gson;
import com.google.inject.Guice;
/**
* @author Adrian Cole
*/
@Test(groups = "unit")
public class AWSEC2ImageParserTest {
public void testParseAlesticCanonicalImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/alestic_canonical.xml");
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UBUNTU).arch("paravirtual").version("8.04").description(
"ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml").is64Bit(false).build())
.description("ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml").defaultCredentials(
new Credentials("ubuntu", null)).id("us-east-1/ami-7e28ca17").providerId("ami-7e28ca17")
.location(defaultLocation).version("20091130").userMetadata(
ImmutableMap.of("owner", "099720109477", "rootDeviceType", "instance-store")).build());
assertEquals(Iterables.get(result, 4), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UBUNTU).arch("paravirtual").version("8.04").description(
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml").is64Bit(false).build()).description(
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml").defaultCredentials(
new Credentials("ubuntu", null)).id("us-east-1/ami-c0fa1ea9").providerId("ami-c0fa1ea9").location(
defaultLocation).version("20080905").userMetadata(
ImmutableMap.of("owner", "063491364108", "rootDeviceType", "instance-store")).build());
assertEquals(Iterables.get(result, 6), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UBUNTU).arch("paravirtual").version("10.04").description(
"099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827").is64Bit(false)
.build()).description("099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827")
.defaultCredentials(new Credentials("ubuntu", null)).id("us-east-1/ami-10f3a255").providerId(
"ami-10f3a255").location(defaultLocation).version("20100827").userMetadata(
ImmutableMap.of("owner", "099720109477", "rootDeviceType", "ebs")).build());
}
public void testParseVostokImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/vostok.xml");
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description(
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml").is64Bit(false).build())
.description("vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml").defaultCredentials(
new Credentials("root", null)).id("us-east-1/ami-870de2ee").providerId("ami-870de2ee")
.location(defaultLocation).version("5622").userMetadata(
ImmutableMap.of("owner", "133804938231", "rootDeviceType", "instance-store")).build());
}
public void testParseCCImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/describe_images_cc.xml");
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("hvm").version("5.4").description(
"amazon/EC2 CentOS 5.4 HVM AMI").is64Bit(true).build()).description("EC2 CentOS 5.4 HVM AMI")
.defaultCredentials(new Credentials("root", null)).id("us-east-1/ami-7ea24a17").providerId(
"ami-7ea24a17").location(defaultLocation).userMetadata(
ImmutableMap.of("owner", "206029621532", "rootDeviceType", "ebs")).build());
}
public void testParseRightScaleImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/rightscale_images.xml");
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("paravirtual").version("5.4").description(
"rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml").is64Bit(true).build()).description(
"rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml").defaultCredentials(
new Credentials("root", null)).id("us-east-1/ami-ccb35ea5").providerId("ami-ccb35ea5").location(
defaultLocation).version("4.4.10").userMetadata(
ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build());
assertEquals(
new Gson().toJson(Iterables.get(result, 1)),
"{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"providerId\":\"ami-c19db6b5\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\"}}");
assertEquals(
new Gson().toJson(Iterables.get(result, 2)),
"{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"providerId\":\"ami-710c2605\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\"},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\"}}");
}
public void testParseAmznImage() {
Set<org.jclouds.compute.domain.Image> result = convertImages("/amzn_images.xml");
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.AMZN_LINUX).arch("paravirtual").version("0.9.7-beta")
.description("137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).description(
"Amazon").defaultCredentials(new Credentials("ec2-user", null)).id("us-east-1/ami-82e4b5c7").providerId(
"ami-82e4b5c7").location(defaultLocation).version("0.9.7-beta").userMetadata(
ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build());
assertEquals(Iterables.get(result, 3), new ImageBuilder().operatingSystem(
new OperatingSystemBuilder().family(OsFamily.AMZN_LINUX).arch("paravirtual").version("0.9.7-beta")
.description("amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml").is64Bit(true)
.build()).description("Amazon Linux AMI x86_64 S3").defaultCredentials(
new Credentials("ec2-user", null)).id("us-east-1/ami-f2e4b5b7").providerId("ami-f2e4b5b7").location(
defaultLocation).version("0.9.7-beta").userMetadata(
ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build());
}
static Location defaultLocation = new LocationImpl(LocationScope.REGION, "us-east-1", "us-east-1", null);
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));
Set<Image> result = DescribeImagesResponseHandlerTest.parseImages(resource);
EC2ImageParser parser = new EC2ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map,
Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(defaultLocation)), Suppliers
.ofInstance(defaultLocation), "ec2", new AWSEC2ReviseParsedImage(map));
return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull()));
}
}

View File

@ -0,0 +1,86 @@
<?xml version="1.0"?>
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
<requestId>6104eee1-affd-49d7-92a0-516cab8a8ba6</requestId>
<imagesSet>
<item>
<imageId>ami-82e4b5c7</imageId>
<imageLocation>137112412989/amzn-ami-0.9.7-beta.i386-ebs</imageLocation>
<imageState>available</imageState>
<imageOwnerId>137112412989</imageOwnerId>
<isPublic>true</isPublic>
<architecture>i386</architecture>
<imageType>machine</imageType>
<kernelId>aki-99a0f1dc</kernelId>
<name>amzn-ami-0.9.7-beta.i386-ebs</name>
<description>Amazon</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<snapshotId>snap-e98b7b82</snapshotId>
<volumeSize>10</volumeSize>
<deleteOnTermination>true</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
<virtualizationType>paravirtual</virtualizationType>
</item>
<item>
<imageId>ami-8ce4b5c9</imageId>
<imageLocation>137112412989/amzn-ami-0.9.7-beta.x86_64-ebs</imageLocation>
<imageState>available</imageState>
<imageOwnerId>137112412989</imageOwnerId>
<isPublic>true</isPublic>
<architecture>x86_64</architecture>
<imageType>machine</imageType>
<kernelId>aki-9ba0f1de</kernelId>
<name>amzn-ami-0.9.7-beta.x86_64-ebs</name>
<description>Amazon</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<snapshotId>snap-8d8b7be6</snapshotId>
<volumeSize>10</volumeSize>
<deleteOnTermination>true</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
<virtualizationType>paravirtual</virtualizationType>
</item>
<item>
<imageId>ami-f0e4b5b5</imageId>
<imageLocation>amzn-ami-us-west-1/amzn-ami-0.9.7-beta.i386.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>137112412989</imageOwnerId>
<isPublic>true</isPublic>
<architecture>i386</architecture>
<imageType>machine</imageType>
<kernelId>aki-99a0f1dc</kernelId>
<name>amzn-ami-0.9.7-beta.i386-S3</name>
<description>Amazon Linux AMI i386 S3</description>
<rootDeviceType>instance-store</rootDeviceType>
<blockDeviceMapping/>
<virtualizationType>paravirtual</virtualizationType>
</item>
<item>
<imageId>ami-f2e4b5b7</imageId>
<imageLocation>amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>137112412989</imageOwnerId>
<isPublic>true</isPublic>
<architecture>x86_64</architecture>
<imageType>machine</imageType>
<kernelId>aki-9ba0f1de</kernelId>
<name>amzn-ami-0.9.7-beta.x86_64-S3</name>
<description>Amazon Linux AMI x86_64 S3</description>
<rootDeviceType>instance-store</rootDeviceType>
<blockDeviceMapping/>
<virtualizationType>paravirtual</virtualizationType>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -19,6 +19,8 @@
package org.jclouds.azureblob.handlers;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -31,6 +33,10 @@ import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpResponse;
import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
/**
* @author Adrian Cole
*
@ -43,22 +49,28 @@ public class ParseAzureBlobErrorFromXmlContent extends ParseAzureStorageErrorFro
super(utils);
}
protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception, AzureStorageError error,
String message) {
protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception,
AzureStorageError error, String message) {
switch (response.getStatusCode()) {
case 404:
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
exception = new ResourceNotFoundException(message, exception);
String container = command.getCurrentRequest().getEndpoint().getHost();
String key = command.getCurrentRequest().getEndpoint().getPath();
if (key == null || key.equals("/"))
exception = new ContainerNotFoundException(container, message);
else
exception = new KeyNotFoundException(container, key, message);
}
return exception;
default:
return super.refineException(command, response, exception, error, message);
case 404:
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
exception = new ResourceNotFoundException(message, exception);
List<String> parts = Lists.newArrayList(Splitter.on('/').split(
command.getCurrentRequest().getEndpoint().getPath()));
parts.remove("");
if (parts.size() > 0) {
String container = parts.remove(0);
String query = command.getCurrentRequest().getEndpoint().getQuery();
if (query != null && query.indexOf("container") != -1) {
exception = new ContainerNotFoundException(container, message);
} else {
exception = new KeyNotFoundException(container, Joiner.on('/').join(parts), message);
}
}
}
return exception;
default:
return super.refineException(command, response, exception, error, message);
}
}
}

View File

@ -0,0 +1,115 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.azure.storage.handlers;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.reportMatcher;
import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay;
import static org.easymock.classextension.EasyMock.verify;
import java.net.URI;
import org.easymock.IArgumentMatcher;
import org.jclouds.azure.storage.filters.SharedKeyLiteAuthentication;
import org.jclouds.azureblob.handlers.ParseAzureBlobErrorFromXmlContent;
import org.jclouds.blobstore.ContainerNotFoundException;
import org.jclouds.blobstore.KeyNotFoundException;
import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.io.Payloads;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
/**
*
* @author Adrian Cole
*/
@Test(groups = { "unit" })
public class ParseAzureBlobErrorFromXmlContentTest {
@Test
public void test404OnContainerIsContainerNotFound() {
assertCodeMakes("GET", URI
.create("https://jclouds.blob.core.windows.net/adriancole-azureblob-413790770?restype=container"), 404,
"Not Found", "text/html; charset=us-ascii", "<HTML><HEAD><TITLE>Not Found</TITLE>\r\n",
ContainerNotFoundException.class);
}
@Test
public void test404WithoutContainerIsKeyNotFound() {
assertCodeMakes("GET", URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore0/apples"), 404,
"Not Found", "text/html; charset=us-ascii", "<HTML><HEAD><TITLE>Not Found</TITLE>\r\n",
KeyNotFoundException.class);
}
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
String content, Class<? extends Exception> expected) {
ParseAzureBlobErrorFromXmlContent function = Guice.createInjector(new SaxParserModule(), new AbstractModule() {
@Override
protected void configure() {
bind(SharedKeyLiteAuthentication.class).toInstance(createMock(SharedKeyLiteAuthentication.class));
}
}).getInstance(ParseAzureBlobErrorFromXmlContent.class);
HttpCommand command = createMock(HttpCommand.class);
HttpRequest request = new HttpRequest(method, uri);
HttpResponse response = new HttpResponse(statusCode, message, Payloads.newInputStreamPayload(Strings2
.toInputStream(content)));
response.getPayload().getContentMetadata().setContentType(contentType);
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
command.setException(classEq(expected));
replay(command);
function.handleError(command, response);
verify(command);
}
public static Exception classEq(final Class<? extends Exception> in) {
reportMatcher(new IArgumentMatcher() {
@Override
public void appendTo(StringBuffer buffer) {
buffer.append("classEq(");
buffer.append(in);
buffer.append(")");
}
@Override
public boolean matches(Object arg) {
return arg.getClass() == in;
}
});
return null;
}
}

View File

@ -19,7 +19,8 @@
package org.jclouds.rackspace.cloudfiles;
import org.jclouds.cloudfiles.CloudFilesClientLiveTest;
import org.jclouds.cloudfiles.CloudFilesClient;
import org.jclouds.openstack.swift.CommonSwiftClientLiveTest;
import org.testng.annotations.Test;
/**
@ -28,6 +29,11 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", sequential = true, testName = "CloudFilesUKClientLiveTest")
public class CloudFilesUKClientLiveTest extends CloudFilesClientLiveTest {
public class CloudFilesUKClientLiveTest extends CommonSwiftClientLiveTest<CloudFilesClient> {
// NOTE cloudfilesuk doesn't have cdn
@Override
public CloudFilesClient getApi() {
return (CloudFilesClient) context.getProviderSpecificContext().getApi();
}
}

View File

@ -19,14 +19,14 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKBlobIntegrationLiveTest")
public class CloudFilesUKBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
public class CloudFilesUKBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKBlobLiveTest")
public class CloudFilesUKBlobLiveTest extends SwiftBlobLiveTest {
public class CloudFilesUKBlobLiveTest extends CloudFilesBlobLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobMapIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKBlobMapIntegrationLiveTest")
public class CloudFilesUKBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
public class CloudFilesUKBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest {
}

View File

@ -19,7 +19,7 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobSignerLiveTest;
import org.testng.annotations.Test;
/**
@ -27,6 +27,6 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKBlobSignerLiveTest")
public class CloudFilesUKBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
public class CloudFilesUKBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKContainerIntegrationLiveTest")
public class CloudFilesUKContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
public class CloudFilesUKContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKContainerLiveTest")
public class CloudFilesUKContainerLiveTest extends SwiftContainerLiveTest {
public class CloudFilesUKContainerLiveTest extends CloudFilesContainerLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftInputStreamMapIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesInputStreamMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKInputStreamMapIntegrationLiveTest")
public class CloudFilesUKInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
public class CloudFilesUKInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftServiceIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesServiceIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUKServiceIntegrationLiveTest")
public class CloudFilesUKServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
public class CloudFilesUKServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer;
/**
*
* @author Adrian Cole
*/
public class CloudFilesUKTestInitializer extends SwiftTestInitializer {
public class CloudFilesUKTestInitializer extends CloudFilesTestInitializer {
public CloudFilesUKTestInitializer() {
provider = "cloudfiles-uk";

View File

@ -19,14 +19,14 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSBlobIntegrationLiveTest")
public class CloudFilesUSBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
public class CloudFilesUSBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSBlobLiveTest")
public class CloudFilesUSBlobLiveTest extends SwiftBlobLiveTest {
public class CloudFilesUSBlobLiveTest extends CloudFilesBlobLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobMapIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSBlobMapIntegrationLiveTest")
public class CloudFilesUSBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
public class CloudFilesUSBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest {
}

View File

@ -19,7 +19,7 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesBlobSignerLiveTest;
import org.testng.annotations.Test;
/**
@ -27,6 +27,6 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSBlobSignerLiveTest")
public class CloudFilesUSBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
public class CloudFilesUSBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSContainerIntegrationLiveTest")
public class CloudFilesUSContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
public class CloudFilesUSContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesContainerLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSContainerLiveTest")
public class CloudFilesUSContainerLiveTest extends SwiftContainerLiveTest {
public class CloudFilesUSContainerLiveTest extends CloudFilesContainerLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftInputStreamMapIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesInputStreamMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSInputStreamMapIntegrationLiveTest")
public class CloudFilesUSInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
public class CloudFilesUSInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftServiceIntegrationLiveTest;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesServiceIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudFilesUSServiceIntegrationLiveTest")
public class CloudFilesUSServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
public class CloudFilesUSServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer;
import org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer;
/**
*
* @author Adrian Cole
*/
public class CloudFilesUSTestInitializer extends SwiftTestInitializer {
public class CloudFilesUSTestInitializer extends CloudFilesTestInitializer {
public CloudFilesUSTestInitializer() {
provider = "cloudfiles-us";

View File

@ -19,22 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.jclouds.atmos.blobstore.integration.AtmosIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageBlobIntegrationLiveTest")
public class CloudOneStorageBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
@Override
@Test(expectedExceptions = IllegalArgumentException.class)
public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException {
super.testPutObjectStream();
}
public class CloudOneStorageBlobIntegrationLiveTest extends AtmosIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest;
import org.jclouds.atmos.blobstore.integration.AtmosLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageBlobLiveTest")
public class CloudOneStorageBlobLiveTest extends BaseBlobLiveTest {
public class CloudOneStorageBlobLiveTest extends AtmosLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseBlobMapIntegrationTest;
import org.jclouds.atmos.blobstore.integration.AtmosMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageBlobMapIntegrationLiveTest")
public class CloudOneStorageBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
public class CloudOneStorageBlobMapIntegrationLiveTest extends AtmosMapIntegrationLiveTest {
}

View File

@ -19,7 +19,7 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest;
import org.jclouds.atmos.blobstore.integration.AtmosBlobSignerLiveTest;
import org.testng.annotations.Test;
/**
@ -27,6 +27,6 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageBlobSignerLiveTest")
public class CloudOneStorageBlobSignerLiveTest extends BaseBlobSignerLiveTest {
public class CloudOneStorageBlobSignerLiveTest extends AtmosBlobSignerLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
import org.jclouds.atmos.blobstore.integration.AtmosContainerIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageContainerIntegrationLiveTest")
public class CloudOneStorageContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
public class CloudOneStorageContainerIntegrationLiveTest extends AtmosContainerIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest;
import org.jclouds.atmos.blobstore.integration.AtmosContainerLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageContainerLiveTest")
public class CloudOneStorageContainerLiveTest extends BaseContainerLiveTest {
public class CloudOneStorageContainerLiveTest extends AtmosContainerLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseInputStreamMapIntegrationTest;
import org.jclouds.atmos.blobstore.integration.AtmosInputStreamMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageInputStreamMapIntegrationLiveTest")
public class CloudOneStorageInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
public class CloudOneStorageInputStreamMapIntegrationLiveTest extends AtmosInputStreamMapIntegrationLiveTest {
}

View File

@ -19,13 +19,13 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest;
import org.jclouds.atmos.blobstore.integration.AtmosServiceIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "CloudOneStorageServiceIntegrationLiveTest")
public class CloudOneStorageServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
public class CloudOneStorageServiceIntegrationLiveTest extends AtmosServiceIntegrationLiveTest {
}

View File

@ -19,33 +19,18 @@
package org.jclouds.cloudonestorage.blobstore.integration;
import java.io.IOException;
import org.jclouds.atmos.blobstore.integration.AtmosTestInitializer;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer;
import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class CloudOneStorageTestInitializer extends TransientBlobStoreTestInitializer {
public class CloudOneStorageTestInitializer extends AtmosTestInitializer {
public CloudOneStorageTestInitializer() {
provider = "cloudonestorage";
BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true;
}
@Override
protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiversion,
String app, String identity, String credential) throws IOException {
return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule,
new Log4JLoggingModule()), setupProperties(endpoint, apiversion, identity, credential));
}
}

View File

@ -35,9 +35,11 @@ import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
import org.jclouds.cloudsigma.domain.Drive;
import org.jclouds.cloudsigma.domain.DriveData;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.cloudsigma.domain.ProfileInfo;
import org.jclouds.cloudsigma.domain.Server;
import org.jclouds.cloudsigma.domain.ServerInfo;
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
@ -101,13 +103,22 @@ public interface CloudSigmaAsyncClient {
ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid,
@MapPayloadParam("name") String newName, CloneDriveOptions... options);
/**
* @see CloudSigmaClient#getProfileInfo
*/
@GET
@Path("/profile/info")
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(KeyValuesDelimitedByBlankLinesToProfileInfo.class)
ListenableFuture<ProfileInfo> getProfileInfo();
/**
* @see CloudSigmaClient#listDriveInfo
*/
@GET
@Path("/drives/info")
@ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
ListenableFuture<Set<org.jclouds.cloudsigma.domain.DriveInfo>> listDriveInfo();
ListenableFuture<Set<DriveInfo>> listDriveInfo();
/**
* @see CloudSigmaClient#getDriveInfo
@ -143,8 +154,7 @@ public interface CloudSigmaAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
@Path("/servers/create")
ListenableFuture<ServerInfo> createServer(
@BinderParam(BindServerToPlainTextString.class) Server createServer);
ListenableFuture<ServerInfo> createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer);
/**
* @see CloudSigmaClient#listServerInfo

View File

@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.cloudsigma.domain.Drive;
import org.jclouds.cloudsigma.domain.DriveData;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.cloudsigma.domain.ProfileInfo;
import org.jclouds.cloudsigma.domain.Server;
import org.jclouds.cloudsigma.domain.ServerInfo;
import org.jclouds.cloudsigma.options.CloneDriveOptions;
@ -40,13 +41,21 @@ import org.jclouds.concurrent.Timeout;
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface CloudSigmaClient {
/**
* Get profile info
*
* @return info or null, if not found
*/
ProfileInfo getProfileInfo();
/**
* list of server uuids in your account
*
* @return or empty set if no servers are found
*/
Set<String> listServers();
/**
* Get all servers info
*

View File

@ -0,0 +1,198 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.cloudsigma.domain;
import static com.google.common.base.Preconditions.checkNotNull;
/**
*
* @author Adrian Cole
*/
public class ProfileInfo {
public static class Builder {
protected String uuid;
protected String email;
protected String firstName;
protected String lastName;
protected String nickName;
protected ProfileType type = ProfileType.REGULAR;
public Builder uuid(String uuid) {
this.uuid = uuid;
return this;
}
public Builder email(String email) {
this.email = email;
return this;
}
public Builder firstName(String firstName) {
this.firstName = firstName;
return this;
}
public Builder lastName(String lastName) {
this.lastName = lastName;
return this;
}
public Builder nickName(String nickName) {
this.nickName = nickName;
return this;
}
public Builder type(ProfileType type) {
this.type = type;
return this;
}
public ProfileInfo build() {
return new ProfileInfo(uuid, email, firstName, lastName, nickName, type);
}
}
protected final String uuid;
protected final String email;
protected final String firstName;
protected final String lastName;
protected final String nickName;
protected final ProfileType type;
public ProfileInfo(String uuid, String email, String firstName, String lastName, String nickName, ProfileType type) {
this.uuid = checkNotNull(uuid, "uuid");
this.email = checkNotNull(email, "email");
this.firstName = checkNotNull(firstName, "firstName");
this.lastName = checkNotNull(lastName, "lastName");
this.nickName = checkNotNull(nickName, "nickName");
this.type = checkNotNull(type, "type");
}
/**
*
* @return uuid of the profile.
*/
public String getUuid() {
return uuid;
}
/**
* Checks for valid email address
*
* @return email of the profile.
*/
public String getEmail() {
return email;
}
/**
*
* @return firstName of the profile.
*/
protected String getFirstName() {
return firstName;
}
/**
*
* @return lastName of the profile.
*/
protected String getLastName() {
return lastName;
}
/**
* Used in phpBB nick name
*
* @return nickName of the profile.
*/
protected String getNickName() {
return nickName;
}
/**
*
* @return type of the profile.
*/
protected ProfileType getType() {
return type;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
result = prime * result + ((nickName == null) ? 0 : nickName.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ProfileInfo other = (ProfileInfo) obj;
if (email == null) {
if (other.email != null)
return false;
} else if (!email.equals(other.email))
return false;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
if (nickName == null) {
if (other.nickName != null)
return false;
} else if (!nickName.equals(other.nickName))
return false;
if (type != other.type)
return false;
if (uuid == null) {
if (other.uuid != null)
return false;
} else if (!uuid.equals(other.uuid))
return false;
return true;
}
@Override
public String toString() {
return "[uuid=" + uuid + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName
+ ", nickName=" + nickName + ", type=" + type + "]";
}
}

View File

@ -0,0 +1,47 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.cloudsigma.domain;
import static com.google.common.base.Preconditions.checkNotNull;
/**
*
* @author Adrian Cole
*/
public enum ProfileType {
REGULAR, UNRECOGNIZED;
public String value() {
return name().toLowerCase();
}
@Override
public String toString() {
return value();
}
public static ProfileType fromValue(String type) {
try {
return valueOf(checkNotNull(type, "type").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
}

View File

@ -0,0 +1,53 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.cloudsigma.functions;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.cloudsigma.domain.ProfileInfo;
import org.jclouds.http.HttpResponse;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
@Singleton
public class KeyValuesDelimitedByBlankLinesToProfileInfo implements Function<HttpResponse, ProfileInfo> {
private final ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet setParser;
@Inject
public KeyValuesDelimitedByBlankLinesToProfileInfo(ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet setParser) {
this.setParser = setParser;
}
@Override
public ProfileInfo apply(HttpResponse response) {
Set<ProfileInfo> drives = setParser.apply(response);
if (drives.size() == 0)
return null;
return Iterables.get(drives, 0);
}
}

Some files were not shown because too many files have changed in this diff Show More