mirror of https://github.com/apache/jclouds.git
Issue 497:revise template options on a per-provider basis
This commit is contained in:
parent
e3e0ad3e84
commit
59c0dbb6cd
|
@ -53,7 +53,7 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
protected EC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||||
Supplier<Location> defaultLocation, Provider<TemplateOptions> optionsProvider,
|
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Map<RegionAndName, Image> imageMap) {
|
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Map<RegionAndName, Image> imageMap) {
|
||||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
||||||
this.imageMap = imageMap;
|
this.imageMap = imageMap;
|
||||||
|
@ -85,8 +85,7 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
||||||
if (imageId != null) {
|
if (imageId != null) {
|
||||||
String[] regionName = imageId.split("/");
|
String[] regionName = imageId.split("/");
|
||||||
checkArgument(regionName.length == 2,
|
checkArgument(regionName.length == 2,
|
||||||
"amazon image ids must include the region ( ex. us-east-1/ami-7ea24a17 ) you specified: "
|
"amazon image ids must include the region ( ex. us-east-1/ami-7ea24a17 ) you specified: " + imageId);
|
||||||
+ imageId);
|
|
||||||
RegionAndName key = new RegionAndName(regionName[0], regionName[1]);
|
RegionAndName key = new RegionAndName(regionName[0], regionName[1]);
|
||||||
try {
|
try {
|
||||||
return imageMap.get(key);
|
return imageMap.get(key);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl {
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudTemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
protected VCloudTemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||||
Supplier<Location> defaultLocation, Provider<TemplateOptions> optionsProvider,
|
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
|
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
|
||||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,8 @@ public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl {
|
||||||
VCloudTemplateOptions eTo = VCloudTemplateOptions.class.cast(to);
|
VCloudTemplateOptions eTo = VCloudTemplateOptions.class.cast(to);
|
||||||
if (eFrom.getCustomizationScript() != null)
|
if (eFrom.getCustomizationScript() != null)
|
||||||
eTo.customizationScript(eFrom.getCustomizationScript());
|
eTo.customizationScript(eFrom.getCustomizationScript());
|
||||||
|
if (eFrom.getIpAddressAllocationMode() != null)
|
||||||
|
eTo.ipAddressAllocationMode(eFrom.getIpAddressAllocationMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@ public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
|
||||||
public void testDefault() throws UnknownHostException {
|
public void testDefault() throws UnknownHostException {
|
||||||
InputStream is = getClass().getResourceAsStream("/guestCustomization.xml");
|
InputStream is = getClass().getResourceAsStream("/guestCustomization.xml");
|
||||||
|
|
||||||
GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class)).parse(is);
|
GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class))
|
||||||
|
.parse(is);
|
||||||
|
|
||||||
checkGuestCustomization(result);
|
checkGuestCustomization(result);
|
||||||
|
|
||||||
|
@ -52,8 +53,8 @@ public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public static void checkGuestCustomization(GuestCustomizationSection result) {
|
public static void checkGuestCustomization(GuestCustomizationSection result) {
|
||||||
assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
|
assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
|
||||||
assertEquals(result.getHref(), URI
|
assertEquals(result.getHref(),
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"));
|
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"));
|
||||||
assertEquals(result.getInfo(), "Specifies Guest OS Customization Settings");
|
assertEquals(result.getInfo(), "Specifies Guest OS Customization Settings");
|
||||||
assertEquals(result.isEnabled(), new Boolean(true));
|
assertEquals(result.isEnabled(), new Boolean(true));
|
||||||
assertEquals(result.shouldChangeSid(), new Boolean(false));
|
assertEquals(result.shouldChangeSid(), new Boolean(false));
|
||||||
|
@ -67,11 +68,11 @@ public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
|
||||||
assertEquals(result.isAdminPasswordAuto(), new Boolean(true));
|
assertEquals(result.isAdminPasswordAuto(), new Boolean(true));
|
||||||
assertEquals(result.getAdminPassword(), null);
|
assertEquals(result.getAdminPassword(), null);
|
||||||
assertEquals(result.isResetPasswordRequired(), new Boolean(false));
|
assertEquals(result.isResetPasswordRequired(), new Boolean(false));
|
||||||
assertEquals(
|
assertEquals(result.getCustomizationScript(), "cat > /root/foo.txt<<EOF\nI '\"love\"' {asc|!}*&\nEOF\n");
|
||||||
result.getCustomizationScript(),
|
|
||||||
"#!/bin/bash if [[ $1 == \"postcustomization\" ]]; then echo \"post customization\" touch /root/.postcustomization ping www.redhat.com -c 1 sleep 30 # register with RHN /usr/sbin/rhnreg_ks --profilename vic_`hostname`_`dmidecode -s system-uuid` --activationkey=XXXXXXXXXXXX --force echo \"rhn registered\" # make hostname fully qualified to speed up sendmail start perl -i -pe \"s/`hostname`/`hostname`.victory.blk/g\" /etc/sysconfig/network rm /etc/ssh/*_key* service sshd restart echo \"completed\" fi");
|
|
||||||
assertEquals(result.getComputerName(), "RHEL5");
|
assertEquals(result.getComputerName(), "RHEL5");
|
||||||
assertEquals(result.getEdit(), new ReferenceTypeImpl(null, VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML, URI
|
assertEquals(
|
||||||
|
result.getEdit(),
|
||||||
|
new ReferenceTypeImpl(null, VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML, URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/")));
|
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@Inject
|
@Inject
|
||||||
protected TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
protected TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares,
|
||||||
Supplier<Location> defaultLocation2, Provider<TemplateOptions> optionsProvider,
|
Supplier<Location> defaultLocation2, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
|
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider) {
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
this.images = images;
|
this.images = images;
|
||||||
|
@ -400,16 +400,16 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
};
|
};
|
||||||
static final Ordering<Image> DEFAULT_IMAGE_ORDERING = new Ordering<Image>() {
|
static final Ordering<Image> DEFAULT_IMAGE_ORDERING = new Ordering<Image>() {
|
||||||
public int compare(Image left, Image right) {
|
public int compare(Image left, Image right) {
|
||||||
return ComparisonChain.start().compare(left.getName(), right.getName(),
|
return ComparisonChain.start()
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getVersion(), right.getVersion(),
|
.compare(left.getName(), right.getName(), Ordering.<String> natural().nullsLast())
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getName(),
|
.compare(left.getVersion(), right.getVersion(), Ordering.<String> natural().nullsLast())
|
||||||
right.getOperatingSystem().getName(),//
|
.compare(left.getOperatingSystem().getName(), right.getOperatingSystem().getName(),//
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getVersion(),
|
Ordering.<String> natural().nullsLast())
|
||||||
right.getOperatingSystem().getVersion(),//
|
.compare(left.getOperatingSystem().getVersion(), right.getOperatingSystem().getVersion(),//
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getDescription(),
|
Ordering.<String> natural().nullsLast())
|
||||||
right.getOperatingSystem().getDescription(),//
|
.compare(left.getOperatingSystem().getDescription(), right.getOperatingSystem().getDescription(),//
|
||||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getArch(),
|
Ordering.<String> natural().nullsLast())
|
||||||
right.getOperatingSystem().getArch()).result();
|
.compare(left.getOperatingSystem().getArch(), right.getOperatingSystem().getArch()).result();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -840,9 +840,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean nothingChangedExceptOptions() {
|
boolean nothingChangedExceptOptions() {
|
||||||
return osFamily == null && location == null && imageId == null && hardwareId == null && osName == null
|
return osFamily == null && location == null && imageId == null && hardwareId == null && osName == null
|
||||||
&& osDescription == null && imageVersion == null && osVersion == null && osArch == null
|
&& osDescription == null && imageVersion == null && osVersion == null && osArch == null && os64Bit == null
|
||||||
&& os64Bit == null && imageName == null && imageDescription == null && minCores == 0 && minRam == 0
|
&& imageName == null && imageDescription == null && minCores == 0 && minRam == 0 && !biggest && !fastest;
|
||||||
&& !biggest && !fastest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -856,10 +855,10 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName + ", imageDescription="
|
return "[biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName + ", imageDescription="
|
||||||
+ imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion + ", location="
|
+ imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion + ", location=" + location
|
||||||
+ location + ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily + ", osName="
|
+ ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily + ", osName=" + osName
|
||||||
+ osName + ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch
|
+ ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch + ", os64Bit="
|
||||||
+ ", os64Bit=" + os64Bit + ", hardwareId=" + hardwareId + "]";
|
+ os64Bit + ", hardwareId=" + hardwareId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl {
|
||||||
@Inject
|
@Inject
|
||||||
protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||||
Supplier<Location> defaultLocation, Provider<TemplateOptions> optionsProvider,
|
Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
|
||||||
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Map<RegionAndName, Image> imageMap) {
|
@Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Map<RegionAndName, Image> imageMap) {
|
||||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
|
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue