mirror of
https://github.com/apache/jclouds.git
synced 2025-02-26 12:35:52 +00:00
Issue 662:ec2 ami query syntax from < 1.1.0 doesn't work on >= 1.1.0
This commit is contained in:
parent
99e7c86799
commit
648d2f4236
@ -83,10 +83,12 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
|
|||||||
if (props.containsKey(PROPERTY_EC2_AMI_OWNERS)) {
|
if (props.containsKey(PROPERTY_EC2_AMI_OWNERS)) {
|
||||||
StringBuilder query = new StringBuilder();
|
StringBuilder query = new StringBuilder();
|
||||||
String owners = properties.remove(PROPERTY_EC2_AMI_OWNERS).toString();
|
String owners = properties.remove(PROPERTY_EC2_AMI_OWNERS).toString();
|
||||||
if (!"*".equals(owners) && !"".equals(owners))
|
if ("*".equals(owners))
|
||||||
query.append("owner-id=").append(owners).append(';');
|
|
||||||
if (!"".equals(owners))
|
|
||||||
query.append("state=available;image-type=machine");
|
query.append("state=available;image-type=machine");
|
||||||
|
else if (!"".equals(owners))
|
||||||
|
query.append("owner-id=").append(owners).append(";state=available;image-type=machine");
|
||||||
|
else if ("".equals(owners))
|
||||||
|
query = new StringBuilder();
|
||||||
props.setProperty(PROPERTY_EC2_AMI_QUERY, query.toString());
|
props.setProperty(PROPERTY_EC2_AMI_QUERY, query.toString());
|
||||||
Logger.getAnonymousLogger().warning(
|
Logger.getAnonymousLogger().warning(
|
||||||
String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS,
|
String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS,
|
||||||
@ -97,7 +99,7 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
|
|||||||
protected void warnAndReplaceIfUsingOldCCImageKey(Properties props) {
|
protected void warnAndReplaceIfUsingOldCCImageKey(Properties props) {
|
||||||
if (props.containsKey(PROPERTY_EC2_CC_AMIs)) {
|
if (props.containsKey(PROPERTY_EC2_CC_AMIs)) {
|
||||||
String amis = properties.remove(PROPERTY_EC2_CC_AMIs).toString();
|
String amis = properties.remove(PROPERTY_EC2_CC_AMIs).toString();
|
||||||
String value = "image-id=" + amis.replace("us-east-1/", "");
|
String value = ("".equals(amis)) ? "" : "image-id=" + amis.replace("us-east-1/", "");
|
||||||
props.setProperty(PROPERTY_EC2_CC_AMI_QUERY, value);
|
props.setProperty(PROPERTY_EC2_CC_AMI_QUERY, value);
|
||||||
Logger.getAnonymousLogger().warning(
|
Logger.getAnonymousLogger().warning(
|
||||||
String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_CC_AMIs,
|
String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_CC_AMIs,
|
||||||
|
@ -37,6 +37,7 @@ import org.jclouds.compute.domain.Template;
|
|||||||
import org.jclouds.ec2.compute.predicates.EC2ImagePredicates;
|
import org.jclouds.ec2.compute.predicates.EC2ImagePredicates;
|
||||||
import org.jclouds.ec2.domain.InstanceType;
|
import org.jclouds.ec2.domain.InstanceType;
|
||||||
import org.jclouds.ec2.domain.RootDeviceType;
|
import org.jclouds.ec2.domain.RootDeviceType;
|
||||||
|
import org.jclouds.ec2.reference.EC2Constants;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@ -243,6 +244,42 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTemplateBuilderWithNoOwnersParsesImageOnDemandDeprecated() throws IOException {
|
||||||
|
ComputeServiceContext context = null;
|
||||||
|
try {
|
||||||
|
Properties overrides = setupProperties();
|
||||||
|
// set owners to nothing
|
||||||
|
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMIs, "");
|
||||||
|
overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
|
||||||
|
|
||||||
|
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet
|
||||||
|
.<Module> of(new Log4JLoggingModule()), overrides);
|
||||||
|
|
||||||
|
assertEquals(context.getComputeService().listImages().size(), 0);
|
||||||
|
|
||||||
|
Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5").build();
|
||||||
|
System.out.println(template.getHardware());
|
||||||
|
assert (template.getImage().getProviderId().startsWith("ami-")) : template;
|
||||||
|
assertEquals(template.getImage().getOperatingSystem().getVersion(), "5.4");
|
||||||
|
assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
|
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
|
||||||
|
assertEquals(template.getImage().getVersion(), "4.4.10");
|
||||||
|
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||||
|
assertEquals(template.getLocation().getId(), "us-east-1");
|
||||||
|
assertEquals(getCores(template.getHardware()), 2.0d);
|
||||||
|
assertEquals(template.getHardware().getId(), "m1.large"); // because it
|
||||||
|
// is 64bit
|
||||||
|
|
||||||
|
// ensure we cache the new image for next time
|
||||||
|
assertEquals(context.getComputeService().listImages().size(), 1);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if (context != null)
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilderWithLessRegions() throws IOException {
|
public void testTemplateBuilderWithLessRegions() throws IOException {
|
||||||
ComputeServiceContext context = null;
|
ComputeServiceContext context = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user