cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject [1/2] git commit: updated refs/heads/4.2 to 48c8e64
Date Sat, 10 Aug 2013 12:40:24 GMT
Updated Branches:
  refs/heads/4.2 3455a7623 -> 48c8e64ae
  refs/heads/master 3ba68a162 -> 5404bf606


CLOUDSTACK-4123: 3.0.6 to ASF 4.2 Upgrade: On Adding VMWare Cluster to the Setup, 3.0.6 System
VM Template for VMWare is downloaded instead of 4.2

Updating the new system template URLs for the existing templates during upgrade to 4.2.
If new 4.2 system template is registered before upgrade then marking the old templates as
removed during upgrade.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/48c8e64a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/48c8e64a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/48c8e64a

Branch: refs/heads/4.2
Commit: 48c8e64ae9c872d339b0fb8a2fc7fa453862fada
Parents: 3455a76
Author: Harikrishna Patnala <harikrishna.patnala@citrix.com>
Authored: Sat Aug 10 15:36:06 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Sat Aug 10 17:43:53 2013 +0530

----------------------------------------------------------------------
 .../cloud/storage/dao/VMTemplateDaoImpl.java    |  2 +-
 .../com/cloud/upgrade/dao/Upgrade412to420.java  | 30 ++++++++++++++++++++
 .../consoleproxy/ConsoleProxyManagerImpl.java   | 15 +++-------
 .../com/cloud/resource/ResourceManagerImpl.java |  2 ++
 .../secondary/SecondaryStorageManagerImpl.java  | 15 +++-------
 5 files changed, 41 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c8e64a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
index 9243225..2aca203 100755
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -334,6 +334,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
         tmpltTypeHyperSearch.done();
 
         readySystemTemplateSearch = createSearchBuilder();
+        readySystemTemplateSearch.and("removed", readySystemTemplateSearch.entity().getRemoved(),
SearchCriteria.Op.NULL);
         readySystemTemplateSearch.and("templateType", readySystemTemplateSearch.entity().getTemplateType(),
SearchCriteria.Op.EQ);
         SearchBuilder<TemplateDataStoreVO>  templateDownloadSearch = _templateDataStoreDao.createSearchBuilder();
         templateDownloadSearch.and("downloadState", templateDownloadSearch.entity().getDownloadState(),
SearchCriteria.Op.EQ);
@@ -800,7 +801,6 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
 
         if (tmplts.size() > 0) {
             if (hypervisorType == HypervisorType.Any) {
-                Collections.shuffle(tmplts);
                 return tmplts.get(0);
             }
             for (VMTemplateVO tmplt : tmplts) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c8e64a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
index d703cc3..501633a 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
@@ -301,6 +301,24 @@ public class Upgrade412to420 implements DbUpgrade {
                 }
             };
 
