public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
Template mutableTemplate = template.clone();
JoyentCloudTemplateOptions templateOptions = JoyentCloudTemplateOptions.class.cast(mutableTemplate.getOptions());
assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
templateOptions.userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);
String datacenter = mutableTemplate.getLocation().getId();
if (!templateOptions.shouldGenerateKey().isPresent())
templateOptions.generateKey(defaultToAutogenerateKeys);
if (templateOptions.shouldGenerateKey().get()) {
KeyAndPrivateKey keyPair = keyCache.getUnchecked(DatacenterAndName.fromDatacenterAndName(datacenter, namingConvention.create()
.sharedNameForGroup(group)));
// in order to delete the key later
keyCache.asMap().put(DatacenterAndName.fromDatacenterAndName(datacenter, keyPair.getKey().getName()), keyPair);
templateOptions.overrideLoginPrivateKey(keyPair.getPrivateKey());
}
checkArgument(templateOptions.getRunScript() == null || templateOptions.getLoginPrivateKey() != null,
"when specifying runScript, you must either set overrideLoginPrivateKey, or generateKey(true)");
return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses);
}