This commit is contained in:
Adrian Cole 2012-06-16 19:06:26 -04:00
commit 8900413995
297 changed files with 10156 additions and 2549 deletions

View File

@ -37,12 +37,10 @@
<properties>
<test.cloudservers.endpoint>https://auth.api.rackspacecloud.com</test.cloudservers.endpoint>
<test.cloudservers.api-version>1.0</test.cloudservers.api-version>
<test.cloudservers.build-version />
<test.cloudservers.build-version></test.cloudservers.build-version>
<test.cloudservers.identity>${test.rackspace.identity}</test.cloudservers.identity>
<test.cloudservers.credential>${test.rackspace.credential}</test.cloudservers.credential>
<test.cloudservers.image-id />
<test.cloudservers.image.login-user />
<test.cloudservers.image.authenticate-sudo />
<test.cloudservers.template></test.cloudservers.template>
<jclouds.osgi.export>org.jclouds.cloudservers*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -120,10 +118,8 @@
<test.cloudstack.build-version>${test.cloudstack.build-version}</test.cloudstack.build-version>
<test.cloudstack.identity>${test.cloudstack.identity}</test.cloudstack.identity>
<test.cloudstack.credential>${test.cloudstack.credential}</test.cloudstack.credential>
<test.cloudstack.image-id>${test.cloudstack.image-id}</test.cloudstack.image-id>
<test.cloudstack.image.login-user>${test.cloudstack.image.login-user}</test.cloudstack.image.login-user>
<test.cloudstack.image.authenticate-sudo>${test.cloudstack.image.authenticate-sudo}</test.cloudstack.image.authenticate-sudo>
</systemPropertyVariables>
<test.cloudstack.template>${test.cloudstack.template}</test.cloudstack.template>
</systemPropertyVariables>
</configuration>
</execution>
</executions>

View File

@ -36,13 +36,10 @@
<properties>
<test.cloudsigma.endpoint>https://api.cloudsigma.com</test.cloudsigma.endpoint>
<test.cloudsigma.api-version>1.0</test.cloudsigma.api-version>
<test.cloudsigma.build-version />
<test.cloudsigma.build-version></test.cloudsigma.build-version>
<test.cloudsigma.identity>FIXME</test.cloudsigma.identity>
<test.cloudsigma.credential>FIXME</test.cloudsigma.credential>
<test.cloudsigma.image-id>f3c7c665-cd54-4a78-8fd2-7ec2f028cf29</test.cloudsigma.image-id>
<test.cloudsigma.image.login-user />
<test.cloudsigma.image.authenticate-sudo />
<test.cloudsigma.template>imageId=f3c7c665-cd54-4a78-8fd2-7ec2f028cf29</test.cloudsigma.template>
<jclouds.osgi.export>org.jclouds.cloudsigma*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -107,9 +104,7 @@
<test.cloudsigma.build-version>${test.cloudsigma.build-version}</test.cloudsigma.build-version>
<test.cloudsigma.identity>${test.cloudsigma.identity}</test.cloudsigma.identity>
<test.cloudsigma.credential>${test.cloudsigma.credential}</test.cloudsigma.credential>
<test.cloudsigma.image-id>${test.cloudsigma.image-id}</test.cloudsigma.image-id>
<test.cloudsigma.image.login-user>${test.cloudsigma.image.login-user}</test.cloudsigma.image.login-user>
<test.cloudsigma.image.authenticate-sudo>${test.cloudsigma.image.authenticate-sudo}</test.cloudsigma.image.authenticate-sudo>
<test.cloudsigma.template>${test.cloudsigma.template}</test.cloudsigma.template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -57,7 +57,6 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.HostAndPort;
@ -84,6 +83,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
protected Predicate<HostAndPort> socketTester;
protected Predicate<DriveInfo> driveNotClaimed;
protected String imageId;
@BeforeGroups(groups = { "integration", "live" })
@Override
@ -97,7 +97,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
socketTester = new RetryablePredicate<HostAndPort>(new InetSocketAddressConnect(), maxDriveImageTime, 1,
TimeUnit.SECONDS);
if (Strings.emptyToNull(imageId) == null) {
if (template == null || template.getImageId() == null) {
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
}
}

View File

@ -49,18 +49,15 @@
<properties>
<test.cloudstack.endpoint>http://localhost:8080/client/api</test.cloudstack.endpoint>
<test.cloudstack.api-version>2.2.12</test.cloudstack.api-version>
<test.cloudstack.build-version />
<test.cloudstack.api-version>3.0.3</test.cloudstack.api-version>
<test.cloudstack.build-version></test.cloudstack.build-version>
<test.cloudstack.identity>FIXME_apiKey</test.cloudstack.identity>
<test.cloudstack.credential>FIXME_secretKey</test.cloudstack.credential>
<test.cloudstack.domainAdminIdentity />
<test.cloudstack.domainAdminCredential />
<test.cloudstack.globalAdminIdentity />
<test.cloudstack.globalAdminCredential />
<test.cloudstack.image-id />
<test.cloudstack.image.login-user />
<test.cloudstack.image.authenticate-sudo />
<test.cloudstack.domainAdminIdentity></test.cloudstack.domainAdminIdentity>
<test.cloudstack.domainAdminCredential></test.cloudstack.domainAdminCredential>
<test.cloudstack.globalAdminIdentity></test.cloudstack.globalAdminIdentity>
<test.cloudstack.globalAdminCredential></test.cloudstack.globalAdminCredential>
<test.cloudstack.template></test.cloudstack.template>
<jclouds.osgi.export>org.jclouds.cloudstack*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -137,9 +134,7 @@
<test.cloudstack.build-version>${test.cloudstack.build-version}</test.cloudstack.build-version>
<test.cloudstack.identity>${test.cloudstack.identity}</test.cloudstack.identity>
<test.cloudstack.credential>${test.cloudstack.credential}</test.cloudstack.credential>
<test.cloudstack.image-id>${test.cloudstack.image-id}</test.cloudstack.image-id>
<test.cloudstack.image.login-user>${test.cloudstack.image.login-user}</test.cloudstack.image.login-user>
<test.cloudstack.image.authenticate-sudo>${test.cloudstack.image.authenticate-sudo}</test.cloudstack.image.authenticate-sudo>
<test.cloudstack.template>${test.cloudstack.template}</test.cloudstack.template>
<test.cloudstack.domainAdminIdentity>${test.cloudstack.domainAdminIdentity}</test.cloudstack.domainAdminIdentity>
<test.cloudstack.domainAdminCredential>${test.cloudstack.domainAdminCredential}</test.cloudstack.domainAdminCredential>
<test.cloudstack.globalAdminIdentity>${test.cloudstack.globalAdminIdentity}</test.cloudstack.globalAdminIdentity>

View File

@ -75,7 +75,7 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
}
}));
String defaultTemplate = (imageId != null && !"".equals(imageId)) ? imageId : null;
String defaultTemplate = template != null ? template.getImageId() : null;
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network,
defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()),

View File

@ -92,7 +92,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
public void testCreateVm() {
if (networksDisabled)
return;
String defaultTemplate = (imageId != null && !"".equals(imageId)) ? imageId : null;
String defaultTemplate = template != null ? template.getImageId() : null;
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network,
defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()),
client, jobComplete, virtualMachineRunning);

View File

@ -171,7 +171,7 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
public void testCreateVMInSecurityGroup() throws Exception {
if (!securityGroupsSupported)
return;
String defaultTemplate = (imageId != null && !"".equals(imageId)) ? imageId : null;
String defaultTemplate = template != null ? template.getImageId() : null;
vm = VirtualMachineClientLiveTest.createVirtualMachineWithSecurityGroupInZone(zone.getId(),
defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), group.getId(), client,
jobComplete, virtualMachineRunning);
@ -200,7 +200,7 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
public void testCreateVMWithoutSecurityGroupAssignsDefault() throws Exception {
if (!securityGroupsSupported)
return;
String defaultTemplate = (imageId != null && !"".equals(imageId)) ? imageId : null;
String defaultTemplate = template != null ? template.getImageId() : null;
VirtualMachine newVm = VirtualMachineClientLiveTest.createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions.NONE,
zone.getId(), defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), client,
jobComplete, virtualMachineRunning);

View File

@ -115,8 +115,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
assertNotNull(network);
// Create a VM and stop it
String templateId = (imageId != null && !"".equals(imageId)) ? imageId : null;
vmForCreation = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, templateId, client, jobComplete, virtualMachineRunning);
String defaultTemplate = template != null ? template.getImageId() : null;
vmForCreation = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, defaultTemplate, client, jobComplete, virtualMachineRunning);
assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
// Work out the VM's volume

View File

@ -181,8 +181,8 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
@Test
public void testCreateVirtualMachine() throws Exception {
String templateId = (imageId != null && !"".equals(imageId)) ? imageId : null;
vm = createVirtualMachine(client, templateId, jobComplete, virtualMachineRunning);
String defaultTemplate = template != null ? template.getImageId() : null;
vm = createVirtualMachine(client, defaultTemplate, jobComplete, virtualMachineRunning);
if (vm.getPassword() != null) {
conditionallyCheckSSH();
}
@ -195,12 +195,12 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
public void testCreateVirtualMachineWithSpecificIp() throws Exception {
skipIfNotGlobalAdmin();
String templateId = (imageId != null && !"".equals(imageId)) ? imageId : null;
String defaultTemplate = template != null ? template.getImageId() : null;
Network network = null;
try {
Template template = getOnlyElement(
client.getTemplateClient().listTemplates(ListTemplatesOptions.Builder.id(templateId)));
client.getTemplateClient().listTemplates(ListTemplatesOptions.Builder.id(defaultTemplate)));
logger.info("Using template: " + template);
Set<Network> allSafeNetworksInZone = adminClient.getNetworkClient().listNetworks(
@ -252,7 +252,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
ipsToNetworks.put(ipAddress, network.getId());
vm = createVirtualMachineInNetworkWithIp(
adminClient, templateId, ImmutableSet.of(requiredNetwork, network),
adminClient, defaultTemplate, ImmutableSet.of(requiredNetwork, network),
ipsToNetworks, adminJobComplete, adminVirtualMachineRunning);
logger.info("Created VM: " + vm);

View File

@ -64,7 +64,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
prefix += "nat";
try {
network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsStaticNAT());
String defaultTemplate = (imageId != null && !"".equals(imageId)) ? imageId : null;
String defaultTemplate = template != null ? template.getImageId() : null;
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network,
defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete,
virtualMachineRunning);

View File

@ -27,9 +27,6 @@ import java.net.URI;
import java.util.Date;
import java.util.Map;
import javax.inject.Named;
import org.jclouds.Constants;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.filters.FormSigner;
@ -111,8 +108,7 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy
}
@Override
protected String provideTimeStamp(final DateService dateService,
@Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) {
protected String provideTimeStamp(final DateService dateService) {
return "2009-11-08T15:54:08.897Z";
}
}

View File

@ -23,9 +23,6 @@ import static com.google.common.collect.Maps.transformValues;
import java.net.URI;
import java.util.Map;
import javax.inject.Named;
import org.jclouds.Constants;
import org.jclouds.aws.domain.Region;
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
import org.jclouds.date.DateService;
@ -69,8 +66,7 @@ public class BaseCloudWatchExpectTest<T> extends BaseRestClientExpectTest<T> {
}
@Override
protected String provideTimeStamp(final DateService dateService,
@Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) {
protected String provideTimeStamp(final DateService dateService) {
return "2009-11-08T15:54:08.897Z";
}
}

View File

@ -50,13 +50,10 @@
<properties>
<test.deltacloud.endpoint>http://localhost:3001/api</test.deltacloud.endpoint>
<test.deltacloud.api-version>0.3.0</test.deltacloud.api-version>
<test.deltacloud.build-version />
<test.deltacloud.build-version></test.deltacloud.build-version>
<test.deltacloud.identity>mockuser</test.deltacloud.identity>
<test.deltacloud.credential>mockpassword</test.deltacloud.credential>
<test.deltacloud.image-id />
<test.deltacloud.image.login-user />
<test.deltacloud.image.authenticate-sudo />
<test.deltacloud.template></test.deltacloud.template>
<jclouds.osgi.export>org.jclouds.deltacloud*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -120,9 +117,7 @@
<test.deltacloud.build-version>${test.deltacloud.build-version}</test.deltacloud.build-version>
<test.deltacloud.identity>${test.deltacloud.identity}</test.deltacloud.identity>
<test.deltacloud.credential>${test.deltacloud.credential}</test.deltacloud.credential>
<test.deltacloud.image-id>${test.deltacloud.image-id}</test.deltacloud.image-id>
<test.deltacloud.image.login-user>${test.deltacloud.image.login-user}</test.deltacloud.image.login-user>
<test.deltacloud.image.authenticate-sudo>${test.deltacloud.image.authenticate-sudo}</test.deltacloud.image.authenticate-sudo>
<test.deltacloud.template>${test.deltacloud.template}</test.deltacloud.template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -36,13 +36,11 @@
<properties>
<test.ec2.endpoint>https://ec2.us-east-1.amazonaws.com</test.ec2.endpoint>
<test.ec2.api-version>2010-06-15</test.ec2.api-version>
<test.ec2.build-version />
<test.ec2.build-version></test.ec2.build-version>
<test.ec2.identity>${test.aws.identity}</test.ec2.identity>
<test.ec2.credential>${test.aws.credential}</test.ec2.credential>
<test.ec2.image-id />
<test.ec2.image.login-user />
<test.ec2.image.authenticate-sudo />
<test.ec2.template></test.ec2.template>
<test.ec2.ebs-template>hardwareId=m1.small,imageId=us-west-2/ami-38c64a08</test.ec2.ebs-template>
<jclouds.osgi.export>org.jclouds.ec2*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -128,9 +126,8 @@
<test.ec2.build-version>${test.ec2.build-version}</test.ec2.build-version>
<test.ec2.identity>${test.ec2.identity}</test.ec2.identity>
<test.ec2.credential>${test.ec2.credential}</test.ec2.credential>
<test.ec2.image-id>${test.ec2.image-id}</test.ec2.image-id>
<test.ec2.image.login-user>${test.ec2.image.login-user}</test.ec2.image.login-user>
<test.ec2.image.authenticate-sudo>${test.ec2.image.authenticate-sudo}</test.ec2.image.authenticate-sudo>
<test.ec2.template>${test.ec2.template}</test.ec2.template>
<test.ec2.ebs-template>${test.ec2.ebs-template}</test.ec2.ebs-template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -32,10 +32,10 @@ import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.Image.Status;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Image.Status;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.compute.util.ComputeServiceUtils;
@ -100,7 +100,7 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
OperatingSystem.Builder osBuilder = OperatingSystem.builder();
osBuilder.is64Bit(from.getArchitecture() == Architecture.X86_64);
OsFamily family = parseOsFamilyOrUnrecognized(from.getImageLocation());
OsFamily family = parseOsFamily(from);
osBuilder.family(family);
osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, from.getImageLocation(),
osVersionMap));
@ -131,4 +131,20 @@ public class EC2ImageParser implements Function<org.jclouds.ec2.domain.Image, Im
return builder.build();
}
/**
* First treats windows as a special case: check if platform==windows.
* Then tries matching based on the image name.
* And then falls back to checking other types of platform.
*/
private OsFamily parseOsFamily(org.jclouds.ec2.domain.Image from) {
if (from.getPlatform() != null && from.getPlatform().equalsIgnoreCase("windows")) {
return OsFamily.WINDOWS;
}
OsFamily family = parseOsFamilyOrUnrecognized(from.getImageLocation());
if (family == OsFamily.UNRECOGNIZED && from.getPlatform() != null) {
family = parseOsFamilyOrUnrecognized(from.getPlatform());
}
return family;
}
}

View File

@ -40,11 +40,15 @@ import org.jclouds.ec2.services.SecurityGroupClient;
import org.jclouds.ec2.services.WindowsAsyncClient;
import org.jclouds.ec2.services.WindowsClient;
import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion;
import org.jclouds.ec2.suppliers.DescribeRegionsForConfiguredRegions;
import org.jclouds.ec2.suppliers.DescribeRegionsForRegionURIs;
import org.jclouds.location.config.LocationModule;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier;
import org.jclouds.location.suppliers.RegionIdsSupplier;
import org.jclouds.location.suppliers.ZoneIdToURISupplier;
import org.jclouds.location.suppliers.ZoneIdsSupplier;
import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet;
import org.jclouds.location.suppliers.derived.ZoneIdToURIFromJoinOnRegionIdToURI;
import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues;
import org.jclouds.rest.ConfiguresRestClient;
@ -81,13 +85,13 @@ public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient>
super(syncClientType, asyncClientType, sync2Async);
}
@Override
protected void installLocations() {
install(new LocationModule());
bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON);
bind(RegionIdToURISupplier.class).to(DescribeRegionsForConfiguredRegions.class).in(Scopes.SINGLETON);
bind(RegionIdToURISupplier.class).to(DescribeRegionsForRegionURIs.class).in(Scopes.SINGLETON);
bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON);
bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class).in(Scopes.SINGLETON);
bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromJoinOnRegionIdToURI.class).in(Scopes.SINGLETON);
}
}

