From 57641d85f7a1b235098ea8cd3e8927c883c86b76 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 27 Jun 2013 20:16:42 +0530 Subject: [PATCH] Set all templates/volumes to Ready in the simulator Signed-off-by: Prasanna Santhanam --- .../tomcatconf/nonossComponentContext.xml.in | 1 - .../driver/SimulatorImageStoreDriverImpl.java | 45 ++++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in index 4ea1d31b684..e7828e1d2af 100644 --- a/client/tomcatconf/nonossComponentContext.xml.in +++ b/client/tomcatconf/nonossComponentContext.xml.in @@ -183,7 +183,6 @@ --> - 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 74177ed242c..8816fc2d9a3 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 callback, CreateContext 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 callback, CreateContext 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