cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject [3/4] git commit: updated refs/heads/4.1 to 3b5bcac
Date Fri, 12 Jul 2013 09:35:51 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/2963f047
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2963f047
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2963f047

Branch: refs/heads/4.1
Commit: 2963f0479e81d6202630cbcb99379311790e4981
Parents: 7b2f68e
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 11:31:20 2013 +0200

----------------------------------------------------------------------
 .../secondary/SecondaryStorageManagerImpl.java  |  7 +++++++
 .../cloud/storage/upload/UploadMonitorImpl.java | 21 +++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2963f047/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 fca89dc..6be6ecb 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -97,11 +97,13 @@ import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Storage;
+import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 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.dao.VMTemplateHostDao;
 import com.cloud.storage.resource.DummySecondaryStorageResource;
@@ -117,6 +119,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;
@@ -233,6 +236,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements
Secondar
     protected IPAddressDao _ipAddressDao = null;
     @Inject
     protected RulesManager _rulesMgr;
+    @Inject
+    UploadDao _uploadDao;
     
     @Inject
     KeystoreManager _keystoreMgr;
@@ -664,6 +669,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/2963f047/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 31f3e74..e431f15 100755
--- a/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
+++ b/server/src/com/cloud/storage/upload/UploadMonitorImpl.java
@@ -216,7 +216,26 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor
{
 	    //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 = ssvm.getPublicIpAddress().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(ssvm.getPublicIpAddress(), 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.	    


Mime
View raw message