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);
}