@Override
public NodeAndInitialCredentials<ServerInZone> createNodeWithGroupEncodedIntoName(String group, String name,
Template template) {
LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder();
NovaTemplateOptions templateOptions = template.getOptions().as(NovaTemplateOptions.class);
CreateServerOptions options = new CreateServerOptions();
options.metadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions()));
if (templateOptions.getSecurityGroupNames().isPresent())
options.securityGroupNames(templateOptions.getSecurityGroupNames().get());
options.userData(templateOptions.getUserData());
options.diskConfig(templateOptions.getDiskConfig());
Optional<String> privateKey = Optional.absent();
if (templateOptions.getKeyPairName() != null) {
options.keyPairName(templateOptions.getKeyPairName());
KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
if (keyPair != null && keyPair.getPrivateKey() != null) {
privateKey = Optional.of(keyPair.getPrivateKey());
credentialsBuilder.privateKey(privateKey.get());
}
}