View File

@ -269,9 +269,9 @@ public class RunningInstance implements Comparable<RunningInstance> {
this.dnsName = dnsName; // nullable on runinstances.
this.imageId = imageId; // nullable on runinstances.
this.instanceId = checkNotNull(instanceId, "instanceId");
this.instanceState = checkNotNull(instanceState, "instanceState");
this.rawState = checkNotNull(rawState, "rawState");
this.instanceType = checkNotNull(instanceType, "instanceType");
this.instanceState = checkNotNull(instanceState, "instanceState for %s/%s", region, instanceId);
this.rawState = checkNotNull(rawState, "rawState for %s/%s", region, instanceId);
this.instanceType = checkNotNull(instanceType, "instanceType for %s/%s", region, instanceId);
this.ipAddress = ipAddress;
this.kernelId = kernelId;
this.keyName = keyName;
@ -283,10 +283,10 @@ public class RunningInstance implements Comparable<RunningInstance> {
this.privateIpAddress = privateIpAddress;// nullable on runinstances.
this.ramdiskId = ramdiskId;
this.reason = reason;
this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType");
this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType for %s/%s", region, instanceId);
this.rootDeviceName = rootDeviceName;
this.ebsBlockDevices = ImmutableMap.copyOf(checkNotNull(ebsBlockDevices, "ebsBlockDevices"));
this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds"));
this.ebsBlockDevices = ImmutableMap.copyOf(checkNotNull(ebsBlockDevices, "ebsBlockDevices for %s/%s", region, instanceId));
this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds for %s/%s", region, instanceId));
}
/**

View File

@ -97,7 +97,7 @@ public class Volume implements Comparable<Volume> {
private String availabilityZone;
private Status status;
private Date createTime;
private Set<Attachment> attachments;
private Set<Attachment> attachments = ImmutableSet.of();
public Builder region(String region) {
this.region = region;

View File

@ -114,6 +114,7 @@ public interface InstanceAsyncClient {
@Path("/")
@FormParams(keys = ACTION, values = "TerminateInstances")
@XMLResponseParser(InstanceStateChangeHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<? extends InstanceStateChange>> terminateInstancesInRegion(
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);

View File

@ -20,7 +20,6 @@ package org.jclouds.ec2.suppliers;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -31,29 +30,23 @@ import org.jclouds.location.Region;
import org.jclouds.location.suppliers.RegionIdToURISupplier;
import org.jclouds.util.Suppliers2;
import com.google.common.base.Predicates;
import com.google.common.base.Supplier;
import com.google.common.collect.Maps;
@Singleton
public class DescribeRegionsForConfiguredRegions implements RegionIdToURISupplier {
public class DescribeRegionsForRegionURIs implements RegionIdToURISupplier {
private final AvailabilityZoneAndRegionClient client;
private final Supplier<Set<String>> regions;
@Inject
public DescribeRegionsForConfiguredRegions(EC2Client client, @Region Supplier<Set<String>> regions) {
public DescribeRegionsForRegionURIs(EC2Client client) {
this.client = client.getAvailabilityZoneAndRegionServices();
this.regions = regions;
}
@Singleton
@Region
@Override
public Map<String, Supplier<URI>> get() {
Set<String> regionWhiteList = regions.get();
Map<String, URI> regionToUris = client.describeRegions();
if (regionWhiteList.size() > 0)
regionToUris = Maps.filterKeys(regionToUris, Predicates.in(regionWhiteList));
return Maps.transformValues(regionToUris, Suppliers2.<URI> ofInstanceFunction());
}
}

View File

@ -72,7 +72,10 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
protected Builder builder;
protected int itemDepth;
boolean inInstancesSet;
protected boolean inInstancesSet;
protected boolean inProductCodes;
protected boolean inGroupSet;
// attachments
private String volumeId;
private Attachment.Status attachmentStatus;
@ -88,12 +91,17 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
private Set<RunningInstance> instances = Sets.newLinkedHashSet();
public void startElement(String uri, String name, String qName, Attributes attrs) {
if (equalsOrSuffix(qName, "item")) {
itemDepth++;
} else if (equalsOrSuffix(qName, "instancesSet")) {
inInstancesSet = true;
}
} else if (equalsOrSuffix(qName, "productCodes")) {
inProductCodes = true;
} else if (equalsOrSuffix(qName, "groupSet")) {
inGroupSet = true;
}
}
public void endElement(String uri, String name, String qName) {
@ -102,6 +110,10 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
itemDepth--;
} else if (equalsOrSuffix(qName, "instancesSet")) {
inInstancesSet = false;
} else if (equalsOrSuffix(qName, "productCodes")) {
inProductCodes = false;
} else if (equalsOrSuffix(qName, "groupSet")) {
inGroupSet = false;
} else if (equalsOrSuffix(qName, "groupId")) {
groupIds.add(currentOrNull(currentText));
} else if (equalsOrSuffix(qName, "ownerId")) {
@ -219,7 +231,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
}
protected boolean endOfInstanceItem() {
return itemDepth <= 2 && inInstancesSet;
return itemDepth <= 2 && inInstancesSet && !inProductCodes && !inGroupSet;
}
public void characters(char ch[], int start, int length) {

View File

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

View File

@ -59,8 +59,7 @@ public abstract class BaseEC2ComputeServiceExpectTest<T> extends BaseRestClientE
private static final class TestEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
@Override
@Provides
protected String provideTimeStamp(final DateService dateService,
@Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) {
protected String provideTimeStamp(DateService dateService) {
return CONSTANT_DATE;
}
}

View File

@ -29,8 +29,8 @@ import java.util.Set;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilderSpec;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.predicates.NodePredicates;
@ -41,7 +41,6 @@ import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.IpProtocol;
import org.jclouds.ec2.domain.KeyPair;
import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
@ -57,6 +56,7 @@ import org.jclouds.ec2.services.SecurityGroupClient;
import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.util.InetAddresses2;
import org.testng.SkipException;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
@ -74,6 +74,8 @@ import com.google.inject.Module;
@Test(groups = "live", singleThreaded = true)
public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
protected TemplateBuilderSpec ebsTemplate;
public EC2ComputeServiceLiveTest() {
provider = "ec2";
}
@ -227,12 +229,24 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}
}
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
String ebsSpec = setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template");
if (ebsSpec != null)
ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
return overrides;
}
/**
* Note we cannot use the micro size as it has no ephemeral space.
*/
@Test(enabled = true)
@Test
public void testMapEBS() throws Exception {
if (ebsTemplate == null) {
throw new SkipException("Test cannot run without the parameter test." + provider
+ ".ebs-template; this property should be in the format defined in TemplateBuilderSpec");
}
InstanceClient instanceClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
.getInstanceServices();
@ -242,8 +256,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
String group = this.group + "e";
int volumeSize = 8;
final Template template = view.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL)
.osFamily(OsFamily.UBUNTU).osVersionMatches("10.04").imageDescriptionMatches(".*ebs.*").build();
final Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build();
Location zone = Iterables.find(view.getComputeService().listAssignableLocations(), new Predicate<Location>() {

View File

@ -24,10 +24,10 @@ import java.util.Map;
import java.util.Set;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.Image.Status;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Image.Status;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
@ -64,24 +64,48 @@ public class EC2ImageParserTest {
assertEquals(image.getBackendStatus(), "available");
}
assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
assertImageEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem(
new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description(
"137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).description("Amazon")
.defaultCredentials(new LoginCredentials("ec2-user", false)).id("us-east-1/ami-82e4b5c7").name(
"amzn-ami-0.9.7-beta.i386-ebs").providerId("ami-82e4b5c7").location(defaultLocation)
.userMetadata(ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).status(
Status.AVAILABLE).build());
Status.AVAILABLE).backendStatus("available").build());
assertEquals(Iterables.get(result, 3), new ImageBuilder().operatingSystem(
assertImageEquals(Iterables.get(result, 3), new ImageBuilder().operatingSystem(
new OperatingSystem.Builder().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 LoginCredentials("ec2-user", false))
.id("us-east-1/ami-f2e4b5b7").providerId("ami-f2e4b5b7").name("amzn-ami-0.9.7-beta.x86_64-S3").location(
defaultLocation)
.userMetadata(ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).status(
Status.AVAILABLE).build());
Status.AVAILABLE).backendStatus("available").build());
assertImageEquals(Iterables.get(result, 4), new ImageBuilder().operatingSystem(
new OperatingSystem.Builder().family(OsFamily.WINDOWS).arch("hvm").version("2008").description(
"amazon/NameGivesNoClue_Server-2008-R2_SP1-Language_Packs-64Bit-Base-2012.05.10")
.is64Bit(true).build())
.description("Microsoft Windows Server 2008 R2 SP1 Datacenter 64-bit Multi-language AMI provided by Amazon")
.defaultCredentials(new LoginCredentials("root", false))
.id("us-east-1/ami-85457ff1").providerId("ami-85457ff1").name("NameGivesNoClue_Server-2008-R2_SP1-Language_Packs-64Bit-Base-2012.05.10")
.location(defaultLocation)
.userMetadata(ImmutableMap.of("owner", "801119661308", "rootDeviceType", "ebs"))
.status(Status.AVAILABLE).backendStatus("available").build());
}
private void assertImageEquals(org.jclouds.compute.domain.Image actual, org.jclouds.compute.domain.Image expected) {
// Note that ImageImpl.equals does not compare operating system etc; there's an explicit comment:
// equals from super is sufficient to establish identity equivalence
assertEquals(actual, expected);
assertEquals(actual.getOperatingSystem(), expected.getOperatingSystem());
assertEquals(actual.getStatus(), expected.getStatus());
assertEquals(actual.getBackendStatus(), expected.getBackendStatus());
assertEquals(actual.getVersion(), expected.getVersion());
assertEquals(actual.getDescription(), expected.getDescription());
assertEquals(actual.getDefaultCredentials(), expected.getDefaultCredentials());
}
static Location defaultLocation = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description(
"us-east-1").build();

View File

@ -0,0 +1,143 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.ec2.config;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.jclouds.ec2.internal.BaseEC2ExpectTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.location.Region;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "EC2RestClientModuleExpectTest")
public class EC2RestClientModuleExpectTest extends BaseEC2ExpectTest<Injector> {
private Injector injector;
public EC2RestClientModuleExpectTest() {
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder();
builder.put(describeRegionsRequest, describeRegionsResponse);
builder.putAll(describeAvailabilityZonesRequestResponse);
injector = requestsSendResponses(builder.build());
}
public void testLocationIdAndURIBindings() {
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
}, Region.class)).get(), ImmutableSet.<String> of("sa-east-1", "ap-northeast-1", "eu-west-1", "us-east-1",
"us-west-1", "us-west-2", "ap-southeast-1"));
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
}, Zone.class)).get(), ImmutableSet.<String> of("sa-east-1a", "sa-east-1b", "ap-northeast-1a", "ap-northeast-1b",
"eu-west-1a", "eu-west-1b", "eu-west-1c", "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d",
"us-east-1e", "us-west-1a", "us-west-1b", "us-west-1c", "us-west-2a", "us-west-2b", "us-west-2c",
"ap-southeast-1a", "ap-southeast-1b"));
Map<String, Supplier<URI>> regionToURISupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
}, Region.class)).get();
assertEquals(regionToURISupplier.get("sa-east-1").get(), URI.create("https://ec2.sa-east-1.amazonaws.com"));
assertEquals(regionToURISupplier.get("ap-northeast-1").get(),
URI.create("https://ec2.ap-northeast-1.amazonaws.com"));
assertEquals(regionToURISupplier.get("eu-west-1").get(), URI.create("https://ec2.eu-west-1.amazonaws.com"));
assertEquals(regionToURISupplier.get("us-east-1").get(), URI.create("https://ec2.us-east-1.amazonaws.com"));
assertEquals(regionToURISupplier.get("us-west-1").get(), URI.create("https://ec2.us-west-1.amazonaws.com"));
assertEquals(regionToURISupplier.get("us-west-2").get(), URI.create("https://ec2.us-west-2.amazonaws.com"));
assertEquals(regionToURISupplier.get("ap-southeast-1").get(),
URI.create("https://ec2.ap-southeast-1.amazonaws.com"));
Map<String, Supplier<Set<String>>> regionToZoneIdSupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<Set<String>>>>>() {
}, Zone.class)).get();
assertEquals(regionToZoneIdSupplier.get("sa-east-1").get(), ImmutableSet.of("sa-east-1a", "sa-east-1b"));
assertEquals(regionToZoneIdSupplier.get("ap-northeast-1").get(),
ImmutableSet.of("ap-northeast-1a", "ap-northeast-1b"));
assertEquals(regionToZoneIdSupplier.get("eu-west-1").get(),
ImmutableSet.of("eu-west-1a", "eu-west-1b", "eu-west-1c"));
assertEquals(regionToZoneIdSupplier.get("us-east-1").get(),
ImmutableSet.of("us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e"));
assertEquals(regionToZoneIdSupplier.get("us-west-1").get(),
ImmutableSet.of("us-west-1a", "us-west-1b", "us-west-1c"));
assertEquals(regionToZoneIdSupplier.get("us-west-2").get(),
ImmutableSet.of("us-west-2a", "us-west-2b", "us-west-2c"));
assertEquals(regionToZoneIdSupplier.get("ap-southeast-1").get(),
ImmutableSet.of("ap-southeast-1a", "ap-southeast-1b"));
Map<String, Supplier<URI>> zoneToURISupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
}, Zone.class)).get();
assertEquals(zoneToURISupplier.get("sa-east-1a").get(), URI.create("https://ec2.sa-east-1.amazonaws.com"));
assertEquals(zoneToURISupplier.get("ap-northeast-1a").get(),
URI.create("https://ec2.ap-northeast-1.amazonaws.com"));
assertEquals(zoneToURISupplier.get("eu-west-1a").get(), URI.create("https://ec2.eu-west-1.amazonaws.com"));
assertEquals(zoneToURISupplier.get("us-east-1a").get(), URI.create("https://ec2.us-east-1.amazonaws.com"));
assertEquals(zoneToURISupplier.get("us-west-1a").get(), URI.create("https://ec2.us-west-1.amazonaws.com"));
assertEquals(zoneToURISupplier.get("us-west-2a").get(), URI.create("https://ec2.us-west-2.amazonaws.com"));
assertEquals(zoneToURISupplier.get("ap-southeast-1a").get(),
URI.create("https://ec2.ap-southeast-1.amazonaws.com"));
}
public void testZoneToEndpoint() {
assertEquals(injector.getInstance(ZoneToEndpoint.class).apply("us-west-2a"),
URI.create("https://ec2.us-west-2.amazonaws.com"));
}
public void testRegionToEndpointOrProviderIfNull() {
assertEquals(injector.getInstance(RegionToEndpointOrProviderIfNull.class).apply("us-west-2"),
URI.create("https://ec2.us-west-2.amazonaws.com"));
}
@Override
public Injector createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props);
}
}

View File

