cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/object_store to dcbeea0
Date Thu, 11 Apr 2013 17:21:16 GMT
Updated Branches:
  refs/heads/object_store 02686583c -> dcbeea057


Extract a common routine to associate template to zones in
template_zone_ref table.

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

Branch: refs/heads/object_store
Commit: dcbeea057bf9096ca8bc51a9540a493898728922
Parents: 0268658
Author: Min Chen <min.chen@citrix.com>
Authored: Thu Apr 11 10:20:58 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Thu Apr 11 10:20:58 2013 -0700

----------------------------------------------------------------------
 .../storage/download/DownloadMonitorImpl.java      |   67 ++++++---------
 1 files changed, 27 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcbeea05/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
index 70254de..82665e3 100755
--- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
+++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
@@ -922,26 +922,7 @@ public class DownloadMonitorImpl extends ManagerBase implements  DownloadMonitor
                     tmpltStore.setSize(tmpltInfo.getSize());
                     tmpltStore.setPhysicalSize(tmpltInfo.getPhysicalSize());
                     _vmTemplateStoreDao.persist(tmpltStore);
-                    List<Long> dcs = new ArrayList<Long>();
-                    if (zoneId != null ){
-                        dcs.add(zoneId);
-                    }
-                    else{
-                        List<DataCenterVO> zones = _dcDao.listAll();
-                        for (DataCenterVO zone : zones){
-                            dcs.add(zone.getId());
-                        }
-                    }
-                    for (Long id : dcs) {
-                        VMTemplateZoneVO tmpltZoneVO = _vmTemplateZoneDao.findByZoneTemplate(id,
tmplt.getId());
-                        if (tmpltZoneVO == null) {
-                            tmpltZoneVO = new VMTemplateZoneVO(id, tmplt.getId(), new Date());
-                            _vmTemplateZoneDao.persist(tmpltZoneVO);
-                        } else {
-                            tmpltZoneVO.setLastUpdated(new Date());
-                            _vmTemplateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO);
-                        }
-                    }
+                    this.associateTemplateToZone(tmplt.getId(), zoneId);
                 }
 
                 continue;
@@ -953,26 +934,7 @@ public class DownloadMonitorImpl extends ManagerBase implements  DownloadMonitor
                 s_logger.info("Template Sync did not find " + uniqueName + " on the server
" + storeId + ", will request download shortly");
                 TemplateDataStoreVO templtStore = new TemplateDataStoreVO(storeId, tmplt.getId(),
new Date(), 0, Status.NOT_DOWNLOADED, null, null, null, null, tmplt.getUrl());
                 _vmTemplateStoreDao.persist(templtStore);
-                List<Long> dcs = new ArrayList<Long>();
-                if (zoneId != null ){
-                    dcs.add(zoneId);
-                }
-                else{
-                    List<DataCenterVO> zones = _dcDao.listAll();
-                    for (DataCenterVO zone : zones){
-                        dcs.add(zone.getId());
-                    }
-                }
-                for (Long id : dcs) {
-                    VMTemplateZoneVO tmpltZoneVO = _vmTemplateZoneDao.findByZoneTemplate(id,
tmplt.getId());
-                    if (tmpltZoneVO == null) {
-                        tmpltZoneVO = new VMTemplateZoneVO(id, tmplt.getId(), new Date());
-                        _vmTemplateZoneDao.persist(tmpltZoneVO);
-                    } else {
-                        tmpltZoneVO.setLastUpdated(new Date());
-                        _vmTemplateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO);
-                    }
-                }
+                this.associateTemplateToZone(tmplt.getId(), zoneId);
             }
 
         }
@@ -1105,5 +1067,30 @@ public class DownloadMonitorImpl extends ManagerBase implements  DownloadMonitor
 		}
 	}
 
+	// persist entry in template_zone_ref table. zoneId can be empty for region-wide image store,
in that case,
+	// we will associate the template to all the zones.
+	private void associateTemplateToZone(long templateId, Long zoneId){
+        List<Long> dcs = new ArrayList<Long>();
+        if (zoneId != null ){
+            dcs.add(zoneId);
+        }
+        else{
+            List<DataCenterVO> zones = _dcDao.listAll();
+            for (DataCenterVO zone : zones){
+                dcs.add(zone.getId());
+            }
+        }
+        for (Long id : dcs) {
+            VMTemplateZoneVO tmpltZoneVO = _vmTemplateZoneDao.findByZoneTemplate(id, templateId);
+            if (tmpltZoneVO == null) {
+                tmpltZoneVO = new VMTemplateZoneVO(id, templateId, new Date());
+                _vmTemplateZoneDao.persist(tmpltZoneVO);
+            } else {
+                tmpltZoneVO.setLastUpdated(new Date());
+                _vmTemplateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO);
+            }
+        }
+	}
+
 }
 


Mime
View raw message