DaanHoogland commented on a change in pull request #4793:
URL: https://github.com/apache/cloudstack/pull/4793#discussion_r593047900



##########
File path: 
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41500to41510.java
##########
@@ -58,6 +66,175 @@ public boolean supportsRollingUpgrade() {
     public void performDataMigration(Connection conn) {
     }
 
+    @Override
+    @SuppressWarnings("serial")
+    public void updateSystemVmTemplates(final Connection conn) {
+        LOG.debug("Updating System Vm template IDs");
+        final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new 
HashSet<Hypervisor.HypervisorType>();
+        try (PreparedStatement pstmt = conn.prepareStatement("select 
distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); 
ResultSet rs = pstmt.executeQuery()) {
+            while (rs.next()) {
+                switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
+                    case XenServer:
+                        
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
+                        break;
+                    case KVM:
+                        
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
+                        break;
+                    case VMware:
+                        
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
+                        break;
+                    case Hyperv:
+                        
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
+                        break;
+                    case LXC:
+                        
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
+                        break;
+                    case Ovm3:
+                        
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        } catch (final SQLException e) {
+            LOG.error("updateSystemVmTemplates: Exception caught while getting 
hypervisor types from clusters: " + e.getMessage());
+            throw new CloudRuntimeException("updateSystemVmTemplates:Exception 
while getting hypervisor types from clusters", e);
+        }
+
+        final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new 
HashMap<Hypervisor.HypervisorType, String>() {
+            {
+                put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.15.1");
+                put(Hypervisor.HypervisorType.VMware, 
"systemvm-vmware-4.15.1");
+                put(Hypervisor.HypervisorType.XenServer, 
"systemvm-xenserver-4.15.1");
+                put(Hypervisor.HypervisorType.Hyperv, 
"systemvm-hyperv-4.15.1");
+                put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.15.1");
+                put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.15.1");
+            }
+        };
+
+        final Map<Hypervisor.HypervisorType, String> 
routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, 
String>() {
+            {
+                put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
+                put(Hypervisor.HypervisorType.VMware, 
"router.template.vmware");
+                put(Hypervisor.HypervisorType.XenServer, 
"router.template.xenserver");
+                put(Hypervisor.HypervisorType.Hyperv, 
"router.template.hyperv");
+                put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
+                put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
+            }
+        };
+
+        final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new 
HashMap<Hypervisor.HypervisorType, String>() {
+            {
+                put(Hypervisor.HypervisorType.KVM, 
"https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2";);
+                put(Hypervisor.HypervisorType.VMware, 
"https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-vmware.ova";);
+                put(Hypervisor.HypervisorType.XenServer, 
"https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-xen.vhd.bz2";);
+                put(Hypervisor.HypervisorType.Hyperv, 
"https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-hyperv.vhd.zip";);
+                put(Hypervisor.HypervisorType.LXC, 
"https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-kvm.qcow2.bz2";);
+                put(Hypervisor.HypervisorType.Ovm3, 
"https://download.cloudstack.org/systemvm/4.15/systemvmtemplate-4.15.1-ovm.raw.bz2";);
+            }
+        };
+
+        final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new 
HashMap<Hypervisor.HypervisorType, String>() {
+            {
+                put(Hypervisor.HypervisorType.KVM, 
"0e9f9a7d0957c3e0a2088e41b2da2cec");
+                put(Hypervisor.HypervisorType.XenServer, 
"86373992740b1eca8aff8b08ebf3aea5");
+                put(Hypervisor.HypervisorType.VMware, 
"4006982765846d373eb3719b2fe4d720");
+                put(Hypervisor.HypervisorType.Hyperv, 
"0b9514e4b6cba1f636fea2125f0f7a5f");
+                put(Hypervisor.HypervisorType.LXC, 
"0e9f9a7d0957c3e0a2088e41b2da2cec");
+                put(Hypervisor.HypervisorType.Ovm3, 
"ae3977e696b3e6c81bdcbb792d514d29");
+            }
+        };
+
+        for (final Map.Entry<Hypervisor.HypervisorType, String> 
hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
+            LOG.debug("Updating " + hypervisorAndTemplateName.getKey() + " 
System Vms");
+            try (PreparedStatement pstmt = conn.prepareStatement("select id 
from `cloud`.`vm_template` where name = ? and removed is null order by id desc 
limit 1")) {

Review comment:
       what would be the issue, @rhtyd? except that the account used will fail 
registering systemvm templates?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to