cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject [2/3] git commit: updated refs/heads/4.2 to b2a077d
Date Fri, 12 Jul 2013 08:57:02 GMT
CLOUDSTACK-3368: clear download URLs when create SSVM and validate download URLs


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

Branch: refs/heads/4.2
Commit: b3ac91ef6391533e72c5a7524403dad5e65dddbf
Parents: 838cfa2
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Thu Jul 11 16:07:48 2013 +0200
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Fri Jul 12 10:43:49 2013 +0200

----------------------------------------------------------------------
 .../secondary/SecondaryStorageManagerImpl.java  |  7 +++++
 .../cloud/storage/upload/UploadMonitorImpl.java | 27 +++++++++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b3ac91ef/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 05256a8..6859b0b 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -98,9 +98,11 @@ import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.StoragePoolHostDao;
+import com.cloud.storage.dao.UploadDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.template.TemplateConstants;
 import com.cloud.template.TemplateManager;
@@ -114,6 +116,7 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria2;
 import com.cloud.utils.db.SearchCriteriaService;
 import com.cloud.utils.events.SubscriptionMgr;
@@ -225,6 +228,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements
Secondar
     protected RulesManager _rulesMgr;
     @Inject
     TemplateManager templateMgr;
+    @Inject
+    UploadDao _uploadDao;
 
     @Inject
     KeystoreManager _keystoreMgr;
@@ -658,6 +663,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements
Secondar
             if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
                 try {
                     secStorageVm = startNew(dataCenterId, role);
+                    for (UploadVO upload :_uploadDao.listAll())
+                        _uploadDao.expunge(upload.getId());
                 } finally {
                     _allocLock.unlock();
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b3ac91ef/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
index d46db0c..a589e7d 100755
--- a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
+++ b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
@@ -211,11 +211,33 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor
{
 	    boolean success = false;
 	    Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE ;
 
+            // find an endpoint to send command
+            DataStore store = this.storeMgr.getDataStore(vmTemplateHost.getDataStoreId(),
DataStoreRole.Image);
+            EndPoint ep = _epSelector.select(store);
 
 	    //Check if it already exists.
 	    List<UploadVO> extractURLList = _uploadDao.listByTypeUploadStatus(template.getId(),
type, UploadVO.Status.DOWNLOAD_URL_CREATED);
 	    if (extractURLList.size() > 0) {
-            return extractURLList.get(0);
+               // do some check here
+               UploadVO upload = extractURLList.get(0);
+               String uploadUrl = extractURLList.get(0).getUploadUrl();
+               String[] token = uploadUrl.split("/");
+               // example: uploadUrl = https://10-11-101-112.realhostip.com/userdata/2fdd9a70-9c4a-4a04-b1d5-1e41c221a1f9.iso
+               // then token[2] = 10-11-101-112.realhostip.com, token[4] = 2fdd9a70-9c4a-4a04-b1d5-1e41c221a1f9.iso
+               String hostname = ep.getPublicAddr().replace(".", "-") + ".";
+               if ((token != null) && (token.length == 5) && (token[2].equals(hostname
+ _ssvmUrlDomain))) // ssvm publicip and domain suffix not changed
+                   return extractURLList.get(0);
+               else if ((token != null) && (token.length == 5) && (token[2].startsWith(hostname)))
{ // domain suffix changed
+                   String uuid = token[4];
+                   uploadUrl = generateCopyUrl(ep.getPublicAddr(), uuid);
+                   UploadVO vo = _uploadDao.createForUpdate();
+                   vo.setLastUpdated(new Date());
+                   vo.setUploadUrl(uploadUrl);
+                   _uploadDao.update(upload.getId(), vo);
+                   return _uploadDao.findById(upload.getId(), true);
+               } else { // ssvm publicip changed
+                   return null;
+               }
         }
 
 	    // It doesn't exist so create a DB entry.
@@ -224,9 +246,6 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor
{
 	    uploadTemplateObj.setInstallPath(vmTemplateHost.getInstallPath());
 	    _uploadDao.persist(uploadTemplateObj);
 
-	    // find an endpoint to send command
-	    DataStore store = this.storeMgr.getDataStore(vmTemplateHost.getDataStoreId(), DataStoreRole.Image);
-	    EndPoint ep = _epSelector.select(store);
 	    try{
     	    // Create Symlink at ssvm
 	    	String path = vmTemplateHost.getInstallPath();


Mime
View raw message