6464import com .cloud .dc .dao .DataCenterDaoImpl ;
6565import com .cloud .hypervisor .Hypervisor ;
6666import com .cloud .storage .DataStoreRole ;
67+ import com .cloud .storage .GuestOSVO ;
6768import com .cloud .storage .Storage ;
6869import com .cloud .storage .Storage .ImageFormat ;
6970import com .cloud .storage .VMTemplateStorageResourceAssoc ;
7071import com .cloud .storage .VMTemplateVO ;
7172import com .cloud .storage .VMTemplateZoneVO ;
73+ import com .cloud .storage .dao .GuestOSDao ;
74+ import com .cloud .storage .dao .GuestOSDaoImpl ;
7275import com .cloud .storage .dao .VMTemplateDao ;
7376import com .cloud .storage .dao .VMTemplateDaoImpl ;
7477import com .cloud .storage .dao .VMTemplateZoneDao ;
@@ -101,16 +104,14 @@ public class SystemVmTemplateRegistration {
101104 public static final String TEMPORARY_SECONDARY_STORE = "tmp" ;
102105 private static final String PARTIAL_TEMPLATE_FOLDER = String .format ("/template/tmpl/%d/" , Account .ACCOUNT_ID_SYSTEM );
103106 private static final String storageScriptsDir = "scripts/storage/secondary" ;
104- private static final Integer OTHER_LINUX_ID = 99 ;
105- private static final Integer LINUX_5_ID = 15 ;
107+ private static Integer LINUX_12_ID = 363 ;
106108 private static final Integer LINUX_7_ID = 183 ;
107109 private static final Integer SCRIPT_TIMEOUT = 1800000 ;
108110 private static final Integer LOCK_WAIT_TIMEOUT = 1200 ;
109111 protected static final List <CPU .CPUArch > DOWNLOADABLE_TEMPLATE_ARCH_TYPES = Arrays .asList (
110112 CPU .CPUArch .arm64
111113 );
112114
113-
114115 public static String CS_MAJOR_VERSION = null ;
115116 public static String CS_TINY_VERSION = null ;
116117
@@ -132,6 +133,8 @@ public class SystemVmTemplateRegistration {
132133 ClusterDao clusterDao ;
133134 @ Inject
134135 ConfigurationDao configurationDao ;
136+ @ Inject
137+ private GuestOSDao guestOSDao ;
135138
136139 private String systemVmTemplateVersion ;
137140
@@ -147,6 +150,7 @@ public SystemVmTemplateRegistration() {
147150 imageStoreDetailsDao = new ImageStoreDetailsDaoImpl ();
148151 clusterDao = new ClusterDaoImpl ();
149152 configurationDao = new ConfigurationDaoImpl ();
153+ guestOSDao = new GuestOSDaoImpl ();
150154 tempDownloadDir = new File (System .getProperty ("java.io.tmpdir" ));
151155 }
152156
@@ -331,13 +335,13 @@ public void setUpdated(Date updated) {
331335 }
332336 };
333337
334- public static final Map <Hypervisor .HypervisorType , Integer > hypervisorGuestOsMap = new HashMap <Hypervisor .HypervisorType , Integer >() {
338+ public static Map <Hypervisor .HypervisorType , Integer > hypervisorGuestOsMap = new HashMap <Hypervisor .HypervisorType , Integer >() {
335339 {
336- put (Hypervisor .HypervisorType .KVM , LINUX_5_ID );
337- put (Hypervisor .HypervisorType .XenServer , OTHER_LINUX_ID );
338- put (Hypervisor .HypervisorType .VMware , OTHER_LINUX_ID );
339- put (Hypervisor .HypervisorType .Hyperv , LINUX_5_ID );
340- put (Hypervisor .HypervisorType .LXC , LINUX_5_ID );
340+ put (Hypervisor .HypervisorType .KVM , LINUX_12_ID );
341+ put (Hypervisor .HypervisorType .XenServer , LINUX_12_ID );
342+ put (Hypervisor .HypervisorType .VMware , LINUX_12_ID );
343+ put (Hypervisor .HypervisorType .Hyperv , LINUX_12_ID );
344+ put (Hypervisor .HypervisorType .LXC , LINUX_12_ID );
341345 put (Hypervisor .HypervisorType .Ovm3 , LINUX_7_ID );
342346 }
343347 };
@@ -595,6 +599,20 @@ public void updateSystemVMEntries(Long templateId, Hypervisor.HypervisorType hyp
595599 vmInstanceDao .updateSystemVmTemplateId (templateId , hypervisorType );
596600 }
597601
602+ public void updateSystemVmTemplateGuestOsId () {
603+ String systemVmGuestOsName = "Debian GNU/Linux 12 (64-bit)" ;
604+ GuestOSVO guestOS = guestOSDao .findOneByDisplayName (systemVmGuestOsName );
605+ if (guestOS != null ) {
606+ LOGGER .debug ("Updating SystemVM Template Guest OS [{}] id" , systemVmGuestOsName );
607+ SystemVmTemplateRegistration .LINUX_12_ID = Math .toIntExact (guestOS .getId ());
608+ hypervisorGuestOsMap .put (Hypervisor .HypervisorType .KVM , LINUX_12_ID );
609+ hypervisorGuestOsMap .put (Hypervisor .HypervisorType .XenServer , LINUX_12_ID );
610+ hypervisorGuestOsMap .put (Hypervisor .HypervisorType .VMware , LINUX_12_ID );
611+ hypervisorGuestOsMap .put (Hypervisor .HypervisorType .Hyperv , LINUX_12_ID );
612+ hypervisorGuestOsMap .put (Hypervisor .HypervisorType .LXC , LINUX_12_ID );
613+ }
614+ }
615+
598616 public void updateConfigurationParams (Map <String , String > configParams ) {
599617 for (Map .Entry <String , String > config : configParams .entrySet ()) {
600618 boolean updated = configurationDao .update (config .getKey (), config .getValue ());
@@ -731,6 +749,7 @@ public void registerTemplateForNonExistingEntries(Hypervisor.HypervisorType hype
731749 Long templateId = null ;
732750 try {
733751 MetadataTemplateDetails templateDetails = getMetadataTemplateDetails (hypervisor , arch );
752+ updateSystemVmTemplateGuestOsId ();
734753 templateId = performTemplateRegistrationOperations (hypervisor , name ,
735754 templateDetails .getArch (), templateDetails .getUrl (),
736755 templateDetails .getChecksum (), hypervisorImageFormat .get (hypervisor ),
0 commit comments