mirror of https://github.com/apache/jclouds.git
Merge remote branch 'upstream/master'
This commit is contained in:
commit
9254305248
|
@ -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,
|
our blobstore api supports: aws-s3, cloudfiles (generic), cloudfiles-us, cloudfiles-uk,
|
||||||
azureblob, atmos (generic), synaptic-storage,
|
azureblob, atmos (generic), synaptic-storage,
|
||||||
cloudonestorage, s3 (generic), walrus(generic), googlestorage,
|
cloudonestorage, s3 (generic), walrus(generic), googlestorage,
|
||||||
scaleup-storage, eucalyptus-partnercloud-s3, swift (generic),
|
eucalyptus-partnercloud-s3, swift (generic), transient (in-mem),
|
||||||
transient (in-mem), filesystem (on-disk)
|
filesystem (on-disk)
|
||||||
|
|
||||||
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
|
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
|
||||||
to all of these providers
|
to all of these providers
|
||||||
|
|
||||||
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, openstack nova,
|
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
|
If you want access to all jclouds components, include the maven dependency org.jclouds/jclouds-all
|
||||||
|
|
|
@ -49,11 +49,6 @@
|
||||||
<artifactId>synaptic-storage</artifactId>
|
<artifactId>synaptic-storage</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.provider</groupId>
|
|
||||||
<artifactId>scaleup-storage</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.provider</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>cloudonestorage</artifactId>
|
<artifactId>cloudonestorage</artifactId>
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class SignRequest implements HttpRequestFilter {
|
||||||
for (String header : new String[] { "Range" })
|
for (String header : new String[] { "Range" })
|
||||||
toSign.append(utils.valueOrEmpty(request.getHeaders().get(header)).toLowerCase()).append("\n");
|
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.
|
// 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
|
@VisibleForTesting
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.jclouds.cloudservers.domain.ServerStatus;
|
||||||
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
||||||
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
||||||
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
|
@ -55,7 +56,6 @@ import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
package org.jclouds.ec2.compute.config;
|
package org.jclouds.ec2.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
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;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -31,16 +29,12 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.ec2.compute.EC2ComputeService;
|
import org.jclouds.ec2.compute.EC2ComputeService;
|
||||||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||||
import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
|
import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
|
||||||
import org.jclouds.location.Provider;
|
|
||||||
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,18 +51,6 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
|
||||||
super.configure();
|
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
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Map<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
protected Supplier<Map<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
|
||||||
|
|
|
@ -20,25 +20,21 @@
|
||||||
package org.jclouds.ec2.compute.functions;
|
package org.jclouds.ec2.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
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.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
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.domain.OsFamily;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
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.Location;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
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.location.Provider;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
@ -59,49 +58,29 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ImageParser implements Function<org.jclouds.ec2.domain.Image, Image> {
|
public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Image> {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
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 PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
||||||
private final Supplier<Set<? extends Location>> locations;
|
private final Supplier<Set<? extends Location>> locations;
|
||||||
|
|
||||||
private final Supplier<Location> defaultLocation;
|
private final Supplier<Location> defaultLocation;
|
||||||
private final String provider;
|
private final String provider;
|
||||||
private final Map<OsFamily, Map<String, String>> osVersionMap;
|
private final Map<OsFamily, Map<String, String>> osVersionMap;
|
||||||
|
private final ReviseParsedImage reviseParsedImage;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
public
|
||||||
|
EC2ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||||
Map<OsFamily, Map<String, String>> osVersionMap, @Memoized Supplier<Set<? extends Location>> locations,
|
Map<OsFamily, Map<String, String>> osVersionMap, @Memoized Supplier<Set<? extends Location>> locations,
|
||||||
Supplier<Location> defaultLocation, @Provider String provider) {
|
Supplier<Location> defaultLocation, @Provider String provider, ReviseParsedImage reviseParsedImage) {
|
||||||
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
||||||
this.locations = checkNotNull(locations, "locations");
|
this.locations = checkNotNull(locations, "locations");
|
||||||
this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
|
this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
|
||||||
this.provider = checkNotNull(provider, "provider");
|
this.provider = checkNotNull(provider, "provider");
|
||||||
this.osVersionMap = checkNotNull(osVersionMap, "utils");
|
this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
|
||||||
|
this.reviseParsedImage = checkNotNull(reviseParsedImage, "reviseParsedImage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,31 +96,16 @@ public class ImageParser implements Function<org.jclouds.ec2.domain.Image, Image
|
||||||
builder.userMetadata(ImmutableMap.<String, String> of("owner", from.getImageOwnerId(), "rootDeviceType", from
|
builder.userMetadata(ImmutableMap.<String, String> of("owner", from.getImageOwnerId(), "rootDeviceType", from
|
||||||
.getRootDeviceType().toString()));
|
.getRootDeviceType().toString()));
|
||||||
|
|
||||||
OsFamily osFamily = parseOsFamilyOrNull(provider, from.getImageLocation());
|
OperatingSystemBuilder osBuilder = new OperatingSystemBuilder();
|
||||||
String osName = null;
|
osBuilder.is64Bit(from.getArchitecture() == Architecture.X86_64);
|
||||||
String osArch = from.getVirtualizationType();
|
OsFamily family = parseOsFamilyOrUnrecognized(provider, from.getImageLocation());
|
||||||
String osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, from.getImageLocation(),
|
osBuilder.family(family);
|
||||||
osVersionMap);
|
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, from.getImageLocation(),
|
||||||
String osDescription = from.getImageLocation();
|
osVersionMap));
|
||||||
boolean is64Bit = from.getArchitecture() == Architecture.X86_64;
|
osBuilder.description(from.getImageLocation());
|
||||||
try {
|
osBuilder.arch(from.getVirtualizationType());
|
||||||
Matcher matcher = getMatcherAndFind(from.getImageLocation());
|
|
||||||
if (matcher.pattern() == AMZN_PATTERN) {
|
reviseParsedImage.reviseParsedImage(from, builder, family, osBuilder);
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.defaultCredentials(credentialProvider.execute(from));
|
builder.defaultCredentials(credentialProvider.execute(from));
|
||||||
|
|
||||||
|
@ -159,22 +123,8 @@ public class ImageParser implements Function<org.jclouds.ec2.domain.Image, Image
|
||||||
builder.location(new LocationImpl(LocationScope.REGION, from.getRegion(), from.getRegion(), defaultLocation
|
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();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -45,11 +45,11 @@ public final class RegionAndIdToImage implements Function<RegionAndName, Image>
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final ImageParser parser;
|
private final EC2ImageParser parser;
|
||||||
private final EC2Client sync;
|
private final EC2Client sync;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RegionAndIdToImage(ImageParser parser, EC2Client sync) {
|
public RegionAndIdToImage(EC2ImageParser parser, EC2Client sync) {
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
this.sync = sync;
|
this.sync = sync;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -58,7 +58,7 @@ import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
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.compute.strategy.DescribeImagesParallel;
|
||||||
import org.jclouds.ec2.options.DescribeImagesOptions;
|
import org.jclouds.ec2.options.DescribeImagesOptions;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -86,13 +86,13 @@ public class RegionAndNameToImageSupplier implements Supplier<Map<RegionAndName,
|
||||||
private final DescribeImagesParallel describer;
|
private final DescribeImagesParallel describer;
|
||||||
private final String[] ccAmis;
|
private final String[] ccAmis;
|
||||||
private final String[] amiOwners;
|
private final String[] amiOwners;
|
||||||
private final ImageParser parser;
|
private final EC2ImageParser parser;
|
||||||
private final Map<RegionAndName, Image> images;
|
private final Map<RegionAndName, Image> images;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RegionAndNameToImageSupplier(@Region Set<String> regions, DescribeImagesParallel describer,
|
RegionAndNameToImageSupplier(@Region Set<String> regions, DescribeImagesParallel describer,
|
||||||
@Named(PROPERTY_EC2_CC_AMIs) String[] ccAmis, @Named(PROPERTY_EC2_AMI_OWNERS) final String[] amiOwners,
|
@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.regions = regions;
|
||||||
this.describer = describer;
|
this.describer = describer;
|
||||||
this.ccAmis = ccAmis;
|
this.ccAmis = ccAmis;
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.ec2.domain.Image.EbsBlockDevice;
|
import org.jclouds.ec2.domain.Image.EbsBlockDevice;
|
||||||
|
@ -58,7 +59,6 @@ import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.scriptbuilder.ScriptBuilder;
|
import org.jclouds.scriptbuilder.ScriptBuilder;
|
||||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.AWSResponseException;
|
import org.jclouds.aws.AWSResponseException;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.ec2.domain.Attachment;
|
import org.jclouds.ec2.domain.Attachment;
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
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.OsFamily;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.scriptbuilder.domain.Statements;
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
|
|
|
@ -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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -49,7 +49,7 @@ public class RegionAndIdToImageTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApply() {
|
public void testApply() {
|
||||||
|
|
||||||
ImageParser parser = createMock(ImageParser.class);
|
EC2ImageParser parser = createMock(EC2ImageParser.class);
|
||||||
EC2Client caller = createMock(EC2Client.class);
|
EC2Client caller = createMock(EC2Client.class);
|
||||||
AMIClient client = createMock(AMIClient.class);
|
AMIClient client = createMock(AMIClient.class);
|
||||||
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
|
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
|
||||||
|
@ -80,7 +80,7 @@ public class RegionAndIdToImageTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApplyNotFound() {
|
public void testApplyNotFound() {
|
||||||
|
|
||||||
ImageParser parser = createMock(ImageParser.class);
|
EC2ImageParser parser = createMock(EC2ImageParser.class);
|
||||||
EC2Client caller = createMock(EC2Client.class);
|
EC2Client caller = createMock(EC2Client.class);
|
||||||
AMIClient client = createMock(AMIClient.class);
|
AMIClient client = createMock(AMIClient.class);
|
||||||
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
|
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
|
||||||
|
@ -111,7 +111,7 @@ public class RegionAndIdToImageTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApplyNoSuchElementException() {
|
public void testApplyNoSuchElementException() {
|
||||||
|
|
||||||
ImageParser parser = createMock(ImageParser.class);
|
EC2ImageParser parser = createMock(EC2ImageParser.class);
|
||||||
EC2Client caller = createMock(EC2Client.class);
|
EC2Client caller = createMock(EC2Client.class);
|
||||||
AMIClient client = createMock(AMIClient.class);
|
AMIClient client = createMock(AMIClient.class);
|
||||||
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
|
org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
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;
|
||||||
import org.jclouds.ec2.domain.Image.Architecture;
|
import org.jclouds.ec2.domain.Image.Architecture;
|
||||||
import org.jclouds.ec2.domain.Image.EbsBlockDevice;
|
import org.jclouds.ec2.domain.Image.EbsBlockDevice;
|
||||||
|
@ -100,7 +100,7 @@ public class DescribeImagesResponseHandlerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Image> parseImages(String resource) {
|
public static Set<Image> parseImages(String resource) {
|
||||||
InputStream is = ImageParserTest.class.getResourceAsStream(resource);
|
InputStream is = EC2ImageParserTest.class.getResourceAsStream(resource);
|
||||||
return createParser().parse(is);
|
return createParser().parse(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||||
Set<Reservation<? extends RunningInstance>> contents = Sets.newLinkedHashSet();
|
Set<Reservation<? extends RunningInstance>> contents = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
contents.add(new Reservation<RunningInstance>(defaultRegion, ImmutableSet.of("default"), ImmutableSet
|
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
|
InstanceState.TERMINATED, InstanceType.M1_SMALL, null, null, "nebulatanimislam", dateService
|
||||||
.iso8601SecondsDateParse("2010-09-09T18:09:42Z"), null, null, null, "paravirtual", null, null,
|
.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,
|
"10.128.207.5", ImmutableSet.<String> of("None"), null, null, null, null, null,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<dnsName />
|
<dnsName />
|
||||||
<launchTime>2010-09-09T18:09:42Z</launchTime>
|
<launchTime>2010-09-09T18:09:42Z</launchTime>
|
||||||
<instanceId>i-9slweygo</instanceId>
|
<instanceId>i-9slweygo</instanceId>
|
||||||
<imageId>ami-25CB1213</imageId>
|
<imageId>ami-82e4b5c7</imageId>
|
||||||
<instanceState>
|
<instanceState>
|
||||||
<code>1</code>
|
<code>1</code>
|
||||||
<name>shutdown</name>
|
<name>shutdown</name>
|
||||||
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -31,6 +31,7 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.elasticstack.domain.ClaimType;
|
import org.jclouds.elasticstack.domain.ClaimType;
|
||||||
import org.jclouds.elasticstack.domain.CreateDriveRequest;
|
import org.jclouds.elasticstack.domain.CreateDriveRequest;
|
||||||
|
@ -51,7 +52,6 @@ import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
|
@ -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.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_AMI_OWNERS;
|
||||||
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
|
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
|
||||||
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -39,9 +40,7 @@ public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_ENDPOINT,
|
properties.setProperty(PROPERTY_ENDPOINT,
|
||||||
"http://173.205.188.130:8773/services/Eucalyptus");
|
"http://173.205.188.130:8773/services/Eucalyptus");
|
||||||
// TODO
|
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
|
||||||
// properties.setProperty(PROPERTY_ELB_ENDPOINT,
|
|
||||||
// "https://elasticloadbalancing.us-east-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin");
|
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin");
|
||||||
// amis that work with the cluster instances
|
// amis that work with the cluster instances
|
||||||
properties.setProperty(PROPERTY_EC2_CC_AMIs, "");
|
properties.setProperty(PROPERTY_EC2_CC_AMIs, "");
|
||||||
|
|
|
@ -53,7 +53,7 @@ import org.jclouds.s3.functions.ObjectKey;
|
||||||
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
||||||
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
||||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
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.CopyObjectOptions;
|
||||||
import org.jclouds.s3.options.ListBucketOptions;
|
import org.jclouds.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.s3.options.PutBucketOptions;
|
import org.jclouds.s3.options.PutBucketOptions;
|
||||||
|
@ -182,7 +182,7 @@ public interface S3AsyncClient {
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseIfNotEmpty.class)
|
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseOnIllegalState.class)
|
||||||
ListenableFuture<Boolean> deleteBucketIfEmpty(
|
ListenableFuture<Boolean> deleteBucketIfEmpty(
|
||||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||||
|
|
||||||
|
|
|
@ -20,18 +20,12 @@
|
||||||
package org.jclouds.s3.functions;
|
package org.jclouds.s3.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Predicates.equalTo;
|
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.http.HttpUtils.returnValueOnCodeOrNull;
|
||||||
|
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
|
||||||
import static org.jclouds.util.Throwables2.propagateOrNull;
|
import static org.jclouds.util.Throwables2.propagateOrNull;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.AWSResponseException;
|
|
||||||
import org.jclouds.blobstore.ContainerNotFoundException;
|
import org.jclouds.blobstore.ContainerNotFoundException;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -41,20 +35,13 @@ import com.google.common.base.Function;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ReturnTrueOn404OrNotFoundFalseIfNotEmpty implements Function<Exception, Boolean> {
|
public class ReturnTrueOn404OrNotFoundFalseOnIllegalState implements Function<Exception, Boolean> {
|
||||||
|
|
||||||
public Boolean apply(Exception from) {
|
public Boolean apply(Exception from) {
|
||||||
List<Throwable> throwables = getCausalChain(from);
|
if (getFirstThrowableOfType(from, IllegalStateException.class) != null) {
|
||||||
|
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (getFirstThrowableOfType(from, ContainerNotFoundException.class) != null) {
|
||||||
Iterable<ContainerNotFoundException> matchingContainerNotFoundException = filter(throwables,
|
|
||||||
ContainerNotFoundException.class);
|
|
||||||
if (size(matchingContainerNotFoundException) >= 1) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (returnValueOnCodeOrNull(from, true, equalTo(404)) != null)
|
if (returnValueOnCodeOrNull(from, true, equalTo(404)) != null)
|
|
@ -38,7 +38,7 @@ import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||||
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
||||||
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
||||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
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.CopyObjectOptions;
|
||||||
import org.jclouds.s3.options.ListBucketOptions;
|
import org.jclouds.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.s3.options.PutBucketOptions;
|
import org.jclouds.s3.options.PutBucketOptions;
|
||||||
|
@ -231,7 +231,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, ReturnTrueOn404OrNotFoundFalseIfNotEmpty.class);
|
assertExceptionParserClassEquals(method, ReturnTrueOn404OrNotFoundFalseOnIllegalState.class);
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
validateContent(destinationContainer, destinationKey);
|
validateContent(destinationContainer, destinationKey);
|
||||||
|
|
||||||
URL url = new URL(String.format("http://%1$s.s3.amazonaws.com/%2$s", destinationContainer,
|
URL url = new URL(String.format("http://%1$s.s3.amazonaws.com/%2$s", destinationContainer, destinationKey));
|
||||||
destinationKey));
|
|
||||||
Strings2.toStringAndClose(url.openStream());
|
Strings2.toStringAndClose(url.openStream());
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -130,8 +129,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
String sourceKey = "apples";
|
String sourceKey = "apples";
|
||||||
String destinationKey = "pears";
|
String destinationKey = "pears";
|
||||||
|
|
||||||
public void testPublicWriteOnObject() throws InterruptedException, ExecutionException,
|
public void testPublicWriteOnObject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
TimeoutException, IOException {
|
|
||||||
final String publicReadWriteObjectKey = "public-read-write-acl";
|
final String publicReadWriteObjectKey = "public-read-write-acl";
|
||||||
final String containerName = getContainerName();
|
final String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
@ -139,14 +137,14 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
object.getMetadata().setKey(publicReadWriteObjectKey);
|
object.getMetadata().setKey(publicReadWriteObjectKey);
|
||||||
object.setPayload("");
|
object.setPayload("");
|
||||||
// Public Read-Write object
|
// Public Read-Write object
|
||||||
getApi().putObject(containerName, object,
|
getApi()
|
||||||
|
.putObject(containerName, object,
|
||||||
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE));
|
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE));
|
||||||
|
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
AccessControlList acl = getApi().getObjectACL(containerName,
|
AccessControlList acl = getApi().getObjectACL(containerName, publicReadWriteObjectKey);
|
||||||
publicReadWriteObjectKey);
|
|
||||||
assertEquals(acl.getGrants().size(), 3);
|
assertEquals(acl.getGrants().size(), 3);
|
||||||
assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 2);
|
assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 2);
|
||||||
assertTrue(acl.getOwner() != null);
|
assertTrue(acl.getOwner() != null);
|
||||||
|
@ -168,8 +166,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateObjectACL() throws InterruptedException, ExecutionException,
|
public void testUpdateObjectACL() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
TimeoutException, IOException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
String objectKey = "private-acl";
|
String objectKey = "private-acl";
|
||||||
|
@ -214,8 +211,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPrivateAclIsDefaultForObject() throws InterruptedException, ExecutionException,
|
public void testPrivateAclIsDefaultForObject() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
TimeoutException, IOException {
|
IOException {
|
||||||
String privateObjectKey = "private-acl";
|
String privateObjectKey = "private-acl";
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
@ -233,16 +230,14 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPublicReadOnObject() throws InterruptedException, ExecutionException,
|
public void testPublicReadOnObject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
TimeoutException, IOException {
|
|
||||||
final String publicReadObjectKey = "public-read-acl";
|
final String publicReadObjectKey = "public-read-acl";
|
||||||
final String containerName = getContainerName();
|
final String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
S3Object object = getApi().newS3Object();
|
S3Object object = getApi().newS3Object();
|
||||||
object.getMetadata().setKey(publicReadObjectKey);
|
object.getMetadata().setKey(publicReadObjectKey);
|
||||||
object.setPayload("");
|
object.setPayload("");
|
||||||
getApi().putObject(containerName, object,
|
getApi().putObject(containerName, object, new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ));
|
||||||
new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ));
|
|
||||||
|
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -275,8 +270,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
return getApi().putObject(sourceContainer, sourceObject);
|
return getApi().putObject(sourceContainer, sourceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected S3Object validateObject(String sourceContainer, String key)
|
protected S3Object validateObject(String sourceContainer, String key) throws InterruptedException,
|
||||||
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
ExecutionException, TimeoutException, IOException {
|
||||||
assertConsistencyAwareContainerSize(sourceContainer, 1);
|
assertConsistencyAwareContainerSize(sourceContainer, 1);
|
||||||
S3Object newObject = getApi().getObject(sourceContainer, key);
|
S3Object newObject = getApi().getObject(sourceContainer, key);
|
||||||
assert newObject != null;
|
assert newObject != null;
|
||||||
|
@ -298,7 +293,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
S3Object newObject = validateObject(containerName, key);
|
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(),
|
assertEquals(newObject.getMetadata().getContentMetadata().getContentDisposition(),
|
||||||
"attachment; filename=hello.txt");
|
"attachment; filename=hello.txt");
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -342,16 +338,15 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String addToContainerAndValidate(String containerName, String sourceKey)
|
protected String addToContainerAndValidate(String containerName, String sourceKey) throws InterruptedException,
|
||||||
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
ExecutionException, TimeoutException, IOException {
|
||||||
String etag = addBlobToContainer(containerName, sourceKey);
|
String etag = addBlobToContainer(containerName, sourceKey);
|
||||||
validateContent(containerName, sourceKey);
|
validateContent(containerName, sourceKey);
|
||||||
return etag;
|
return etag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fails on linux and windows
|
// TODO: fails on linux and windows
|
||||||
public void testCopyIfModifiedSince() throws InterruptedException, ExecutionException,
|
public void testCopyIfModifiedSince() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
TimeoutException, IOException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
String destinationContainer = getContainerName();
|
String destinationContainer = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
@ -359,13 +354,13 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
addToContainerAndValidate(containerName, sourceKey + "mod");
|
addToContainerAndValidate(containerName, sourceKey + "mod");
|
||||||
Date after = new Date(System.currentTimeMillis() + 1000);
|
Date after = new Date(System.currentTimeMillis() + 1000);
|
||||||
|
|
||||||
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer,
|
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer, destinationKey,
|
||||||
destinationKey, ifSourceModifiedSince(before));
|
ifSourceModifiedSince(before));
|
||||||
validateContent(destinationContainer, destinationKey);
|
validateContent(destinationContainer, destinationKey);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer,
|
getApi().copyObject(containerName, sourceKey + "mod", destinationContainer, destinationKey,
|
||||||
destinationKey, ifSourceModifiedSince(after));
|
ifSourceModifiedSince(after));
|
||||||
} catch (HttpResponseException ex) {
|
} catch (HttpResponseException ex) {
|
||||||
assertEquals(ex.getResponse().getStatusCode(), 412);
|
assertEquals(ex.getResponse().getStatusCode(), 412);
|
||||||
}
|
}
|
||||||
|
@ -377,8 +372,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fails on linux and windows
|
// TODO: fails on linux and windows
|
||||||
public void testCopyIfUnmodifiedSince() throws InterruptedException, ExecutionException,
|
public void testCopyIfUnmodifiedSince() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
TimeoutException, IOException {
|
IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
String destinationContainer = getContainerName();
|
String destinationContainer = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
@ -391,8 +386,8 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
validateContent(destinationContainer, destinationKey);
|
validateContent(destinationContainer, destinationKey);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getApi().copyObject(containerName, sourceKey + "un", destinationContainer,
|
getApi().copyObject(containerName, sourceKey + "un", destinationContainer, destinationKey,
|
||||||
destinationKey, ifSourceModifiedSince(before));
|
ifSourceModifiedSince(before));
|
||||||
} catch (HttpResponseException ex) {
|
} catch (HttpResponseException ex) {
|
||||||
assertEquals(ex.getResponse().getStatusCode(), 412);
|
assertEquals(ex.getResponse().getStatusCode(), 412);
|
||||||
}
|
}
|
||||||
|
@ -402,8 +397,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyIfMatch() throws InterruptedException, ExecutionException, TimeoutException,
|
public void testCopyIfMatch() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
IOException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
String destinationContainer = getContainerName();
|
String destinationContainer = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
@ -425,8 +419,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyIfNoneMatch() throws IOException, InterruptedException, ExecutionException,
|
public void testCopyIfNoneMatch() throws IOException, InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
String destinationContainer = getContainerName();
|
String destinationContainer = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
@ -448,8 +441,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyWithMetadata() throws InterruptedException, ExecutionException,
|
public void testCopyWithMetadata() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
TimeoutException, IOException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
String destinationContainer = getContainerName();
|
String destinationContainer = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,17 +34,17 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
|
||||||
@Override
|
@Override
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testGetTwoRanges() {
|
public void testGetTwoRanges() {
|
||||||
// not supported in cloud files
|
// not supported in swift
|
||||||
}
|
}
|
||||||
|
|
||||||
// not supported
|
// not supported in swift
|
||||||
@Override
|
@Override
|
||||||
protected void checkContentDisposition(Blob blob, String contentDisposition) {
|
protected void checkContentDisposition(Blob blob, String contentDisposition) {
|
||||||
assert blob.getPayload().getContentMetadata().getContentDisposition() == null;
|
assert blob.getPayload().getContentMetadata().getContentDisposition() == null;
|
||||||
assert blob.getMetadata().getContentMetadata().getContentDisposition() == null;
|
assert blob.getMetadata().getContentMetadata().getContentDisposition() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not supported
|
// not supported in swift
|
||||||
@Override
|
@Override
|
||||||
protected void checkContentLanguage(Blob blob, String contentLanguage) {
|
protected void checkContentLanguage(Blob blob, String contentLanguage) {
|
||||||
assert blob.getPayload().getContentMetadata().getContentLanguage() == null;
|
assert blob.getPayload().getContentMetadata().getContentLanguage() == null;
|
||||||
|
|
|
@ -106,10 +106,13 @@
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<category name="jclouds.wire">
|
<!--
|
||||||
<priority value="DEBUG" />
|
NOTE!! enabling this logger will cause the following test to
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
fail BaseBlobIntegrationTest.testPutObjectStream <category
|
||||||
</category>
|
name="jclouds.wire"> <priority value="DEBUG" /> <appender-ref
|
||||||
|
ref="ASYNCWIRE" /> </category>
|
||||||
|
-->
|
||||||
|
|
||||||
<category name="jclouds.blobstore">
|
<category name="jclouds.blobstore">
|
||||||
<priority value="DEBUG" />
|
<priority value="DEBUG" />
|
||||||
<appender-ref ref="ASYNCBLOBSTORE" />
|
<appender-ref ref="ASYNCBLOBSTORE" />
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.jclouds.vcloud.compute.functions;
|
package org.jclouds.vcloud.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -81,7 +81,7 @@ public class ImageForVCloudExpressVAppTemplate implements Function<VCloudExpress
|
||||||
|
|
||||||
protected OperatingSystem parseOs(VCloudExpressVAppTemplate from) {
|
protected OperatingSystem parseOs(VCloudExpressVAppTemplate from) {
|
||||||
OperatingSystemBuilder builder = new OperatingSystemBuilder();
|
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.family(osFamily);
|
||||||
builder.description(from.getName());
|
builder.description(from.getName());
|
||||||
builder.is64Bit(from.getName().indexOf("64") != -1);
|
builder.is64Bit(from.getName().indexOf("64") != -1);
|
||||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.blobstore.functions;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
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.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||||
import static org.jclouds.blobstore.util.BlobStoreUtils.getNameFor;
|
import static org.jclouds.blobstore.util.BlobStoreUtils.getNameFor;
|
||||||
|
|
||||||
|
@ -53,17 +52,15 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
private final String metadataPrefix;
|
private final String metadataPrefix;
|
||||||
private final DateService dateParser;
|
private final DateService dateParser;
|
||||||
private final Provider<MutableBlobMetadata> metadataFactory;
|
private final Provider<MutableBlobMetadata> metadataFactory;
|
||||||
private final String apiVersion;
|
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseSystemAndUserMetadataFromHeaders(Provider<MutableBlobMetadata> metadataFactory, DateService dateParser,
|
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.metadataFactory = checkNotNull(metadataFactory, "metadataFactory");
|
||||||
this.dateParser = checkNotNull(dateParser, "dateParser");
|
this.dateParser = checkNotNull(dateParser, "dateParser");
|
||||||
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix");
|
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix");
|
||||||
this.apiVersion = checkNotNull(metadataPrefix, "metadataPrefix");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlobMetadata apply(HttpResponse from) {
|
public MutableBlobMetadata apply(HttpResponse from) {
|
||||||
|
@ -97,9 +94,10 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
throw new HttpException(HttpHeaders.LAST_MODIFIED + " header not present in response: "
|
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) {
|
// Walrus
|
||||||
metadata.setLastModified(dateParser.iso8601DateParse(lastModified.replace("+0000", "Z")));
|
if (lastModified.startsWith("20")) {
|
||||||
|
metadata.setLastModified(dateParser.iso8601DateParse(lastModified));
|
||||||
} else {
|
} else {
|
||||||
metadata.setLastModified(dateParser.rfc822DateParse(lastModified));
|
metadata.setLastModified(dateParser.rfc822DateParse(lastModified));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ParseSystemAndUserMetadataFromHeadersTest {
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
void setUp() {
|
void setUp() {
|
||||||
parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider, new SimpleDateFormatDateService(),
|
parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider, new SimpleDateFormatDateService(),
|
||||||
"prefix", "default");
|
"prefix");
|
||||||
parser.setName("key");
|
parser.setName("key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ public class ParseSystemAndUserMetadataFromHeadersTest {
|
||||||
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();
|
MutableBlobMetadata metadata = blobMetadataProvider.get();
|
||||||
parser.parseLastModifiedOrThrowException(from, metadata);
|
parser.parseLastModifiedOrThrowException(from, metadata);
|
||||||
assertEquals(metadata.getLastModified(),
|
assertEquals(metadata.getLastModified(), new SimpleDateFormatDateService()
|
||||||
new SimpleDateFormatDateService().rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT"));
|
.rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = HttpException.class)
|
@Test(expectedExceptions = HttpException.class)
|
||||||
|
|
|
@ -513,7 +513,6 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
.getPayload().getContentMetadata().getContentLanguage();
|
.getPayload().getContentMetadata().getContentLanguage();
|
||||||
assert blob.getMetadata().getContentMetadata().getContentLanguage().startsWith(contentLanguage) : blob
|
assert blob.getMetadata().getContentMetadata().getContentLanguage().startsWith(contentLanguage) : blob
|
||||||
.getMetadata().getContentMetadata().getContentLanguage();
|
.getMetadata().getContentMetadata().getContentLanguage();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected volatile static Crypto crypto;
|
protected volatile static Crypto crypto;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.blobstore.integration.internal;
|
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.options.ListContainerOptions.Builder.maxResults;
|
||||||
import static org.jclouds.blobstore.util.BlobStoreUtils.getContentAsStringOrNullAndClose;
|
import static org.jclouds.blobstore.util.BlobStoreUtils.getContentAsStringOrNullAndClose;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -68,8 +69,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
blobsAsString.add(getContentAsStringOrNullAndClose(blob));
|
blobsAsString.add(getContentAsStringOrNullAndClose(blob));
|
||||||
}
|
}
|
||||||
blobsAsString.removeAll(fiveStrings.values());
|
blobsAsString.removeAll(fiveStrings.values());
|
||||||
assert blobsAsString.size() == 0 : blobsAsString.size() + ": " + blobs + ": "
|
assert blobsAsString.size() == 0 : blobsAsString.size() + ": " + blobs + ": " + blobsAsString;
|
||||||
+ blobsAsString;
|
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(bucketName);
|
returnContainer(bucketName);
|
||||||
}
|
}
|
||||||
|
@ -91,8 +91,8 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertConsistencyAwareContentEquals(final Map<String, Blob> map, final String key,
|
private void assertConsistencyAwareContentEquals(final Map<String, Blob> map, final String key, final String blob)
|
||||||
final String blob) throws InterruptedException {
|
throws InterruptedException {
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Blob old = map.remove(key);
|
Blob old = map.remove(key);
|
||||||
|
@ -116,8 +116,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
Set<Entry<String, Blob>> entries = map.entrySet();
|
Set<Entry<String, Blob>> entries = map.entrySet();
|
||||||
assertEquals(entries.size(), 5);
|
assertEquals(entries.size(), 5);
|
||||||
for (Entry<String, Blob> entry : entries) {
|
for (Entry<String, Blob> entry : entries) {
|
||||||
assertEquals(fiveStrings.get(entry.getKey()), getContentAsStringOrNullAndClose(entry
|
assertEquals(fiveStrings.get(entry.getKey()), getContentAsStringOrNullAndClose(entry.getValue()));
|
||||||
.getValue()));
|
|
||||||
Blob blob = entry.getValue();
|
Blob blob = entry.getValue();
|
||||||
blob.setPayload("");
|
blob.setPayload("");
|
||||||
Payloads.calculateMD5(blob);
|
Payloads.calculateMD5(blob);
|
||||||
|
@ -155,16 +154,15 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getOneReturnsAppleAndOldValueIsNull(Map<String, Blob> map, Blob old) throws IOException,
|
void getOneReturnsAppleAndOldValueIsNull(Map<String, Blob> map, Blob old) throws IOException, InterruptedException {
|
||||||
InterruptedException {
|
|
||||||
assert old == null;
|
assert old == null;
|
||||||
assertEquals(getContentAsStringOrNullAndClose(map.get("one")), "apple");
|
assertEquals(getContentAsStringOrNullAndClose(map.get("one")), "apple");
|
||||||
assertConsistencyAwareMapSize(map, 1);
|
assertConsistencyAwareMapSize(map, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getOneReturnsBearAndOldValueIsApple(Map<String, Blob> map, Blob oldValue)
|
void getOneReturnsBearAndOldValueIsApple(Map<String, Blob> map, Blob oldValue) throws IOException,
|
||||||
throws IOException, InterruptedException {
|
InterruptedException {
|
||||||
assertEquals(getContentAsStringOrNullAndClose(map.get("one")), "bear");
|
assertEquals(getContentAsStringOrNullAndClose(checkNotNull(map.get("one"), "one")), "bear");
|
||||||
assertEquals(getContentAsStringOrNullAndClose(oldValue), "apple");
|
assertEquals(getContentAsStringOrNullAndClose(oldValue), "apple");
|
||||||
assertConsistencyAwareMapSize(map, 1);
|
assertConsistencyAwareMapSize(map, 1);
|
||||||
}
|
}
|
||||||
|
@ -210,8 +208,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException,
|
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
if (maxResultsForTestListings() == 0)
|
if (maxResultsForTestListings() == 0)
|
||||||
return;
|
return;
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.blobstore.integration.internal;
|
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.options.ListContainerOptions.Builder.maxResults;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -65,16 +66,14 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
valuesAsString.add(Strings2.toStringAndClose(stream));
|
valuesAsString.add(Strings2.toStringAndClose(stream));
|
||||||
}
|
}
|
||||||
valuesAsString.removeAll(fiveStrings.values());
|
valuesAsString.removeAll(fiveStrings.values());
|
||||||
assert valuesAsString.size() == 0 : valuesAsString.size() + ": " + values + ": "
|
assert valuesAsString.size() == 0 : valuesAsString.size() + ": " + values + ": " + valuesAsString;
|
||||||
+ valuesAsString;
|
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException,
|
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
InputStreamMap map = createMap(context, containerName);
|
InputStreamMap map = createMap(context, containerName);
|
||||||
|
@ -134,8 +133,8 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
entry.setValue(Strings2.toInputStream(""));
|
entry.setValue(Strings2.toInputStream(""));
|
||||||
}
|
}
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
for (InputStream value : map.values()) {
|
for (Entry<String, InputStream> entry : map.entrySet()) {
|
||||||
assertEquals(Strings2.toStringAndClose(value), "");
|
assertEquals(Strings2.toStringAndClose(checkNotNull(entry.getValue(), entry.getKey())), "");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
|
@ -143,8 +142,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testContainsStringValue() throws InterruptedException, ExecutionException,
|
public void testContainsStringValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(context, containerName);
|
Map<String, InputStream> map = createMap(context, containerName);
|
||||||
|
@ -156,8 +154,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testContainsFileValue() throws InterruptedException, ExecutionException,
|
public void testContainsFileValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(context, containerName);
|
Map<String, InputStream> map = createMap(context, containerName);
|
||||||
|
@ -169,8 +166,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testContainsInputStreamValue() throws InterruptedException, ExecutionException,
|
public void testContainsInputStreamValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(context, containerName);
|
Map<String, InputStream> map = createMap(context, containerName);
|
||||||
|
@ -182,8 +178,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testContainsBytesValue() throws InterruptedException, ExecutionException,
|
public void testContainsBytesValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
TimeoutException {
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(context, containerName);
|
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)
|
void getOneReturnsAppleAndOldValueIsNull(Map<String, InputStream> map, InputStream old) throws IOException,
|
||||||
throws IOException, InterruptedException {
|
InterruptedException {
|
||||||
assert old == null;
|
assert old == null;
|
||||||
assertEquals(Strings2.toStringAndClose(map.get("one")), String
|
assertEquals(Strings2.toStringAndClose(map.get("one")), String.format(XML_STRING_FORMAT, "apple"));
|
||||||
.format(XML_STRING_FORMAT, "apple"));
|
|
||||||
assertConsistencyAwareMapSize(map, 1);
|
assertConsistencyAwareMapSize(map, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getOneReturnsBearAndOldValueIsApple(Map<String, InputStream> map, InputStream oldValue)
|
void getOneReturnsBearAndOldValueIsApple(Map<String, InputStream> map, InputStream oldValue) throws IOException,
|
||||||
throws IOException, InterruptedException {
|
InterruptedException {
|
||||||
assertEquals(Strings2.toStringAndClose(map.get("one")), String.format(XML_STRING_FORMAT, "bear"));
|
assertEquals(Strings2.toStringAndClose(map.get("one")), String.format(XML_STRING_FORMAT, "bear"));
|
||||||
assertEquals(Strings2.toStringAndClose(oldValue), String.format(XML_STRING_FORMAT, "apple"));
|
assertEquals(Strings2.toStringAndClose(oldValue), String.format(XML_STRING_FORMAT, "apple"));
|
||||||
assertConsistencyAwareMapSize(map, 1);
|
assertConsistencyAwareMapSize(map, 1);
|
||||||
|
@ -330,8 +324,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putStringWithMD5(Map<String, InputStream> map, String key, String value)
|
protected void putStringWithMD5(Map<String, InputStream> map, String key, String value) throws InterruptedException {
|
||||||
throws InterruptedException {
|
|
||||||
((InputStreamMap) map).putString(key, value);
|
((InputStreamMap) map).putString(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +336,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
return createMap(context, bucket, maxResults(maxResultsForTestListings()));
|
return createMap(context, bucket, maxResults(maxResultsForTestListings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InputStreamMap createMap(BlobStoreContext context, String bucket,
|
protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) {
|
||||||
ListContainerOptions options) {
|
|
||||||
return context.createInputStreamMap(bucket, options);
|
return context.createInputStreamMap(bucket, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import static org.testng.Assert.assertNotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -41,7 +40,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.http.HttpResponseException;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
@ -83,13 +81,6 @@ import com.google.inject.Module;
|
||||||
|
|
||||||
public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTest {
|
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 expectedOs = "Ubuntu Linux (64-bit)";
|
||||||
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
|
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
|
||||||
|
|
||||||
|
@ -149,7 +140,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
prepare();
|
prepare();
|
||||||
StringBuffer name = new StringBuffer();
|
StringBuffer name = new StringBuffer();
|
||||||
for (int i = 0; i < 15; i++)
|
for (int i = 0; i < 15; i++)
|
||||||
name.append("a");
|
name.append("c");
|
||||||
String serverName = name.toString();// "adriantest";
|
String serverName = name.toString();// "adriantest";
|
||||||
|
|
||||||
long hardDisk = 4194304;
|
long hardDisk = 4194304;
|
||||||
|
@ -166,6 +157,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
|
|
||||||
TerremarkCatalogItem item = tmClient.findCatalogItemInOrgCatalogNamed(null, null, itemName);
|
TerremarkCatalogItem item = tmClient.findCatalogItemInOrgCatalogNamed(null, null, itemName);
|
||||||
|
|
||||||
|
assert item != null;
|
||||||
|
|
||||||
// if this template supports setting the root password, let's add it to
|
// if this template supports setting the root password, let's add it to
|
||||||
// our options
|
// our options
|
||||||
CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions()
|
CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions()
|
||||||
|
@ -175,6 +168,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
|
|
||||||
VCloudExpressVAppTemplate vAppTemplate = tmClient.getVAppTemplate(item.getEntity().getHref());
|
VCloudExpressVAppTemplate vAppTemplate = tmClient.getVAppTemplate(item.getEntity().getHref());
|
||||||
|
|
||||||
|
assert vAppTemplate != null;
|
||||||
|
|
||||||
// instantiate, noting vApp returned has minimal details
|
// instantiate, noting vApp returned has minimal details
|
||||||
vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
|
vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
|
||||||
instantiateOptions);
|
instantiateOptions);
|
||||||
|
@ -196,8 +191,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
tmClient.cancelTask(deployTask.getHref());
|
tmClient.cancelTask(deployTask.getHref());
|
||||||
} catch (HttpResponseException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert successTester.apply(deployTask.getHref());
|
assert successTester.apply(deployTask.getHref());
|
||||||
|
@ -302,14 +296,14 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
tmClient.undeployVApp(vApp.getHref());
|
tmClient.undeployVApp(vApp.getHref());
|
||||||
} catch (HttpResponseException e) {
|
assert false;
|
||||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
tmClient.suspendVApp(vApp.getHref());
|
tmClient.suspendVApp(vApp.getHref());
|
||||||
} catch (HttpResponseException e) {
|
assert false;
|
||||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert successTester.apply(tmClient.resetVApp(vApp.getHref()).getHref());
|
assert successTester.apply(tmClient.resetVApp(vApp.getHref()).getHref());
|
||||||
|
|
|
@ -65,13 +65,23 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
|
||||||
org = defaultOrg;
|
org = defaultOrg;
|
||||||
if (catalog == null)
|
if (catalog == null)
|
||||||
catalog = defaultCatalog;
|
catalog = defaultCatalog;
|
||||||
try {
|
Map<String, Map<String, Map<String, ? extends CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
|
||||||
Map<String, Map<String, ? extends CatalogItem>> catalogs = checkNotNull(orgCatalogItemMap.get().get(org));
|
|
||||||
return catalogs.get(catalog).get(catalogItem).getEntity().getHref();
|
if (!orgCatalogItemMap.containsKey(org))
|
||||||
} catch (NullPointerException e) {
|
throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet());
|
||||||
throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in "
|
Map<String, Map<String, ? extends CatalogItem>> catalogs = orgCatalogItemMap.get(org);
|
||||||
+ orgCatalogItemMap.get());
|
|
||||||
}
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,7 +20,8 @@
|
||||||
(:require
|
(:require
|
||||||
[clojure.contrib.logging :as logging])
|
[clojure.contrib.logging :as logging])
|
||||||
(:import
|
(:import
|
||||||
[org.jclouds.ssh SshClient ExecResponse]
|
org.jclouds.ssh.SshClient
|
||||||
|
org.jclouds.compute.domain.ExecResponse
|
||||||
com.google.inject.Module
|
com.google.inject.Module
|
||||||
com.google.common.collect.ImmutableSet
|
com.google.common.collect.ImmutableSet
|
||||||
org.jclouds.domain.Credentials
|
org.jclouds.domain.Credentials
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
@ -34,7 +35,6 @@ import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
|
@ -26,10 +26,10 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,10 +21,10 @@ package org.jclouds.compute.callables;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Collections;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
@ -34,7 +35,6 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.scriptbuilder.InitBuilder;
|
import org.jclouds.scriptbuilder.InitBuilder;
|
||||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
|
@ -24,11 +24,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
|
import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
|
@ -25,13 +25,13 @@ import static com.google.common.base.Preconditions.checkState;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.scriptbuilder.domain.OsFamily;
|
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.ssh;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.jclouds.compute.RunScriptOnNodesException;
|
||||||
import org.jclouds.compute.callables.RunScriptOnNode;
|
import org.jclouds.compute.callables.RunScriptOnNode;
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
@ -85,7 +86,6 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.scriptbuilder.domain.Statements;
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
|
@ -22,8 +22,8 @@ package org.jclouds.compute.predicates;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.compute.callables.RunScriptOnNode;
|
import org.jclouds.compute.callables.RunScriptOnNode;
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.predicates.RetryIfSocketNotYetOpen;
|
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.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
|
@ -30,10 +30,10 @@ import javax.annotation.Resource;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.compute.callables.RunScriptOnNode;
|
import org.jclouds.compute.callables.RunScriptOnNode;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.inject.assistedinject.AssistedInject;
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class ComputeServiceUtils {
|
||||||
return total;
|
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;
|
org.jclouds.compute.domain.OsFamily myOs = null;
|
||||||
for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
|
for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
|
||||||
if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
|
if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
|
||||||
|
@ -142,7 +142,7 @@ public class ComputeServiceUtils {
|
||||||
if (myOs == null && provider.indexOf("nebula") != -1) {
|
if (myOs == null && provider.indexOf("nebula") != -1) {
|
||||||
myOs = OsFamily.UBUNTU;
|
myOs = OsFamily.UBUNTU;
|
||||||
}
|
}
|
||||||
return myOs;
|
return OsFamily.UNRECOGNIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createExecutionErrorMessage(Map<?, Exception> executionExceptions) {
|
public static String createExecutionErrorMessage(Map<?, Exception> executionExceptions) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.jclouds.ssh;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
[clojure.contrib.logging :as logging]
|
[clojure.contrib.logging :as logging]
|
||||||
[org.jclouds.modules :as modules])
|
[org.jclouds.modules :as modules])
|
||||||
(:import
|
(:import
|
||||||
[org.jclouds.ssh SshClient ExecResponse]
|
org.jclouds.ssh.SshClient
|
||||||
|
org.jclouds.compute.domain.ExecResponse
|
||||||
org.jclouds.io.Payload
|
org.jclouds.io.Payload
|
||||||
org.jclouds.net.IPSocket))
|
org.jclouds.net.IPSocket))
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
@ -78,7 +79,6 @@ import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.scriptbuilder.domain.Statements;
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
|
@ -239,8 +239,8 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
||||||
runningWithTag(tag), Statements.exec("echo hello"), overrideCredentialsWith(good).wrapInInitScript(false))
|
runningWithTag(tag), Statements.exec("echo hello"),
|
||||||
.entrySet())
|
overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet())
|
||||||
assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": "
|
assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": "
|
||||||
+ response.getValue();
|
+ response.getValue();
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.easymock.IArgumentMatcher;
|
import org.easymock.IArgumentMatcher;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
|
@ -43,7 +44,6 @@ import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
|
@ -62,7 +62,7 @@ aws-s3.propertiesbuilder=org.jclouds.aws.s3.AWSS3PropertiesBuilder
|
||||||
ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
||||||
ec2.propertiesbuilder=org.jclouds.ec2.EC2PropertiesBuilder
|
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
|
aws-ec2.propertiesbuilder=org.jclouds.aws.ec2.AWSEC2PropertiesBuilder
|
||||||
|
|
||||||
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
|
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
|
||||||
|
@ -95,8 +95,8 @@ vcloudexpress.propertiesbuilder=org.jclouds.vcloud.VCloudExpressPropertiesBuilde
|
||||||
eucalyptus.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
eucalyptus.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
||||||
eucalyptus.propertiesbuilder=org.jclouds.eucalyptus.EucalyptusPropertiesBuilder
|
eucalyptus.propertiesbuilder=org.jclouds.eucalyptus.EucalyptusPropertiesBuilder
|
||||||
|
|
||||||
eucalyptus-partnercloud-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
eucalyptus-partnercloud-ec2.contextbuilder=org.jclouds.epc.EucalyptusPartnerCloudContextBuilder
|
||||||
eucalyptus-partnercloud-ec2.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudEucalyptusPropertiesBuilder
|
eucalyptus-partnercloud-ec2.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudPropertiesBuilder
|
||||||
|
|
||||||
nova-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
nova-ec2.contextbuilder=org.jclouds.ec2.EC2ContextBuilder
|
||||||
nova-ec2.propertiesbuilder=org.jclouds.nova.ec2.NovaEC2PropertiesBuilder
|
nova-ec2.propertiesbuilder=org.jclouds.nova.ec2.NovaEC2PropertiesBuilder
|
||||||
|
|
|
@ -40,12 +40,12 @@ import javax.inject.Named;
|
||||||
|
|
||||||
import org.apache.commons.io.input.ProxyInputStream;
|
import org.apache.commons.io.input.ProxyInputStream;
|
||||||
import org.apache.commons.io.output.ByteArrayOutputStream;
|
import org.apache.commons.io.output.ByteArrayOutputStream;
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.io.Payloads;
|
import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
|
@ -26,11 +26,11 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.io.Payloads;
|
import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.ssh.ExecResponse;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.jclouds.azureblob.handlers;
|
package org.jclouds.azureblob.handlers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -31,6 +33,10 @@ import org.jclouds.http.HttpCommand;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
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
|
* @author Adrian Cole
|
||||||
*
|
*
|
||||||
|
@ -43,18 +49,24 @@ public class ParseAzureBlobErrorFromXmlContent extends ParseAzureStorageErrorFro
|
||||||
super(utils);
|
super(utils);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception, AzureStorageError error,
|
protected Exception refineException(HttpCommand command, HttpResponse response, Exception exception,
|
||||||
String message) {
|
AzureStorageError error, String message) {
|
||||||
switch (response.getStatusCode()) {
|
switch (response.getStatusCode()) {
|
||||||
case 404:
|
case 404:
|
||||||
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
|
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
|
||||||
exception = new ResourceNotFoundException(message, exception);
|
exception = new ResourceNotFoundException(message, exception);
|
||||||
String container = command.getCurrentRequest().getEndpoint().getHost();
|
List<String> parts = Lists.newArrayList(Splitter.on('/').split(
|
||||||
String key = command.getCurrentRequest().getEndpoint().getPath();
|
command.getCurrentRequest().getEndpoint().getPath()));
|
||||||
if (key == null || key.equals("/"))
|
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);
|
exception = new ContainerNotFoundException(container, message);
|
||||||
else
|
} else {
|
||||||
exception = new KeyNotFoundException(container, key, message);
|
exception = new KeyNotFoundException(container, Joiner.on('/').join(parts), message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return exception;
|
return exception;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +29,11 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "CloudFilesUKClientLiveTest")
|
@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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKBlobIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKBlobIntegrationLiveTest")
|
||||||
public class CloudFilesUKBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
|
public class CloudFilesUKBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKBlobLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKBlobLiveTest")
|
||||||
public class CloudFilesUKBlobLiveTest extends SwiftBlobLiveTest {
|
public class CloudFilesUKBlobLiveTest extends CloudFilesBlobLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKBlobMapIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKBlobMapIntegrationLiveTest")
|
||||||
public class CloudFilesUKBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
|
public class CloudFilesUKBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,6 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKBlobSignerLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKBlobSignerLiveTest")
|
||||||
public class CloudFilesUKBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
|
public class CloudFilesUKBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKContainerIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKContainerIntegrationLiveTest")
|
||||||
public class CloudFilesUKContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
|
public class CloudFilesUKContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKContainerLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKContainerLiveTest")
|
||||||
public class CloudFilesUKContainerLiveTest extends SwiftContainerLiveTest {
|
public class CloudFilesUKContainerLiveTest extends CloudFilesContainerLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKInputStreamMapIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKInputStreamMapIntegrationLiveTest")
|
||||||
public class CloudFilesUKInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
|
public class CloudFilesUKInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUKServiceIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUKServiceIntegrationLiveTest")
|
||||||
public class CloudFilesUKServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
|
public class CloudFilesUKServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudFilesUKTestInitializer extends SwiftTestInitializer {
|
public class CloudFilesUKTestInitializer extends CloudFilesTestInitializer {
|
||||||
|
|
||||||
public CloudFilesUKTestInitializer() {
|
public CloudFilesUKTestInitializer() {
|
||||||
provider = "cloudfiles-uk";
|
provider = "cloudfiles-uk";
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSBlobIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSBlobIntegrationLiveTest")
|
||||||
public class CloudFilesUSBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
|
public class CloudFilesUSBlobIntegrationLiveTest extends CloudFilesBlobIntegrationLiveTest {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSBlobLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSBlobLiveTest")
|
||||||
public class CloudFilesUSBlobLiveTest extends SwiftBlobLiveTest {
|
public class CloudFilesUSBlobLiveTest extends CloudFilesBlobLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSBlobMapIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSBlobMapIntegrationLiveTest")
|
||||||
public class CloudFilesUSBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
|
public class CloudFilesUSBlobMapIntegrationLiveTest extends CloudFilesBlobMapIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,6 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSBlobSignerLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSBlobSignerLiveTest")
|
||||||
public class CloudFilesUSBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
|
public class CloudFilesUSBlobSignerLiveTest extends CloudFilesBlobSignerLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSContainerIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSContainerIntegrationLiveTest")
|
||||||
public class CloudFilesUSContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
|
public class CloudFilesUSContainerIntegrationLiveTest extends CloudFilesContainerIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSContainerLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSContainerLiveTest")
|
||||||
public class CloudFilesUSContainerLiveTest extends SwiftContainerLiveTest {
|
public class CloudFilesUSContainerLiveTest extends CloudFilesContainerLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSInputStreamMapIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSInputStreamMapIntegrationLiveTest")
|
||||||
public class CloudFilesUSInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
|
public class CloudFilesUSInputStreamMapIntegrationLiveTest extends CloudFilesInputStreamMapIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudFilesUSServiceIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudFilesUSServiceIntegrationLiveTest")
|
||||||
public class CloudFilesUSServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
|
public class CloudFilesUSServiceIntegrationLiveTest extends CloudFilesServiceIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudfiles.blobstore.integration;
|
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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudFilesUSTestInitializer extends SwiftTestInitializer {
|
public class CloudFilesUSTestInitializer extends CloudFilesTestInitializer {
|
||||||
|
|
||||||
public CloudFilesUSTestInitializer() {
|
public CloudFilesUSTestInitializer() {
|
||||||
provider = "cloudfiles-us";
|
provider = "cloudfiles-us";
|
||||||
|
|
|
@ -19,22 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
package org.jclouds.cloudonestorage.blobstore.integration;
|
||||||
|
|
||||||
import java.io.IOException;
|
import org.jclouds.atmos.blobstore.integration.AtmosIntegrationLiveTest;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageBlobIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageBlobIntegrationLiveTest")
|
||||||
public class CloudOneStorageBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
|
public class CloudOneStorageBlobIntegrationLiveTest extends AtmosIntegrationLiveTest {
|
||||||
|
|
||||||
@Override
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
|
||||||
public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException {
|
|
||||||
super.testPutObjectStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageBlobLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageBlobLiveTest")
|
||||||
public class CloudOneStorageBlobLiveTest extends BaseBlobLiveTest {
|
public class CloudOneStorageBlobLiveTest extends AtmosLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageBlobMapIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageBlobMapIntegrationLiveTest")
|
||||||
public class CloudOneStorageBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
|
public class CloudOneStorageBlobMapIntegrationLiveTest extends AtmosMapIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,6 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageBlobSignerLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageBlobSignerLiveTest")
|
||||||
public class CloudOneStorageBlobSignerLiveTest extends BaseBlobSignerLiveTest {
|
public class CloudOneStorageBlobSignerLiveTest extends AtmosBlobSignerLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageContainerIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageContainerIntegrationLiveTest")
|
||||||
public class CloudOneStorageContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
|
public class CloudOneStorageContainerIntegrationLiveTest extends AtmosContainerIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageContainerLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageContainerLiveTest")
|
||||||
public class CloudOneStorageContainerLiveTest extends BaseContainerLiveTest {
|
public class CloudOneStorageContainerLiveTest extends AtmosContainerLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageInputStreamMapIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageInputStreamMapIntegrationLiveTest")
|
||||||
public class CloudOneStorageInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
|
public class CloudOneStorageInputStreamMapIntegrationLiveTest extends AtmosInputStreamMapIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CloudOneStorageServiceIntegrationLiveTest")
|
@Test(groups = "live", testName = "CloudOneStorageServiceIntegrationLiveTest")
|
||||||
public class CloudOneStorageServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
|
public class CloudOneStorageServiceIntegrationLiveTest extends AtmosServiceIntegrationLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,33 +19,18 @@
|
||||||
|
|
||||||
package org.jclouds.cloudonestorage.blobstore.integration;
|
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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudOneStorageTestInitializer extends TransientBlobStoreTestInitializer {
|
public class CloudOneStorageTestInitializer extends AtmosTestInitializer {
|
||||||
|
|
||||||
public CloudOneStorageTestInitializer() {
|
public CloudOneStorageTestInitializer() {
|
||||||
provider = "cloudonestorage";
|
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,11 @@ import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
|
||||||
import org.jclouds.cloudsigma.domain.Drive;
|
import org.jclouds.cloudsigma.domain.Drive;
|
||||||
import org.jclouds.cloudsigma.domain.DriveData;
|
import org.jclouds.cloudsigma.domain.DriveData;
|
||||||
import org.jclouds.cloudsigma.domain.DriveInfo;
|
import org.jclouds.cloudsigma.domain.DriveInfo;
|
||||||
|
import org.jclouds.cloudsigma.domain.ProfileInfo;
|
||||||
import org.jclouds.cloudsigma.domain.Server;
|
import org.jclouds.cloudsigma.domain.Server;
|
||||||
import org.jclouds.cloudsigma.domain.ServerInfo;
|
import org.jclouds.cloudsigma.domain.ServerInfo;
|
||||||
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
|
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
|
||||||
|
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
|
||||||
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
|
import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
|
||||||
import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
|
import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
|
||||||
import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
|
import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
|
||||||
|
@ -101,13 +103,22 @@ public interface CloudSigmaAsyncClient {
|
||||||
ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid,
|
ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid,
|
||||||
@MapPayloadParam("name") String newName, CloneDriveOptions... options);
|
@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
|
* @see CloudSigmaClient#listDriveInfo
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/drives/info")
|
@Path("/drives/info")
|
||||||
@ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
|
@ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
|
||||||
ListenableFuture<Set<org.jclouds.cloudsigma.domain.DriveInfo>> listDriveInfo();
|
ListenableFuture<Set<DriveInfo>> listDriveInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CloudSigmaClient#getDriveInfo
|
* @see CloudSigmaClient#getDriveInfo
|
||||||
|
@ -143,8 +154,7 @@ public interface CloudSigmaAsyncClient {
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
@ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
|
@ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
|
||||||
@Path("/servers/create")
|
@Path("/servers/create")
|
||||||
ListenableFuture<ServerInfo> createServer(
|
ListenableFuture<ServerInfo> createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer);
|
||||||
@BinderParam(BindServerToPlainTextString.class) Server createServer);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CloudSigmaClient#listServerInfo
|
* @see CloudSigmaClient#listServerInfo
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.cloudsigma.domain.Drive;
|
import org.jclouds.cloudsigma.domain.Drive;
|
||||||
import org.jclouds.cloudsigma.domain.DriveData;
|
import org.jclouds.cloudsigma.domain.DriveData;
|
||||||
import org.jclouds.cloudsigma.domain.DriveInfo;
|
import org.jclouds.cloudsigma.domain.DriveInfo;
|
||||||
|
import org.jclouds.cloudsigma.domain.ProfileInfo;
|
||||||
import org.jclouds.cloudsigma.domain.Server;
|
import org.jclouds.cloudsigma.domain.Server;
|
||||||
import org.jclouds.cloudsigma.domain.ServerInfo;
|
import org.jclouds.cloudsigma.domain.ServerInfo;
|
||||||
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
||||||
|
@ -40,6 +41,14 @@ import org.jclouds.concurrent.Timeout;
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface CloudSigmaClient {
|
public interface CloudSigmaClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get profile info
|
||||||
|
*
|
||||||
|
* @return info or null, if not found
|
||||||
|
*/
|
||||||
|
ProfileInfo getProfileInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list of server uuids in your account
|
* list of server uuids in your account
|
||||||
*
|
*
|
||||||
|
|
|
@ -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 + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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
Loading…
Reference in New Issue