@ -0,0 +1,99 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.ec2.internal;
import java.net.URI;
import java.util.Map;
import javax.ws.rs.core.MediaType;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.config.EC2RestClientModule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
import com.google.inject.Provides;
public abstract class BaseEC2ExpectTest<T> extends BaseRestClientExpectTest<T> {
protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z";
protected DateService dateService = new SimpleDateFormatDateService();
protected HttpRequest describeRegionsRequest = HttpRequest
.builder()
.method("POST")
.endpoint(URI.create("https://ec2.us-east-1.amazonaws.com/"))
.headers(ImmutableMultimap.of("Host", "ec2.us-east-1.amazonaws.com"))
.payload(payloadFromStringWithContentType(
"Action=DescribeRegions&Signature=s5OXKqaaeKhJW5FVrRntuMsUL4Ed5fjzgUWeukU96ko%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
MediaType.APPLICATION_FORM_URLENCODED)).build();
protected HttpResponse describeRegionsResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/regionEndpoints-all.xml", MediaType.APPLICATION_XML))
.build();
protected final Map<HttpRequest, HttpResponse> describeAvailabilityZonesRequestResponse;
public BaseEC2ExpectTest() {
provider = "ec2";
FormSigner formSigner = createInjector(Functions.forMap(ImmutableMap.<HttpRequest, HttpResponse> of()),
createModule(), setupProperties()).getInstance(FormSigner.class);
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder();
for (String region : ImmutableSet.of("ap-northeast-1", "ap-southeast-1", "eu-west-1", "sa-east-1", "us-east-1", "us-west-1", "us-west-2")){
builder.put(
formSigner.filter(HttpRequest.builder()
.method("POST")
.endpoint(URI.create("https://ec2." + region + ".amazonaws.com/"))
.headers(ImmutableMultimap.of("Host", "ec2." + region + ".amazonaws.com"))
.payload(payloadFromStringWithContentType(
"Action=DescribeAvailabilityZones&Version=2010-06-15",
MediaType.APPLICATION_FORM_URLENCODED)).build()),
HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType(
"/availabilityZones-" + region + ".xml", MediaType.APPLICATION_XML)).build());
}
describeAvailabilityZonesRequestResponse = builder.build();
}
@ConfiguresRestClient
private static final class TestEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
@Override
@Provides
protected String provideTimeStamp(DateService dateService) {
return CONSTANT_DATE;
}
}
@Override
protected Module createModule() {
return new TestEC2RestClientModule();
}
}

View File

@ -0,0 +1,186 @@
package org.jclouds.ec2.services;
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds;
import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.RunNodesException;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilderSpec;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.compute.predicates.ImagePredicates;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Image;
import org.jclouds.ec2.domain.Image.ImageType;
import org.jclouds.ec2.domain.Reservation;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.ec2.domain.Snapshot;
import org.jclouds.ec2.services.AMIClient;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
/**
* Tests behavior of {@code AMIClient}
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true)
public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest {
private TemplateBuilderSpec ebsTemplate;
public AMIClientLiveTest() {
provider = "ec2";
}
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
String ebsSpec = setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template");
if (ebsSpec != null)
ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
return overrides;
}
protected AMIClient client;
protected Set<String> imagesToDeregister = Sets.newHashSet();
protected Set<String> snapshotsToDelete = Sets.newHashSet();
protected String regionId;
protected String ebsBackedImageId;
protected String ebsBackedImageName = "jcloudstest1";
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAMIServices();
if (ebsTemplate != null) {
Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build();
regionId = template.getLocation().getId();
for (Image image : client.describeImagesInRegion(regionId)) {
if (ebsBackedImageName.equals(image.getName()))
client.deregisterImageInRegion(regionId, image.getId());
}
}
}
public void testDescribeImageNotExists() {
assertEquals(client.describeImagesInRegion(null, imageIds("ami-cdf819a3")).size(), 0);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testDescribeImageBadId() {
client.describeImagesInRegion(null, imageIds("asdaasdsa"));
}
public void testDescribeImages() {
for (String region : view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices()
.describeRegions().keySet()) {
Set<? extends Image> allResults = client.describeImagesInRegion(region);
assertNotNull(allResults);
assert allResults.size() >= 2 : allResults.size();
Iterator<? extends Image> iterator = allResults.iterator();
String id1 = iterator.next().getId();
String id2 = iterator.next().getId();
Set<? extends Image> twoResults = client.describeImagesInRegion(region, imageIds(id1, id2));
assertNotNull(twoResults);
assertEquals(twoResults.size(), 2);
iterator = twoResults.iterator();
assertEquals(iterator.next().getId(), id1);
assertEquals(iterator.next().getId(), id2);
}
}
@Test
public void testCreateAndListEBSBackedImage() throws Exception {
ComputeService computeService = view.getComputeService();
Snapshot snapshot = createSnapshot(computeService);
// List of images before...
int sizeBefore = computeService.listImages().size();
// Register a new image...
ebsBackedImageId = client.registerUnixImageBackedByEbsInRegion(regionId, ebsBackedImageName, snapshot.getId(),
addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
imagesToDeregister.add(ebsBackedImageId);
final Image ebsBackedImage = Iterables.getOnlyElement(client.describeImagesInRegion(regionId,
imageIds(ebsBackedImageId)));
assertEquals(ebsBackedImage.getName(), ebsBackedImageName);
assertEquals(ebsBackedImage.getImageType(), ImageType.MACHINE);
assertEquals(ebsBackedImage.getRootDeviceType(), RootDeviceType.EBS);
assertEquals(ebsBackedImage.getRootDeviceName(), "/dev/sda1");
assertEquals(ebsBackedImage.getDescription(), "adrian");
assertEquals(
ebsBackedImage.getEbsBlockDevices().entrySet(),
ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), snapshot.getVolumeSize(), true),
"/dev/sda2", new Image.EbsBlockDevice(null, 1, false)).entrySet());
// This is the suggested method to ensure the new image ID is inserted
// into the cache
// (suggested by adriancole_ on #jclouds)
computeService.templateBuilder().imageId(ebsBackedImage.getRegion() + "/" + ebsBackedImageId).build();
// List of images after - should be one larger than before
Set<? extends org.jclouds.compute.domain.Image> after = computeService.listImages();
assertEquals(after.size(), sizeBefore + 1);
// Detailed check: filter for the AMI ID
Iterable<? extends org.jclouds.compute.domain.Image> filtered = Iterables.filter(after,
ImagePredicates.idEquals(ebsBackedImage.getRegion() + "/" + ebsBackedImageId));
assertEquals(Iterables.size(filtered), 1);
}
// Fires up an instance, finds its root volume ID, takes a snapshot, then
// terminates the instance.
private Snapshot createSnapshot(ComputeService computeService) throws RunNodesException {
Template template = computeService.templateBuilder().from(ebsTemplate).build();
regionId = template.getLocation().getId();
Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup("jcloudstest", 1, template);
try {
String instanceId = Iterables.getOnlyElement(nodes).getProviderId();
Reservation<? extends RunningInstance> reservation = Iterables.getOnlyElement(view
.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices()
.describeInstancesInRegion(regionId, instanceId));
RunningInstance instance = Iterables.getOnlyElement(reservation);
BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1");
Snapshot snapshot = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices()
.createSnapshotInRegion(regionId, device.getVolumeId());
snapshotsToDelete.add(snapshot.getId());
return snapshot;
} finally {
computeService.destroyNodesMatching(Predicates.in(nodes));
}
}
@Test(dependsOnMethods = "testCreateAndListEBSBackedImage")
public void testGetLaunchPermissionForImage() {
System.out.println(client.getLaunchPermissionForImageInRegion(regionId, ebsBackedImageId));
}
@Override
@AfterClass(groups = { "integration", "live" })
protected void tearDownContext() {
for (String imageId : imagesToDeregister)
client.deregisterImageInRegion(regionId, imageId);
for (String snapshotId : snapshotsToDelete)
view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices()
.deleteSnapshotInRegion(regionId, snapshotId);
super.tearDownContext();
}
}

View File

@ -79,7 +79,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends BaseAsyncClientTest<T> {
}
@Override
protected String provideTimeStamp(DateService dateService, int expiration) {
protected String provideTimeStamp(DateService dateService) {
return "2009-11-08T15:54:08.897Z";
}

View File

@ -0,0 +1,71 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.ec2.services;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.domain.Volume;
import org.jclouds.ec2.internal.BaseEC2ExpectTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableMultimap;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "EC2ElasticBlockStoreClientExpectTest")
public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ExpectTest<EC2Client> {
public void testCreateVolumeInAvailabilityZone() {
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse>builder();
builder.put(describeRegionsRequest, describeRegionsResponse);
builder.putAll(describeAvailabilityZonesRequestResponse);
builder.put(
HttpRequest.builder()
.method("POST")
.endpoint(URI.create("https://ec2.us-east-1.amazonaws.com/"))
.headers(ImmutableMultimap.of("Host", "ec2.us-east-1.amazonaws.com"))
.payload(payloadFromStringWithContentType("Action=CreateVolume&AvailabilityZone=us-east-1a&Signature=FB5hTZHKSAuiygoafIdJh1EnfTu0ogC2VfRQOar85mg%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Size=4&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
HttpResponse.builder()
.statusCode(200)
.payload(payloadFromResource("/created_volume.xml")).build());
ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices();
Volume expected = Volume
.builder()
.id("vol-2a21e543")
.status(Volume.Status.CREATING)
.availabilityZone("us-east-1a")
.region("us-east-1")
.id("vol-2a21e543")
.size(1)
.createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"))
.build();
assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), expected);
}
}

View File

@ -99,7 +99,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, InstanceStateChangeHandler.class);
assertExceptionParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
checkFilters(request);
}

View File

@ -29,6 +29,7 @@ import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Reservation;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest;
@ -57,7 +58,7 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
assert dateService != null;
}
public void testApplyInputStream() {
public void testEC2() {
InputStream is = getClass().getResourceAsStream("/run_instances.xml");
@ -90,6 +91,26 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
assertEquals(result.toString(), expected.toString());
}
public void testCloudBridge() {
InputStream is = getClass().getResourceAsStream("/run_instances_cloudbridge.xml");
Reservation<? extends RunningInstance> expected = new Reservation<RunningInstance>(defaultRegion, ImmutableSet
.of("default"), ImmutableSet.of(
new RunningInstance.Builder().region(defaultRegion).groupId("jclouds#greenqloud-computeblock").amiLaunchIndex("0")
.imageId("qmi-9ac92558").instanceId("i-01b0dac3").instanceState(InstanceState.PENDING).rawState(
"pending").instanceType(InstanceType.M1_SMALL).keyName("jclouds#greenqloud-computeblock#35")
.launchTime(dateService.iso8601DateParse("2012-06-15T19:06:35.000+00:00"))
.rootDeviceType(RootDeviceType.EBS).availabilityZone("is-1a").build())
, "56eeacd9-c790-45c3-85f3-e4380b55e1d8<", null, "r-f847a6ca");
RunInstancesResponseHandler handler = injector.getInstance(RunInstancesResponseHandler.class);
addDefaultRegionToHandler(handler);
Reservation<? extends RunningInstance> result = factory.create(handler).parse(is);
assertEquals(result.toString(), expected.toString());
}
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getArgs()).andReturn(ImmutableList.<Object> of()).atLeastOnce();

View File

@ -82,5 +82,32 @@
<blockDeviceMapping/>
<virtualizationType>paravirtual</virtualizationType>
</item>
<item>
<imageId>ami-85457ff1</imageId>
<imageLocation>amazon/NameGivesNoClue_Server-2008-R2_SP1-Language_Packs-64Bit-Base-2012.05.10</imageLocation>
<imageState>available</imageState>
<imageOwnerId>801119661308</imageOwnerId>
<isPublic>true</isPublic>
<architecture>x86_64</architecture>
<imageType>machine</imageType>
<platform>windows</platform>
<imageOwnerAlias>amazon</imageOwnerAlias>
<name>NameGivesNoClue_Server-2008-R2_SP1-Language_Packs-64Bit-Base-2012.05.10</name>
<description>Microsoft Windows Server 2008 R2 SP1 Datacenter 64-bit Multi-language AMI provided by Amazon</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<snapshotId>snap-84a433ef</snapshotId>
<volumeSize>30</volumeSize>
<deleteOnTermination>true</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
<virtualizationType>hvm</virtualizationType>
<hypervisor>xen</hypervisor>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -0,0 +1,17 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>24251909-7fb6-4080-8ca3-fbb5a1ddb02d</requestId>
<availabilityZoneInfo>
<item>
<zoneName>ap-northeast-1a</zoneName>
<zoneState>available</zoneState>
<regionName>ap-northeast-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>ap-northeast-1b</zoneName>
<zoneState>available</zoneState>
<regionName>ap-northeast-1</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,17 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>22c5332d-c331-4310-b695-e21e76c3fdb0</requestId>
<availabilityZoneInfo>
<item>
<zoneName>ap-southeast-1a</zoneName>
<zoneState>available</zoneState>
<regionName>ap-southeast-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>ap-southeast-1b</zoneName>
<zoneState>available</zoneState>
<regionName>ap-southeast-1</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,23 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>386c8215-6ec8-4495-aaa6-8c4175688093</requestId>
<availabilityZoneInfo>
<item>
<zoneName>eu-west-1a</zoneName>
<zoneState>available</zoneState>
<regionName>eu-west-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>eu-west-1b</zoneName>
<zoneState>available</zoneState>
<regionName>eu-west-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>eu-west-1c</zoneName>
<zoneState>available</zoneState>
<regionName>eu-west-1</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,17 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>d2e09bd5-b2ec-4c6b-aac9-6bf1fa217cb5</requestId>
<availabilityZoneInfo>
<item>
<zoneName>sa-east-1a</zoneName>
<zoneState>available</zoneState>
<regionName>sa-east-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>sa-east-1b</zoneName>
<zoneState>available</zoneState>
<regionName>sa-east-1</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,35 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>ed825abf-edbb-4677-83d5-0fbd86ce5a5d</requestId>
<availabilityZoneInfo>
<item>
<zoneName>us-east-1a</zoneName>
<zoneState>available</zoneState>
<regionName>us-east-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-east-1b</zoneName>
<zoneState>available</zoneState>
<regionName>us-east-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-east-1c</zoneName>
<zoneState>available</zoneState>
<regionName>us-east-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-east-1d</zoneName>
<zoneState>available</zoneState>
<regionName>us-east-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-east-1e</zoneName>
<zoneState>available</zoneState>
<regionName>us-east-1</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,23 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>dbfb2a5f-ce75-49fb-846b-e2cf2fc5cdbb</requestId>
<availabilityZoneInfo>
<item>
<zoneName>us-west-1a</zoneName>
<zoneState>available</zoneState>
<regionName>us-west-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-west-1b</zoneName>
<zoneState>available</zoneState>
<regionName>us-west-1</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-west-1c</zoneName>
<zoneState>available</zoneState>
<regionName>us-west-1</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,23 @@
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>e40c2bc4-7231-4df1-a604-202bb8333332</requestId>
<availabilityZoneInfo>
<item>
<zoneName>us-west-2a</zoneName>
<zoneState>available</zoneState>
<regionName>us-west-2</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-west-2b</zoneName>
<zoneState>available</zoneState>
<regionName>us-west-2</regionName>
<messageSet/>
</item>
<item>
<zoneName>us-west-2c</zoneName>
<zoneState>available</zoneState>
<regionName>us-west-2</regionName>
<messageSet/>
</item>
</availabilityZoneInfo>
</DescribeAvailabilityZonesResponse>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>8392a998-c7bb-41fc-be15-045f528d7627</requestId>
<regionInfo>
<item>
<regionName>eu-west-1</regionName>
<regionEndpoint>ec2.eu-west-1.amazonaws.com</regionEndpoint>
</item>
<item>
<regionName>sa-east-1</regionName>
<regionEndpoint>ec2.sa-east-1.amazonaws.com</regionEndpoint>
</item>
<item>
<regionName>us-east-1</regionName>
<regionEndpoint>ec2.us-east-1.amazonaws.com</regionEndpoint>
</item>
<item>
<regionName>ap-northeast-1</regionName>
<regionEndpoint>ec2.ap-northeast-1.amazonaws.com</regionEndpoint>
</item>
<item>
<regionName>us-west-2</regionName>
<regionEndpoint>ec2.us-west-2.amazonaws.com</regionEndpoint>
</item>
<item>
<regionName>us-west-1</regionName>
<regionEndpoint>ec2.us-west-1.amazonaws.com</regionEndpoint>
</item>
<item>
<regionName>ap-southeast-1</regionName>
<regionEndpoint>ec2.ap-southeast-1.amazonaws.com</regionEndpoint>
</item>
</regionInfo>
</DescribeRegionsResponse>

View File

@ -0,0 +1,68 @@
<?xml version="1.0"?>
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
<requestId>56eeacd9-c790-45c3-85f3-e4380b55e1d8</requestId>
<reservationId>r-f847a6ca</reservationId>
<ownerId>55ed6530-9b32-48f1-acb7-6ec0d3255a65</ownerId>
<groupSet>
<item>
<groupId>jclouds#greenqloud-computeblock</groupId>
</item>
<item>
<groupId>jclouds#greenqloud-computeblock</groupId>
</item>
</groupSet>
<instancesSet>
<item>
<instanceId>i-01b0dac3</instanceId>
<imageId>qmi-9ac92558</imageId>
<instanceState>
<code>0</code>
<name>pending</name>
</instanceState>
<privateDnsName/>
<dnsName/>
<reason/>
<keyName>jclouds#greenqloud-computeblock#35</keyName>
<amiLaunchIndex>0</amiLaunchIndex>
<productCodes>
<item>
<productCode/>
</item>
</productCodes>
<instanceType>m1.small</instanceType>
<launchTime>2012-06-15T19:06:35.000+00:00</launchTime>
<placement>
<availabilityZone>is-1a</availabilityZone>
</placement>
<kernelId/>
<ramdiskId/>
<platform/>
<monitoring>
<state>disabled</state>
</monitoring>
<subnetId/>
<vpcId/>
<privateIpAddress/>
<groupSet>
<item>
<groupId>jclouds#greenqloud-computeblock</groupId>
</item>
<item>
<groupId>jclouds#greenqloud-computeblock</groupId>
</item>
</groupSet>
<stateReason>
<code>pending</code>
<message>pending</message>
</stateReason>
<architecture/>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName/>
<blockDeviceMapping/>
<instanceLifecycle/>
<spotInstanceRequestId/>
<hypervisor>xen</hypervisor>
</item>
</instancesSet>
<requesterId/>
</RunInstancesResponse>

View File

@ -50,13 +50,10 @@
<properties>
<test.elasticstack.endpoint>https://api.lon-p.elastichosts.com</test.elasticstack.endpoint>
<test.elasticstack.api-version>1.0</test.elasticstack.api-version>
<test.elasticstack.build-version />
<test.elasticstack.build-version></test.elasticstack.build-version>
<test.elasticstack.identity>FIXME</test.elasticstack.identity>
<test.elasticstack.credential>FIXME</test.elasticstack.credential>
<test.elasticstack.image-id>38df0986-4d85-4b76-b502-3878ffc80161</test.elasticstack.image-id>
<test.elasticstack.image.login-user />
<test.elasticstack.image.authenticate-sudo />
<test.elasticstack.template>imageId=38df0986-4d85-4b76-b502-3878ffc80161</test.elasticstack.template>
<jclouds.osgi.export>org.jclouds.elasticstack*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -120,9 +117,7 @@
<test.elasticstack.build-version>${test.elasticstack.build-version}</test.elasticstack.build-version>
<test.elasticstack.identity>${test.elasticstack.identity}</test.elasticstack.identity>
<test.elasticstack.credential>${test.elasticstack.credential}</test.elasticstack.credential>
<test.elasticstack.image-id>${test.elasticstack.image-id}</test.elasticstack.image-id>
<test.elasticstack.image.login-user>${test.elasticstack.image.login-user}</test.elasticstack.image.login-user>
<test.elasticstack.image.authenticate-sudo>${test.elasticstack.image.authenticate-sudo}</test.elasticstack.image.authenticate-sudo>
<test.elasticstack.template>${test.elasticstack.template}</test.elasticstack.template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -55,7 +55,6 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.HostAndPort;
@ -83,6 +82,7 @@ public class ElasticStackClientLiveTest
protected RestContext<ElasticStackClient, ElasticStackAsyncClient> cloudStackContext;
protected Predicate<HostAndPort> socketTester;
protected Predicate<DriveInfo> driveNotClaimed;
protected String imageId;
@BeforeGroups(groups = { "integration", "live" })
@Override
@ -96,7 +96,7 @@ public class ElasticStackClientLiveTest
socketTester = new RetryablePredicate<HostAndPort>(new InetSocketAddressConnect(), maxDriveImageTime, 1,
TimeUnit.SECONDS);
if (Strings.emptyToNull(imageId) == null) {
if (template == null || template.getImageId() == null) {
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
}
}

View File

@ -36,13 +36,11 @@
<properties>
<test.eucalyptus.endpoint>http://ecc.eucalyptus.com:8773/services/Eucalyptus</test.eucalyptus.endpoint>
<test.eucalyptus.api-version>2010-06-15</test.eucalyptus.api-version>
<test.eucalyptus.build-version />
<test.eucalyptus.build-version></test.eucalyptus.build-version>
<test.eucalyptus.identity>FIXME_IDENTITY</test.eucalyptus.identity>
<test.eucalyptus.credential>FIXME_CREDENTIAL</test.eucalyptus.credential>
<test.eucalyptus.image-id />
<test.eucalyptus.image.login-user />
<test.eucalyptus.image.authenticate-sudo />
<test.eucalyptus.template></test.eucalyptus.template>
<test.eucalyptus.ebs-template></test.eucalyptus.ebs-template>
<jclouds.osgi.export>org.jclouds.eucalyptus*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -115,9 +113,8 @@
<test.eucalyptus.build-version>${test.eucalyptus.build-version}</test.eucalyptus.build-version>
<test.eucalyptus.identity>${test.eucalyptus.identity}</test.eucalyptus.identity>
<test.eucalyptus.credential>${test.eucalyptus.credential}</test.eucalyptus.credential>
<test.eucalyptus.image-id>${test.eucalyptus.image-id}</test.eucalyptus.image-id>
<test.eucalyptus.image.login-user>${test.eucalyptus.image.login-user}</test.eucalyptus.image.login-user>
<test.eucalyptus.image.authenticate-sudo>${test.eucalyptus.image.authenticate-sudo}</test.eucalyptus.image.authenticate-sudo>
<test.eucalyptus.template>${test.eucalyptus.template}</test.eucalyptus.template>
<test.eucalyptus.ebs-template>${test.eucalyptus.ebs-template}</test.eucalyptus.ebs-template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -17,9 +17,7 @@
* under the License.
*/
package org.jclouds.eucalyptus;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN;
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Properties;
@ -57,8 +55,8 @@ public class EucalyptusApiMetadata extends EC2ApiMetadata {
public static Properties defaultProperties() {
Properties properties = EC2ApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_REGIONS, "Eucalyptus");
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin");
// in version 3, lowecase 'e' version 2, uppercase 'E'
properties.setProperty(PROPERTY_REGIONS, "eucalyptus");
properties.setProperty(TIMEOUT_PORT_OPEN, 5 * 60 * 1000 + "");
return properties;
}
@ -67,7 +65,7 @@ public class EucalyptusApiMetadata extends EC2ApiMetadata {
protected Builder(){
super(EC2Client.class, EC2AsyncClient.class);
id("eucalyptus")
.defaultEndpoint("http://173.205.188.130:8773/services/Eucalyptus")
.defaultEndpoint("http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/")
.name("Eucalyptus (EC2 clone) API")
.defaultProperties(EucalyptusApiMetadata.defaultProperties());
}

View File

@ -0,0 +1,106 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.eucalyptus.config;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.jclouds.eucalyptus.internal.BaseEucalyptusExpectTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.location.Region;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "EucalyptusRestClientModuleExpectTest")
public class EucalyptusRestClientModuleExpectTest extends BaseEucalyptusExpectTest<Injector> {
private Injector injector;
public EucalyptusRestClientModuleExpectTest() {
Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder();
builder.put(describeRegionsRequest, describeRegionsResponse);
builder.put(describeAZRequest, describeAZResponse);
injector = requestsSendResponses(builder.build());
}
public void testLocationIdAndURIBindings() {
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
}, Region.class)).get(), ImmutableSet.<String> of("eucalyptus"));
assertEquals(injector.getInstance(Key.get(new TypeLiteral<Supplier<Set<String>>>() {
}, Zone.class)).get(), ImmutableSet.<String> of("partner01"));
Map<String, Supplier<URI>> regionToURISupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
}, Region.class)).get();
assertEquals(regionToURISupplier.get("eucalyptus").get(), URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
Map<String, Supplier<Set<String>>> regionToZoneIdSupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<Set<String>>>>>() {
}, Zone.class)).get();
assertEquals(regionToZoneIdSupplier.get("eucalyptus").get(), ImmutableSet.of("partner01"));
Map<String, Supplier<URI>> zoneToURISupplier = injector.getInstance(
Key.get(new TypeLiteral<Supplier<Map<String, Supplier<URI>>>>() {
}, Zone.class)).get();
assertEquals(zoneToURISupplier.get("partner01").get(), URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
}
public void testZoneToEndpoint() {
assertEquals(injector.getInstance(ZoneToEndpoint.class).apply("partner01"),
URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
}
public void testRegionToEndpointOrProviderIfNull() {
assertEquals(injector.getInstance(RegionToEndpointOrProviderIfNull.class).apply("eucalyptus"),
URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus"));
}
@Override
public Injector createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props);
}
}

