@Override public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception { out.printf("CloudStack templates for provider %s\n", getProvider().getId()); for (Template template : client.getTemplateClient().listTemplates()) { out.printf("---\n%s\n", template.toString()); } out.println(); return null; } }
@Test(enabled = true, dependsOnMethods = "testRegisterTemplate") public void testExtractTemplate() throws Exception { // Initiate the extraction and wait for it to complete AsyncCreateResponse response = client.getTemplateClient().extractTemplate(registeredTemplate.getId(), ExtractMode.HTTP_DOWNLOAD, registeredTemplate.getZoneId()); assertTrue(jobComplete.apply(response.getJobId()), registeredTemplate.toString()); // Get the result AsyncJob<TemplateExtraction> asyncJob = client.getAsyncJobClient().getAsyncJob(response.getJobId()); TemplateExtraction extract = asyncJob.getResult(); assertNotNull(extract); // Check that the URL can be retrieved String extractUrl = extract.getUrl(); assertNotNull(extractUrl); URI uri = new URI(URLDecoder.decode(extractUrl, "utf-8")); assertTrue(cloudStackContext.utils().http().exists(uri), "does not exist: " + uri); }
@Test(enabled = true, dependsOnMethods = "testRegisterTemplate") public void testExtractTemplate() throws Exception { // Initiate the extraction and wait for it to complete AsyncCreateResponse response = client.getTemplateApi().extractTemplate(registeredTemplate.getId(), ExtractMode.HTTP_DOWNLOAD, registeredTemplate.getZoneId()); assertTrue(jobComplete.apply(response.getJobId()), registeredTemplate.toString()); // Get the result AsyncJob<TemplateExtraction> asyncJob = client.getAsyncJobApi().getAsyncJob(response.getJobId()); TemplateExtraction extract = asyncJob.getResult(); assertNotNull(extract); // Check that the URL can be retrieved String extractUrl = extract.getUrl(); assertNotNull(extractUrl); URI uri = new URI(URLDecoder.decode(extractUrl, "utf-8")); assertTrue(cloudStackContext.utils().http().exists(uri), "does not exist: " + uri); }