cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [37/50] [abbrv] squash changes into one giant patch
Date Thu, 14 Feb 2013 01:11:26 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
new file mode 100644
index 0000000..d686336
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -0,0 +1,581 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.motion;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
+import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
+import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
+import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
+import com.cloud.agent.api.UpgradeSnapshotCommand;
+import com.cloud.agent.api.storage.CopyVolumeAnswer;
+import com.cloud.agent.api.storage.CopyVolumeCommand;
+import com.cloud.agent.api.storage.CreateAnswer;
+import com.cloud.agent.api.storage.CreateCommand;
+import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDao;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.StorageManager;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.VMTemplateHostVO;
+import com.cloud.storage.VMTemplateStoragePoolVO;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VolumeHostVO;
+import com.cloud.storage.VolumeManager;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.DiskOfferingDao;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VMTemplateHostDao;
+import com.cloud.storage.dao.VMTemplatePoolDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.VolumeHostDao;
+import com.cloud.storage.snapshot.SnapshotManager;
+import com.cloud.template.TemplateManager;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.DiskProfile;
+
+@Component
+public class AncientDataMotionStrategy implements DataMotionStrategy {
+    private static final Logger s_logger = Logger
+            .getLogger(AncientDataMotionStrategy.class);
+    @Inject
+    TemplateManager templateMgr;
+    @Inject
+    VolumeHostDao volumeHostDao;
+    @Inject
+    HostDao hostDao;
+    @Inject
+    ConfigurationDao configDao;
+    @Inject
+    StorageManager storagMgr;
+    @Inject
+    VolumeDao volDao;
+    @Inject
+    VMTemplateDao templateDao;
+    @Inject
+    SnapshotManager snapshotMgr;
+    @Inject
+    SnapshotDao snapshotDao;
+    @Inject
+    PrimaryDataStoreDao primaryDataStoreDao;
+    @Inject
+    DataStoreManager dataStoreMgr;
+    @Inject
+    VMTemplateHostDao templateHostDao;
+    @Inject DiskOfferingDao diskOfferingDao;
+    @Inject VMTemplatePoolDao templatePoolDao;
+    @Inject
+    VolumeManager volumeMgr;
+
+    @Override
+    public boolean canHandle(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    @DB
+    protected String copyVolumeFromImage(DataObject srcData, DataObject destData) {
+        String value = configDao.getValue(Config.RecreateSystemVmEnabled.key());
+        int _copyvolumewait = NumbersUtil.parseInt(value,
+                Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
+
+        VolumeHostVO volumeHostVO = volumeHostDao.findByVolumeId(srcData
+                .getId());
+        HostVO secStorage = hostDao.findById(volumeHostVO.getHostId());
+        String secondaryStorageURL = secStorage.getStorageUrl();
+        String[] volumePath = volumeHostVO.getInstallPath().split("/");
+        String volumeUUID = volumePath[volumePath.length - 1].split("\\.")[0];
+        StoragePool destPool = (StoragePool) destData.getDataStore();
+        CopyVolumeCommand cvCmd = new CopyVolumeCommand(srcData.getId(),
+                volumeUUID, destPool, secondaryStorageURL, false,
+                _copyvolumewait);
+        CopyVolumeAnswer cvAnswer = null;
+        String errMsg = null;
+        try {
+            cvAnswer = (CopyVolumeAnswer) this.storagMgr.sendToPool(destPool,
+                    cvCmd);
+        } catch (StorageUnavailableException e1) {
+            s_logger.debug("Failed to copy volume " + srcData.getId() + " to "
+                    + destData.getId(), e1);
+            errMsg = e1.toString();
+        }
+
+        if (cvAnswer == null || !cvAnswer.getResult()) {
+            errMsg = cvAnswer.getDetails();
+        }
+
+        VolumeVO vol = this.volDao.findById(destData.getId());
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        vol.setPath(cvAnswer.getVolumePath());
+        vol.setFolder(destPool.getPath());
+        vol.setPodId(destPool.getPodId());
+        vol.setPoolId(destPool.getId());
+        vol.setPodId(destPool.getPodId());
+
+        this.volDao.update(vol.getId(), vol);
+        volumeHostDao.remove(volumeHostVO.getId());
+        txn.commit();
+        return errMsg;
+    }
+
+    private void copyTemplate(DataObject srcData, DataObject destData) {
+        VMTemplateVO template = this.templateDao.findById(srcData.getId());
+        templateMgr.prepareTemplateForCreate(template,
+                (StoragePool) destData.getDataStore());
+    }
+
+    protected String copyFromSnapshot(DataObject snapObj, DataObject volObj) {
+        SnapshotVO snapshot = this.snapshotDao.findById(snapObj.getId());
+        StoragePool pool = (StoragePool) volObj.getDataStore();
+        String vdiUUID = null;
+        Long snapshotId = snapshot.getId();
+        Long volumeId = snapshot.getVolumeId();
+        Long dcId = snapshot.getDataCenterId();
+        String secondaryStoragePoolUrl = this.snapshotMgr
+                .getSecondaryStorageURL(snapshot);
+        long accountId = snapshot.getAccountId();
+
+        String backedUpSnapshotUuid = snapshot.getBackupSnapshotId();
+        snapshot = snapshotDao.findById(snapshotId);
+        if (snapshot.getVersion().trim().equals("2.1")) {
+            VolumeVO volume = this.volDao.findByIdIncludingRemoved(volumeId);
+            if (volume == null) {
+                throw new CloudRuntimeException("failed to upgrade snapshot "
+                        + snapshotId + " due to unable to find orignal volume:"
+                        + volumeId + ", try it later ");
+            }
+            if (volume.getTemplateId() == null) {
+                snapshotDao.updateSnapshotVersion(volumeId, "2.1", "2.2");
+            } else {
+                VMTemplateVO template = templateDao
+                        .findByIdIncludingRemoved(volume.getTemplateId());
+                if (template == null) {
+                    throw new CloudRuntimeException(
+                            "failed to upgrade snapshot "
+                                    + snapshotId
+                                    + " due to unalbe to find orignal template :"
+                                    + volume.getTemplateId()
+                                    + ", try it later ");
+                }
+                Long templateId = template.getId();
+                Long tmpltAccountId = template.getAccountId();
+                if (!snapshotDao.lockInLockTable(snapshotId.toString(), 10)) {
+                    throw new CloudRuntimeException(
+                            "failed to upgrade snapshot "
+                                    + snapshotId
+                                    + " due to this snapshot is being used, try it later ");
+                }
+                UpgradeSnapshotCommand cmd = new UpgradeSnapshotCommand(null,
+                        secondaryStoragePoolUrl, dcId, accountId, volumeId,
+                        templateId, tmpltAccountId, null,
+                        snapshot.getBackupSnapshotId(), snapshot.getName(),
+                        "2.1");
+                Answer answer = null;
+                try {
+                    answer = this.storagMgr.sendToPool(pool, cmd);
+                } catch (StorageUnavailableException e) {
+                } finally {
+                    snapshotDao.unlockFromLockTable(snapshotId.toString());
+                }
+                if ((answer != null) && answer.getResult()) {
+                    snapshotDao.updateSnapshotVersion(volumeId, "2.1", "2.2");
+                } else {
+                    return "Unable to upgrade snapshot from 2.1 to 2.2 for "
+                            + snapshot.getId();
+                }
+            }
+        }
+        String basicErrMsg = "Failed to create volume from "
+                + snapshot.getName() + " on pool " + pool;
+
+        try {
+            if (snapshot.getSwiftId() != null && snapshot.getSwiftId() != 0) {
+                snapshotMgr.downloadSnapshotsFromSwift(snapshot);
+            } else if (snapshot.getS3Id() != null && snapshot.getS3Id() != 0) {
+                snapshotMgr.downloadSnapshotsFromS3(snapshot);
+            }
+            String value = configDao
+                    .getValue(Config.CreateVolumeFromSnapshotWait.toString());
+            int _createVolumeFromSnapshotWait = NumbersUtil.parseInt(value,
+                    Integer.parseInt(Config.CreateVolumeFromSnapshotWait
+                            .getDefaultValue()));
+            CreateVolumeFromSnapshotCommand createVolumeFromSnapshotCommand = new CreateVolumeFromSnapshotCommand(
+                    pool, secondaryStoragePoolUrl, dcId, accountId, volumeId,
+                    backedUpSnapshotUuid, snapshot.getName(),
+                    _createVolumeFromSnapshotWait);
+            CreateVolumeFromSnapshotAnswer answer;
+            if (!snapshotDao.lockInLockTable(snapshotId.toString(), 10)) {
+                throw new CloudRuntimeException("failed to create volume from "
+                        + snapshotId
+                        + " due to this snapshot is being used, try it later ");
+            }
+            answer = (CreateVolumeFromSnapshotAnswer) this.storagMgr
+                    .sendToPool(pool, createVolumeFromSnapshotCommand);
+            if (answer != null && answer.getResult()) {
+                vdiUUID = answer.getVdi();
+                VolumeVO vol = this.volDao.findById(volObj.getId());
+                vol.setPath(vdiUUID);
+                this.volDao.update(vol.getId(), vol);
+                return null;
+            } else {
+                s_logger.error(basicErrMsg + " due to "
+                        + ((answer == null) ? "null" : answer.getDetails()));
+                throw new CloudRuntimeException(basicErrMsg);
+            }
+        } catch (StorageUnavailableException e) {
+            s_logger.error(basicErrMsg, e);
+            throw new CloudRuntimeException(basicErrMsg);
+        } finally {
+            if (snapshot.getSwiftId() != null) {
+                snapshotMgr.deleteSnapshotsDirForVolume(
+                        secondaryStoragePoolUrl, dcId, accountId, volumeId);
+            }
+            snapshotDao.unlockFromLockTable(snapshotId.toString());
+        }
+    }
+    
+    protected String cloneVolume(DataObject template, DataObject volume) {
+        
+        DiskOfferingVO offering = diskOfferingDao.findById(volume.getId());
+        VMTemplateStoragePoolVO  tmpltStoredOn =  templatePoolDao.findByPoolTemplate(template.getDataStore().getId(), template.getId());
+        VolumeInfo volInfo = (VolumeInfo)volume;
+        DiskProfile diskProfile = new DiskProfile(volInfo, offering,
+                null);
+        CreateCommand cmd = new CreateCommand(diskProfile,
+                tmpltStoredOn.getLocalDownloadPath(),
+                new StorageFilerTO((StoragePool)template.getDataStore()));
+        Answer answer = null;
+        StoragePool pool = (StoragePool)volume.getDataStore();
+        String errMsg = null;
+        try {
+            answer = storagMgr.sendToPool(pool, null, cmd);
+        } catch (StorageUnavailableException e) {
+            s_logger.debug("Failed to send to storage pool", e);
+            errMsg = e.toString();
+            return errMsg;
+        }
+        
+        if (answer.getResult()) {
+            VolumeVO vol = this.volDao.findById(volume.getId());
+            CreateAnswer createAnswer = (CreateAnswer) answer;
+            vol.setFolder(pool.getPath());
+            vol.setPath(createAnswer.getVolume().getPath());
+            vol.setSize(createAnswer.getVolume().getSize());
+            vol.setPoolType(pool.getPoolType());
+            vol.setPoolId(pool.getId());
+            vol.setPodId(pool.getPodId());
+            this.volDao.update(vol.getId(), vol);
+           
+        } else {
+            if (tmpltStoredOn != null
+                    && (answer instanceof CreateAnswer)
+                    && ((CreateAnswer) answer)
+                            .templateReloadRequested()) {
+                if (!templateMgr
+                        .resetTemplateDownloadStateOnPool(tmpltStoredOn
+                                .getId())) {
+                   
+                }
+            }
+            errMsg = answer.getDetails();
+        }
+        
+        return errMsg;
+    }
+
+    @Override
+    public Void copyAsync(DataObject srcData, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        String errMsg = null;
+        try {
+            if (destData.getType() == DataObjectType.VOLUME
+                    && srcData.getType() == DataObjectType.VOLUME) {
+                errMsg = copyVolumeFromImage(srcData, destData);
+            } else if (destData.getType() == DataObjectType.TEMPLATE
+                    && srcData.getType() == DataObjectType.TEMPLATE) {
+                copyTemplate(srcData, destData);
+            } else if (srcData.getType() == DataObjectType.SNAPSHOT
+                    && destData.getType() == DataObjectType.VOLUME) {
+                errMsg = copyFromSnapshot(srcData, destData);
+            } else if (srcData.getType() == DataObjectType.SNAPSHOT
+                    && destData.getType() == DataObjectType.TEMPLATE) {
+                errMsg = createTemplateFromSnashot(srcData, destData);
+            } else if (srcData.getType() == DataObjectType.VOLUME
+                    && destData.getType() == DataObjectType.TEMPLATE) {
+                errMsg = createTemplateFromVolume(srcData, destData);
+            } else if (srcData.getType() == DataObjectType.TEMPLATE 
+                    && destData.getType() == DataObjectType.VOLUME) {
+                errMsg = cloneVolume(srcData, destData);
+            }
+        } catch (Exception e) {
+            s_logger.debug("copy failed", e);
+            errMsg = e.toString();
+        }
+        CopyCommandResult result = new CopyCommandResult(null);
+        result.setResult(errMsg);
+        callback.complete(result);
+
+        return null;
+    }
+
+    @DB
+    protected String createTemplateFromSnashot(DataObject srcData,
+            DataObject destData) {
+        long snapshotId = srcData.getId();
+        SnapshotVO snapshot = snapshotDao.findById(snapshotId);
+        if (snapshot == null) {
+            throw new CloudRuntimeException("Unable to find Snapshot for Id "
+                    + srcData.getId());
+        }
+        Long zoneId = snapshot.getDataCenterId();
+        HostVO secondaryStorageHost = this.templateMgr
+                .getSecondaryStorageHost(zoneId);
+        String secondaryStorageURL = snapshotMgr
+                .getSecondaryStorageURL(snapshot);
+        VMTemplateVO template = this.templateDao.findById(destData.getId());
+        String name = template.getName();
+        String backupSnapshotUUID = snapshot.getBackupSnapshotId();
+        if (backupSnapshotUUID == null) {
+            throw new CloudRuntimeException(
+                    "Unable to create private template from snapshot "
+                            + snapshotId
+                            + " due to there is no backupSnapshotUUID for this snapshot");
+        }
+
+        Long dcId = snapshot.getDataCenterId();
+        Long accountId = snapshot.getAccountId();
+        Long volumeId = snapshot.getVolumeId();
+
+        String origTemplateInstallPath = null;
+        List<StoragePoolVO> pools = this.storagMgr
+                .ListByDataCenterHypervisor(zoneId,
+                        snapshot.getHypervisorType());
+        if (pools == null || pools.size() == 0) {
+            throw new CloudRuntimeException(
+                    "Unable to find storage pools in zone " + zoneId);
+        }
+        StoragePoolVO poolvo = pools.get(0);
+        StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(
+                poolvo.getId(), DataStoreRole.Primary);
+        if (snapshot.getVersion() != null
+                && snapshot.getVersion().equalsIgnoreCase("2.1")) {
+            VolumeVO volume = this.volDao.findByIdIncludingRemoved(volumeId);
+            if (volume == null) {
+                throw new CloudRuntimeException("failed to upgrade snapshot "
+                        + snapshotId + " due to unable to find orignal volume:"
+                        + volumeId + ", try it later ");
+            }
+            if (volume.getTemplateId() == null) {
+                snapshotDao.updateSnapshotVersion(volumeId, "2.1", "2.2");
+            } else {
+                template = templateDao.findByIdIncludingRemoved(volume
+                        .getTemplateId());
+                if (template == null) {
+                    throw new CloudRuntimeException(
+                            "failed to upgrade snapshot "
+                                    + snapshotId
+                                    + " due to unalbe to find orignal template :"
+                                    + volume.getTemplateId()
+                                    + ", try it later ");
+                }
+                Long origTemplateId = template.getId();
+                Long origTmpltAccountId = template.getAccountId();
+                if (!this.volDao.lockInLockTable(volumeId.toString(), 10)) {
+                    throw new CloudRuntimeException(
+                            "failed to upgrade snapshot " + snapshotId
+                                    + " due to volume:" + volumeId
+                                    + " is being used, try it later ");
+                }
+                UpgradeSnapshotCommand cmd = new UpgradeSnapshotCommand(null,
+                        secondaryStorageURL, dcId, accountId, volumeId,
+                        origTemplateId, origTmpltAccountId, null,
+                        snapshot.getBackupSnapshotId(), snapshot.getName(),
+                        "2.1");
+                if (!this.volDao.lockInLockTable(volumeId.toString(), 10)) {
+                    throw new CloudRuntimeException(
+                            "Creating template failed due to volume:"
+                                    + volumeId
+                                    + " is being used, try it later ");
+                }
+                Answer answer = null;
+                try {
+                    answer = this.storagMgr.sendToPool(pool, cmd);
+                    cmd = null;
+                } catch (StorageUnavailableException e) {
+                } finally {
+                    this.volDao.unlockFromLockTable(volumeId.toString());
+                }
+                if ((answer != null) && answer.getResult()) {
+                    snapshotDao.updateSnapshotVersion(volumeId, "2.1", "2.2");
+                } else {
+                    throw new CloudRuntimeException(
+                            "Unable to upgrade snapshot");
+                }
+            }
+        }
+        if (snapshot.getSwiftId() != null && snapshot.getSwiftId() != 0) {
+            snapshotMgr.downloadSnapshotsFromSwift(snapshot);
+        }
+        String value = configDao
+                .getValue(Config.CreatePrivateTemplateFromSnapshotWait
+                        .toString());
+        int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(
+                value, Integer
+                        .parseInt(Config.CreatePrivateTemplateFromSnapshotWait
+                                .getDefaultValue()));
+
+        CreatePrivateTemplateFromSnapshotCommand cmd = new CreatePrivateTemplateFromSnapshotCommand(
+                pool, secondaryStorageURL, dcId, accountId,
+                snapshot.getVolumeId(), backupSnapshotUUID, snapshot.getName(),
+                origTemplateInstallPath, template.getId(), name,
+                _createprivatetemplatefromsnapshotwait);
+
+        return sendCommand(cmd, pool, template.getId(), dcId,
+                secondaryStorageHost.getId());
+    }
+
+    @DB
+    protected String sendCommand(Command cmd, StoragePool pool,
+            long templateId, long zoneId, long hostId) {
+
+        CreatePrivateTemplateAnswer answer = null;
+        try {
+            answer = (CreatePrivateTemplateAnswer) this.storagMgr.sendToPool(
+                    pool, cmd);
+        } catch (StorageUnavailableException e) {
+            throw new CloudRuntimeException(
+                    "Failed to execute CreatePrivateTemplateFromSnapshotCommand",
+                    e);
+        }
+
+        if (answer == null) {
+            return "Failed to execute CreatePrivateTemplateFromSnapshotCommand";
+        } else if (!answer.getResult()) {
+            return "Failed to execute CreatePrivateTemplateFromSnapshotCommand"
+                    + answer.getDetails();
+        }
+
+        VMTemplateVO privateTemplate = templateDao.findById(templateId);
+        String answerUniqueName = answer.getUniqueName();
+        if (answerUniqueName != null) {
+            privateTemplate.setUniqueName(answerUniqueName);
+        }
+        ImageFormat format = answer.getImageFormat();
+        if (format != null) {
+            privateTemplate.setFormat(format);
+        } else {
+            // This never occurs.
+            // Specify RAW format makes it unusable for snapshots.
+            privateTemplate.setFormat(ImageFormat.RAW);
+        }
+
+        String checkSum = this.templateMgr
+                .getChecksum(hostId, answer.getPath());
+
+        Transaction txn = Transaction.currentTxn();
+
+        txn.start();
+
+        privateTemplate.setChecksum(checkSum);
+        templateDao.update(privateTemplate.getId(), privateTemplate);
+
+        // add template zone ref for this template
+        templateDao.addTemplateToZone(privateTemplate, zoneId);
+        VMTemplateHostVO templateHostVO = new VMTemplateHostVO(hostId,
+                privateTemplate.getId());
+        templateHostVO.setDownloadPercent(100);
+        templateHostVO.setDownloadState(Status.DOWNLOADED);
+        templateHostVO.setInstallPath(answer.getPath());
+        templateHostVO.setLastUpdated(new Date());
+        templateHostVO.setSize(answer.getVirtualSize());
+        templateHostVO.setPhysicalSize(answer.getphysicalSize());
+        templateHostDao.persist(templateHostVO);
+        txn.close();
+        return null;
+    }
+
+    private String createTemplateFromVolume(DataObject srcObj,
+            DataObject destObj) {
+        long volumeId = srcObj.getId();
+        VolumeVO volume = this.volDao.findById(volumeId);
+        if (volume == null) {
+            throw new CloudRuntimeException("Unable to find volume for Id "
+                    + volumeId);
+        }
+        long accountId = volume.getAccountId();
+
+        String vmName = this.volumeMgr.getVmNameOnVolume(volume);
+        Long zoneId = volume.getDataCenterId();
+        HostVO secondaryStorageHost = this.templateMgr
+                .getSecondaryStorageHost(zoneId);
+        if (secondaryStorageHost == null) {
+            throw new CloudRuntimeException(
+                    "Can not find the secondary storage for zoneId " + zoneId);
+        }
+        String secondaryStorageURL = secondaryStorageHost.getStorageUrl();
+        VMTemplateVO template = this.templateDao.findById(destObj.getId());
+        StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(
+                volume.getPoolId(), DataStoreRole.Primary);
+        String value = configDao
+                .getValue(Config.CreatePrivateTemplateFromVolumeWait.toString());
+        int _createprivatetemplatefromvolumewait = NumbersUtil.parseInt(value,
+                Integer.parseInt(Config.CreatePrivateTemplateFromVolumeWait
+                        .getDefaultValue()));
+
+        CreatePrivateTemplateFromVolumeCommand cmd = new CreatePrivateTemplateFromVolumeCommand(
+                pool, secondaryStorageURL, destObj.getId(), accountId,
+                template.getName(), template.getUniqueName(), volume.getPath(),
+                vmName, _createprivatetemplatefromvolumewait);
+
+        return sendCommand(cmd, pool, template.getId(), zoneId,
+                secondaryStorageHost.getId());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java
deleted file mode 100644
index 22d328f..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.snapshot;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-
-public interface SnapshotDataFactory {
-    public SnapshotInfo getSnapshot(long snapshotId, DataStore store);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
deleted file mode 100644
index 755531d..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.snapshot;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-
-public interface SnapshotInfo extends DataObject {
-	public SnapshotInfo getParent();
-	public SnapshotInfo getChild();
-	public VolumeInfo getBaseVolume();
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java
index d50c9a0..f3e5c4a 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java
@@ -17,6 +17,7 @@
 package org.apache.cloudstack.storage.snapshot;
 
 import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 
 public interface SnapshotService {
 	public SnapshotEntity getSnapshotEntity(long snapshotId);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotStrategy.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotStrategy.java
index 4e31186..8c4c815 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotStrategy.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotStrategy.java
@@ -16,6 +16,8 @@
 // under the License.
 package org.apache.cloudstack.storage.snapshot;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+
 public interface SnapshotStrategy {
 	public boolean takeSnapshot(SnapshotInfo snapshot);
 	public boolean revertSnapshot(SnapshotInfo snapshot);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
index cd67b97..aa47e8f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
@@ -21,12 +21,12 @@ import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 public class PrimaryDataStoreTO {
     private final String uuid;
     private final String name;
-    private final String type;
+    private  String type;
     private final long id;
     public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
         this.uuid = dataStore.getUuid();
         this.name = dataStore.getName();
-        this.type = dataStore.getType();
+      //  this.type = dataStore.getType();
         this.id = dataStore.getId();
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
index ed59909..bc55ea8 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
@@ -16,8 +16,8 @@
 // under the License.
 package org.apache.cloudstack.storage.to;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
-import org.apache.cloudstack.storage.image.TemplateInfo;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreInfo;
 
 public class TemplateTO {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java b/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
deleted file mode 100644
index d0530d1..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.volume;
-
-import com.cloud.utils.fsm.StateObject;
-
-public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> {
-    enum State {
-        Allocated("The initial state"),
-        Creating2("This is only used with createOnlyRequested event"),
-        Creating("The object is being creating on data store"),
-        Created("The object is created"),
-        Ready("Template downloading is complished"),
-        Copying("The object is being coping"),
-        Destroying("Template is destroying"),
-        Destroyed("Template is destroyed"),
-        Failed("Failed to download template");
-        String _description;
-
-        private State(String description) {
-            _description = description;
-        }
-
-        public String getDescription() {
-            return _description;
-        }
-    }
-    
-    enum Event {
-        CreateRequested,
-        CreateOnlyRequested,
-        DestroyRequested,
-        OperationSuccessed,
-        OperationFailed,
-        CopyingRequested,
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java b/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java
index 60db60b..2b49eee 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java
@@ -20,8 +20,8 @@ package org.apache.cloudstack.storage.volume;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
 
 public interface PrimaryDataStoreDriver extends DataStoreDriver {
     public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/TemplateOnPrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/TemplateOnPrimaryDataStoreInfo.java b/engine/storage/src/org/apache/cloudstack/storage/volume/TemplateOnPrimaryDataStoreInfo.java
index 368c33a..b8d0857 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/TemplateOnPrimaryDataStoreInfo.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/TemplateOnPrimaryDataStoreInfo.java
@@ -18,8 +18,8 @@
  */
 package org.apache.cloudstack.storage.volume;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.image.TemplateInfo;
 
 public interface TemplateOnPrimaryDataStoreInfo {
     public String getPath();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
deleted file mode 100644
index 19a4c3a..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.volume;
-
-import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-import org.apache.cloudstack.framework.async.AsyncCallFuture;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-
-public interface VolumeService {
-    
-    public class VolumeApiResult extends CommandResult {
-        private final VolumeInfo volume;
-        public VolumeApiResult(VolumeInfo volume) {
-            this.volume = volume;
-        }
-        
-        public VolumeInfo getVolume() {
-            return this.volume;
-        }
-    }
-    /**
-	 * 
-	 */
-    VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId);
-
-    /**
-     * Creates the volume based on the given criteria
-     * 
-     * @param cmd
-     * 
-     * @return the volume object
-     */
-    AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, long dataStoreId);
-
-    /**
-     * Delete volume
-     * 
-     * @param volumeId
-     * @return
-     * @throws ConcurrentOperationException
-     */
-    AsyncCallFuture<VolumeApiResult> deleteVolumeAsync(VolumeInfo volume);
-
-    /**
-     * 
-     */
-    boolean cloneVolume(long volumeId, long baseVolId);
-
-    /**
-     * 
-     */
-    boolean createVolumeFromSnapshot(long volumeId, long snapshotId);
-
-    /**
-     * 
-     */
-    String grantAccess(VolumeInfo volume, EndPoint endpointId);
-
-    TemplateOnPrimaryDataStoreInfo grantAccess(TemplateOnPrimaryDataStoreInfo template, EndPoint endPoint);
-
-    /**
-     * 
-     */
-    boolean rokeAccess(long volumeId, long endpointId);
-
-    VolumeEntity getVolumeEntity(long volumeId);
-
-    AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
index 20ceaa3..c6ca90d 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
@@ -23,40 +23,38 @@ import java.util.Map;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.springframework.stereotype.Component;
 
+import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @Component
 public class PrimaryDataStoreHelper {
     @Inject
     private PrimaryDataStoreDao dataStoreDao;
-    public PrimaryDataStoreVO createPrimaryDataStore(Map<String, String> params) {
-        PrimaryDataStoreVO dataStoreVO = dataStoreDao.findPoolByUUID(params.get("uuid"));
+    public StoragePoolVO createPrimaryDataStore(Map<String, Object> params) {
+        StoragePoolVO dataStoreVO = dataStoreDao.findPoolByUUID((String)params.get("uuid"));
         if (dataStoreVO != null) {
             throw new CloudRuntimeException("duplicate uuid: " + params.get("uuid"));
         }
         
-        dataStoreVO = new PrimaryDataStoreVO();
-        dataStoreVO.setStorageProviderId(Long.parseLong(params.get("providerId")));
-        dataStoreVO.setHostAddress(params.get("server"));
-        dataStoreVO.setPath(params.get("path"));
-        dataStoreVO.setPoolType(params.get("protocol"));
-        dataStoreVO.setPort(Integer.parseInt(params.get("port")));
-        dataStoreVO.setName(params.get("name"));
-        dataStoreVO.setUuid(params.get("uuid"));
+        dataStoreVO = new StoragePoolVO();
+        dataStoreVO.setStorageProviderId(Long.parseLong((String)params.get("providerId")));
+        dataStoreVO.setHostAddress((String)params.get("server"));
+        dataStoreVO.setPath((String)params.get("path"));
+        dataStoreVO.setPoolType((StoragePoolType)params.get("protocol"));
+        dataStoreVO.setPort(Integer.parseInt((String)params.get("port")));
+        dataStoreVO.setName((String)params.get("name"));
+        dataStoreVO.setUuid((String)params.get("uuid"));
         dataStoreVO = dataStoreDao.persist(dataStoreVO);
         return dataStoreVO;
     }
     
     public boolean deletePrimaryDataStore(long id) {
-        PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(id);
+        StoragePoolVO dataStoreVO = dataStoreDao.findById(id);
         if (dataStoreVO == null) {
             throw new CloudRuntimeException("can't find store: " + id);
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDao.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDao.java
index 45ff1ec..63cdb16 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDao.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDao.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cloudstack.storage.volume.db;
 
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.fsm.StateDao;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
index b47f088..ad56150 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
@@ -20,9 +20,9 @@ package org.apache.cloudstack.storage.volume.db;
 
 import java.util.Date;
 
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.State;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreVO.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreVO.java
index 2d355df..48a9f33 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreVO.java
@@ -32,7 +32,9 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.fsm.StateObject;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
index 9c009c9..72c1843 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
@@ -18,45 +18,50 @@ package org.apache.cloudstack.storage.datastore;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
 import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
 import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
 import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
-import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
-import org.apache.cloudstack.storage.image.ImageDataFactory;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.snapshot.SnapshotDataFactory;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
 import org.apache.cloudstack.storage.volume.VolumeObject;
-import org.apache.cloudstack.storage.volume.db.VolumeDao2;
-import org.apache.cloudstack.storage.volume.db.VolumeVO;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.storage.VMTemplateStoragePoolVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.VMTemplatePoolDao;
+import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.storage.encoding.EncodingType;
 
 public class DefaultPrimaryDataStore implements PrimaryDataStore {
     private static final Logger s_logger = Logger
             .getLogger(DefaultPrimaryDataStore.class);
     protected PrimaryDataStoreDriver driver;
-    protected PrimaryDataStoreVO pdsv;
+    protected StoragePoolVO pdsv;
     @Inject
     protected PrimaryDataStoreDao dataStoreDao;
     protected PrimaryDataStoreLifeCycle lifeCycle;
@@ -67,15 +72,16 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     @Inject
     SnapshotDataFactory snapshotFactory;
     protected DataStoreProvider provider;
-
     @Inject
-    private VolumeDao2 volumeDao;
+    VMTemplatePoolDao templatePoolDao;
+
+    private VolumeDao volumeDao;
 
     protected DefaultPrimaryDataStore() {
        
     }
     
-    public void configure(PrimaryDataStoreVO pdsv,
+    public void configure(StoragePoolVO pdsv,
             PrimaryDataStoreDriver driver, DataStoreProvider provider) {
         this.pdsv = pdsv;
         this.driver = driver;
@@ -83,7 +89,7 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     }
 
     public static DefaultPrimaryDataStore createDataStore(
-            PrimaryDataStoreVO pdsv, PrimaryDataStoreDriver driver,
+            StoragePoolVO pdsv, PrimaryDataStoreDriver driver,
             DataStoreProvider provider) {
         DefaultPrimaryDataStore dataStore = (DefaultPrimaryDataStore)ComponentContext.inject(DefaultPrimaryDataStore.class);
         dataStore.configure(pdsv, driver, provider);
@@ -109,19 +115,16 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
 
     @Override
     public DataStoreDriver getDriver() {
-        // TODO Auto-generated method stub
         return this.driver;
     }
 
     @Override
     public DataStoreRole getRole() {
-        // TODO Auto-generated method stub
         return DataStoreRole.Primary;
     }
 
     @Override
     public long getId() {
-        // TODO Auto-generated method stub
         return this.pdsv.getId();
     }
 
@@ -143,7 +146,7 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
 
     @Override
     public Scope getScope() {
-        PrimaryDataStoreVO vo = dataStoreDao.findById(this.pdsv.getId());
+        StoragePoolVO vo = dataStoreDao.findById(this.pdsv.getId());
         if (vo.getScope() == ScopeType.CLUSTER) {
             return new ClusterScope(vo.getClusterId(), vo.getPodId(),
                     vo.getDataCenterId());
@@ -156,7 +159,7 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     @Override
     public boolean isHypervisorSupported(HypervisorType hypervisor) {
         // TODO Auto-generated method stub
-        return false;
+        return true;
     }
 
     @Override
@@ -171,28 +174,10 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
         return false;
     }
 
-    @Override
-    public long getCapacity() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    @Override
-    public long getAvailableCapacity() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
 
     @Override
     public String getUuid() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public State getManagedState() {
-        // TODO Auto-generated method stub
-        return null;
+        return this.pdsv.getUuid();
     }
 
     @Override
@@ -202,26 +187,19 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     }
 
     @Override
-    public String getType() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
     public PrimaryDataStoreLifeCycle getLifeCycle() {
         return this.lifeCycle;
     }
 
     @Override
     public boolean exists(DataObject data) {
-        return (objectInStoreMgr.findObject(data.getId(), data.getType(),
-                this.getId(), this.getRole()) != null) ? true : false;
+        return (objectInStoreMgr.findObject(data, data.getDataStore()) != null) ? true : false;
     }
 
     @Override
     public TemplateInfo getTemplate(long templateId) {
-        ObjectInDataStoreVO obj = objectInStoreMgr.findObject(templateId, DataObjectType.TEMPLATE, this.getId(), this.getRole());
-        if (obj == null) {
+        VMTemplateStoragePoolVO template = templatePoolDao.findByPoolTemplate(this.getId(), templateId);
+        if (template == null || template.getState() != ObjectInDataStoreStateMachine.State.Ready) {
             return null;
         }
         return imageDataFactory.getTemplate(templateId, this);
@@ -238,4 +216,117 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public DataObject create(DataObject obj) {
+        //create template on primary storage
+        if (obj.getType() == DataObjectType.TEMPLATE) {
+            VMTemplateStoragePoolVO templateStoragePoolRef = templatePoolDao.findByPoolTemplate(this.getId(), obj.getId());
+            if (templateStoragePoolRef == null) {
+                try {
+                templateStoragePoolRef = new VMTemplateStoragePoolVO(this.getId(), obj.getId());
+                templateStoragePoolRef = templatePoolDao.persist(templateStoragePoolRef);
+                } catch (Throwable t) {
+                    templateStoragePoolRef = templatePoolDao.findByPoolTemplate(this.getId(), obj.getId());
+                    if (templateStoragePoolRef == null) {
+                        throw new CloudRuntimeException("Failed to create template storage pool entry");
+                    }
+                }
+            }
+            
+        }
+        
+        return objectInStoreMgr.get(obj, this);
+    }
+
+    @Override
+    public boolean delete(DataObject obj) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public long getDataCenterId() {
+        return this.pdsv.getDataCenterId();
+    }
+
+    @Override
+    public String getPath() {
+        return this.pdsv.getPath();
+    }
+
+    @Override
+    public StoragePoolType getPoolType() {
+       return this.pdsv.getPoolType();
+    }
+
+    @Override
+    public Date getCreated() {
+       return this.pdsv.getCreated();
+    }
+
+    @Override
+    public Date getUpdateTime() {
+       return this.pdsv.getUpdateTime();
+    }
+
+    @Override
+    public long getCapacityBytes() {
+       return this.pdsv.getCapacityBytes();
+    }
+
+    @Override
+    public long getAvailableBytes() {
+        return this.pdsv.getAvailableBytes();
+    }
+
+    @Override
+    public Long getClusterId() {
+        return this.pdsv.getClusterId();
+    }
+
+    @Override
+    public String getHostAddress() {
+        return this.pdsv.getHostAddress();
+    }
+
+    @Override
+    public String getUserInfo() {
+        return this.pdsv.getUserInfo();
+    }
+
+    @Override
+    public boolean isShared() {
+       return this.pdsv.getScope() == ScopeType.HOST ? false : true;
+    }
+
+    @Override
+    public boolean isLocal() {
+        return !this.isShared();
+    }
+
+    @Override
+    public StoragePoolStatus getStatus() {
+        return this.pdsv.getStatus();
+    }
+
+    @Override
+    public int getPort() {
+        return this.pdsv.getPort();
+    }
+
+    @Override
+    public Long getPodId() {
+        return this.pdsv.getPodId();
+    }
+
+    @Override
+    public Long getStorageProviderId() {
+        return this.pdsv.getStorageProviderId();
+    }
+
+    @Override
+    public boolean isInMaintenance() {
+        return this.getStatus() == StoragePoolStatus.Maintenance ? true : false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/AncientPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/AncientPrimaryDataStoreDriverImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/AncientPrimaryDataStoreDriverImpl.java
new file mode 100644
index 0000000..9946fba
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/AncientPrimaryDataStoreDriverImpl.java
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+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.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.storage.CreateAnswer;
+import com.cloud.agent.api.storage.CreateCommand;
+import com.cloud.agent.api.storage.DestroyCommand;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.Storage;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.StorageManager;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.VMTemplateHostVO;
+import com.cloud.storage.VMTemplateStoragePoolVO;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.DiskOfferingDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.template.TemplateManager;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.vm.DiskProfile;
+import com.cloud.vm.dao.VMInstanceDao;
+
+public class AncientPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
+    private static final Logger s_logger = Logger
+            .getLogger(AncientPrimaryDataStoreDriverImpl.class);
+    @Inject DiskOfferingDao diskOfferingDao;
+    @Inject VMTemplateDao templateDao;
+    @Inject VolumeDao volumeDao;
+    @Inject TemplateManager templateMgr;
+    @Inject HostDao hostDao;
+    @Inject StorageManager storageMgr;
+    @Inject VMInstanceDao vmDao;
+    @Inject PrimaryDataStoreDao primaryStoreDao;
+    @Override
+    public String grantAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean revokeAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean createVolume(
+            VolumeInfo volume) throws StorageUnavailableException {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Creating volume: " + volume);
+        }
+        
+        DiskOfferingVO offering = diskOfferingDao.findById(volume.getDiskOfferingId());
+        DiskProfile diskProfile = new DiskProfile(volume, offering,
+                null);
+
+        VMTemplateVO template = null;
+        if (volume.getTemplateId() != null) {
+            template = templateDao.findById(volume.getTemplateId());
+        }
+
+        StoragePool pool = (StoragePool)volume.getDataStore();
+        VolumeVO vol = volumeDao.findById(volume.getId());
+        if (pool != null) {
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Trying to create in " + pool);
+            }
+            vol.setPoolId(pool.getId());
+   
+            CreateCommand cmd = null;
+            VMTemplateStoragePoolVO tmpltStoredOn = null;
+
+            for (int i = 0; i < 2; i++) {
+                if (template != null
+                        && template.getFormat() != Storage.ImageFormat.ISO) {
+                    if (pool.getPoolType() == StoragePoolType.CLVM) {
+                        // prepareISOForCreate does what we need, which is to
+                        // tell us where the template is
+                        VMTemplateHostVO tmpltHostOn = templateMgr
+                                .prepareISOForCreate(template, pool);
+                        if (tmpltHostOn == null) {
+                            s_logger.debug("cannot find template "
+                                    + template.getId() + " "
+                                    + template.getName());
+                            throw new CloudRuntimeException("cannot find template"
+                                    + template.getId() 
+                                    + template.getName());
+                        }
+                        HostVO secondaryStorageHost = hostDao
+                                .findById(tmpltHostOn.getHostId());
+                        String tmpltHostUrl = secondaryStorageHost
+                                .getStorageUrl();
+                        String fullTmpltUrl = tmpltHostUrl + "/"
+                                + tmpltHostOn.getInstallPath();
+                        cmd = new CreateCommand(diskProfile, fullTmpltUrl,
+                                new StorageFilerTO(pool));
+                    } else {
+                        tmpltStoredOn = templateMgr.prepareTemplateForCreate(
+                                template, pool);
+                        if (tmpltStoredOn == null) {
+                            s_logger.debug("Cannot use this pool " + pool
+                                    + " because we can't propagate template "
+                                    + template);
+                            throw new CloudRuntimeException("Cannot use this pool " + pool
+                                    + " because we can't propagate template "
+                                    + template);
+                        }
+                        cmd = new CreateCommand(diskProfile,
+                                tmpltStoredOn.getLocalDownloadPath(),
+                                new StorageFilerTO(pool));
+                    }
+                } else {
+                    if (template != null
+                            && Storage.ImageFormat.ISO == template.getFormat()) {
+                        VMTemplateHostVO tmpltHostOn = templateMgr
+                                .prepareISOForCreate(template, pool);
+                        if (tmpltHostOn == null) {
+                            throw new CloudRuntimeException(
+                                    "Did not find ISO in secondry storage in zone "
+                                            + pool.getDataCenterId());
+                        }
+                    }
+                    cmd = new CreateCommand(diskProfile, new StorageFilerTO(
+                            pool));
+                }
+
+                Answer answer = storageMgr.sendToPool(pool, null, cmd);
+                if (answer.getResult()) {
+                    CreateAnswer createAnswer = (CreateAnswer) answer;
+                    vol.setFolder(pool.getPath());
+                    vol.setPath(createAnswer.getVolume().getPath());
+                    vol.setSize(createAnswer.getVolume().getSize());
+                    vol.setPoolType(pool.getPoolType());
+                    vol.setPoolId(pool.getId());
+                    vol.setPodId(pool.getPodId());
+                    this.volumeDao.update(vol.getId(), vol);
+                    return true;
+                } else {
+                    if (tmpltStoredOn != null
+                            && (answer instanceof CreateAnswer)
+                            && ((CreateAnswer) answer)
+                                    .templateReloadRequested()) {
+                        if (!templateMgr
+                                .resetTemplateDownloadStateOnPool(tmpltStoredOn
+                                        .getId())) {
+                            break; // break out of template-redeploy retry loop
+                        }
+                    } else {
+                        break;
+                    }
+                }
+            }
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Unable to create volume " + volume.getId());
+        }
+        return false;
+    }
+
+    @Override
+    public void createAsync(DataObject data,
+            AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
+        String errMsg = null;
+        if (data.getType() == DataObjectType.VOLUME) {
+            try {
+                createVolume((VolumeInfo)data);
+            } catch (StorageUnavailableException e) {
+                s_logger.debug("failed to create volume", e);
+                errMsg = e.toString();
+            } catch (Exception e) {
+                s_logger.debug("failed to create volume", e);
+                errMsg = e.toString();
+            }
+        }
+        CreateCmdResult result = new CreateCmdResult(null, null);
+        if (errMsg != null) {
+            result.setResult(errMsg);
+        }
+        
+        callback.complete(result);
+        
+    }
+
+    @Override
+    public void deleteAsync(DataObject data,
+            AsyncCompletionCallback<CommandResult> callback) {
+
+        String vmName = null;
+        VolumeVO vol = this.volumeDao.findById(data.getId());
+
+
+        StoragePool pool = (StoragePool)data.getDataStore();
+
+        DestroyCommand cmd = new DestroyCommand(pool, vol, vmName);
+
+        CommandResult result = new CommandResult();
+        try {
+            Answer answer = this.storageMgr.sendToPool(pool, cmd);
+            if (answer != null && !answer.getResult()) {
+                result.setResult(answer.getDetails());
+                s_logger.info("Will retry delete of " + vol + " from " + pool.getId());
+            }
+        } catch (StorageUnavailableException e) {
+            s_logger.error("Storage is unavailable currently.  Will retry delete of "
+                        + vol + " from " + pool.getId(), e);
+            result.setResult(e.toString());
+        } catch (Exception ex) {
+            s_logger.debug("Unable to destoy volume" + vol + " from " + pool.getId(), ex);
+            result.setResult(ex.toString());
+        }
+        callback.complete(result);
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void takeSnapshot(SnapshotInfo snapshot,
+            AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void revertSnapshot(SnapshotInfo snapshot,
+            AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9b79359/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
index dfe4518..efd04d1 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
@@ -27,6 +27,7 @@ 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.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.framework.async.AsyncRpcConext;
@@ -35,7 +36,6 @@ import org.apache.cloudstack.storage.command.CreateObjectCommand;
 import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.datastore.DataObjectManager;
 import org.apache.cloudstack.storage.endpoint.EndPointSelector;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
 import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
 import org.apache.log4j.Logger;
 


Mime
View raw message