View File

@ -0,0 +1,91 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.eucalyptus.internal;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.config.EC2RestClientModule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
import com.google.common.collect.ImmutableMultimap;
import com.google.inject.Module;
import com.google.inject.Provides;
/**
*
* @author Adrian Cole
*/
public abstract class BaseEucalyptusExpectTest<T> extends BaseRestClientExpectTest<T> {
protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z";
protected DateService dateService = new SimpleDateFormatDateService();
protected HttpRequest describeRegionsRequest = HttpRequest
.builder()
.method("POST")
.endpoint(URI.create("http://partnercloud.eucalyptus.com:8773/services/Eucalyptus/"))
.headers(ImmutableMultimap.of("Host", "partnercloud.eucalyptus.com:8773"))
.payload(payloadFromStringWithContentType(
"Action=DescribeRegions&Signature=tp9WpT8503JdxIXYu6Eu2Dmu%2Bd%2FpqviST7N7Fvr%2FyQo%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
MediaType.APPLICATION_FORM_URLENCODED)).build();
protected HttpResponse describeRegionsResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/regionEndpoints-euca.xml", MediaType.APPLICATION_XML))
.build();
protected HttpRequest describeAZRequest = HttpRequest.builder()
.method("POST")
.endpoint(URI.create("http://eucalyptus.partner.eucalyptus.com:8773/services/Eucalyptus/"))
.headers(ImmutableMultimap.of("Host", "eucalyptus.partner.eucalyptus.com:8773"))
.payload(payloadFromStringWithContentType(
"Action=DescribeAvailabilityZones&Signature=i4OkMed1sqQV7hlF%2Fl1KdbQwmwJ4Fh4o9W32eVGayPk%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
MediaType.APPLICATION_FORM_URLENCODED)).build();
protected HttpResponse describeAZResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType(
"/availabilityZones-eucalyptus.xml", MediaType.APPLICATION_XML)).build();
public BaseEucalyptusExpectTest() {
provider = "eucalyptus";
}
@ConfiguresRestClient
private static final class TestEucalyptusRestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
@Override
@Provides
protected String provideTimeStamp(DateService dateService) {
return CONSTANT_DATE;
}
}
@Override
protected Module createModule() {
return new TestEucalyptusRestClientModule();
}
}

View File

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

View File

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

View File

