-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Update System VM template Guest OS version #11291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,11 +64,14 @@ | |||||||
| import com.cloud.dc.dao.DataCenterDaoImpl; | ||||||||
| import com.cloud.hypervisor.Hypervisor; | ||||||||
| import com.cloud.storage.DataStoreRole; | ||||||||
| import com.cloud.storage.GuestOSVO; | ||||||||
| import com.cloud.storage.Storage; | ||||||||
| import com.cloud.storage.Storage.ImageFormat; | ||||||||
| import com.cloud.storage.VMTemplateStorageResourceAssoc; | ||||||||
| import com.cloud.storage.VMTemplateVO; | ||||||||
| import com.cloud.storage.VMTemplateZoneVO; | ||||||||
| import com.cloud.storage.dao.GuestOSDao; | ||||||||
| import com.cloud.storage.dao.GuestOSDaoImpl; | ||||||||
| import com.cloud.storage.dao.VMTemplateDao; | ||||||||
| import com.cloud.storage.dao.VMTemplateDaoImpl; | ||||||||
| import com.cloud.storage.dao.VMTemplateZoneDao; | ||||||||
|
|
@@ -102,15 +105,14 @@ public class SystemVmTemplateRegistration { | |||||||
| private static final String PARTIAL_TEMPLATE_FOLDER = String.format("/template/tmpl/%d/", Account.ACCOUNT_ID_SYSTEM); | ||||||||
| private static final String storageScriptsDir = "scripts/storage/secondary"; | ||||||||
| private static final Integer OTHER_LINUX_ID = 99; | ||||||||
| private static final Integer LINUX_5_ID = 15; | ||||||||
| private static Integer LINUX_12_ID = 363; | ||||||||
| private static final Integer LINUX_7_ID = 183; | ||||||||
| 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 | ||||||||
| ); | ||||||||
|
|
||||||||
|
|
||||||||
| public static String CS_MAJOR_VERSION = null; | ||||||||
| public static String CS_TINY_VERSION = null; | ||||||||
|
|
||||||||
|
|
@@ -132,6 +134,8 @@ public class SystemVmTemplateRegistration { | |||||||
| ClusterDao clusterDao; | ||||||||
| @Inject | ||||||||
| ConfigurationDao configurationDao; | ||||||||
| @Inject | ||||||||
| private GuestOSDao guestOSDao; | ||||||||
|
|
||||||||
| private String systemVmTemplateVersion; | ||||||||
|
|
||||||||
|
|
@@ -147,6 +151,7 @@ public SystemVmTemplateRegistration() { | |||||||
| imageStoreDetailsDao = new ImageStoreDetailsDaoImpl(); | ||||||||
| clusterDao = new ClusterDaoImpl(); | ||||||||
| configurationDao = new ConfigurationDaoImpl(); | ||||||||
| guestOSDao = new GuestOSDaoImpl(); | ||||||||
| tempDownloadDir = new File(System.getProperty("java.io.tmpdir")); | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -331,13 +336,13 @@ public void setUpdated(Date updated) { | |||||||
| } | ||||||||
| }; | ||||||||
|
|
||||||||
| public static final Map<Hypervisor.HypervisorType, Integer> hypervisorGuestOsMap = new HashMap<Hypervisor.HypervisorType, Integer>() { | ||||||||
| public static Map<Hypervisor.HypervisorType, Integer> hypervisorGuestOsMap = new HashMap<Hypervisor.HypervisorType, Integer>() { | ||||||||
| { | ||||||||
| put(Hypervisor.HypervisorType.KVM, LINUX_5_ID); | ||||||||
| put(Hypervisor.HypervisorType.KVM, LINUX_12_ID); | ||||||||
| put(Hypervisor.HypervisorType.XenServer, OTHER_LINUX_ID); | ||||||||
| put(Hypervisor.HypervisorType.VMware, OTHER_LINUX_ID); | ||||||||
| put(Hypervisor.HypervisorType.Hyperv, LINUX_5_ID); | ||||||||
| put(Hypervisor.HypervisorType.LXC, LINUX_5_ID); | ||||||||
| put(Hypervisor.HypervisorType.Hyperv, LINUX_12_ID); | ||||||||
| put(Hypervisor.HypervisorType.LXC, LINUX_12_ID); | ||||||||
| put(Hypervisor.HypervisorType.Ovm3, LINUX_7_ID); | ||||||||
| } | ||||||||
| }; | ||||||||
|
|
@@ -595,6 +600,18 @@ public void updateSystemVMEntries(Long templateId, Hypervisor.HypervisorType hyp | |||||||
| vmInstanceDao.updateSystemVmTemplateId(templateId, hypervisorType); | ||||||||
| } | ||||||||
|
|
||||||||
| public void updateSystemVmTemplateGuestOsId() { | ||||||||
| String systemVmGuestOsName = "Debian GNU/Linux 12 (64-bit)"; | ||||||||
| GuestOSVO guestOS = guestOSDao.findOneByDisplayName(systemVmGuestOsName); | ||||||||
| if (guestOS != null) { | ||||||||
| LOGGER.debug("Updating SystemVM Template Guest OS [{}] id", systemVmGuestOsName); | ||||||||
| SystemVmTemplateRegistration.LINUX_12_ID = Math.toIntExact(guestOS.getId()); | ||||||||
| hypervisorGuestOsMap.put(Hypervisor.HypervisorType.KVM, LINUX_12_ID); | ||||||||
| hypervisorGuestOsMap.put(Hypervisor.HypervisorType.Hyperv, LINUX_12_ID); | ||||||||
| hypervisorGuestOsMap.put(Hypervisor.HypervisorType.LXC, LINUX_12_ID); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| public void updateConfigurationParams(Map<String, String> configParams) { | ||||||||
| for (Map.Entry<String, String> config : configParams.entrySet()) { | ||||||||
| boolean updated = configurationDao.update(config.getKey(), config.getValue()); | ||||||||
|
|
@@ -731,6 +748,7 @@ public void registerTemplateForNonExistingEntries(Hypervisor.HypervisorType hype | |||||||
| Long templateId = null; | ||||||||
| try { | ||||||||
| MetadataTemplateDetails templateDetails = getMetadataTemplateDetails(hypervisor, arch); | ||||||||
| updateSystemVmTemplateGuestOsId(); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry @sureshanaparti , could you please explain the reason for this? Wouldn't https://github.com/apache/cloudstack/pull/11291/files#diff-a9c9a38684718059c060de404bf9529de96e502f1e81b30793e6a32f725042a9R339 already handle it? I'm probably missing something.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. guest os id for debian 5 is hardcoded to 15 (very old entries), later user is allowed to add guest os and there are no hardcoded ids. if there are no user guest os added, the default id for debian 12 would be 363. this call will update the guest os id before registering the non existing systemvm templates. Moved this call to updateSystemVmTemplates().
cloudstack/engine/schema/src/main/resources/META-INF/db/schema-21to22.sql Lines 962 to 963 in 4aed972
|
||||||||
| templateId = performTemplateRegistrationOperations(hypervisor, name, | ||||||||
| templateDetails.getArch(), templateDetails.getUrl(), | ||||||||
| templateDetails.getChecksum(), hypervisorImageFormat.get(hypervisor), | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.