Remove sendToSSVM reference from SnapshotManagerImpl and
TemplateManagerImpl.

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

Branch: refs/heads/object_store
Commit: 79151f5f5d3e970993ecdcd7ded458bcabc29e48
Parents: 4c174a6
Author: Min Chen <[email protected]>
Authored: Wed Apr 24 17:45:32 2013 -0700
Committer: Min Chen <[email protected]>
Committed: Wed Apr 24 17:45:32 2013 -0700

----------------------------------------------------------------------
 .../driver/CloudStackImageStoreDriverImpl.java     |   11 +-
 .../storage/snapshot/SnapshotManagerImpl.java      |   12 +--
 .../com/cloud/template/TemplateManagerImpl.java    |   75 +--------------
 3 files changed, 11 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79151f5f/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git 
a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
 
b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
index 20ddd90..0ef735c 100644
--- 
a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
+++ 
b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
@@ -310,12 +310,13 @@ public class CloudStackImageStoreDriverImpl implements 
ImageStoreDriver {
                     callback.complete(result);
                 }
 
-                VMTemplateZoneVO templateZone = 
templateZoneDao.findByZoneTemplate(sZoneId, templateId);
-
-                if (templateZone != null) {
-                    templateZoneDao.remove(templateZone.getId());
+                List<VMTemplateZoneVO> templateZones = 
templateZoneDao.listByZoneTemplate(sZoneId, templateId);
+                if (templateZones != null) {
+                    for (VMTemplateZoneVO templateZone : templateZones) {
+                        templateZoneDao.remove(templateZone.getId());
+                    }
                 }
-            }
+             }
         }
 
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79151f5f/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java 
b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 4fa6834..11408f9 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -319,20 +319,14 @@ public class SnapshotManagerImpl extends ManagerBase 
implements SnapshotManager,
         return snapshot;
     }
 
-    private void checkObjectStorageConfiguration(SwiftTO swift, S3TO s3) {
-
-        if (swift != null && s3 != null) {
-            throw new CloudRuntimeException(
-                    "Swift and S3 are not simultaneously supported for 
snapshot backup.");
-        }
-
-    }
 
     @Override
     public void deleteSnapshotsDirForVolume(String secondaryStoragePoolUrl, 
Long dcId, Long accountId, Long volumeId) {
         DeleteSnapshotsDirCommand cmd = new 
DeleteSnapshotsDirCommand(secondaryStoragePoolUrl, dcId, accountId, volumeId);
         try {
-            Answer ans = _agentMgr.sendToSSVM(dcId, cmd);
+            DataStore store = this.dataStoreMgr.getImageStore(dcId);
+            EndPoint ep = _epSelector.select(store);
+            Answer ans = ep.sendMessage(cmd);
             if (ans == null || !ans.getResult()) {
                 s_logger.warn("DeleteSnapshotsDirCommand failed due to " + 
ans.getDetails() + " volume id: " + volumeId);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79151f5f/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java 
b/server/src/com/cloud/template/TemplateManagerImpl.java
index eb628a9..fb226c3 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -530,61 +530,6 @@ public class TemplateManagerImpl extends ManagerBase 
implements TemplateManager,
     }
 
 
-
-    String uploadTemplateToSwiftFromSecondaryStorage(VMTemplateHostVO 
templateHostRef) {
-        Long templateId = templateHostRef.getTemplateId();
-        VMTemplateVO template = _tmpltDao.findById(templateId);
-        if (template == null) {
-            String errMsg = " Can not find template " + templateId;
-            s_logger.warn(errMsg);
-            return errMsg;
-        }
-
-        if (template.getTemplateType() == TemplateType.PERHOST) {
-            return null;
-        }
-
-        SwiftTO swift = _swiftMgr.getSwiftTO();
-        if (swift == null) {
-            String errMsg = " There is no Swift in this setup ";
-            s_logger.warn(errMsg);
-            return errMsg;
-        }
-
-        HostVO secHost = _hostDao.findById(templateHostRef.getHostId());
-        if (secHost == null) {
-            String errMsg = "Can not find secondary storage " + 
templateHostRef.getHostId();
-            s_logger.warn(errMsg);
-            return errMsg;
-        }
-
-        uploadTemplateToSwiftFromSecondaryStorageCommand cmd = new 
uploadTemplateToSwiftFromSecondaryStorageCommand(swift, secHost.getName(), 
secHost.getDataCenterId(), template.getAccountId(),
-                templateId, _primaryStorageDownloadWait);
-        Answer answer = null;
-        try {
-            answer = _agentMgr.sendToSSVM(secHost.getDataCenterId(), cmd);
-            if (answer == null || !answer.getResult()) {
-                if (template.getTemplateType() != TemplateType.SYSTEM) {
-                    String errMsg = "Failed to upload template " + templateId 
+ " to Swift from secondary storage due to " + ((answer == null) ? "null" : 
answer.getDetails());
-                    s_logger.warn(errMsg);
-                    throw new CloudRuntimeException(errMsg);
-                }
-                return null;
-            }
-            String path = templateHostRef.getInstallPath();
-            int index = path.lastIndexOf('/');
-            path = path.substring(index + 1);
-            VMTemplateSwiftVO tmpltSwift = new 
VMTemplateSwiftVO(swift.getId(), templateHostRef.getTemplateId(), new Date(), 
path, templateHostRef.getSize(), templateHostRef.getPhysicalSize());
-            _tmpltSwiftDao.persist(tmpltSwift);
-            
_swiftMgr.propagateTemplateOnAllZones(templateHostRef.getTemplateId());
-        } catch (Exception e) {
-            String errMsg = "Failed to upload template " + templateId + " to 
Swift from secondary storage due to " + e.toString();
-            s_logger.warn(errMsg);
-            throw new CloudRuntimeException(errMsg);
-        }
-        return null;
-    }
-
     @Override @DB
     public VMTemplateStoragePoolVO prepareTemplateForCreate(VMTemplateVO 
templ, StoragePool pool) {
        VMTemplateVO template = _tmpltDao.findById(templ.getId(), true);
@@ -1182,30 +1127,14 @@ public class TemplateManagerImpl extends ManagerBase 
implements TemplateManager,
        if (template.getFormat() != ImageFormat.ISO) {
                throw new InvalidParameterValueException("Please specify a 
valid iso.");
        }
-        if (cmd.getZoneId() == null && _swiftMgr.isSwiftEnabled()) {
-            _swiftMgr.deleteIso(cmd);
-       }
-        if (cmd.getZoneId() == null && _s3Mgr.isS3Enabled()) {
-            _s3Mgr.deleteTemplate(caller.getAccountId(), templateId);
-        }
 
-       if (zoneId != null && (_ssvmMgr.findSecondaryStorageHost(zoneId) == 
null)) {
-               throw new InvalidParameterValueException("Failed to find a 
secondary storage host in the specified zone.");
+       if (zoneId != null && (this._dataStoreMgr.getImageStore(zoneId) == 
null)) {
+               throw new InvalidParameterValueException("Failed to find a 
secondary storage store in the specified zone.");
        }
        TemplateAdapter adapter = getAdapter(template.getHypervisorType());
        TemplateProfile profile = adapter.prepareDelete(cmd);
         boolean result = adapter.delete(profile);
         if (result) {
-            if (cmd.getZoneId() == null
-                    && (_swiftMgr.isSwiftEnabled() || _s3Mgr.isS3Enabled())) {
-                List<VMTemplateZoneVO> templateZones = _tmpltZoneDao
-                        .listByZoneTemplate(null, templateId);
-                if (templateZones != null) {
-                    for (VMTemplateZoneVO templateZone : templateZones) {
-                        _tmpltZoneDao.remove(templateZone.getId());
-                    }
-                }
-            }
             return true;
         } else {
                throw new CloudRuntimeException("Failed to delete ISO");

Reply via email to