@ -858,7 +858,7 @@ public class FilesystemAsyncBlobStoreTest {
// nothing expected
if (null == expectedBlobKeys || 0 == expectedBlobKeys.size()) {
assertTrue(blobsRetrieved.isEmpty(), "Wrong blob number retrieved in the containter [" + containerName + "]");
assertTrue(blobsRetrieved.isEmpty(), "Wrong blob number retrieved in the container [" + containerName + "]");
return;
}
@ -868,7 +868,7 @@ public class FilesystemAsyncBlobStoreTest {
expectedBlobKeysCopy.add(value);
}
assertEquals(blobsRetrieved.size(), expectedBlobKeysCopy.size(),
"Wrong blob number retrieved in the containter [" + containerName + "]");
"Wrong blob number retrieved in the container [" + containerName + "]");
for (StorageMetadata data : blobsRetrieved) {
String blobName = data.getName();
if (!expectedBlobKeysCopy.remove(blobName)) {

View File

@ -36,14 +36,12 @@
<properties>
<test.nova.endpoint>http://localhost:8773/services/Cloud</test.nova.endpoint>
<test.nova.api-version>1.1</test.nova.api-version>
<test.nova.build-version />
<test.nova.build-version></test.nova.build-version>
<test.nova.identity>FIXME_IDENTITY</test.nova.identity>
<test.nova.credential>FIXME_CREDENTIALS</test.nova.credential>
<test.nova.image-id />
<test.nova.image.login-user />
<test.nova.image.authenticate-sudo />
<test.ssh.keyfile.public />
<test.ssh.keyfile.private />
<test.nova.template></test.nova.template>
<test.ssh.keyfile.public></test.ssh.keyfile.public>
<test.ssh.keyfile.private></test.ssh.keyfile.private>
<jclouds.osgi.export>org.jclouds.openstack.nova*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
@ -122,9 +120,7 @@
<test.nova.build-version>${test.nova.build-version}</test.nova.build-version>
<test.nova.identity>${test.nova.identity}</test.nova.identity>
<test.nova.credential>${test.nova.credential}</test.nova.credential>
<test.nova.image-id>${test.nova.image-id}</test.nova.image-id>
<test.nova.image.login-user>${test.nova.image.login-user}</test.nova.image.login-user>
<test.nova.image.authenticate-sudo>${test.nova.image.authenticate-sudo}</test.nova.image.authenticate-sudo>
<test.nova.template>${test.nova.template}</test.nova.template>
<test.ssh.keyfile.public>${test.ssh.keyfile.public}</test.ssh.keyfile.public>
<test.ssh.keyfile.private>${test.ssh.keyfile.private}</test.ssh.keyfile.private>
</systemPropertyVariables>

View File

@ -214,7 +214,7 @@ public class NovaClientLiveTest extends BaseComputeServiceContextLiveTest {
while (server == null) {
String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
try {
server = client.createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt",
server = client.createServer(serverName, template.getImageId(), flavorId, withFile("/etc/jclouds.txt",
"nova".getBytes()).withMetadata(metadata));
} catch (UndeclaredThrowableException e) {
HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();

View File

@ -43,9 +43,7 @@
<test.openstack-keystone.credential>FIXME_CREDENTIALS</test.openstack-keystone.credential>
<test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
<jclouds.osgi.export>org.jclouds.openstack.v2_0*;version="${project.version}",
org.jclouds.openstack.keystone.v2_0*;version="${project.version}"
</jclouds.osgi.export>
<jclouds.osgi.export>org.jclouds.openstack*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.rest.internal;version="${project.version}",
org.jclouds*;version="${project.version}",

View File

@ -36,13 +36,11 @@
<properties>
<test.openstack-nova-ec2.endpoint>http://localhost:8773/services/Cloud</test.openstack-nova-ec2.endpoint>
<test.openstack-nova-ec2.api-version>2010-06-15</test.openstack-nova-ec2.api-version>
<test.openstack-nova-ec2.build-version />
<test.openstack-nova-ec2.build-version></test.openstack-nova-ec2.build-version>
<test.openstack-nova-ec2.identity>FIXME_IDENTITY</test.openstack-nova-ec2.identity>
<test.openstack-nova-ec2.credential>FIXME_CREDENTIAL</test.openstack-nova-ec2.credential>
<test.openstack-nova-ec2.image-id />
<test.openstack-nova-ec2.image.login-user />
<test.openstack-nova-ec2.image.authenticate-sudo />
<test.openstack-nova-ec2.template></test.openstack-nova-ec2.template>
<test.openstack-nova-ec2.ebs-template></test.openstack-nova-ec2.ebs-template>
<jclouds.osgi.export>org.jclouds.openstack.nova.ec2*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -120,9 +118,8 @@
<test.openstack-nova-ec2.build-version>${test.openstack-nova-ec2.build-version}</test.openstack-nova-ec2.build-version>
<test.openstack-nova-ec2.identity>${test.openstack-nova-ec2.identity}</test.openstack-nova-ec2.identity>
<test.openstack-nova-ec2.credential>${test.openstack-nova-ec2.credential}</test.openstack-nova-ec2.credential>
<test.openstack-nova-ec2.image-id>${test.openstack-nova-ec2.image-id}</test.openstack-nova-ec2.image-id>
<test.openstack-nova-ec2.image.login-user>${test.openstack-nova-ec2.image.login-user}</test.openstack-nova-ec2.image.login-user>
<test.openstack-nova-ec2.image.authenticate-sudo>${test.openstack-nova-ec2.image.authenticate-sudo}</test.openstack-nova-ec2.image.authenticate-sudo>
<test.openstack-nova-ec2.template>${test.openstack-nova-ec2.template}</test.openstack-nova-ec2.template>
<test.openstack-nova-ec2.ebs-template>${test.openstack-nova-ec2.ebs-template}</test.openstack-nova-ec2.ebs-template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -2,10 +2,8 @@ package org.jclouds.openstack.nova.ec2.internal;
import java.net.URI;
import javax.inject.Named;
import javax.ws.rs.core.MediaType;
import org.jclouds.Constants;
import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpRequest;
@ -45,8 +43,7 @@ public abstract class BaseNovaEC2RestClientExpectTest extends BaseRestClientExpe
private static final class TestNovaEC2RestClientModule extends NovaEC2RestClientModule {
@Override
@Provides
protected String provideTimeStamp(final DateService dateService,
@Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) {
protected String provideTimeStamp(DateService dateService) {
return CONSTANT_DATE;
}
}

View File

@ -38,12 +38,10 @@
<test.openstack-nova.endpoint>http://localhost:5000</test.openstack-nova.endpoint>
<!-- keystone version -->
<test.openstack-nova.api-version>1.1</test.openstack-nova.api-version>
<test.openstack-nova.build-version />
<test.openstack-nova.build-version></test.openstack-nova.build-version>
<test.openstack-nova.identity>FIXME_IDENTITY</test.openstack-nova.identity>
<test.openstack-nova.credential>FIXME_CREDENTIALS</test.openstack-nova.credential>
<test.openstack-nova.image-id />
<test.openstack-nova.image.login-user />
<test.openstack-nova.image.authenticate-sudo />
<test.openstack-nova.template></test.openstack-nova.template>
<test.jclouds.openstack-nova.auto-allocate-floating-ips>false</test.jclouds.openstack-nova.auto-allocate-floating-ips>
<test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
@ -130,9 +128,7 @@
<test.openstack-nova.build-version>${test.openstack-nova.build-version}</test.openstack-nova.build-version>
<test.openstack-nova.identity>${test.openstack-nova.identity}</test.openstack-nova.identity>
<test.openstack-nova.credential>${test.openstack-nova.credential}</test.openstack-nova.credential>
<test.openstack-nova.image-id>${test.openstack-nova.image-id}</test.openstack-nova.image-id>
<test.openstack-nova.image.login-user>${test.openstack-nova.image.login-user}</test.openstack-nova.image.login-user>
<test.openstack-nova.image.authenticate-sudo>${test.openstack-nova.image.authenticate-sudo}</test.openstack-nova.image.authenticate-sudo>
<test.openstack-nova.template>${test.openstack-nova.template}</test.openstack-nova.template>
<test.jclouds.openstack-nova.auto-allocate-floating-ips>${test.jclouds.openstack-nova.auto-allocate-floating-ips}</test.jclouds.openstack-nova.auto-allocate-floating-ips>
<test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
</systemPropertyVariables>

View File

@ -165,7 +165,7 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
}
});
} catch (NoSuchElementException e) {
logger.debug("could not find %s with id(%s) for server(%s)", type, objectId, serverInZone);
logger.trace("could not find %s with id(%s) for server(%s)", type, objectId, serverInZone);
}
return null;
}

View File

@ -103,9 +103,16 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
@Override
public ToStringHelper string() {
return super.string().add("autoAssignFloatingIp", autoAssignFloatingIp)
.add("securityGroupNames", securityGroupNames).add("generateKeyPair", generateKeyPair)
.add("keyPairName", keyPairName).add("userData", userData);
ToStringHelper toString = super.string();
if (!autoAssignFloatingIp)
toString.add("autoAssignFloatingIp", autoAssignFloatingIp);
if (securityGroupNames.size() != 0)
toString.add("securityGroupNames", securityGroupNames);
if (generateKeyPair)
toString.add("generateKeyPair", generateKeyPair);
toString.add("keyPairName", keyPairName);
toString.add("userData", userData);
return toString;
}
public static final NovaTemplateOptions NONE = new NovaTemplateOptions();

View File

@ -32,14 +32,12 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.compute.config.CustomizationResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.functions.GroupNamingConvention;
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
@ -71,7 +69,6 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
private final NovaClient novaClient;
private final Provider<TemplateBuilder> templateBuilderProvider;
@Inject
protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(
@ -80,13 +77,11 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
GroupNamingConvention.Factory namingConvention,
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
Provider<TemplateBuilder> templateBuilderProvider,
AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode,
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaClient novaClient) {
super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, executor,
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
this.templateBuilderProvider = checkNotNull(templateBuilderProvider, "templateBuilderProvider");
this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
this.allocateAndAddFloatingIpToNode = checkNotNull(allocateAndAddFloatingIpToNode,
@ -98,16 +93,7 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
public Map<?, Future<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
Template mutableTemplate;
// ensure we don't mutate the input template, fromTemplate ignores imageId so
// build directly from imageId if we have it
if (template.getImage() != null && template.getImage().getId() != null) {
mutableTemplate = templateBuilderProvider.get().imageId(template.getImage().getId()).fromTemplate(template)
.build();
// otherwise build from generic parameters
} else {
mutableTemplate = templateBuilderProvider.get().fromTemplate(template).build();
}
Template mutableTemplate = template.clone();
NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(mutableTemplate.getOptions());

View File

@ -26,8 +26,8 @@ import static com.google.common.base.Preconditions.checkState;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import javax.inject.Inject;
@ -40,8 +40,8 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import org.jclouds.util.Preconditions2;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
@ -133,10 +133,18 @@ public class CreateServerOptions implements MapBinder {
}
protected ToStringHelper string() {
return toStringHelper("").add("keyName", keyName).add("securityGroupNames", securityGroupNames)
.add("metadata", metadata).add("personality", personality)
.add("adminPassPresent", adminPass != null)
.add("userData", userData == null ? null : new String(userData));
ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
toString.add("keyName", keyName);
if (securityGroupNames.size() > 0)
toString.add("securityGroupNames", securityGroupNames);
if (metadata.size() > 0)
toString.add("metadata", metadata);
if (personality.size() > 0)
toString.add("personality", personality);
if (adminPass != null)
toString.add("adminPassPresent", true);
toString.add("userData", userData == null ? null : new String(userData));
return toString;
}
@Override

View File

@ -204,7 +204,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra
String eTag = client.putObjectManifest(container, key);
logger.debug(String.format("multipart upload of %s to container %s" +
" succeffully finished with %s retries", key, container, errors.get()));
" successfully finished with %s retries", key, container, errors.get()));
return eTag;
} catch (Exception ex) {
RuntimeException rtex = Throwables2.getFirstThrowableOfType(ex, RuntimeException.class);

View File

@ -36,13 +36,10 @@
<properties>
<test.vcloud.endpoint>FIXME</test.vcloud.endpoint>
<test.vcloud.api-version>1.0</test.vcloud.api-version>
<test.vcloud.build-version />
<test.vcloud.build-version></test.vcloud.build-version>
<test.vcloud.identity>FIXME</test.vcloud.identity>
<test.vcloud.credential>FIXME</test.vcloud.credential>
<test.vcloud.image-id />
<test.vcloud.image.login-user />
<test.vcloud.image.authenticate-sudo />
<test.vcloud.template></test.vcloud.template>
<jclouds.osgi.export>org.jclouds.vcloud*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.compute.internal;version="${project.version}",
@ -118,9 +115,7 @@
<test.vcloud.build-version>${test.vcloud.build-version}</test.vcloud.build-version>
<test.vcloud.identity>${test.vcloud.identity}</test.vcloud.identity>
<test.vcloud.credential>${test.vcloud.credential}</test.vcloud.credential>
<test.vcloud.image-id>${test.vcloud.image-id}</test.vcloud.image-id>
<test.vcloud.image.login-user>${test.vcloud.image.login-user}</test.vcloud.image.login-user>
<test.vcloud.image.authenticate-sudo>${test.vcloud.image.authenticate-sudo}</test.vcloud.image.authenticate-sudo>
<test.vcloud.template>${test.vcloud.template}</test.vcloud.template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -139,7 +139,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
public void testListRootUsesDelimiter() throws InterruptedException {
String containerName = getContainerName();
try {
String prefix = "rootdelimeter";
String prefix = "rootdelimiter";
addTenObjectsUnderPrefix(containerName, prefix);
add15UnderRoot(containerName);
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName);

View File

@ -21,10 +21,8 @@ package org.jclouds.aws.config;
import java.util.Date;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.date.DateService;
import org.jclouds.date.TimeStamp;
@ -59,9 +57,8 @@ public abstract class FormSigningRestClientModule<S, A> extends AWSRestClientMod
@Provides
@TimeStamp
protected String provideTimeStamp(final DateService dateService,
@Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) {
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis() + (expiration * 1000)));
protected String provideTimeStamp(DateService dateService) {
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()));
}
@Provides

View File

@ -112,7 +112,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
".InUse")))
|| (message != null && (message.indexOf("already exists") != -1 || message.indexOf("is in use") != -1)))
exception = new IllegalStateException(message, exception);
else if ("AuthFailure".equals(errorCode))
else if (errorCode != null && errorCode.indexOf("AuthFailure") != -1)
exception = new AuthorizationException(message, exception);
else if (message != null
&& (message.indexOf("Invalid id") != -1 || message.indexOf("Failed to bind") != -1))

View File

@ -56,7 +56,13 @@ public class ParseAWSErrorFromXmlContentTest {
assertCodeMakes("GET", URI.create("https://amazonaws.com/foo"), 400, "",
"<Error><Code>Monster.NotFound</Code></Error>", ResourceNotFoundException.class);
}
@Test
public void test400WithCloudBridgeNotFoundSetsResourceNotFoundException() {
assertCodeMakes("POST", URI.create("https://api.greenqloud.com/"), 400, "",
"<Error><Code>Client.InvalidInstanceID.NotFound</Code></Error>", ResourceNotFoundException.class);
}
@Test
public void test400WithInvalidIdIllegalArgumentException() {
assertCodeMakes("POST", URI.create("https://ec2.us-east-1.amazonaws.com"), 400, "HTTP/1.1 400", "",
@ -164,6 +170,12 @@ public class ParseAWSErrorFromXmlContentTest {
"<Error><Code>AuthFailure</Code></Error>", AuthorizationException.class);
}
@Test
public void test400WithCloudBridgeAuthFailureSetsAuthorizationException() {
assertCodeMakes("POST", URI.create("https://api.greenqloud.com/"), 400, "",
"<Error><Code>Client.AuthFailure</Code></Error>", AuthorizationException.class);
}
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
Class<? extends Exception> expected) {
assertCodeMakes(method, uri, statusCode, message, "text/xml", content, expected);

View File

@ -35,18 +35,7 @@
<packaging>bundle</packaging>
<properties>
<jclouds.osgi.export>org.jclouds.openstack.config*;version="${project.version}",
org.jclouds.openstack.domain*;version="${project.version}"
org.jclouds.openstack.filters*;version="${project.version}"
org.jclouds.openstack.functions*;version="${project.version}"
org.jclouds.openstack.handlers*;version="${project.version}"
org.jclouds.openstack.internal*;version="${project.version}"
org.jclouds.openstack.keystone.v1_1*;version="${project.version}"
org.jclouds.openstack.options*;version="${project.version}"
org.jclouds.openstack.predicates*;version="${project.version}"
org.jclouds.openstack.reference*;version="${project.version}"
org.jclouds.openstack.services*;version="${project.version}"
</jclouds.osgi.export>
<jclouds.osgi.export>org.jclouds.openstack*;version="${project.version}";-noimport:=true</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
</properties>

View File

@ -119,7 +119,7 @@ public class RunScriptOnNodeAsInitScriptUsingSsh extends SudoAwareInitManager im
ssh.connect();
ssh.exec("rm " + initFile);
ssh.exec(Statements.appendFile(initFile, Splitter.on('\n').split(init.render(OsFamily.UNIX)),
AppendFile.DELIMETER + "_" + init.getInstanceName()).render(OsFamily.UNIX));
AppendFile.DELIMITER + "_" + init.getInstanceName()).render(OsFamily.UNIX));
}
ssh.exec("chmod 755 " + initFile);

View File