+            Map<HypervisorType, String> newTemplateUrl = new HashMap<HypervisorType,
String>(){
+                {   put(HypervisorType.XenServer, "http://download.cloud.com/templates/4.2/systemvmtemplate-2013-06-12-master-xen.vhd.bz2");
+                    put(HypervisorType.VMware, "http://download.cloud.com/templates/4.2/systemvmtemplate-4.2-vh7.ova");
+                    put(HypervisorType.KVM, "http://download.cloud.com/templates/4.2/systemvmtemplate-2013-06-12-master-kvm.qcow2.bz2");
+                    put(HypervisorType.LXC, "http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2");
+                    put(HypervisorType.Hyperv, "http://download.cloud.com/templates/4.2/systemvmtemplate-2013-06-12-master-xen.vhd.bz2");
+                }
+            };
+
+            Map<HypervisorType, String> newTemplateChecksum = new HashMap<HypervisorType,
String>(){
+                {   put(HypervisorType.XenServer, "fb1b6e032a160d86f2c28feb5add6d83");
+                    put(HypervisorType.VMware, "8fde62b1089e5844a9cd3b9b953f9596");
+                    put(HypervisorType.KVM, "6cea42b2633841648040becb588bd8f0");
+                    put(HypervisorType.LXC, "2755de1f9ef2ce4d6f2bee2efbb4da92");
+                    put(HypervisorType.Hyperv, "fb1b6e032a160d86f2c28feb5add6d83");
+                }
+            };
+
             for (Map.Entry<HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()){
                 s_logger.debug("Updating " + hypervisorAndTemplateName.getKey() + " System
Vms");
                 try {
@@ -312,6 +330,11 @@ public class Upgrade412to420 implements DbUpgrade {
                         long templateId = rs.getLong(1);
                         rs.close();
                         pstmt.close();
+                        // Mark the old system templates as removed
+                        pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` SET removed
= now() WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null");
+                        pstmt.setString(1, hypervisorAndTemplateName.getKey().toString());
+                        pstmt.executeUpdate();
+                        pstmt.close();
                         // change template type to SYSTEM
                         pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM'
where id = ?");
                         pstmt.setLong(1, templateId);
@@ -334,6 +357,13 @@ public class Upgrade412to420 implements DbUpgrade {
                             throw new CloudRuntimeException("4.2.0 " + hypervisorAndTemplateName.getKey()
+ " SystemVm template not found. Cannot upgrade system Vms");
                         } else {
                             s_logger.warn("4.2.0 " + hypervisorAndTemplateName.getKey() +
" SystemVm template not found. " + hypervisorAndTemplateName.getKey() + " hypervisor is not
used, so not failing upgrade");
+                            // Update the latest template URLs for corresponding hypervisor
+                            pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` SET
url = ? , checksum = ? WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null order
by id desc limit 1");
+                            pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
+                            pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
+                            pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
+                            pstmt.executeUpdate();
+                            pstmt.close();
                         }
                     }
                 } catch (SQLException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c8e64a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index a583954..c5c0c0c 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -647,17 +647,10 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements
ConsoleProxy
         }
 
         VMTemplateVO template = null;
-        HypervisorType defaultHypervisor = _resourceMgr.getDefaultHypervisor(dataCenterId);
-        if (defaultHypervisor != HypervisorType.None) {
-            template = _templateDao.findSystemVMReadyTemplate(dataCenterId, defaultHypervisor);
-            if (template == null) {
-                throw new CloudRuntimeException("Not able to find the System template or
not downloaded in zone " + dataCenterId + " corresponding to default System vm hypervisor
" + defaultHypervisor);
-            }
-        } else {
-            template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any);
-            if (template == null) {
-                throw new CloudRuntimeException("Not able to find the System templates or
not downloaded in zone " + dataCenterId);
-            }
+        HypervisorType availableHypervisor = _resourceMgr.getAvailableHypervisor(dataCenterId);
+        template = _templateDao.findSystemVMReadyTemplate(dataCenterId, availableHypervisor);
+        if (template == null) {
+             throw new CloudRuntimeException("Not able to find the System templates or not
downloaded in zone " + dataCenterId);
         }
 
         Map<String, Object> context = createProxyInstance(dataCenterId, template);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c8e64a/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index e5441af..d6069a4 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Collections;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
@@ -1394,6 +1395,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
         if (defaultHype == HypervisorType.None) {
             List<HypervisorType> supportedHypes = getSupportedHypervisorTypes(zoneId,
false, null);
             if (supportedHypes.size() > 0) {
+                Collections.shuffle(supportedHypes);
                 defaultHype = supportedHypes.get(0);
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c8e64a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
index 17cbf5c..3c1165b 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -572,17 +572,10 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements
Secondar
         }
 
         VMTemplateVO template = null;
-        HypervisorType defaultHypervisor = _resourceMgr.getDefaultHypervisor(dataCenterId);
-        if (defaultHypervisor != HypervisorType.None) {
-            template = _templateDao.findSystemVMReadyTemplate(dataCenterId, defaultHypervisor);
-            if (template == null) {
-                throw new CloudRuntimeException("Not able to find the System template or
not downloaded in zone " + dataCenterId + " corresponding to default System vm hypervisor
" + defaultHypervisor);
-            }
-        } else {
-            template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any);
-            if (template == null) {
-                throw new CloudRuntimeException("Not able to find the System templates or
not downloaded in zone " + dataCenterId);
-            }
+        HypervisorType availableHypervisor = _resourceMgr.getAvailableHypervisor(dataCenterId);
+        template = _templateDao.findSystemVMReadyTemplate(dataCenterId, availableHypervisor);
+        if (template == null) {
+            throw new CloudRuntimeException("Not able to find the System templates or not
downloaded in zone " + dataCenterId);
         }
 
         SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(),
name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,


Mime
View raw message