assertTrue(cloudStackContext.utils().http().exists(uri), "does not exist: " + uri);
}
@Test(enabled = true)
public void testRegisterTemplate() throws Exception {
Zone zone = Iterables.getFirst(client.getZoneApi().listZones(), null);
assertNotNull(zone);
Iterable<Network> networks = client.getNetworkApi().listNetworks(ListNetworksOptions.Builder.zoneId(zone.getId()).isDefault(true));
networks = Iterables.filter(networks, new Predicate<Network>() {
@Override
public boolean apply(Network network) {
return network != null && network.getName().equals("Virtual Network");
}
});
assertEquals(Iterables.size(networks), 1);
Network network = Iterables.getOnlyElement(networks, null);
assertNotNull(network);
Set<OSType> osTypes = client.getGuestOSApi().listOSTypes();
OSType osType = Iterables.getFirst(osTypes, null);
// Register a template
RegisterTemplateOptions options = RegisterTemplateOptions.Builder.bits(32).isExtractable(true);
TemplateMetadata templateMetadata = TemplateMetadata.builder().name(prefix+"-registerTemplate").osTypeId(osType.getId()).displayText("jclouds live testRegisterTemplate").build();
Set<Template> templates = client.getTemplateApi().registerTemplate(templateMetadata, "VHD", "XenServer", IMPORT_VHD_URL, zone.getId(), options);
registeredTemplate = Iterables.getOnlyElement(templates, null);
assertNotNull(registeredTemplate);
// Ensure it is available
final String zoneId = zone.getId();
Predicate<Template> templateReadyPredicate = new Predicate<Template>() {
@Override
public boolean apply(Template template) {
if (template == null) return false;
Template t2 = client.getTemplateApi().getTemplateInZone(template.getId(), zoneId);