@ -90,7 +90,7 @@ public class SudoAwareInitManager {
String command = (runAsRoot && Predicates.in(ImmutableSet.of("start", "stop", "run")).apply(action)) ? execScriptAsRoot(action)
: execScriptAsDefaultUser(action);
returnVal = runCommand(command);
if ("status".equals(action))
if (ImmutableSet.of("status", "stdout", "stderr").contains(action))
logger.trace("<< %s(%d)", action, returnVal.getExitStatus());
else if (computeLogger.isTraceEnabled())
computeLogger.trace("<< %s[%s]", action, returnVal);
@ -103,8 +103,8 @@ public class SudoAwareInitManager {
String statement = String.format("[%s] as %s@%s", command.replace(
node.getCredentials().getPassword() != null ? node.getCredentials().getPassword() : "XXXXX", "XXXXX"), ssh
.getUsername(), ssh.getHostAddress());
if (command.endsWith("status"))
logger.trace(">> running " + statement);
if (command.endsWith("status") || command.endsWith("stdout") || command.endsWith("stderr"))
logger.trace(">> running %s", statement);
else
computeLogger.debug(">> running " + statement);
ExecResponse returnVal = ssh.exec(command);

View File

@ -47,4 +47,11 @@ public interface Template extends Cloneable {
* options for launching this template, like run scripts or inbound ports
*/
TemplateOptions getOptions();
/**
* clone this template
*
* @see Object#clone
*/
Template clone();
}

View File

@ -152,7 +152,7 @@ public class TemplateBuilderSpec implements Serializable {
.put("authenticateSudo", new AuthenticateSudoParser())
.put("locationId", new LocationIdParser())
.build();
@VisibleForTesting
String hardwareId;
@VisibleForTesting
@ -553,4 +553,63 @@ public class TemplateBuilderSpec implements Serializable {
}
}
public String getHardwareId() {
return hardwareId;
}
public Double getMinCores() {
return minCores;
}
public Integer getMinRam() {
return minRam;
}
public String getHypervisorMatches() {
return hypervisorMatches;
}
public String getImageId() {
return imageId;
}
public String getImageNameMatches() {
return imageNameMatches;
}
public OsFamily getOsFamily() {
return osFamily;
}
public String getOsVersionMatches() {
return osVersionMatches;
}
public Boolean getOs64Bit() {
return os64Bit;
}
public String getOsArchMatches() {
return osArchMatches;
}
public String getOsDescriptionMatches() {
return osDescriptionMatches;
}
public String getLoginUser() {
return loginUser;
}
public Boolean getAuthenticateSudo() {
return authenticateSudo;
}
public String getLocationId() {
return locationId;
}
public String getSpecification() {
return specification;
}
}

View File

@ -24,6 +24,7 @@ import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.size;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Iterables.tryFind;
import static com.google.common.collect.Lists.newArrayList;
import static java.lang.String.format;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
@ -57,6 +58,8 @@ import org.jclouds.util.Lists2;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Supplier;
@ -403,27 +406,23 @@ public class TemplateBuilderImpl implements TemplateBuilder {
private Predicate<Hardware> buildHardwarePredicate() {
List<Predicate<Hardware>> predicates = newArrayList();
if (hardwareId != null) {
predicates.add(hardwareIdPredicate);
} else {
if (location != null)
predicates.add(new Predicate<Hardware>() {
if (location != null)
predicates.add(new Predicate<Hardware>() {
@Override
public boolean apply(Hardware input) {
return locationPredicate.apply(input);
}
@Override
public boolean apply(Hardware input) {
return locationPredicate.apply(input);
}
@Override
public String toString() {
return locationPredicate.toString();
}
});
if (hypervisor != null)
predicates.add(hypervisorPredicate);
predicates.add(hardwareCoresPredicate);
predicates.add(hardwareRamPredicate);
}
@Override
public String toString() {
return locationPredicate.toString();
}
});
if (hypervisor != null)
predicates.add(hypervisorPredicate);
predicates.add(hardwareCoresPredicate);
predicates.add(hardwareRamPredicate);
// looks verbose, but explicit <Hardware> type needed for this to compile
// properly
@ -612,35 +611,87 @@ public class TemplateBuilderImpl implements TemplateBuilder {
options = optionsProvider.get();
logger.debug(">> searching params(%s)", this);
Set<? extends Image> images = getImages();
Set<? extends Hardware> hardwaresToSearch = hardwares.get();
Image image = null;
if (imageId != null) {
image = findImageWithId(images);
if (currentLocationWiderThan(image.getLocation()))
this.location = image.getLocation();
}
Hardware hardware = null;
if (hardwareId != null) {
hardware = findHardwareWithId(hardwaresToSearch);
if (currentLocationWiderThan(hardware.getLocation()))
this.location = hardware.getLocation();
}
// if the user hasn't specified a location id, or an image or hardware
// with location, let's search scoped to the implicit one
if (location == null)
location = defaultLocation.get();
Predicate<Image> imagePredicate = buildImagePredicate();
Iterable<? extends Image> supportedImages = filter(images, imagePredicate);
if (size(supportedImages) == 0) {
if (imagePredicate == idPredicate) {
throwNoSuchElementExceptionAfterLoggingImageIds(format("%s not found", idPredicate), images);
} else {
throwNoSuchElementExceptionAfterLoggingImageIds(format("no image matched predicate: %s", imagePredicate),
images);
}
if (image == null) {
Iterable<? extends Image> supportedImages = findSupportedImages(images);
if (hardware == null)
hardware = resolveHardware(hardwaresToSearch, supportedImages);
image = resolveImage(hardware, supportedImages);
} else {
if (hardware == null)
hardware = resolveHardware(hardwaresToSearch, ImmutableSet.of(image));
}
Hardware hardware = resolveHardware(hardwareSorter(), supportedImages);
Image image = resolveImage(hardware, supportedImages);
logger.debug("<< matched image(%s)", image.getId());
logger.debug("<< matched image(%s) hardware(%s) location(%s)", image.getId(), hardware.getId(),
location.getId());
return new TemplateImpl(image, hardware, location, options);
}
protected void throwNoSuchElementExceptionAfterLoggingImageIds(String message, Iterable<? extends Image> images) {
private Iterable<? extends Image> findSupportedImages(Set<? extends Image> images) {
Predicate<Image> imagePredicate = buildImagePredicate();
Iterable<? extends Image> supportedImages = filter(images, imagePredicate);
if (size(supportedImages) == 0) {
throw throwNoSuchElementExceptionAfterLoggingImageIds(
format("no image matched predicate: %s", imagePredicate), images);
}
return supportedImages;
}
private Image findImageWithId(Set<? extends Image> images) {
Image image;
// TODO: switch to GetImageStrategy in version 1.5
image = tryFind(images, idPredicate).orNull();
if (image == null)
throwNoSuchElementExceptionAfterLoggingImageIds(format("%s not found", idPredicate), images);
return image;
}
private Hardware findHardwareWithId(Set<? extends Hardware> hardwaresToSearch) {
Hardware hardware;
// TODO: switch to GetHardwareStrategy in version 1.5
hardware = tryFind(hardwaresToSearch, hardwareIdPredicate).orNull();
if (hardware == null)
throw throwNoSuchElementExceptionAfterLoggingHardwareIds(format("%s not found", hardwareIdPredicate),
hardwaresToSearch);
return hardware;
}
protected NoSuchElementException throwNoSuchElementExceptionAfterLoggingImageIds(String message, Iterable<? extends Image> images) {
NoSuchElementException exception = new NoSuchElementException(message);
if (logger.isTraceEnabled())
logger.warn(exception, "image ids that didn't match: %s", transform(images, imageToId));
throw exception;
}
protected Hardware resolveHardware(Ordering<Hardware> hardwareOrdering, final Iterable<? extends Image> images) {
Set<? extends Hardware> hardwarel = hardwares.get();
protected NoSuchElementException throwNoSuchElementExceptionAfterLoggingHardwareIds(String message, Iterable<? extends Hardware> hardwares) {
NoSuchElementException exception = new NoSuchElementException(message);
if (logger.isTraceEnabled())
logger.warn(exception, "hardware ids that didn't match: %s", transform(hardwares, hardwareToId));
throw exception;
}
protected Hardware resolveHardware(Set<? extends Hardware> hardwarel, final Iterable<? extends Image> images) {
Ordering<Hardware> hardwareOrdering = hardwareSorter();
Iterable<? extends Hardware> hardwaresThatAreCompatibleWithOurImages = ImmutableSet.of();
try {
hardwaresThatAreCompatibleWithOurImages = filter(hardwarel, new Predicate<Hardware>() {
@ -667,11 +718,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
}
if (size(hardwaresThatAreCompatibleWithOurImages) == 0) {
String message = format("no hardware profiles support images matching params: %s", toString());
NoSuchElementException exception = new NoSuchElementException(message);
if (logger.isTraceEnabled())
logger.warn(exception, "hardware profiles %s\nimage ids %s", transform(hardwarel, hardwareToId), transform(
images, imageToId));
throw exception;
throw throwNoSuchElementExceptionAfterLoggingHardwareIds(message, hardwaresThatAreCompatibleWithOurImages);
}
Predicate<Hardware> hardwarePredicate = buildHardwarePredicate();
Hardware hardware;
@ -679,13 +726,9 @@ public class TemplateBuilderImpl implements TemplateBuilder {
hardware = hardwareOrdering.max(filter(hardwaresThatAreCompatibleWithOurImages, hardwarePredicate));
} catch (NoSuchElementException exception) {
String message = format("no hardware profiles match params: %s", hardwarePredicate);
exception = new NoSuchElementException(message);
if (logger.isTraceEnabled())
logger.warn(exception, "hardware profiles %s", transform(hardwaresThatAreCompatibleWithOurImages,
hardwareToId));
throw exception;
throw throwNoSuchElementExceptionAfterLoggingHardwareIds(message, hardwaresThatAreCompatibleWithOurImages);
}
logger.debug("<< matched hardware(%s)", hardware.getId());
logger.trace("<< matched hardware(%s)", hardware.getId());
return hardware;
}
@ -741,59 +784,55 @@ public class TemplateBuilderImpl implements TemplateBuilder {
private Predicate<Image> buildImagePredicate() {
List<Predicate<Image>> predicates = newArrayList();
if (imageId != null) {
predicates.add(idPredicate);
} else {
if (location != null)
predicates.add(new Predicate<Image>() {
if (location != null)
predicates.add(new Predicate<Image>() {
@Override
public boolean apply(Image input) {
return locationPredicate.apply(input);
}
@Override
public boolean apply(Image input) {
return locationPredicate.apply(input);
}
@Override
public String toString() {
return locationPredicate.toString();
}
});
@Override
public String toString() {
return locationPredicate.toString();
}
});
final List<Predicate<OperatingSystem>> osPredicates = newArrayList();
if (osFamily != null)
osPredicates.add(osFamilyPredicate);
if (osName != null)
osPredicates.add(osNamePredicate);
if (osDescription != null)
osPredicates.add(osDescriptionPredicate);
if (osVersion != null)
osPredicates.add(osVersionPredicate);
if (os64Bit != null)
osPredicates.add(os64BitPredicate);
if (osArch != null)
osPredicates.add(osArchPredicate);
if (osPredicates.size() > 0)
predicates.add(new Predicate<Image>() {
final List<Predicate<OperatingSystem>> osPredicates = newArrayList();
if (osFamily != null)
osPredicates.add(osFamilyPredicate);
if (osName != null)
osPredicates.add(osNamePredicate);
if (osDescription != null)
osPredicates.add(osDescriptionPredicate);
if (osVersion != null)
osPredicates.add(osVersionPredicate);
if (os64Bit != null)
osPredicates.add(os64BitPredicate);
if (osArch != null)
osPredicates.add(osArchPredicate);
if (osPredicates.size() > 0)
predicates.add(new Predicate<Image>() {
@Override
public boolean apply(Image input) {
return and(osPredicates).apply(input.getOperatingSystem());
}
@Override
public boolean apply(Image input) {
return and(osPredicates).apply(input.getOperatingSystem());
}
@Override
public String toString() {
return and(osPredicates).toString();
}
@Override
public String toString() {
return and(osPredicates).toString();
}
});
if (imageVersion != null)
predicates.add(imageVersionPredicate);
if (imageName != null)
predicates.add(imageNamePredicate);
if (imageDescription != null)
predicates.add(imageDescriptionPredicate);
if (imagePredicate != null)
predicates.add(imagePredicate);
}
});
if (imageVersion != null)
predicates.add(imageVersionPredicate);
if (imageName != null)
predicates.add(imageNamePredicate);
if (imageDescription != null)
predicates.add(imageDescriptionPredicate);
if (imagePredicate != null)
predicates.add(imagePredicate);
// looks verbose, but explicit <Image> type needed for this to compile
// properly
@ -958,11 +997,40 @@ public class TemplateBuilderImpl implements TemplateBuilder {
@Override
public String toString() {
return "[biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName + ", imageDescription="
+ imageDescription + ", imageId=" + imageId + ", imagePredicate=" + imagePredicate + ", imageVersion=" + imageVersion + ", location=" + location
+ ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily + ", osName=" + osName
+ ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch + ", os64Bit="
+ os64Bit + ", hardwareId=" + hardwareId + ", hypervisor=" + hypervisor + "]";
return string().toString();
}
/**
* @since 1.5
*/
protected ToStringHelper string() {
ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
if (biggest)
toString.add("biggest", biggest);
if (fastest)
toString.add("fastest", fastest);
toString.add("imageName", imageName);
toString.add("imageDescription", imageDescription);
toString.add("imageId", imageId);
toString.add("imagePredicate", imagePredicate);
toString.add("imageVersion", imageVersion);
if (location != null)
toString.add("locationId", location.getId());
if (minCores >0) //TODO: make non-primitive
toString.add("minCores", minCores);
if (minRam >0) //TODO: make non-primitive
toString.add("minRam", minRam);
if (minRam >0) //TODO: make non-primitive
toString.add("minRam", minRam);
toString.add("osFamily", osFamily);
toString.add("osName", osName);
toString.add("osDescription", osDescription);
toString.add("osVersion", osVersion);
toString.add("osArch", osArch);
toString.add("os64Bit", os64Bit);
toString.add("hardwareId", hardwareId);
toString.add("hypervisor", hypervisor);
return toString;
}
@Override

View File

@ -129,8 +129,8 @@ public class TemplateImpl implements Template {
* {@inheritDoc}
*/
@Override
protected Object clone() throws CloneNotSupportedException {
return new TemplateImpl(image, size, location, options);
public Template clone() {
return new TemplateImpl(image, size, location, options.clone());
}
}

View File

@ -338,9 +338,9 @@ public class BaseComputeService implements ComputeService {
*/
@Override
public Set<ComputeMetadata> listNodes() {
logger.debug(">> listing nodes");
logger.trace(">> listing nodes");
Set<ComputeMetadata> set = newLinkedHashSet(listNodesStrategy.listNodes());
logger.debug("<< list(%d)", set.size());
logger.trace("<< list(%d)", set.size());
return set;
}
@ -350,9 +350,9 @@ public class BaseComputeService implements ComputeService {
@Override
public Set<? extends NodeMetadata> listNodesDetailsMatching(Predicate<ComputeMetadata> filter) {
checkNotNull(filter, "filter");
logger.debug(">> listing node details matching(%s)", filter);
logger.trace(">> listing node details matching(%s)", filter);
Set<NodeMetadata> set = newLinkedHashSet(listNodesStrategy.listDetailsOnNodesMatching(filter));
logger.debug("<< list(%d)", set.size());
logger.trace("<< list(%d)", set.size());
return set;
}

View File

@ -455,11 +455,23 @@ public class RunScriptOptions {
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("loginUser", loginUser)
.add("loginPasswordPresent", (loginPassword != null))
.add("loginPrivateKeyPresent", (loginPrivateKey != null)).add("authenticateSudo", authenticateSudo)
.add("port:seconds", port + ":" + seconds).add("taskName", taskName).add("runAsRoot", runAsRoot)
.add("blockOnComplete", blockOnComplete).add("wrapInInitScript", wrapInInitScript);
ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
toString.add("loginUser", loginUser);
if (loginPassword != null)
toString.add("loginPasswordPresent", true);
if (loginPrivateKey != null)
toString.add("loginPrivateKeyPresent", true);
toString.add("authenticateSudo", authenticateSudo);
if (port != -1 && seconds != -1) // TODO: not primitives
toString.add("blockOnPort:seconds", port + ":" + seconds);
toString.add("taskName", taskName);
if (!runAsRoot)
toString.add("runAsRoot", runAsRoot);
if (!blockOnComplete)
toString.add("blockOnComplete", blockOnComplete);
if (!wrapInInitScript)
toString.add("wrapInInitScript", wrapInInitScript);
return toString;
}
}

View File

@ -317,7 +317,9 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
}
protected Set<Integer> inboundPorts = ImmutableSet.of(22);
private final static Set<Integer> DEFAULT_INBOUND_PORTS = ImmutableSet.of(22);
protected Set<Integer> inboundPorts = DEFAULT_INBOUND_PORTS;
protected Statement script;
@ -352,11 +354,24 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
@Override
public ToStringHelper string() {
return super.string().add("inboundPorts", inboundPorts).add("scriptPresent", script != null)
.add("publicKeyPresent", publicKey != null).add("privateKeyPresent", privateKey != null).add("tags", tags)
.add("blockUntilRunning", blockUntilRunning).add("tags", tags).add("userMetadata", userMetadata);
ToStringHelper toString = super.string();
if (!DEFAULT_INBOUND_PORTS.equals(inboundPorts))
toString.add("inboundPorts", inboundPorts);
if (script != null)
toString.add("scriptPresent", true);
if (publicKey != null)
toString.add("publicKeyPresent", true);
if (privateKey != null)
toString.add("privateKeyPresent", true);
if (!blockUntilRunning)
toString.add("blockUntilRunning", blockUntilRunning);
if (tags.size() != 0)
toString.add("tags", tags);
if (userMetadata.size() != 0)
toString.add("userMetadata", userMetadata);
return toString;
}
public int[] getInboundPorts() {
return Ints.toArray(inboundPorts);
}

View File

@ -75,7 +75,7 @@ public class RunScriptData {
return InitScript.builder()
.name("jboss")
.home(JBOSS_HOME)
.exportVariables(ImmutableMap.of("jbossHome", JBOSS_HOME))
.exportVariables(ImmutableMap.of("JBOSS_HOME", JBOSS_HOME))
.init(appendFile(JBOSS_HOME + "/standalone/configuration/standalone-custom.xml", Splitter.on('\n').split(configuration)))
.run(interpret(new StringBuilder().append("java ").append(' ')
.append("-server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ')

View File

@ -63,6 +63,9 @@ public class TemplateBuilderImplTest {
protected Location region = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description("us-east-1")
.parent(provider).build();
protected Location region2 = new LocationBuilder().scope(LocationScope.REGION).id("us-east-2").description("us-east-2")
.parent(provider).build();
@SuppressWarnings("unchecked")
public void testLocationPredicateWhenComputeMetadataIsNotLocationBound() {
Image image = createMock(Image.class);
@ -371,7 +374,7 @@ public class TemplateBuilderImplTest {
// make sure big data is not in the exception message
assertEquals(
e.getMessage(),
"no hardware profiles support images matching params: [biggest=false, fastest=false, imageName=null, imageDescription=null, imageId=us-east-1/imageId, imagePredicate=null, imageVersion=null, location=[id=us-east-1, scope=REGION, description=us-east-1, parent=aws-ec2, iso3166Codes=[], metadata={}], minCores=0.0, minRam=0, osFamily=null, osName=null, osDescription=null, osVersion=null, osArch=null, os64Bit=false, hardwareId=null, hypervisor=null]");
"no hardware profiles support images matching params: {imageId=us-east-1/imageId, locationId=us-east-1, os64Bit=false}");
verify(image);
verify(os);
verify(defaultTemplate);
@ -849,9 +852,63 @@ public class TemplateBuilderImplTest {
TemplateBuilder templateBuilder = templateBuilderProvider.get().minRam(512).osFamily(OsFamily.UBUNTU)
.hypervisorMatches("OpenVZ").osVersionMatches("1[10].[10][04]").os64Bit(true);
assertEquals(templateBuilder.toString(), "{minRam=512, minRam=512, osFamily=ubuntu, osVersion=1[10].[10][04], os64Bit=true, hypervisor=OpenVZ}");
Template template = templateBuilder.build();
assertEquals(template.getHardware().getHypervisor(), "OpenVZ");
assertEquals(template.getImage().getId(), "Ubuntu 11.04 64-bit");
}
@Test
public void testImageLocationNonDefault() {
final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
.<Location> of(region));
final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
.<Image> of(
new ImageBuilder()
.id("us-east-2/ami-ffff")
.providerId("ami-ffff")
.name("Ubuntu 11.04 x64")
.description("Ubuntu 11.04 x64")
.location(region2)
.status(Status.AVAILABLE)
.operatingSystem(
OperatingSystem.builder().name("Ubuntu 11.04 x64").description("Ubuntu 11.04 x64")
.is64Bit(true).version("11.04").family(OsFamily.UBUNTU).build()).build()));
final Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
.<Hardware> of(
new HardwareBuilder()
.ids("m1.small").ram(512)
.processors(ImmutableList.of(new Processor(1, 1.0)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) 5, true, true))).build()));
final Provider<TemplateOptions> optionsProvider = new Provider<TemplateOptions>() {
@Override
public TemplateOptions get() {
return new TemplateOptions();
}
};
Provider<TemplateBuilder> templateBuilderProvider = new Provider<TemplateBuilder>() {
@Override
public TemplateBuilder get() {
return createTemplateBuilder(null, locations, images, hardwares, region, optionsProvider, this);
}
};
TemplateBuilder templateBuilder = templateBuilderProvider.get().hardwareId("m1.small").imageId("us-east-2/ami-ffff");
assertEquals(templateBuilder.toString(), "{imageId=us-east-2/ami-ffff, hardwareId=m1.small}");
Template template = templateBuilder.build();
assertEquals(template.getLocation().getId(), "us-east-2");
}
}

View File

@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jclouds.apis.BaseViewLiveTest;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.TemplateBuilderSpec;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.domain.LoginCredentials.Builder;
import org.jclouds.io.CopyInputStreamInputSupplierMap;
@ -41,9 +42,7 @@ import com.google.inject.util.Modules;
*/
public abstract class BaseGenericComputeServiceContextLiveTest<W extends ComputeServiceContext> extends BaseViewLiveTest<W> {
protected String imageId;
protected String loginUser;
protected String authenticateSudo;
protected TemplateBuilderSpec template;
protected LoginCredentials loginCredentials = LoginCredentials.builder().user("root").build();
// isolate tests from eachother, as default credentialStore is static
@ -53,19 +52,19 @@ public abstract class BaseGenericComputeServiceContextLiveTest<W extends Compute
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
imageId = setIfTestSystemPropertyPresent(overrides, provider + ".image-id");
loginUser = setIfTestSystemPropertyPresent(overrides, provider + ".image.login-user");
authenticateSudo = setIfTestSystemPropertyPresent(overrides, provider + ".image.authenticate-sudo");
if (loginUser != null) {
Iterable<String> userPass = Splitter.on(':').split(loginUser);
Builder loginCredentialsBuilder = LoginCredentials.builder();
loginCredentialsBuilder.user(Iterables.get(userPass, 0));
if (Iterables.size(userPass) == 2)
loginCredentialsBuilder.password(Iterables.get(userPass, 1));
if (authenticateSudo != null)
loginCredentialsBuilder.authenticateSudo(Boolean.valueOf(authenticateSudo));
loginCredentials = loginCredentialsBuilder.build();
String spec = setIfTestSystemPropertyPresent(overrides, provider + ".template");
if (spec != null) {
template = TemplateBuilderSpec.parse(spec);
if (template.getLoginUser() != null) {
Iterable<String> userPass = Splitter.on(':').split(template.getLoginUser());
Builder loginCredentialsBuilder = LoginCredentials.builder();
loginCredentialsBuilder.user(Iterables.get(userPass, 0));
if (Iterables.size(userPass) == 2)
loginCredentialsBuilder.password(Iterables.get(userPass, 1));
if (template.getAuthenticateSudo() != null)
loginCredentialsBuilder.authenticateSudo(template.getAuthenticateSudo());
loginCredentials = loginCredentialsBuilder.build();
}
}
return overrides;
}

View File

@ -261,9 +261,9 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
ComputeServiceContext context = null;
try {
Properties overrides = setupProperties();
String login = loginUser != null ? loginUser : "foo:bar";
String login = template != null && template.getLoginUser() != null ? template.getLoginUser() : "foo:bar";
overrides.setProperty(propertyKey + ".image.login-user", login);
boolean auth = authenticateSudo != null ? Boolean.valueOf(authenticateSudo) : true;
boolean auth = template != null && template.getAuthenticateSudo() != null ? template.getAuthenticateSudo() : true;
overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + "");
context = createView(overrides, ImmutableSet.<Module>of(credentialStoreModule));

View File

@ -45,6 +45,7 @@ public class TemplateOptionsTest {
public void testinstallPrivateKey() throws IOException {
TemplateOptions options = new TemplateOptions();
options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
assertEquals(options.toString(), "{privateKeyPresent=true}");
assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
}
@ -75,6 +76,7 @@ public class TemplateOptionsTest {
public void testauthorizePublicKey() throws IOException {
TemplateOptions options = new TemplateOptions();
options.authorizePublicKey("ssh-rsa");
assertEquals(options.toString(), "{publicKeyPresent=true}");
assertEquals(options.getPublicKey(), "ssh-rsa");
}
@ -105,6 +107,7 @@ public class TemplateOptionsTest {
public void testblockOnPort() {
TemplateOptions options = new TemplateOptions();
options.blockOnPort(22, 30);
assertEquals(options.toString(), "{blockOnPort:seconds=22:30}");
assertEquals(options.getPort(), 22);
assertEquals(options.getSeconds(), 30);
@ -148,6 +151,7 @@ public class TemplateOptionsTest {
@Test
public void testinboundPortsStatic() {
TemplateOptions options = inboundPorts(22, 30);
assertEquals(options.toString(), "{inboundPorts=[22, 30]}");
assertEquals(options.getInboundPorts()[0], 22);
assertEquals(options.getInboundPorts()[1], 30);
}
@ -155,6 +159,7 @@ public class TemplateOptionsTest {
@Test
public void testblockUntilRunningDefault() {
TemplateOptions options = new TemplateOptions();
assertEquals(options.toString(), "{}");
assertEquals(options.shouldBlockUntilRunning(), true);
}
@ -162,6 +167,7 @@ public class TemplateOptionsTest {
public void testblockUntilRunning() {
TemplateOptions options = new TemplateOptions();
options.blockUntilRunning(false);
assertEquals(options.toString(), "{blockUntilRunning=false}");
assertEquals(options.shouldBlockUntilRunning(), false);
}

View File

@ -33,6 +33,7 @@ import com.google.common.annotations.VisibleForTesting;
/**
* @author Andrew Phillips
* @author Adrian Cole
*/
public class JcloudsVersion {
@VisibleForTesting
@ -105,10 +106,10 @@ public class JcloudsVersion {
String alphaOrBetaOrReleaseCandidateVersionIfPresent = versionMatcher.group(4);
if (alphaOrBetaOrReleaseCandidateVersionIfPresent != null) {
Integer alphaOrReleaseCandidateVersion = Integer.valueOf(versionMatcher.group(5));
Integer alphaOrBetaOrReleaseCandidateVersion = Integer.valueOf(versionMatcher.group(5));
if (alphaOrBetaOrReleaseCandidateVersionIfPresent.equals(ALPHA_VERSION_IDENTIFIER)) {
alpha = true;
alphaVersion = alphaOrReleaseCandidateVersion;
alphaVersion = alphaOrBetaOrReleaseCandidateVersion;
beta = false;
betaVersion = null;
releaseCandidate = false;
@ -117,7 +118,7 @@ public class JcloudsVersion {
alpha = false;
alphaVersion = null;
beta = true;
betaVersion = alphaOrReleaseCandidateVersion;
betaVersion = alphaOrBetaOrReleaseCandidateVersion;
releaseCandidate = false;
releaseCandidateVersion = null;
} else {
@ -126,7 +127,7 @@ public class JcloudsVersion {
beta = false;
betaVersion = null;
releaseCandidate = true;
releaseCandidateVersion = alphaOrReleaseCandidateVersion;
releaseCandidateVersion = alphaOrBetaOrReleaseCandidateVersion;
}
} else {
alpha = false;

View File

@ -0,0 +1,46 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.apis;
import java.util.HashSet;
import java.util.Set;
/**
* A registry for holding {@link org.jclouds.apis.ApiMetadata}.
*/
public class ApiRegistry {
private static final Set<ApiMetadata> apis = new HashSet<ApiMetadata>();
public static void registerApi(ApiMetadata api) {
apis.add(api);
}
public static void unRegisterApi(ApiMetadata api) {
apis.remove(api);
}
public static Iterable<ApiMetadata> fromRegistry() {
return Iterable.class.cast(apis);
}
public static void clear() {
apis.clear();
}
}

View File

@ -69,7 +69,7 @@ public class Apis {
* @return all available apis
*/
public static Iterable<ApiMetadata> all() {
return fromServiceLoader();
return Iterables.concat(fromServiceLoader(), ApiRegistry.fromRegistry());
}
/**

View File

@ -124,13 +124,14 @@ public class SshKeys {
/**
*
* @param used
* @param generator
* to generate RSA key pairs
* @param rand
* for initializing {@code generator}
* @return new 2048 bit keyPair
* @see Crypto#rsaKeyPairGenerator()
*/
public static KeyPair generateRsaKeyPair(KeyPairGenerator generator) {
SecureRandom rand = new SecureRandom();
public static KeyPair generateRsaKeyPair(KeyPairGenerator generator, SecureRandom rand) {
generator.initialize(2048, rand);
return generator.genKeyPair();
}
@ -140,15 +141,15 @@ public class SshKeys {
*/
public static Map<String, String> generate() {
try {
return generate(KeyPairGenerator.getInstance("RSA"));
return generate(KeyPairGenerator.getInstance("RSA"), new SecureRandom());
} catch (NoSuchAlgorithmException e) {
propagate(e);
return null;
}
}
public static Map<String, String> generate(KeyPairGenerator generator) {
KeyPair pair = generateRsaKeyPair(generator);
public static Map<String, String> generate(KeyPairGenerator generator, SecureRandom rand) {
KeyPair pair = generateRsaKeyPair(generator, rand);
Builder<String, String> builder = ImmutableMap.builder();
builder.put("public", encodeAsOpenSSH(RSAPublicKey.class.cast(pair.getPublic())));
builder.put("private", encodeAsPem(RSAPrivateKey.class.cast(pair.getPrivate())));

View File

@ -47,6 +47,6 @@ public class DeadEventLoggingHandler
*/
@Subscribe
public final void handleDeadEvent(DeadEvent deadEvent) {
logger.warn("detected dead event %s", deadEvent.getEvent());
logger.trace("detected dead event %s", deadEvent.getEvent());
}
}

View File

@ -60,7 +60,7 @@ public abstract class BasePayload<V> implements Payload {
*/
@Override
public void writeTo(OutputStream outstream) throws IOException {
checkState(!written || isRepeatable(), "can only be writted to an outputstream once");
checkState(!written || isRepeatable(), "can only write to an outputStream once");
written = true;
InputStream in = getInput();
try {

View File

@ -56,10 +56,15 @@ public class RegionToEndpointOrProviderIfNull implements Function<Object, URI> {
@Override
public URI apply(@Nullable Object from) {
if (from == null || from.equals(defaultProvider))
if (from == null)
return defaultUri.get();
checkArgument(from instanceof String, "region is a String argument");
Map<String, Supplier<URI>> regionToEndpoint = regionToEndpointSupplier.get();
if (from.equals(defaultProvider)){
if (regionToEndpoint.containsKey(from))
return regionToEndpoint.get(from).get();
return defaultUri.get();
}
checkArgument(regionToEndpoint.containsKey(from),
"requested location %s, which is not in the configured locations: %s", from, regionToEndpoint);
return regionToEndpoint.get(from).get();

View File

@ -0,0 +1,64 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.location.suppliers.derived;
import java.net.URI;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.location.Region;
import org.jclouds.location.Zone;
import org.jclouds.location.suppliers.ZoneIdToURISupplier;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
/**
*
*/
@Singleton
public class ZoneIdToURIFromJoinOnRegionIdToURI implements ZoneIdToURISupplier {
private final Supplier<Map<String, Supplier<URI>>> regionIdToURISupplier;
private final Supplier<Map<String, Supplier<Set<String>>>> regionIdToZoneIdsSupplier;
@Inject
protected ZoneIdToURIFromJoinOnRegionIdToURI(@Region Supplier<Map<String, Supplier<URI>>> regionIdToURISupplier,
@Zone Supplier<Map<String, Supplier<Set<String>>>> regionIdToZoneIdsSupplier) {
this.regionIdToURISupplier = regionIdToURISupplier;
this.regionIdToZoneIdsSupplier = regionIdToZoneIdsSupplier;
}
@Override
public Map<String, Supplier<URI>> get() {
Builder<String, Supplier<URI>> builder = ImmutableMap.<String, Supplier<URI>> builder();
for (Entry<String, Supplier<URI>> regionToURI : regionIdToURISupplier.get().entrySet()) {
for (String zone : regionIdToZoneIdsSupplier.get().get(regionToURI.getKey()).get()) {
builder.put(zone, regionToURI.getValue());
}
}
return builder.build();
}
}

View File

@ -18,13 +18,14 @@
*/
package org.jclouds.osgi;
import org.jclouds.apis.ApiRegistry;
import org.jclouds.providers.ProviderRegistry;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
ProviderBundleListener bundleListener = new ProviderBundleListener();
MetadataBundleListener bundleListener = new MetadataBundleListener();
/**
* Called when this bundle is started so the Framework can perform the
@ -43,6 +44,7 @@ public class Activator implements BundleActivator {
*/
@Override
public void start(BundleContext context) throws Exception {
bundleListener.start(context);
context.addBundleListener(bundleListener);
}
@ -65,7 +67,9 @@ public class Activator implements BundleActivator {
*/
@Override
public void stop(BundleContext context) throws Exception {
bundleListener.stop(context);
context.removeBundleListener(bundleListener);
ProviderRegistry.clear();
ApiRegistry.clear();
}
}

View File

@ -0,0 +1,208 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.osgi;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiRegistry;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.ProviderRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
/**
* A {@link BundleListener} that listens for {@link BundleEvent} and searches for {@link org.jclouds.providers.ProviderMetadata} and {@ling org.jclouds.apis.ApiMetadata} in newly
* installed Bundles. This is used as a workaround for OSGi environments where the ServiceLoader cannot cross bundle
* boundaries.
*/
public class MetadataBundleListener implements BundleListener {
private Map<Long, ProviderMetadata> providerMetadataMap = new HashMap<Long, ProviderMetadata>();
private Map<Long, ApiMetadata> apiMetadataMap = new HashMap<Long, ApiMetadata>();
public void start(BundleContext bundleContext) {
bundleContext.addBundleListener(this);
for (Bundle bundle : bundleContext.getBundles()) {
if (bundle.getState() == Bundle.ACTIVE) {
ProviderMetadata providerMetadata = getProviderMetadata(bundle);
ApiMetadata apiMetadata = getApiMetadata(bundle);
if (providerMetadata != null) {
ProviderRegistry.registerProvider(providerMetadata);
providerMetadataMap.put(bundle.getBundleId(), providerMetadata);
}
if (apiMetadata != null) {
ApiRegistry.registerApi(apiMetadata);
apiMetadataMap.put(bundle.getBundleId(), apiMetadata);
}
}
}
}
public void stop(BundleContext bundleContext) {
providerMetadataMap.clear();
apiMetadataMap.clear();
}
@Override
public void bundleChanged(BundleEvent event) {
ProviderMetadata providerMetadata;
ApiMetadata apiMetadata;
switch (event.getType()) {
case BundleEvent.STARTED:
providerMetadata = getProviderMetadata(event.getBundle());
apiMetadata = getApiMetadata(event.getBundle());
if (providerMetadata != null) {
ProviderRegistry.registerProvider(providerMetadata);
providerMetadataMap.put(event.getBundle().getBundleId(), providerMetadata);
}
if (apiMetadata != null) {
ApiRegistry.registerApi(apiMetadata);
apiMetadataMap.put(event.getBundle().getBundleId(), apiMetadata);
}
break;
case BundleEvent.STOPPING:
case BundleEvent.STOPPED:
providerMetadata = providerMetadataMap.get(event.getBundle().getBundleId());
apiMetadata = apiMetadataMap.get(event.getBundle().getBundleId());
if (providerMetadata != null) {
ProviderRegistry.uRegisterProvider(providerMetadata);
}
if (apiMetadata != null) {
ApiRegistry.unRegisterApi(apiMetadata);
}
break;
}
}
/**
* Creates an instance of {@link ProviderMetadata} from the {@link Bundle}.
*
* @param bundle
* @return
*/
public ProviderMetadata getProviderMetadata(Bundle bundle) {
ProviderMetadata metadata = null;
String className = getProviderMetadataClassName(bundle);
if (className != null && !className.isEmpty()) {
try {
Class<? extends ProviderMetadata> providerMetadataClass = bundle.loadClass(className);
metadata = providerMetadataClass.newInstance();
} catch (ClassNotFoundException e) {
// ignore
} catch (InstantiationException e) {
// ignore
} catch (IllegalAccessException e) {
// ignore
}
}
return metadata;
}
/**
* Creates an instance of {@link ApiMetadata} from the {@link Bundle}.
*
* @param bundle
* @return
*/
public ApiMetadata getApiMetadata(Bundle bundle) {
ApiMetadata metadata = null;
String className = getApiMetadataClassName(bundle);
if (className != null && !className.isEmpty()) {
try {
Class<? extends ApiMetadata> apiMetadataClass = bundle.loadClass(className);
metadata = apiMetadataClass.newInstance();
} catch (ClassNotFoundException e) {
// ignore
} catch (InstantiationException e) {
// ignore
} catch (IllegalAccessException e) {
// ignore
}
}
return metadata;
}
public String getMetadataClassName(Bundle bundle, String pathToMetadata) {
URL resource = bundle.getEntry(pathToMetadata);
InputStream is = null;
InputStreamReader reader = null;
BufferedReader bufferedReader = null;
StringBuilder sb = new StringBuilder();
try {
is = resource.openStream();
reader = new InputStreamReader(is, "UTF-8");
bufferedReader = new BufferedReader(reader);
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line).append("\n");
}
} catch (Throwable e) {
} finally {
try {
if (reader != null)
reader.close();
} catch (Throwable e) {
}
try {
if (bufferedReader != null)
bufferedReader.close();
} catch (Throwable e) {
}
try {
is.close();
} catch (Throwable e) {
}
}
return sb.toString().trim();
}
/**
* Retrieves the {@link ProviderMetadata} class name for the bundle if it exists.
*
* @param bundle
* @return
*/
public String getProviderMetadataClassName(Bundle bundle) {
return getMetadataClassName(bundle, "/META-INF/services/org.jclouds.providers.ProviderMetadata");
}
/**
* Retrieves the {@link ProviderMetadata} class name for the bundle if it exists.
*
* @param bundle
* @return
*/
public String getApiMetadataClassName(Bundle bundle) {
return getMetadataClassName(bundle, "/META-INF/services/org.jclouds.apis.ApiMetadata");
}
}

View File

@ -1,129 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.osgi;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.ProviderRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
/**
* A {@link BundleListener} that listens for {@link BundleEvent} and searches for {@link org.jclouds.providers.ProviderMetadata} in newly
* installed Bundles. This is used as a workaround for OSGi environments where the ServiceLoader cannot cross bundle
* boundaries.
*/
public class ProviderBundleListener implements BundleListener {
private Map<Long, ProviderMetadata> bundleMetadataMap = new HashMap<Long, ProviderMetadata>();
@Override
public void bundleChanged(BundleEvent event) {
ProviderMetadata metadata;
switch (event.getType()) {
case BundleEvent.STARTED:
metadata = getProviderMetadata(event.getBundle());
if (metadata != null) {
ProviderRegistry.registerProvider(metadata);
bundleMetadataMap.put(event.getBundle().getBundleId(), metadata);
}
break;
case BundleEvent.STOPPING:
case BundleEvent.STOPPED:
metadata = bundleMetadataMap.get(event.getBundle().getBundleId());
if (metadata != null) {
ProviderRegistry.uRegisterProvider(metadata);
}
break;
}
}
/**
* Creates an instance of {@link ProviderMetadata} from the {@link Bundle}.
*
* @param bundle
* @return
*/
public ProviderMetadata getProviderMetadata(Bundle bundle) {
ProviderMetadata metadata = null;
String className = getProviderMetadataClassName(bundle);
if (className != null && !className.isEmpty()) {
try {
Class<? extends ProviderMetadata> provideClass = bundle.loadClass(className);
metadata = provideClass.newInstance();
} catch (ClassNotFoundException e) {
// ignore
} catch (InstantiationException e) {
// ignore
} catch (IllegalAccessException e) {
// ignore
}
}
return metadata;
}
/**
* Retrieves the {@link ProviderMetadata} class name for the bundle if it exists.
*
* @param bundle
* @return
*/
public String getProviderMetadataClassName(Bundle bundle) {
URL resource = bundle.getEntry("/META-INF/services/org.jclouds.providers.ProviderMetadata");
InputStream is = null;
InputStreamReader reader = null;
BufferedReader bufferedReader = null;
StringBuilder sb = new StringBuilder();
try {
is = resource.openStream();
reader = new InputStreamReader(is, "UTF-8");
bufferedReader = new BufferedReader(reader);
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line).append("\n");
}
} catch (Throwable e) {
} finally {
try {
if (reader != null)
reader.close();
} catch (Throwable e) {
}
try {
if (bufferedReader != null)
bufferedReader.close();
} catch (Throwable e) {
}
try {
is.close();
} catch (Throwable e) {
}
}
return sb.toString().trim();
}
}

View File

@ -43,7 +43,7 @@ public class ApisTest {
ApiMetadata apiMetadata;
try {
apiMetadata = Apis.withId("fake-id");
fail("Looking for a api with an id that doesn't exist should " + "throw an exceptoin.");
fail("Looking for a api with an id that doesn't exist should " + "throw an exception.");
} catch (NoSuchElementException nsee) {
; // Expected
}

View File

@ -38,6 +38,13 @@ import com.google.common.collect.ImmutableMap;
@Test(groups = "unit", testName = "RegionToEndpointOrProviderIfNullTest")
public class RegionToEndpointOrProviderIfNullTest {
@Test
public void testWhenRegionNameIsSameAsProviderName() throws SecurityException, NoSuchMethodException {
RegionToEndpointOrProviderIfNull fn = new RegionToEndpointOrProviderIfNull("leader", Suppliers.ofInstance(URI
.create("http://leader")), Suppliers.<Map<String, Supplier<URI>>>ofInstance(ImmutableMap.of("leader", Suppliers.ofInstance(URI.create("http://leaderregion")))));
assertEquals(fn.apply("leader"), URI.create("http://leaderregion"));
}
@Test
public void testWhenFindsRegion() throws SecurityException, NoSuchMethodException {
RegionToEndpointOrProviderIfNull fn = new RegionToEndpointOrProviderIfNull("leader", Suppliers.ofInstance(URI

View File

@ -49,7 +49,7 @@ public class ProvidersTest {
try {
providerMetadata = Providers.withId("fake-id");
fail("Looking for a provider with an id that doesn't exist should " + "throw an exceptoin.");
fail("Looking for a provider with an id that doesn't exist should " + "throw an exception.");
} catch (NoSuchElementException nsee) {
; // Expected
}

View File

@ -96,7 +96,7 @@ public class AsyncGaeHttpCommandExecutorService implements HttpCommandExecutorSe
request = filter.filter(request);
}
checkRequestHasContentLengthOrChunkedEncoding(request,
"After filtering, the request has niether chunked encoding nor content length: " + request);
"After filtering, the request has neither chunked encoding nor content length: " + request);
logger.debug("Sending request %s: %s", request.hashCode(), request.getRequestLine());
wirePayloadIfEnabled(wire, request);
HTTPRequest nativeRequest = convertToGaeRequest.apply(request);

View File

@ -36,16 +36,16 @@
<properties>
<test.aws-elb.endpoint>https://elasticloadbalancing.us-east-1.amazonaws.com</test.aws-elb.endpoint>
<test.aws-elb.api-version>2010-07-01</test.aws-elb.api-version>
<test.aws-elb.build-version />
<test.aws-elb.build-version></test.aws-elb.build-version>
<test.aws-elb.identity>${test.aws.identity}</test.aws-elb.identity>
<test.aws-elb.credential>${test.aws.credential}</test.aws-elb.credential>
<test.aws-elb.compute.provider>aws-ec2</test.aws-elb.compute.provider>
<test.aws-elb.compute.endpoint>https://ec2.us-east-1.amazonaws.com</test.aws-elb.compute.endpoint>
<test.aws-elb.compute.api-version>2010-06-15</test.aws-elb.compute.api-version>
<test.aws-elb.compute.build-version />
<test.aws-elb.compute.build-version></test.aws-elb.compute.build-version>
<test.aws-elb.compute.identity>${test.aws.identity}</test.aws-elb.compute.identity>
<test.aws-elb.compute.credential>${test.aws.credential}</test.aws-elb.compute.credential>
<test.aws-elb.compute.image-id />
<test.aws-elb.compute.template></test.aws-elb.compute.template>
<jclouds.osgi.export>org.jclouds.aws.elb*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
@ -134,7 +134,7 @@
<test.aws-elb.compute.api-version>${test.aws-elb.compute.api-version}</test.aws-elb.compute.api-version>
<test.aws-elb.compute.identity>${test.aws-elb.compute.identity}</test.aws-elb.compute.identity>
<test.aws-elb.compute.credential>${test.aws-elb.compute.credential}</test.aws-elb.compute.credential>
<test.aws-elb.compute.image-id>${test.aws-elb.compute.image-id}</test.aws-elb.compute.image-id>
<test.aws-elb.compute.template>${test.aws-elb.compute.template}</test.aws-elb.compute.template>
</systemPropertyVariables>
</configuration>
</execution>

View File

@ -39,15 +39,13 @@
<test.carrenza-vcloud-director.build-version>464915</test.carrenza-vcloud-director.build-version>
<test.carrenza-vcloud-director.identity>FIXME_IDENTITY</test.carrenza-vcloud-director.identity>
<test.carrenza-vcloud-director.credential>FIXME_CREDENTIAL</test.carrenza-vcloud-director.credential>
<test.carrenza-vcloud-director.image-id />
<test.carrenza-vcloud-director.image.login-user />
<test.carrenza-vcloud-director.image.authenticate-sudo />
<test.carrenza-vcloud-director.catalog-id />
<test.carrenza-vcloud-director.media-id />
<test.carrenza-vcloud-director.vapptemplate-id />
<test.carrenza-vcloud-director.network-name />
<test.carrenza-vcloud-director.network-id />
<test.carrenza-vcloud-director.vdc-id />
<test.carrenza-vcloud-director.template></test.carrenza-vcloud-director.template>
<test.carrenza-vcloud-director.catalog-id></test.carrenza-vcloud-director.catalog-id>
<test.carrenza-vcloud-director.media-id></test.carrenza-vcloud-director.media-id>
<test.carrenza-vcloud-director.vapptemplate-id></test.carrenza-vcloud-director.vapptemplate-id>
<test.carrenza-vcloud-director.network-name></test.carrenza-vcloud-director.network-name>
<test.carrenza-vcloud-director.network-id></test.carrenza-vcloud-director.network-id>
<test.carrenza-vcloud-director.vdc-id></test.carrenza-vcloud-director.vdc-id>
<jclouds.osgi.export>org.jclouds.carrenza.vcloud.director*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
@ -121,9 +119,7 @@
<test.carrenza-vcloud-director.build-version>${test.carrenza-vcloud-director.build-version}</test.carrenza-vcloud-director.build-version>
<test.carrenza-vcloud-director.identity>${test.carrenza-vcloud-director.identity}</test.carrenza-vcloud-director.identity>
<test.carrenza-vcloud-director.credential>${test.carrenza-vcloud-director.credential}</test.carrenza-vcloud-director.credential>
<test.carrenza-vcloud-director.image-id>${test.carrenza-vcloud-director.image-id}</test.carrenza-vcloud-director.image-id>
<test.carrenza-vcloud-director.image.login-user>${test.carrenza-vcloud-director.image.login-user}</test.carrenza-vcloud-director.image.login-user>
<test.carrenza-vcloud-director.image.authenticate-sudo>${test.carrenza-vcloud-director.image.authenticate-sudo}</test.carrenza-vcloud-director.image.authenticate-sudo>
<test.carrenza-vcloud-director.template>${test.carrenza-vcloud-director.template}</test.carrenza-vcloud-director.template>
<test.carrenza-vcloud-director.catalog-id>${test.carrenza-vcloud-director.catalog-id}</test.carrenza-vcloud-director.catalog-id>
<test.carrenza-vcloud-director.media-id>${test.carrenza-vcloud-director.media-id}</test.carrenza-vcloud-director.media-id>
<test.carrenza-vcloud-director.vapptemplate-id>${test.carrenza-vcloud-director.vapptemplate-id}</test.carrenza-vcloud-director.vapptemplate-id>

View File

@ -29,137 +29,144 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* The base type for all objects in the CDMI model.
*
* @author Adrian Cole
* @author Kenneth Nagin
*/
public class CDMIObject {
public static Builder<?> builder() {
return new ConcreteBuilder();
}
public static Builder<?> builder() {
return new ConcreteBuilder();
}
public Builder<?> toBuilder() {
return builder().fromCDMIObject(this);
}
public Builder<?> toBuilder() {
return builder().fromCDMIObject(this);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
}
public static abstract class Builder<B extends Builder<B>> {
private String objectID;
private String objectType;
private String objectName;
public static abstract class Builder<B extends Builder<B>> {
private String objectID;
private String objectType;
private String objectName;
@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}
@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}
/**
* @see CDMIObject#getObjectID()
*/
public B objectID(String objectID) {
this.objectID = objectID;
return self();
}
/**
* @see CDMIObject#getObjectID()
*/
public B objectID(String objectID) {
this.objectID = objectID;
return self();
}
/**
* @see CDMIObject#getObjectType()
*/
public B objectType(String objectType) {
this.objectType = objectType;
return self();
}
/**
* @see CDMIObject#getObjectType()
*/
public B objectType(String objectType) {
this.objectType = objectType;
return self();
}
/**
* @see CDMIObject#getObjectName()
*/
public B objectName(String objectName) {
this.objectName = objectName;
return self();
}
/**
* @see CDMIObject#getObjectName()
*/
public B objectName(String objectName) {
this.objectName = objectName;
return self();
}
public CDMIObject build() {
return new CDMIObject(this);
}
public CDMIObject build() {
return new CDMIObject(this);
}
protected B fromCDMIObject(CDMIObject in) {
return objectID(in.getObjectID()).objectType(in.getObjectType()).objectName(in.getObjectName());
}
}
protected B fromCDMIObject(CDMIObject in) {
return objectID(in.getObjectID()).objectType(in.getObjectType())
.objectName(in.getObjectName());
}
}
private final String objectID;
private final String objectType;
private final String objectName;
private final String objectID;
private final String objectType;
private final String objectName;
protected CDMIObject(Builder<?> builder) {
this.objectID = checkNotNull(builder.objectID, "objectID");
this.objectType = checkNotNull(builder.objectType, "objectType");
this.objectName = builder.objectName;
}
protected CDMIObject(Builder<?> builder) {
this.objectID = checkNotNull(builder.objectID, "objectID");
this.objectType = checkNotNull(builder.objectType, "objectType");
this.objectName = builder.objectName;
}
/**
* Object ID of the object <br/>
* Every object stored within a CDMI-compliant system shall have a globally unique object
* identifier (ID) assigned at creation time. The CDMI object ID is a string with requirements
* for how it is generated and how it obtains its uniqueness. Each offering that implements CDMI
* is able to produce these identifiers without conflicting with other offerings.
*/
public String getObjectID() {
return objectID;
}
/**
* Object ID of the object <br/>
* Every object stored within a CDMI-compliant system shall have a globally
* unique object identifier (ID) assigned at creation time. The CDMI object
* ID is a string with requirements for how it is generated and how it
* obtains its uniqueness. Each offering that implements CDMI is able to
* produce these identifiers without conflicting with other offerings.
*
* note: CDMI Servers do not always support ObjectID tags, however
* downstream jclouds code does not handle null so we return a empty String
* instead.
*/
public String getObjectID() {
return (objectID == null) ? "" : objectID;
}
/**
*
* type of the object
*/
public String getObjectType() {
return objectType;
}
/**
*
* type of the object
*/
public String getObjectType() {
return objectType;
}
/**
* For objects in a container, the objectName field shall be returned. For objects not in a
* container (objects that are only accessible by ID), the objectName field shall not be
* returned.
*
* Name of the object
*/
@Nullable
public String getObjectName() {
return objectName;
}
/**
* For objects in a container, the objectName field shall be returned. For
* objects not in a container (objects that are only accessible by ID), the
* objectName field shall not be returned.
*
* Name of the object
*/
@Nullable
public String getObjectName() {
return (objectName == null) ? "" : objectName;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CDMIObject that = CDMIObject.class.cast(o);
return equal(this.objectID, that.objectID) && equal(this.objectName, that.objectName)
&& equal(this.objectType, that.objectType);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CDMIObject that = CDMIObject.class.cast(o);
return equal(this.objectID, that.objectID)
&& equal(this.objectName, that.objectName)
&& equal(this.objectType, that.objectType);
}
public boolean clone(Object o) {
if (this == o)
return false;
if (o == null || getClass() != o.getClass())
return false;
CDMIObject that = CDMIObject.class.cast(o);
return equal(this.objectType, that.objectType);
}
public boolean clone(Object o) {
if (this == o)
return false;
if (o == null || getClass() != o.getClass())
return false;
CDMIObject that = CDMIObject.class.cast(o);
return equal(this.objectType, that.objectType);
}
@Override
public int hashCode() {
return Objects.hashCode(objectID, objectName, objectType);
}
@Override
public int hashCode() {
return Objects.hashCode(objectID, objectName, objectType);
}
@Override
public String toString() {
return string().toString();
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("objectID", objectID).add("objectName", objectName).add("objectType",
objectType);
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("objectID", objectID)
.add("objectName", objectName).add("objectType", objectType);
}
}

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