Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,19 @@ public class SystemVmTemplateRegistration {
private static Integer LINUX_12_ID = 363;
private static final Integer SCRIPT_TIMEOUT = 1800000;
private static final Integer LOCK_WAIT_TIMEOUT = 1200;
protected static final List<CPU.CPUArch> DOWNLOADABLE_TEMPLATE_ARCH_TYPES = Arrays.asList(
CPU.CPUArch.arm64
protected static final List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> AVAILABLE_SYSTEM_TEMPLATES_HYPERVISOR_ARCH_LIST = Arrays.asList(
new Pair<>(Hypervisor.HypervisorType.KVM, CPU.CPUArch.amd64),
new Pair<>(Hypervisor.HypervisorType.KVM, CPU.CPUArch.arm64),
new Pair<>(Hypervisor.HypervisorType.VMware, CPU.CPUArch.amd64),
new Pair<>(Hypervisor.HypervisorType.XenServer, CPU.CPUArch.amd64),
new Pair<>(Hypervisor.HypervisorType.Hyperv, CPU.CPUArch.amd64),
new Pair<>(Hypervisor.HypervisorType.LXC, CPU.CPUArch.amd64),
new Pair<>(Hypervisor.HypervisorType.Ovm3, CPU.CPUArch.amd64)
);
protected static final List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> DOWNLOADABLE_TEMPLATE_HYPERVISOR_ARCH_TYPES =
Arrays.asList(
new Pair<>(Hypervisor.HypervisorType.KVM, CPU.CPUArch.arm64)
);

public static String CS_MAJOR_VERSION = null;
public static String CS_TINY_VERSION = null;
Expand Down Expand Up @@ -148,9 +158,9 @@ public SystemVmTemplateRegistration() {
vmInstanceDao = new VMInstanceDaoImpl();
imageStoreDao = new ImageStoreDaoImpl();
imageStoreDetailsDao = new ImageStoreDetailsDaoImpl();
clusterDao = new ClusterDaoImpl();
configurationDao = new ConfigurationDaoImpl();
guestOSDao = new GuestOSDaoImpl();
clusterDao = new ClusterDaoImpl();
tempDownloadDir = new File(System.getProperty("java.io.tmpdir"));
}

Expand Down Expand Up @@ -857,7 +867,9 @@ protected File getTemplateFile(MetadataTemplateDetails templateDetails) {
return templateFile;
}
LOGGER.debug("{} is not present", templateFile.getAbsolutePath());
if (DOWNLOADABLE_TEMPLATE_ARCH_TYPES.contains(templateDetails.getArch()) &&
Pair<Hypervisor.HypervisorType, CPU.CPUArch> templateHypervisorAndArch =
new Pair<>(templateDetails.getHypervisorType(), templateDetails.getArch());
if (DOWNLOADABLE_TEMPLATE_HYPERVISOR_ARCH_TYPES.contains(templateHypervisorAndArch) &&
StringUtils.isNotBlank(templateDetails.getUrl())) {
LOGGER.debug("Downloading the template file {} for {}",
templateDetails.getUrl(), templateDetails.getHypervisorArchLog());
Expand Down Expand Up @@ -894,6 +906,11 @@ protected void validateTemplates(List<Pair<Hypervisor.HypervisorType, CPU.CPUArc
templatesFound = false;
break;
}
if (!AVAILABLE_SYSTEM_TEMPLATES_HYPERVISOR_ARCH_LIST.contains(hypervisorArch)) {
LOGGER.info("No system VM Template available for {}. Skipping validation.",
getHypervisorArchLog(hypervisorArch.first(), hypervisorArch.second()));
continue;
}
File tempFile = getTemplateFile(matchedTemplate);
if (tempFile == null) {
LOGGER.warn("Failed to download template for {}, moving ahead",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,15 @@ public void testValidateTemplates_fileFailure() {
systemVmTemplateRegistration.validateTemplates(list);
}

@Test
public void testValidateTemplates_downloadableFileNotFound() {
CPU.CPUArch arch = SystemVmTemplateRegistration.DOWNLOADABLE_TEMPLATE_ARCH_TYPES.get(0);
Pair<Hypervisor.HypervisorType, CPU.CPUArch> hypervisorTypeCPUArchPair = SystemVmTemplateRegistration.DOWNLOADABLE_TEMPLATE_HYPERVISOR_ARCH_TYPES.get(0);
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> list = new ArrayList<>();
list.add(new Pair<>(Hypervisor.HypervisorType.KVM, arch));
list.add(hypervisorTypeCPUArchPair);
SystemVmTemplateRegistration.MetadataTemplateDetails details =
Mockito.mock(SystemVmTemplateRegistration.MetadataTemplateDetails.class);
SystemVmTemplateRegistration.NewTemplateMap.put(SystemVmTemplateRegistration.getHypervisorArchKey(
Hypervisor.HypervisorType.KVM, arch), details);
hypervisorTypeCPUArchPair.first(), hypervisorTypeCPUArchPair.second()), details);
doReturn(null).when(systemVmTemplateRegistration).getTemplateFile(details);
systemVmTemplateRegistration.validateTemplates(list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
}
}
} catch (Exception e) {
logger.error("Failed to register systemVM template(s)");
logger.error("Failed to register systemVM template(s)", e);
} finally {
SystemVmTemplateRegistration.unmountStore(filePath);
txn.close();
Expand Down
Loading