public T fromTemplate(Template in) { return this .id(in.getId()) .displayText(in.getDisplayText()) .domain(in.getDomain()) .domainId(in.getDomainId()) .account(in.getAccount()) .accountId(in.getAccountId()) .zone(in.getZone()) .zoneId(in.getZoneId()) .OSType(in.getOSType()) .OSTypeId(in.getOSTypeId()) .name(in.getName()) .type(in.getType()) .status(in.getStatus()) .format(in.getFormat()) .hypervisor(in.getHypervisor()) .size(in.getSize()) .created(in.getCreated()) .removed(in.getRemoved()) .crossZones(in.isCrossZones()) .bootable(in.isBootable()) .extractable(in.isExtractable()) .featured(in.isFeatured()) .isPublic(in.ispublic()) .ready(in.isReady()) .passwordEnabled(in.isPasswordEnabled()) .jobId(in.getJobId()) .jobStatus(in.getJobStatus()) .checksum(in.getChecksum())
@Override public Image apply(Template template) { checkNotNull(template, "template"); OperatingSystem os = templateToOperatingSystem.apply(template); ImageBuilder builder = new ImageBuilder().ids(template.getId() + "").name(template.getName()) .description(template.getDisplayText()).operatingSystem(os); if (!template.isCrossZones()) builder.location(FluentIterable.from(locations.get()).firstMatch(idEquals(template.getZoneId())).orNull()); //TODO: implement status mapping!!! builder.status(Status.AVAILABLE); return builder.build(); } }
for (Template template : response) { Template newDetails = Iterables.getOnlyElement(client.getTemplateClient().listTemplates( zoneId(template.getZoneId()).id(template.getId()))); Logger.CONSOLE.info("Checking template: " + template); assertEquals(template, client.getTemplateClient().getTemplateInZone(template.getId(), template.getZoneId())); assert template.getId() != null : template; assert template.getName() != null : template; assert template.getDisplayText() != null : template; assert template.getCreated() != null : template; assert template.getFormat() != null && template.getFormat() != Template.Format.UNRECOGNIZED : template; assert template.getOSType() != null : template; assert template.getOSTypeId() != null : template; assert template.getAccount() != null : template; assert template.getZone() != null : template; assert template.getZoneId() != null : template; assert (template.getStatus() == null || template.getStatus() == Template.Status.DOWNLOADED) : template; assert template.getType() != null && template.getType() != Template.Type.UNRECOGNIZED : template; assert template.getHypervisor() != null : template; assert template.getDomain() != null : template; assert template.getDomainId() != null : template; assert template.getSize() > 0 : template;
@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); }
public OperatingSystem apply(Template from) { Builder builder = OperatingSystem.builder().description(from.getOSType()); OSType type = osTypes.get().get(from.getOSTypeId()); if (type == null) { logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get()); return builder.build(); } builder.description(type.getDescription()); builder.is64Bit(type.getDescription().indexOf("64-bit") != -1); String osCategory = osCategories.get().get(type.getOSCategoryId()); if (osCategory == null) { logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get()); return builder.build(); } builder.name(osCategory); OsFamily family = OsFamily.fromValue(osCategory.toLowerCase()); builder.family(family); Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription()); if (matcher.find()) { builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap)); } return builder.build(); } }
@Override public int compareTo(Template o) { return id.compareTo(o.getId()); }
@Override public boolean apply(Template input) { return Predicates.in(acceptableHypervisorsInZone).apply(input.getHypervisor()); }
for (Template template : response) { Template newDetails = Iterables.getOnlyElement(client.getTemplateApi().listTemplates( zoneId(template.getZoneId()).id(template.getId()))); Logger.CONSOLE.info("Checking template: " + template); assertEquals(template, client.getTemplateApi().getTemplateInZone(template.getId(), template.getZoneId())); assert template.getId() != null : template; assert template.getName() != null : template; assert template.getDisplayText() != null : template; assert template.getCreated() != null : template; assert template.getFormat() != null && template.getFormat() != Template.Format.UNRECOGNIZED : template; assert template.getOSType() != null : template; assert template.getOSTypeId() != null : template; assert template.getAccount() != null : template; assert template.getZone() != null : template; assert template.getZoneId() != null : template; assert template.getStatus() == null || template.getStatus() == Template.Status.DOWNLOADED : template; assert template.getType() != null && template.getType() != Template.Type.UNRECOGNIZED : template; assert template.getHypervisor() != null : template; assert template.getDomain() != null : template; assert template.getDomainId() != null : template; assert template.getSize() > 0 : template;
@Override public Image apply(Template template) { checkNotNull(template, "template"); OperatingSystem os = templateToOperatingSystem.apply(template); ImageBuilder builder = new ImageBuilder().ids(template.getId() + "").name(template.getName()) .description(template.getDisplayText()).operatingSystem(os); if (!template.isCrossZones()) builder.location(FluentIterable.from(locations.get()).firstMatch(idEquals(template.getZoneId())).orNull()); //TODO: implement status mapping!!! builder.status(Status.AVAILABLE); return builder.build(); } }
@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); }
public OperatingSystem apply(Template from) { Builder builder = OperatingSystem.builder().description(from.getOSType()); OSType type = osTypes.get().get(from.getOSTypeId()); if (type == null) { logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get()); return builder.build(); } builder.description(type.getDescription()); builder.is64Bit(type.getDescription().indexOf("64-bit") != -1); String osCategory = osCategories.get().get(type.getOSCategoryId()); if (osCategory == null) { logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get()); return builder.build(); } builder.name(osCategory); OsFamily family = OsFamily.fromValue(osCategory.toLowerCase()); builder.family(family); Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription()); if (matcher.find()) { builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap)); } return builder.build(); } }
@Override public int compareTo(Template o) { return id.compareTo(o.getId()); }
@Override public boolean apply(Template input) { return Predicates.in(acceptableHypervisorsInZone).apply(input.getHypervisor()); }
public T fromTemplate(Template in) { return this .id(in.getId()) .displayText(in.getDisplayText()) .domain(in.getDomain()) .domainId(in.getDomainId()) .account(in.getAccount()) .accountId(in.getAccountId()) .zone(in.getZone()) .zoneId(in.getZoneId()) .OSType(in.getOSType()) .OSTypeId(in.getOSTypeId()) .name(in.getName()) .type(in.getType()) .status(in.getStatus()) .format(in.getFormat()) .hypervisor(in.getHypervisor()) .size(in.getSize()) .created(in.getCreated()) .removed(in.getRemoved()) .crossZones(in.isCrossZones()) .bootable(in.isBootable()) .extractable(in.isExtractable()) .featured(in.isFeatured()) .isPublic(in.ispublic()) .ready(in.isReady()) .passwordEnabled(in.isPasswordEnabled()) .jobId(in.getJobId()) .jobStatus(in.getJobStatus()) .checksum(in.getChecksum())
@Override public Image apply(Template template) { checkNotNull(template, "template"); OperatingSystem os = templateToOperatingSystem.apply(template); ImageBuilder builder = new ImageBuilder().ids(template.getId() + "").name(template.getName()) .description(template.getDisplayText()).operatingSystem(os); if (!template.isCrossZones()) builder.location(FluentIterable.from(locations.get()).firstMatch(idEquals(template.getZoneId())).orNull()); //TODO: implement status mapping!!! builder.status(Status.AVAILABLE); return builder.build(); } }
public OperatingSystem apply(Template from) { Builder builder = OperatingSystem.builder().description(from.getOSType()); OSType type = osTypes.get().get(from.getOSTypeId()); if (type == null) { logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get()); return builder.build(); } builder.description(type.getDescription()); builder.is64Bit(type.getDescription().indexOf("64-bit") != -1); String osCategory = osCategories.get().get(type.getOSCategoryId()); if (osCategory == null) { logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get()); return builder.build(); } builder.name(osCategory); OsFamily family = OsFamily.fromValue(osCategory.toLowerCase()); builder.family(family); Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription()); if (matcher.find()) { builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap)); } return builder.build(); } }
@Override public int compareTo(Template o) { return id.compareTo(o.getId()); }
@Override public boolean apply(Template input) { return Predicates.in(acceptableHypervisorsInZone).apply(input.getHypervisor()); }