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/4.2-forward to ad1633d
Date Wed, 28 Aug 2013 18:26:26 GMT
Updated Branches:
  refs/heads/4.2-forward 63c8b147f -> ad1633dda


CLOUDSTACK-4430:[Automation][vmware] Failed to deploy vm, if one host is
down in a cluster.


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

Branch: refs/heads/4.2-forward
Commit: ad1633dda9f2f0ba5a1cf6e065b87a2f5978fb93
Parents: 63c8b14
Author: Min Chen <min.chen@citrix.com>
Authored: Wed Aug 28 11:17:29 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Wed Aug 28 11:18:01 2013 -0700

----------------------------------------------------------------------
 .../cloud/storage/VMTemplateStoragePoolVO.java  |  5 ++++
 .../storage/volume/VolumeServiceImpl.java       | 31 ++++++++++++++++++--
 2 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad1633dd/engine/schema/src/com/cloud/storage/VMTemplateStoragePoolVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateStoragePoolVO.java b/engine/schema/src/com/cloud/storage/VMTemplateStoragePoolVO.java
index 9331b03..b9886e0 100644
--- a/engine/schema/src/com/cloud/storage/VMTemplateStoragePoolVO.java
+++ b/engine/schema/src/com/cloud/storage/VMTemplateStoragePoolVO.java
@@ -266,6 +266,11 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
         return this.state;
     }
 
+    //TODO: this should be revisited post-4.2 to completely use state transition machine
+    public void setState(ObjectInDataStoreStateMachine.State state) {
+        this.state = state;
+    }
+
     public long getUpdatedCount() {
         return this.updatedCount;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad1633dd/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 8a97c1e..1e68589 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -49,6 +49,7 @@ import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.framework.async.AsyncRpcContext;
 import org.apache.cloudstack.storage.command.CommandResult;
+import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.datastore.DataObjectManager;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
@@ -516,17 +517,41 @@ public class VolumeServiceImpl implements VolumeService {
             AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback,
             CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
         DataObject vo = context.vo;
+        DataObject tmplOnPrimary = context.templateOnStore;
         CopyCommandResult result = callback.getResult();
         VolumeApiResult volResult = new VolumeApiResult((VolumeObject) vo);
 
         if (result.isSuccess()) {
             vo.processEvent(Event.OperationSuccessed, result.getAnswer());
-        } else {
-
+        } else {            
             vo.processEvent(Event.OperationFailed);
             volResult.setResult(result.getResult());
+            // hack for Vmware: host is down, previously download template to the host needs
to be re-downloaded, so we need to reset
+            // template_spool_ref entry here to NOT_DOWNLOADED and Allocated state
+            Answer ans = result.getAnswer();
+            if ( ans != null && ans instanceof CopyCmdAnswer && ans.getDetails().contains("request
template reload")){
+                if (tmplOnPrimary != null){
+                    s_logger.info("Reset template_spool_ref entry so that vmware template
can be reloaded in next try");
+                    VMTemplateStoragePoolVO templatePoolRef = _tmpltPoolDao.findByPoolTemplate(tmplOnPrimary.getDataStore().getId(),
tmplOnPrimary.getId());
+                    if (templatePoolRef != null) {
+                        long templatePoolRefId = templatePoolRef.getId();
+                        templatePoolRef = _tmpltPoolDao.acquireInLockTable(templatePoolRefId,
1200);
+                        if (templatePoolRef == null) {
+                            s_logger.warn("Reset Template State On Pool failed - unable to
lock TemplatePoolRef " + templatePoolRefId);
+                        }
+                        
+                        try {
+                            templatePoolRef.setDownloadState(VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED);
+                            templatePoolRef.setState(ObjectInDataStoreStateMachine.State.Allocated);
+                            _tmpltPoolDao.update(templatePoolRefId, templatePoolRef);
+                        } finally {
+                            _tmpltPoolDao.releaseFromLockTable(templatePoolRefId);
+                        }
+                    }
+                }
+            }
         }
-
+        
         AsyncCallFuture<VolumeApiResult> future = context.getFuture();
         future.complete(volResult);
         return null;


Mime
View raw message