You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/07/01 23:25:05 UTC

[21/50] [abbrv] git commit: updated refs/heads/vmsync to f737019

Set all templates/volumes to Ready in the simulator

Signed-off-by: Prasanna Santhanam <ts...@apache.org>


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

Branch: refs/heads/vmsync
Commit: 57641d85f7a1b235098ea8cd3e8927c883c86b76
Parents: 0dc5b0d
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Thu Jun 27 20:16:42 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 13:53:41 2013 +0530

----------------------------------------------------------------------
 client/tomcatconf/nonossComponentContext.xml.in |  1 -
 .../driver/SimulatorImageStoreDriverImpl.java   | 45 ++++++++++----------
 2 files changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/57641d85/client/tomcatconf/nonossComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in
index 4ea1d31..e7828e1 100644
--- a/client/tomcatconf/nonossComponentContext.xml.in
+++ b/client/tomcatconf/nonossComponentContext.xml.in
@@ -183,7 +183,6 @@
      
 -->
 
-
   <!--Motion Strategies-->
   <bean id="vmwareStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.VmwareStorageMotionStrategy" />
   <bean id="dataMotionServiceImpl" class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl">

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/57641d85/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
index 74177ed..8816fc2 100644
--- a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
+++ b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
@@ -25,6 +25,7 @@ import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.NfsTO;
 import com.cloud.storage.Storage;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.VMTemplateDao;
@@ -32,6 +33,7 @@ import com.cloud.storage.dao.VolumeDao;
 import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.framework.async.AsyncRpcContext;
@@ -41,6 +43,8 @@ import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
 import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
 
 import javax.inject.Inject;
 import java.util.Date;
@@ -93,57 +97,54 @@ public class SimulatorImageStoreDriverImpl extends BaseImageStoreDriverImpl {
 
     protected Void createTemplateAsyncCallback(AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> callback,
                                                CreateContext<CreateCmdResult> context) {
-        DownloadAnswer answer = callback.getResult();
         DataObject obj = context.data;
         DataStore store = obj.getDataStore();
+        TemplateObjectTO templateTO = (TemplateObjectTO)context.data.getTO();
 
         TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
         if (tmpltStoreVO != null) {
             TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
-            updateBuilder.setDownloadPercent(answer.getDownloadPct());
-            updateBuilder.setDownloadState(answer.getDownloadStatus());
+            updateBuilder.setDownloadPercent(100);
+            updateBuilder.setDownloadState(VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
             updateBuilder.setLastUpdated(new Date());
-            updateBuilder.setErrorString(answer.getErrorString());
-            updateBuilder.setJobId(answer.getJobId());
-            updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
-            updateBuilder.setInstallPath(answer.getInstallPath());
-            updateBuilder.setSize(answer.getTemplateSize());
-            updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
+            updateBuilder.setSize(new Long(5 * 1024L * 1024L));
+            updateBuilder.setPhysicalSize(new Long(5 * 1024L * 1024L));
+            updateBuilder.setDownloadUrl(templateTO.getOrigUrl());
+            updateBuilder.setInstallPath(templateTO.getPath());
+            updateBuilder.setTemplateId(templateTO.getId());
+            updateBuilder.setState(ObjectInDataStoreStateMachine.State.Ready);
             _templateStoreDao.update(tmpltStoreVO.getId(), updateBuilder);
             // update size in vm_template table
             VMTemplateVO tmlptUpdater = _templateDao.createForUpdate();
-            tmlptUpdater.setSize(answer.getTemplateSize());
+            tmlptUpdater.setSize(new Long(5 * 1024l * 1024l));
             _templateDao.update(obj.getId(), tmlptUpdater);
         }
-
         return null;
     }
 
     protected Void createVolumeAsyncCallback(AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> callback,
                                              CreateContext<CreateCmdResult> context) {
-        DownloadAnswer answer = callback.getResult();
         DataObject obj = context.data;
         DataStore store = obj.getDataStore();
+        VolumeObjectTO volumeTO = (VolumeObjectTO) context.data.getTO();
 
         VolumeDataStoreVO volStoreVO = _volumeStoreDao.findByStoreVolume(store.getId(), obj.getId());
         if (volStoreVO != null) {
             VolumeDataStoreVO updateBuilder = _volumeStoreDao.createForUpdate();
-            updateBuilder.setDownloadPercent(answer.getDownloadPct());
-            updateBuilder.setDownloadState(answer.getDownloadStatus());
+            updateBuilder.setDownloadPercent(100);
+            updateBuilder.setDownloadState(VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
             updateBuilder.setLastUpdated(new Date());
-            updateBuilder.setErrorString(answer.getErrorString());
-            updateBuilder.setJobId(answer.getJobId());
-            updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
-            updateBuilder.setInstallPath(answer.getInstallPath());
-            updateBuilder.setSize(answer.getTemplateSize());
-            updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
+            updateBuilder.setInstallPath(volumeTO.getPath());
+            updateBuilder.setVolumeId(volumeTO.getVolumeId());
+            updateBuilder.setSize(volumeTO.getSize());
+            updateBuilder.setPhysicalSize(volumeTO.getSize());
+            updateBuilder.setState(ObjectInDataStoreStateMachine.State.Ready);
             _volumeStoreDao.update(volStoreVO.getId(), updateBuilder);
             // update size in volume table
             VolumeVO volUpdater = _volumeDao.createForUpdate();
-            volUpdater.setSize(answer.getTemplateSize());
+            volUpdater.setSize(volumeTO.getSize());
             _volumeDao.update(obj.getId(), volUpdater);
         }
-
         return null;
     }
 }
\ No newline at end of file