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
|
||||
protected EC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||
@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) {
|
||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
||||
this.imageMap = imageMap;
|
||||
|
@ -85,8 +85,7 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl {
|
|||
if (imageId != null) {
|
||||
String[] regionName = imageId.split("/");
|
||||
checkArgument(regionName.length == 2,
|
||||
"amazon image ids must include the region ( ex. us-east-1/ami-7ea24a17 ) you specified: "
|
||||
+ imageId);
|
||||
"amazon image ids must include the region ( ex. us-east-1/ami-7ea24a17 ) you specified: " + imageId);
|
||||
RegionAndName key = new RegionAndName(regionName[0], regionName[1]);
|
||||
try {
|
||||
return imageMap.get(key);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl {
|
|||
@Inject
|
||||
protected VCloudTemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||
@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) {
|
||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider);
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl {
|
|||
VCloudTemplateOptions eTo = VCloudTemplateOptions.class.cast(to);
|
||||
if (eFrom.getCustomizationScript() != null)
|
||||
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 {
|
||||
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);
|
||||
|
||||
|
@ -52,8 +53,8 @@ public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
|
|||
@Test(enabled = false)
|
||||
public static void checkGuestCustomization(GuestCustomizationSection result) {
|
||||
assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
|
||||
assertEquals(result.getHref(), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"));
|
||||
assertEquals(result.getHref(),
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"));
|
||||
assertEquals(result.getInfo(), "Specifies Guest OS Customization Settings");
|
||||
assertEquals(result.isEnabled(), new Boolean(true));
|
||||
assertEquals(result.shouldChangeSid(), new Boolean(false));
|
||||
|
@ -67,11 +68,11 @@ public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
|
|||
assertEquals(result.isAdminPasswordAuto(), new Boolean(true));
|
||||
assertEquals(result.getAdminPassword(), null);
|
||||
assertEquals(result.isResetPasswordRequired(), new Boolean(false));
|
||||
assertEquals(
|
||||
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.getCustomizationScript(), "cat > /root/foo.txt<<EOF\nI '\"love\"' {asc|!}*&\nEOF\n");
|
||||
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/")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
@Inject
|
||||
protected TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||
@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) {
|
||||
this.locations = locations;
|
||||
this.images = images;
|
||||
|
@ -400,16 +400,16 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
};
|
||||
static final Ordering<Image> DEFAULT_IMAGE_ORDERING = new Ordering<Image>() {
|
||||
public int compare(Image left, Image right) {
|
||||
return ComparisonChain.start().compare(left.getName(), right.getName(),
|
||||
Ordering.<String> natural().nullsLast()).compare(left.getVersion(), right.getVersion(),
|
||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getName(),
|
||||
right.getOperatingSystem().getName(),//
|
||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getVersion(),
|
||||
right.getOperatingSystem().getVersion(),//
|
||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getDescription(),
|
||||
right.getOperatingSystem().getDescription(),//
|
||||
Ordering.<String> natural().nullsLast()).compare(left.getOperatingSystem().getArch(),
|
||||
right.getOperatingSystem().getArch()).result();
|
||||
return ComparisonChain.start()
|
||||
.compare(left.getName(), right.getName(), Ordering.<String> natural().nullsLast())
|
||||
.compare(left.getVersion(), right.getVersion(), Ordering.<String> natural().nullsLast())
|
||||
.compare(left.getOperatingSystem().getName(), right.getOperatingSystem().getName(),//
|
||||
Ordering.<String> natural().nullsLast())
|
||||
.compare(left.getOperatingSystem().getVersion(), right.getOperatingSystem().getVersion(),//
|
||||
Ordering.<String> natural().nullsLast())
|
||||
.compare(left.getOperatingSystem().getDescription(), right.getOperatingSystem().getDescription(),//
|
||||
Ordering.<String> natural().nullsLast())
|
||||
.compare(left.getOperatingSystem().getArch(), right.getOperatingSystem().getArch()).result();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -840,9 +840,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
@VisibleForTesting
|
||||
boolean nothingChangedExceptOptions() {
|
||||
return osFamily == null && location == null && imageId == null && hardwareId == null && osName == null
|
||||
&& osDescription == null && imageVersion == null && osVersion == null && osArch == null
|
||||
&& os64Bit == null && imageName == null && imageDescription == null && minCores == 0 && minRam == 0
|
||||
&& !biggest && !fastest;
|
||||
&& osDescription == null && imageVersion == null && osVersion == null && osArch == null && os64Bit == null
|
||||
&& imageName == null && imageDescription == null && minCores == 0 && minRam == 0 && !biggest && !fastest;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -856,10 +855,10 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "[biggest=" + biggest + ", fastest=" + fastest + ", imageName=" + imageName + ", imageDescription="
|
||||
+ imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion + ", location="
|
||||
+ location + ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily + ", osName="
|
||||
+ osName + ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch
|
||||
+ ", os64Bit=" + os64Bit + ", hardwareId=" + hardwareId + "]";
|
||||
+ imageDescription + ", imageId=" + imageId + ", imageVersion=" + imageVersion + ", location=" + location
|
||||
+ ", minCores=" + minCores + ", minRam=" + minRam + ", osFamily=" + osFamily + ", osName=" + osName
|
||||
+ ", osDescription=" + osDescription + ", osVersion=" + osVersion + ", osArch=" + osArch + ", os64Bit="
|
||||
+ os64Bit + ", hardwareId=" + hardwareId + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl {
|
|||
@Inject
|
||||
protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
|
||||
@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) {
|
||||
super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue