Set<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices().get(), diskType);
virtualGuestBuilder.blockDevices(blockDevices);
virtualGuestBuilder.localDiskFlag(isLocalDisk(diskType));
}
VirtualGuest virtualGuest = virtualGuestBuilder.build();
logger.debug(">> creating new VirtualGuest(%s)", virtualGuest);
VirtualGuest result = api.getVirtualGuestApi().createVirtualGuest(virtualGuest);
logger.trace("<< VirtualGuest(%s)", result.getId());
// tags
if (templateOptions.getTags() != null) {
api.getVirtualGuestApi().setTags(result.getId(), templateOptions.getTags());
}
logger.debug(">> awaiting login details for virtualGuest(%s)", result.getId());
boolean orderInSystem = loginDetailsTester.apply(result);
logger.trace("<< VirtualGuest(%s) complete(%s)", result.getId(), orderInSystem);
if (!orderInSystem) {
logger.warn("VirtualGuest(%s) doesn't have login details within %sms so it will be destroyed.", result,
Long.toString(guestLoginDelay));
api.getVirtualGuestApi().deleteVirtualGuest(result.getId());
throw new IllegalStateException(format("VirtualGuest(%s) is being destroyed as it doesn't have login details" +
" after %sms. Please, try by increasing `jclouds.softlayer.virtualguest.login_details_delay` and " +
" try again", result, Long.toString(guestLoginDelay)));
}
result = api.getVirtualGuestApi().getVirtualGuest(result.getId());
Password pwd = get(result.getOperatingSystem().getPasswords(), 0);
return new NodeAndInitialCredentials<VirtualGuest>(result, result.getId() + "",
LoginCredentials.builder().user(pwd.getUsername()).password(pwd.getPassword()).build());
}