}
private PersistentInstance buildPersistentInstanceTemplate() throws OpsException {
SshKey sshKey = service.getSshKey();
String securityGroup = service.getSecurityGroupName();
DiskImageRecipe recipeTemplate = diskImageRecipe.get();
if (recipeTemplate.getKey() == null) {
// TODO: Something nicer than a UUID
String recipeId = UUID.randomUUID().toString();
recipeTemplate.setKey(PlatformLayerKey.fromId(recipeId));
}
DiskImageRecipe recipe = imageFactory.getOrCreateRecipe(recipeTemplate);
PersistentInstance persistentInstanceTemplate = new PersistentInstance();
persistentInstanceTemplate.setDnsName(dnsName);
persistentInstanceTemplate.setSshPublicKey(SshKeys.serialize(sshKey.getKeyPair().getPublic()));
persistentInstanceTemplate.setSecurityGroup(securityGroup);
persistentInstanceTemplate.setMinimumRam(minimumMemoryMb);
persistentInstanceTemplate.setCloud(cloud);
persistentInstanceTemplate.setHostPolicy(hostPolicy);
persistentInstanceTemplate.setRecipe(recipe.getKey());
String id = dnsName;
if (Strings.isNullOrEmpty(id)) {
id = UUID.randomUUID().toString();
}