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 bc244cc
Date Mon, 06 May 2013 02:21:39 GMT
Updated Branches:
  refs/heads/object_store a221ecb48 -> bc244ccc8


Populate template_zone_ref for those cross-zone templates while adding
an image store.

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

Branch: refs/heads/object_store
Commit: bc244ccc8bae28eaca93558eb25ce68829f54650
Parents: a221ecb
Author: Min Chen <min.chen@citrix.com>
Authored: Sun May 5 19:21:09 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Sun May 5 19:21:09 2013 -0700

----------------------------------------------------------------------
 .../src/com/cloud/storage/StorageManagerImpl.java  |   36 +++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc244ccc/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 798ee56..9f5d2fe 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -25,6 +25,7 @@ import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -147,6 +148,7 @@ import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VMTemplatePoolDao;
 import com.cloud.storage.dao.VMTemplateS3Dao;
 import com.cloud.storage.dao.VMTemplateSwiftDao;
+import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.listener.StoragePoolMonitor;
 import com.cloud.storage.listener.VolumeStateListener;
@@ -222,6 +224,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
     @Inject
     protected VMTemplatePoolDao _vmTemplatePoolDao = null;
     @Inject
+    protected VMTemplateZoneDao _vmTemplateZoneDao;
+    @Inject
     protected VMTemplateSwiftDao _vmTemplateSwiftDao = null;
     @Inject
     protected VMTemplateS3Dao _vmTemplateS3Dao;
@@ -1925,9 +1929,41 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
             this._imageSrv.addSystemVMTemplatesToSecondary(store);
         }
 
+        // associate builtin template with zones associated with this image store
+        this.associateCrosszoneTemplatesToZone(dcId);
+
         return (ImageStore) _dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Image);
     }
 
+    private void associateCrosszoneTemplatesToZone(Long zoneId){
+        VMTemplateZoneVO tmpltZone;
+
+        List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
+        List<Long> dcIds = new ArrayList<Long>();
+        if (zoneId != null) {
+            dcIds.add(zoneId);
+        } else {
+            List<DataCenterVO> dcs = _dcDao.listAll();
+            if (dcs != null) {
+                for (DataCenterVO dc : dcs) {
+                    dcIds.add(dc.getId());
+                }
+            }
+        }
+
+        for (VMTemplateVO vt : allTemplates) {
+            if (vt.isCrossZones()) {
+                for (Long dcId : dcIds) {
+                    tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
+                    if (tmpltZone == null) {
+                        VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(),
new Date());
+                        _vmTemplateZoneDao.persist(vmTemplateZone);
+                    }
+                }
+            }
+        }
+    }
+
     @Override
     public boolean deleteImageStore(DeleteImageStoreCmd cmd) {
         long storeId = cmd.getId();


Mime
View raw message