incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [7/7] git commit: refactor api, based on suggestion from community
Date Tue, 15 Jan 2013 02:57:10 GMT
Updated Branches:
  refs/heads/javelin 8ba00f755 -> 8af85b04d


refactor api, based on suggestion from community


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

Branch: refs/heads/javelin
Commit: 8af85b04d0dad8e0aaec842a8afbcb3408ce8451
Parents: 8ba00f7
Author: Edison Su <edison.su@citrix.com>
Authored: Mon Jan 14 18:52:32 2013 -0800
Committer: Edison Su <edison.su@citrix.com>
Committed: Mon Jan 14 18:52:39 2013 -0800

----------------------------------------------------------------------
 engine/api/pom.xml                                 |    5 +
 .../engine/cloud/entity/api/VolumeEntity.java      |    7 +-
 .../subsystem/api/storage/CommandResult.java       |   52 ++
 .../subsystem/api/storage/CopyCommandResult.java   |   31 ++
 .../subsystem/api/storage/CreateCmdResult.java     |   31 ++
 .../engine/subsystem/api/storage/DataObject.java   |   30 ++
 .../subsystem/api/storage/DataObjectType.java      |   25 +
 .../engine/subsystem/api/storage/DataStore.java    |    9 +
 .../subsystem/api/storage/DataStoreDriver.java     |   33 ++
 .../subsystem/api/storage/DataStoreLifeCycle.java  |   42 ++
 .../subsystem/api/storage/DataStoreRole.java       |   54 +++
 .../engine/subsystem/api/storage/EndPoint.java     |   11 +
 .../api/storage/PrimaryDataStoreInfo.java          |   10 +-
 .../api/storage/PrimaryDataStoreLifeCycle.java     |   21 +-
 .../api/storage/PrimaryDataStoreProvider.java      |   18 -
 .../subsystem/api/storage/StorageOrchestrator.java |    6 +-
 .../engine/subsystem/api/storage/VolumeInfo.java   |   24 +-
 .../subsystem/api/storage/disktype/DiskFormat.java |   22 +
 .../subsystem/api/storage/disktype/QCOW2.java      |   10 -
 .../subsystem/api/storage/disktype/Unknown.java    |    7 -
 .../engine/subsystem/api/storage/disktype/VHD.java |   10 -
 .../subsystem/api/storage/disktype/VMDK.java       |   10 -
 .../api/storage/disktype/VolumeDiskType.java       |    4 -
 .../api/storage/disktype/VolumeDiskTypeBase.java   |   34 --
 .../api/storage/disktype/VolumeDiskTypeHelper.java |   29 --
 engine/pom.xml                                     |    1 +
 .../storage/image/ImageDataFactoryImpl.java        |   51 ++
 .../cloudstack/storage/image/ImageServiceImpl.java |  178 +++++---
 .../cloudstack/storage/image/TemplateObject.java   |   61 ---
 .../driver/DefaultImageDataStoreDriverImpl.java    |   81 ++++
 .../storage/image/driver/ImageDataStoreDriver.java |   33 --
 .../image/driver/ImageDataStoreDriverImpl.java     |   53 ---
 .../storage/image/manager/ImageDataManager.java    |   30 ++
 .../image/manager/ImageDataManagerImpl.java        |   48 ++
 .../image/manager/ImageDataStoreManager.java       |   25 -
 .../image/manager/ImageDataStoreManagerImpl.java   |   34 ++-
 .../provider/DefaultImageDataStoreProvider.java    |   75 ---
 .../image/provider/ImageDataStoreProvider.java     |   34 --
 .../provider/ImageDataStoreProviderManager.java    |   39 --
 .../ImageDataStoreProviderManagerImpl.java         |  135 ------
 .../image/store/DefaultImageDataStoreProvider.java |   75 +++
 .../storage/image/store/ImageDataStore.java        |   31 --
 .../storage/image/store/ImageDataStoreImpl.java    |  101 ++---
 .../storage/image/store/TemplateObject.java        |  110 +++++
 .../lifecycle/DefaultImageDataStoreLifeCycle.java  |   85 +++-
 .../store/lifecycle/ImageDataStoreLifeCycle.java   |    7 +-
 .../image/motion/DefaultImageMotionStrategy.java   |   80 +++-
 .../image/motion/ImageMotionServiceImpl.java       |    8 +-
 .../storage/image/motion/ImageMotionStrategy.java  |   12 +-
 .../cloudstack/storage/test/DirectAgentTest.java   |   17 +-
 ...ockHostEndpointRpcServerDirectCallResource.java |    9 +-
 .../test/MockHypervsiorHostEndPointRpcServer.java  |    9 +-
 .../cloudstack/storage/test/volumeServiceTest.java |   72 +--
 .../storage/snapshot/SnapshotDataFactoryImpl.java  |   47 ++
 .../storage/snapshot/SnapshotObject.java           |   98 ++++
 .../storage/snapshot/db/SnapshotDao2.java          |   25 +
 .../storage/snapshot/db/SnapshotDao2Impl.java      |   25 +
 .../cloudstack/storage/snapshot/db/SnapshotVO.java |  296 ++++++++++++
 .../org/apache/cloudstack/storage/EndPoint.java    |   11 -
 .../cloudstack/storage/HypervisorHostEndPoint.java |    1 +
 .../storage/command/AttachPrimaryDataStoreCmd.java |   10 +-
 .../cloudstack/storage/command/CommandResult.java  |   49 --
 .../cloudstack/storage/command/CopyCmdAnswer.java  |   17 +
 .../CopyTemplateToPrimaryStorageAnswer.java        |   17 -
 .../storage/command/CreateVolumeCommand.java       |   12 +-
 .../cloudstack/storage/command/DeleteCommand.java  |   44 ++
 .../storage/command/DeleteVolumeCommand.java       |   44 --
 .../cloudstack/storage/datastore/DataStore.java    |   17 -
 .../storage/datastore/DataStoreManager.java        |   29 ++
 .../storage/datastore/DataStoreManagerImpl.java    |   54 +++
 .../storage/datastore/DataStoreStatus.java         |   23 +
 .../datastore/DefaultDatastoreLifeCyle.java        |  109 +++++
 .../datastore/ObjectInDataStoreManager.java        |   18 +-
 .../datastore/ObjectInDataStoreManagerImpl.java    |  119 ++++--
 .../storage/datastore/PrimaryDataStore.java        |   37 +-
 .../datastore/PrimaryDataStoreProviderManager.java |   28 ++
 .../storage/datastore/TemplateInDataStore.java     |   42 --
 .../storage/datastore/VolumeDataFactory.java       |   26 +
 .../storage/datastore/db/DataStoreProviderDao.java |   25 +
 .../datastore/db/DataStoreProviderDaoImpl.java     |   38 ++
 .../storage/datastore/db/DataStoreProviderVO.java  |   60 +++
 .../storage/datastore/db/PrimaryDataStoreDao.java  |  116 +++++
 .../datastore/db/PrimaryDataStoreDaoImpl.java      |  361 +++++++++++++++
 .../datastore/db/PrimaryDataStoreDetailVO.java     |   79 ++++
 .../datastore/db/PrimaryDataStoreDetailsDao.java   |   28 ++
 .../db/PrimaryDataStoreDetailsDaoImpl.java         |   71 +++
 .../storage/datastore/db/PrimaryDataStoreVO.java   |  266 +++++++++++
 .../datastore/provider/DataStoreProvider.java      |   32 ++
 .../provider/DataStoreProviderManager.java         |   30 ++
 .../provider/DataStoreProviderManagerImpl.java     |  108 +++++
 .../datastore/provider/ImageDataStoreProvider.java |   23 +
 .../provider/PrimaryDataStoreProvider.java         |    5 +
 .../cloudstack/storage/db/ObjectInDataStoreVO.java |   47 ++-
 .../storage/endpoint/DefaultEndPointSelector.java  |  149 ++++++
 .../storage/endpoint/EndPointSelector.java         |   26 +
 .../cloudstack/storage/image/ImageDataFactory.java |   25 +
 .../storage/image/ImageDataStoreDriver.java        |   24 +
 .../cloudstack/storage/image/ImageService.java     |   24 +-
 .../storage/image/TemplateEntityImpl.java          |    2 +-
 .../cloudstack/storage/image/TemplateEvent.java    |   26 +
 .../cloudstack/storage/image/TemplateInfo.java     |   14 +-
 .../cloudstack/storage/image/TemplateState.java    |   27 ++
 .../storage/image/datastore/ImageDataStore.java    |   35 ++
 .../image/datastore/ImageDataStoreHelper.java      |   53 +++
 .../image/datastore/ImageDataStoreInfo.java        |   26 +
 .../image/datastore/ImageDataStoreManager.java     |   26 +
 .../cloudstack/storage/image/db/ImageDataDao.java  |    6 +-
 .../storage/image/db/ImageDataDaoImpl.java         |    9 +
 .../storage/image/db/ImageDataStoreVO.java         |   24 +-
 .../cloudstack/storage/image/db/ImageDataVO.java   |   23 +-
 .../storage/image/motion/ImageMotionService.java   |    2 +-
 .../storage/image/store/ImageDataStoreInfo.java    |   27 --
 .../storage/motion/DataMotionDriver.java           |   25 +
 .../storage/motion/DataMotionService.java          |   28 ++
 .../storage/motion/DataMotionServiceImpl.java      |   61 +++
 .../storage/motion/DataMotionStrategy.java         |   30 ++
 .../storage/snapshot/SnapshotDataFactory.java      |   25 +
 .../cloudstack/storage/snapshot/SnapshotInfo.java  |    3 +-
 .../cloudstack/storage/to/ImageDataStoreTO.java    |    2 +-
 .../storage/to/ImageOnPrimayDataStoreTO.java       |    4 +-
 .../apache/cloudstack/storage/to/TemplateTO.java   |   10 +-
 .../org/apache/cloudstack/storage/to/VolumeTO.java |   21 +-
 .../volume/ObjectInDataStoreStateMachine.java      |    8 +-
 .../storage/volume/PrimaryDataStoreDriver.java     |   29 ++
 .../storage/volume/VolumeEntityImpl.java           |  246 ----------
 .../cloudstack/storage/volume/VolumeService.java   |   10 +-
 .../volume/datastore/PrimaryDataStoreHelper.java   |   77 +++
 .../cloudstack/storage/volume/db/VolumeVO.java     |    8 +-
 .../storage/datastore/DataStoreStatus.java         |   23 -
 .../storage/datastore/DefaultPrimaryDataStore.java |  262 +++--------
 .../AbstractPrimaryDataStoreConfigurator.java      |   54 ---
 .../configurator/PrimaryDataStoreConfigurator.java |   32 --
 .../configurator/kvm/AbstractKvmConfigurator.java  |   48 --
 .../configurator/kvm/KvmCLVMConfigurator.java      |   47 --
 .../configurator/kvm/KvmNfsConfigurator.java       |   51 --
 .../configurator/kvm/KvmRBDConfigurator.java       |   46 --
 .../validator/CLVMProtocolTransformer.java         |   56 ---
 .../validator/FileSystemValidator.java             |   56 ---
 .../validator/ISCSIProtocolTransformer.java        |   55 ---
 .../validator/NfsProtocolTransformer.java          |   96 ----
 .../configurator/validator/RBDValidator.java       |   55 ---
 .../validator/StorageProtocolTransformer.java      |   34 --
 .../configurator/validator/VMFSValidator.java      |   55 ---
 .../vmware/AbstractVmwareConfigurator.java         |   49 --
 .../vmware/VmwareIsciConfigurator.java             |   45 --
 .../configurator/vmware/VmwareNfsConfigurator.java |   49 --
 .../vmware/VmwareVMFSConfigurator.java             |   47 --
 .../configurator/xen/AbstractXenConfigurator.java  |   40 --
 .../configurator/xen/XenIscsiConfigurator.java     |   45 --
 .../configurator/xen/XenNfsConfigurator.java       |   45 --
 .../storage/datastore/db/PrimaryDataStoreDao.java  |  116 -----
 .../datastore/db/PrimaryDataStoreDaoImpl.java      |  360 --------------
 .../datastore/db/PrimaryDataStoreDetailVO.java     |   79 ----
 .../datastore/db/PrimaryDataStoreDetailsDao.java   |   28 --
 .../db/PrimaryDataStoreDetailsDaoImpl.java         |   71 ---
 .../datastore/db/PrimaryDataStoreProviderDao.java  |   25 -
 .../db/PrimaryDataStoreProviderDaoImpl.java        |   38 --
 .../datastore/db/PrimaryDataStoreProviderVO.java   |   49 --
 .../storage/datastore/db/PrimaryDataStoreVO.java   |  265 -----------
 .../driver/DefaultPrimaryDataStoreDriverImpl.java  |  142 +++---
 .../datastore/driver/PrimaryDataStoreDriver.java   |   33 --
 .../DefaultPrimaryDataStoreLifeCycleImpl.java      |   31 +-
 .../DefaultXenPrimaryDataStoreLifeCycle.java       |    7 +-
 .../DefaultPrimaryDataStoreManagerImpl.java        |   50 --
 ...DefaultPrimaryDataStoreProviderManagerImpl.java |   67 +++
 .../datastore/manager/PrimaryDataStoreManager.java |   27 --
 .../storage/datastore/manager/data model.ucls      |   57 +++
 .../DefaultPrimaryDatastoreProviderImpl.java       |  141 +-----
 .../provider/PrimaryDataStoreProviderManager.java  |   13 -
 .../PrimaryDataStoreProviderManagerImpl.java       |  106 -----
 .../storage/volume/TemplateInstallStrategy.java    |   28 ++
 .../volume/TemplateInstallStrategyImpl.java        |  293 ++++++++++++
 .../volume/TemplateOnPrimaryDataStoreObject.java   |   87 ----
 .../volume/TemplatePrimaryDataStoreManager.java    |   35 --
 .../TemplatePrimaryDataStoreManagerImpl.java       |  129 -----
 .../storage/volume/VolumeDataFactoryImpl.java      |   53 +++
 .../storage/volume/VolumeEntityImpl.java           |  207 +++++++++
 .../cloudstack/storage/volume/VolumeObject.java    |   85 +---
 .../storage/volume/VolumeServiceImpl.java          |  121 +++---
 .../storage/volume/test/ConfiguratorTest.java      |   29 +-
 .../xen/resource/XenServerStorageResource.java     |   26 +-
 plugins/pom.xml                                    |    2 +
 .../driver/SolidfirePrimaryDataStoreDriver.java    |   69 ++--
 .../SolidfirePrimaryDataStoreProvider.java         |   31 +--
 .../apache/cloudstack/storage/test/VolumeTest.java |   22 +-
 185 files changed, 5188 insertions(+), 4675 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/pom.xml
----------------------------------------------------------------------
diff --git a/engine/api/pom.xml b/engine/api/pom.xml
index 99c0151..cbb83e4 100644
--- a/engine/api/pom.xml
+++ b/engine/api/pom.xml
@@ -31,6 +31,11 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-framework-ipc</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-bundle-jaxrs</artifactId>
       <version>2.7.0</version>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VolumeEntity.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VolumeEntity.java b/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VolumeEntity.java
index 47fb638..a63c2b47 100755
--- a/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VolumeEntity.java
+++ b/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VolumeEntity.java
@@ -20,7 +20,7 @@ package org.apache.cloudstack.engine.cloud.entity.api;
 
 import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
 import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
 
 
@@ -76,12 +76,9 @@ public interface VolumeEntity extends CloudStackEntity {
     
     long getSize();
     
-    VolumeDiskType getDiskType();
+    DiskFormat getDiskType();
     
     VolumeType getType();
     
     StorageEntity getDataStore();
-    
-    boolean createVolumeFromTemplate(long dataStoreId, VolumeDiskType diskType, TemplateEntity template);
-    boolean createVolume(long dataStoreId, VolumeDiskType diskType);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CommandResult.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CommandResult.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CommandResult.java
new file mode 100644
index 0000000..6b6139b
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CommandResult.java
@@ -0,0 +1,52 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+public class CommandResult {
+    private boolean success;
+    private String result;
+    public CommandResult() {
+        this.success = true;
+        this.result = "";
+    }
+   
+    public boolean isSuccess() {
+        return this.success;
+    }
+    
+    public boolean isFailed() {
+        return !this.success;
+    }
+    
+    public void setSucess(boolean success) {
+        this.success = success;
+    }
+    
+    public String getResult() {
+        return this.result;
+    }
+    
+    public void setResult(String result) {
+        this.result = result;
+        if (result != null) {
+            this.success = false;
+        }
+    }
+}
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CopyCommandResult.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CopyCommandResult.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CopyCommandResult.java
new file mode 100644
index 0000000..100fd4e
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CopyCommandResult.java
@@ -0,0 +1,31 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+public class CopyCommandResult extends CommandResult {
+    private final String path;
+    public CopyCommandResult(String path) {
+        super();
+        this.path = path;
+    }
+    
+    public String getPath() {
+        return this.path;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CreateCmdResult.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CreateCmdResult.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CreateCmdResult.java
new file mode 100644
index 0000000..8934416
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CreateCmdResult.java
@@ -0,0 +1,31 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+public class CreateCmdResult extends CommandResult {
+    private String path;
+    public CreateCmdResult(String path) {
+        super();
+        this.path = path;
+    }
+    
+    public String getPath() {
+        return this.path;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
new file mode 100644
index 0000000..4487330
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
@@ -0,0 +1,30 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
+
+public interface DataObject {
+    public long getId();
+    public String getUri();
+    public DataStore getDataStore();
+    public long getSize();
+    public DataObjectType getType();
+    public DiskFormat getFormat();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectType.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectType.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectType.java
new file mode 100644
index 0000000..b4d1a57
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectType.java
@@ -0,0 +1,25 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+public enum DataObjectType {
+    VOLUME,
+    SNAPSHOT,
+    TEMPLATE
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java
new file mode 100644
index 0000000..ae1fade
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java
@@ -0,0 +1,9 @@
+package org.apache.cloudstack.engine.subsystem.api.storage;
+
+public interface DataStore {
+    DataStoreDriver getDriver();
+    DataStoreRole getRole();
+    long getId();
+    String getUri();
+    Scope getScope();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
new file mode 100644
index 0000000..4aba9bf
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java
@@ -0,0 +1,33 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+import java.util.Set;
+
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+public interface DataStoreDriver {
+    public String grantAccess(DataObject data, EndPoint ep);
+    public boolean revokeAccess(DataObject data, EndPoint ep);
+    public Set<DataObject> listObjects(DataStore store);
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
+    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
+    public boolean canCopy(DataObject srcData, DataObject destData);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
new file mode 100644
index 0000000..cc13c3a
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
@@ -0,0 +1,42 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+import java.util.Map;
+
+
+public interface DataStoreLifeCycle {
+    public boolean initialize(DataStore store, Map<String, String> dsInfos);
+
+    public boolean attachCluster(DataStore store, ClusterScope scope);
+    
+    boolean attachZone(DataStore dataStore, ZoneScope scope);
+    
+    public boolean dettach();
+
+    public boolean unmanaged();
+
+    public boolean maintain();
+
+    public boolean cancelMaintain();
+
+    public boolean deleteDataStore();
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreRole.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreRole.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreRole.java
new file mode 100644
index 0000000..a45ca7a
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreRole.java
@@ -0,0 +1,54 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public enum DataStoreRole {
+    Primary("primary"),
+    Image("image"),
+    ImageCache("imagecache"),
+    Backup("backup");
+    
+    public boolean isImageStore() {
+        return (this.role.equalsIgnoreCase("image") || this.role.equalsIgnoreCase("imagecache")) ? true : false;
+    }
+    
+    private final String role;
+    DataStoreRole(String type) {
+        this.role = type;
+    }
+    
+    public static DataStoreRole getRole(String role) {
+        if (role == null) {
+            throw new CloudRuntimeException("role can't be empty");
+        }
+        if (role.equalsIgnoreCase("primary")) {
+            return Primary;
+        } else if (role.equalsIgnoreCase("image")) {
+            return Image;
+        } else if (role.equalsIgnoreCase("imagecache")) {
+            return ImageCache;
+        } else if (role.equalsIgnoreCase("backup")) {
+            return Backup;
+        } else {
+            throw new CloudRuntimeException("can't identify the role");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
new file mode 100644
index 0000000..414207d
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/EndPoint.java
@@ -0,0 +1,11 @@
+package org.apache.cloudstack.engine.subsystem.api.storage;
+
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public interface EndPoint {
+	public Answer sendMessage(Command cmd);
+	public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
index 11bc26b..ec87cb5 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
@@ -20,17 +20,13 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 
 
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
-
-
-
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Volume;
 
 public interface PrimaryDataStoreInfo {
 	public boolean isHypervisorSupported(HypervisorType hypervisor);
 	public boolean isLocalStorageSupported();
-	public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType);
+	public boolean isVolumeDiskTypeSupported(DiskFormat diskType);
 	public long getCapacity();
 	public long getAvailableCapacity();
 
@@ -40,6 +36,4 @@ public interface PrimaryDataStoreInfo {
 	public String getName();
 	public String getType();
 	public PrimaryDataStoreLifeCycle getLifeCycle();
-	PrimaryDataStoreProvider getProvider();
-	
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
index afdf085..cf29d9f 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
@@ -18,25 +18,6 @@
  */
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
-import java.util.Map;
 
-public interface PrimaryDataStoreLifeCycle {
-    public boolean initialize(Map<String, String> dsInfos);
-
-    public boolean attachCluster(ClusterScope scope);
-
-    public boolean dettach();
-
-    public boolean unmanaged();
-
-    public boolean maintain();
-
-    public boolean cancelMaintain();
-
-    public boolean deleteDataStore();
-
-    /**
-     * @param dataStore
-     */
-    void setDataStore(PrimaryDataStoreInfo dataStore);
+public interface PrimaryDataStoreLifeCycle extends DataStoreLifeCycle {
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
index 9aafebf..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
@@ -14,21 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-import java.util.Map;
-
-public interface PrimaryDataStoreProvider {
-    public PrimaryDataStoreInfo getDataStore(long dataStoreId);
-    public long getId();
-    public String getName();
-
-    /**
-     * @param dsInfos
-     * @return
-     */
-    PrimaryDataStoreInfo registerDataStore(Map<String, String> dsInfos);
-    
-    //LifeCycle of provider
-    public boolean configure();
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
index c1c1e90..fdb15c7 100755
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageOrchestrator.java
@@ -22,7 +22,7 @@ import java.util.List;
 
 import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
 
 import com.cloud.deploy.DeploymentPlan;
@@ -62,7 +62,7 @@ public interface StorageOrchestrator {
      */
     void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
     
-    boolean createVolume(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType);
-    boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, VolumeDiskType dis, TemplateEntity template);
+    boolean createVolume(VolumeEntity volume, long dataStoreId, DiskFormat diskType);
+    boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, DiskFormat dis, TemplateEntity template);
     VolumeEntity allocateVolumeInDb(long size, VolumeType type,String volName, Long templateId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
index 4adc1a8..7c714ef 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
@@ -19,28 +19,12 @@
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
 
-import java.util.Date;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-
-import com.cloud.storage.Volume;
-
-public interface VolumeInfo {
-	public long getSize();
+public interface VolumeInfo extends DataObject {
 	public String getUuid();
-	public String getPath();
-	public PrimaryDataStoreInfo getDataStore() ;
-	public String getTemplateUuid();
-	public String getTemplatePath();
-	public VolumeType getType();
-	public VolumeDiskType getDiskType();
 	public long getId();
-	public Volume.State getCurrentState();
-	public Volume.State getDesiredState();
-	public Date getCreatedDate();
-	public Date getUpdatedDate();
-	public String getOwner();
-	public String getName();
+
 	public boolean isAttachedVM();
+	public String getPath();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/DiskFormat.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/DiskFormat.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/DiskFormat.java
new file mode 100644
index 0000000..c8371ab
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/DiskFormat.java
@@ -0,0 +1,22 @@
+package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public enum DiskFormat {
+    VMDK,
+    VHD,
+    ISO,
+    QCOW2;
+    public static DiskFormat getFormat(String format) {
+        if (VMDK.toString().equalsIgnoreCase(format)) {
+            return VMDK;
+        } else if (VHD.toString().equalsIgnoreCase(format)) {
+            return VHD;
+        } else if (QCOW2.toString().equalsIgnoreCase(format)) {
+            return QCOW2;
+        } else if (ISO.toString().equalsIgnoreCase(format)) {
+            return ISO;
+        }
+        throw new CloudRuntimeException("can't find format match: " + format);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/QCOW2.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/QCOW2.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/QCOW2.java
index b67a735..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/QCOW2.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/QCOW2.java
@@ -14,13 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class QCOW2 extends VolumeDiskTypeBase {
-	public QCOW2() {
-		this.type = "QCOW2";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/Unknown.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/Unknown.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/Unknown.java
index 6600405..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/Unknown.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/Unknown.java
@@ -14,10 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-public class Unknown extends VolumeDiskTypeBase {
-	public Unknown() {
-		this.type = "Unknown";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VHD.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VHD.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VHD.java
index 4f40e3e..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VHD.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VHD.java
@@ -14,13 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class VHD extends VolumeDiskTypeBase {
-	public VHD() {
-		this.type = "VHD";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VMDK.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VMDK.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VMDK.java
index da0adfb..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VMDK.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VMDK.java
@@ -14,13 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class VMDK extends VolumeDiskTypeBase {
-	public VMDK() {
-		this.type = "VMDK";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskType.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskType.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskType.java
index e670d63..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskType.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskType.java
@@ -14,7 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-public interface VolumeDiskType {
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeBase.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeBase.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeBase.java
index 75f7803..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeBase.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeBase.java
@@ -14,37 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-public class VolumeDiskTypeBase implements VolumeDiskType {
-	protected String type = "Unknown";
-
-	@Override
-	public boolean equals(Object that) {
-		if (this == that) {
-			return true;
-		}
-		if (that instanceof String) {
-			if (getType().equalsIgnoreCase((String)that)) {
-				return true;
-			}
-		} else if (that instanceof VolumeDiskTypeBase) {
-			VolumeDiskTypeBase th = (VolumeDiskTypeBase)that;
-			if (this.getType().equalsIgnoreCase(th.getType())) {
-				return true;
-			}
-		} else {
-			return false;
-		}
-		return false;
-	}
-	
-	@Override
-	public String toString() {
-		return getType();
-	}
-	
-	protected String getType() {
-		return this.type;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeHelper.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeHelper.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeHelper.java
index a2b5ede..b248758 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeHelper.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/disktype/VolumeDiskTypeHelper.java
@@ -14,32 +14,3 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class VolumeDiskTypeHelper {
-	
-	static private List<VolumeDiskType> diskTypes;
-	static final private VolumeDiskType defaultType = new Unknown();
-	
-	@Inject
-	public void setDiskTypes(List<VolumeDiskType> diskTypes) {
-		VolumeDiskTypeHelper.diskTypes = diskTypes;
-	}
-	
-	public static VolumeDiskType getDiskType(String type) {
-		for (VolumeDiskType diskType : diskTypes) {
-			if (diskType.equals(type)) {
-				return diskType;
-			}
-		}
-		
-		return VolumeDiskTypeHelper.defaultType;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/pom.xml
----------------------------------------------------------------------
diff --git a/engine/pom.xml b/engine/pom.xml
index 0aca70e..9a5f6d5 100644
--- a/engine/pom.xml
+++ b/engine/pom.xml
@@ -42,6 +42,7 @@
     <module>storage/imagemotion</module>
     <module>storage/backup</module>
     <module>storage/snapshot</module>
+    <module>storage/integration-test</module>
     <module>components-api</module>
     <module>schema</module>
     <module>network</module>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
new file mode 100644
index 0000000..2fbe616
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageDataFactoryImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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.image;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.storage.datastore.DataStoreManager;
+import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
+import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
+import org.apache.cloudstack.storage.image.db.ImageDataDao;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.storage.image.store.TemplateObject;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ImageDataFactoryImpl implements ImageDataFactory {
+    @Inject
+    ImageDataDao imageDataDao;
+    @Inject
+    ObjectInDataStoreManager objMap;
+    @Inject
+    DataStoreManager storeMgr;
+    @Override
+    public TemplateInfo getTemplate(long templateId, DataStore store) {
+        ObjectInDataStoreVO obj = objMap.findObject(templateId, DataObjectType.TEMPLATE, store.getId(), store.getRole());
+        if (obj == null) {
+            return null;
+        }
+        ImageDataVO templ = imageDataDao.findById(templateId);
+        TemplateObject tmpl = new TemplateObject(templ, store);
+        return tmpl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
index 4b65831..99b57e8 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
@@ -20,75 +20,141 @@ package org.apache.cloudstack.storage.image;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
-import org.apache.cloudstack.storage.EndPoint;
-import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
-import org.apache.cloudstack.storage.image.manager.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.framework.async.AsyncCallFuture;
+import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.async.AsyncRpcConext;
+import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
+import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
+import org.apache.cloudstack.storage.image.store.TemplateObject;
+import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
+import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
+import com.cloud.utils.fsm.NoTransitionException;
+
 @Component
 public class ImageServiceImpl implements ImageService {
+    private static final Logger s_logger = Logger.getLogger(ImageServiceImpl.class);
     @Inject
-    ImageDataStoreProviderManager imageStoreProviderMgr;
-
-    public ImageServiceImpl() {
-    }
+    ObjectInDataStoreManager objectInDataStoreMgr;
     
-    @Override
-    public TemplateEntity registerTemplate(long templateId, long imageStoreId) {
-        ImageDataStore ids = imageStoreProviderMgr.getDataStore(imageStoreId);
-        TemplateObject to = ids.registerTemplate(templateId);
-        return new TemplateEntityImpl(to);
-    }
-
-    @Override
-    public boolean deleteTemplate(long templateId) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public long registerIso(String isoUrl, long accountId) {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    @Override
-    public boolean deleteIso(long isoId) {
-        // TODO Auto-generated method stub
-        return false;
+    class CreateTemplateContext<T> extends AsyncRpcConext<T> {
+        final TemplateInfo srcTemplate;
+        final TemplateInfo templateOnStore;
+        final AsyncCallFuture<CommandResult> future;
+        final ObjectInDataStoreVO obj;
+        public CreateTemplateContext(AsyncCompletionCallback<T> callback, TemplateInfo srcTemplate,
+                TemplateInfo templateOnStore,
+                AsyncCallFuture<CommandResult> future,
+                ObjectInDataStoreVO obj) {
+            super(callback);
+            this.srcTemplate = srcTemplate;
+            this.templateOnStore = templateOnStore;
+            this.future = future;
+            this.obj = obj;
+        }
     }
-
+    
     @Override
-    public boolean revokeTemplateAccess(long templateId, long endpointId) {
-        // TODO Auto-generated method stub
-        return false;
+    public AsyncCallFuture<CommandResult> createTemplateAsync(
+            TemplateInfo template, DataStore store) {
+        TemplateObject to = (TemplateObject) template;
+        AsyncCallFuture<CommandResult> future = new AsyncCallFuture<CommandResult>();
+        try {
+            to.stateTransit(TemplateEvent.CreateRequested);
+        } catch (NoTransitionException e) {
+            s_logger.debug("Failed to transit state:", e);
+            CommandResult result = new CommandResult();
+            result.setResult(e.toString());
+            future.complete(result);
+            return future;
+        }
+        
+        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(template.getId(), template.getType(), store.getId(), store.getRole());
+        TemplateInfo templateOnStore = null;
+        if (obj == null) {
+            templateOnStore = objectInDataStoreMgr.create(template, store);
+        } else {
+            CommandResult result = new CommandResult();
+            result.setResult("duplicate template on the storage");
+            future.complete(result);
+            return future;
+        }
+        
+        try {
+            objectInDataStoreMgr.update(templateOnStore, Event.CreateOnlyRequested);
+        } catch (NoTransitionException e) {
+            s_logger.debug("failed to transit", e);
+            CommandResult result = new CommandResult();
+            result.setResult(e.toString());
+            future.complete(result);
+            return future;
+        }
+        CreateTemplateContext<CommandResult> context = new CreateTemplateContext<CommandResult>(null, 
+                template, templateOnStore,
+                future,
+                obj);
+        AsyncCallbackDispatcher<ImageServiceImpl, CreateCmdResult> caller =  AsyncCallbackDispatcher.create(this);
+        caller.setCallback(caller.getTarget().createTemplateCallback(null, null))
+        .setContext(context);
+        store.getDriver().createAsync(templateOnStore, caller);
+        return future;
     }
-
-    @Override
-    public String grantIsoAccess(long isoId, long endpointId) {
-        // TODO Auto-generated method stub
+    
+    protected Void createTemplateCallback(AsyncCallbackDispatcher<ImageServiceImpl, CreateCmdResult> callback, 
+            CreateTemplateContext<CreateCmdResult> context) {
+        
+        TemplateInfo templateOnStore = context.templateOnStore;
+        TemplateObject template = (TemplateObject)context.srcTemplate;
+        AsyncCallFuture<CommandResult> future = context.future;
+        CommandResult result = new CommandResult();
+        
+        CreateCmdResult callbackResult = callback.getResult();
+        if (callbackResult.isFailed()) {
+            try {
+                objectInDataStoreMgr.update(templateOnStore, Event.OperationFailed);
+            } catch (NoTransitionException e) {
+                s_logger.debug("failed to transit state", e);
+            }
+            result.setResult(callbackResult.getResult());
+            future.complete(result);
+            return null;
+        }
+        
+        ObjectInDataStoreVO obj = context.obj;
+        obj.setInstallPath(callbackResult.getPath());
+        
+        try {
+            objectInDataStoreMgr.update(templateOnStore, Event.OperationSuccessed);
+        } catch (NoTransitionException e) {
+            s_logger.debug("Failed to transit state", e);
+            result.setResult(e.toString());
+            future.complete(result);
+            return null;
+        }
+       
+        template.setImageStoreId(templateOnStore.getDataStore().getId());
+        try {
+            template.stateTransit(TemplateEvent.OperationSucceeded);
+        } catch (NoTransitionException e) {
+            s_logger.debug("Failed to transit state", e);
+            result.setResult(e.toString());
+            future.complete(result);
+            return null;
+        }
+        
+        future.complete(result);
         return null;
     }
 
     @Override
-    public boolean revokeIsoAccess(long isoId, long endpointId) {
+    public AsyncCallFuture<CommandResult> deleteTemplateAsync(
+            TemplateInfo template) {
         // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public TemplateEntity getTemplateEntity(long templateId) {
-        ImageDataStore dataStore = imageStoreProviderMgr.getDataStoreFromTemplateId(templateId);
-        TemplateObject to = dataStore.getTemplate(templateId);
-        return new TemplateEntityImpl(to);
-    }
-
-    @Override
-    public boolean grantTemplateAccess(TemplateInfo template, EndPoint endpointId) {
-        // TODO Auto-generated method stub
-        return true;
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java
deleted file mode 100644
index 367302d..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java
+++ /dev/null
@@ -1,61 +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.image;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
-import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
-
-public class TemplateObject implements TemplateInfo {
-    private ImageDataVO imageVO;
-    private ImageDataStoreInfo dataStore;
-
-    public TemplateObject(ImageDataVO template, ImageDataStoreInfo dataStore) {
-        this.imageVO = template;
-        this.dataStore = dataStore;
-    }
-
-    @Override
-    public ImageDataStoreInfo getDataStore() {
-        return this.dataStore;
-    }
-
-    @Override
-    public long getId() {
-        return this.imageVO.getId();
-    }
-
-    @Override
-    public VolumeDiskType getDiskType() {
-        return VolumeDiskTypeHelper.getDiskType(imageVO.getFormat());
-    }
-
-    @Override
-    public String getPath() {
-        //TODO: add installation path if it's downloaded to cache storage already
-        return this.imageVO.getUrl();
-    }
-
-    @Override
-    public String getUuid() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java
new file mode 100644
index 0000000..ae349ff
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java
@@ -0,0 +1,81 @@
+/*
+ * 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.image.driver;
+
+import java.util.Set;
+
+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.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+
+public class DefaultImageDataStoreDriverImpl implements ImageDataStoreDriver {
+
+    public DefaultImageDataStoreDriverImpl() {
+    }
+
+    @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;
+    }
+
+    @Override
+    public void createAsync(DataObject data,
+            AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void deleteAsync(DataObject data,
+            AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java
deleted file mode 100644
index a968c9c..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java
+++ /dev/null
@@ -1,33 +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.image.driver;
-
-import org.apache.cloudstack.storage.EndPoint;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.TemplateObject;
-
-public interface ImageDataStoreDriver {
-    boolean registerTemplate(TemplateInfo template);
-
-    String grantAccess(TemplateObject template, EndPoint endPointId);
-
-    boolean revokeAccess(long templateId, long endPointId);
-
-    boolean deleteTemplate(TemplateInfo template);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java
deleted file mode 100644
index cae57c0..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java
+++ /dev/null
@@ -1,53 +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.image.driver;
-
-import org.apache.cloudstack.storage.EndPoint;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.TemplateObject;
-
-public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
-
-    public ImageDataStoreDriverImpl() {
-    }
-
-    @Override
-    public boolean registerTemplate(TemplateInfo template) {
-        // TODO: check the availability of template
-        return true;
-    }
-
-    @Override
-    public String grantAccess(TemplateObject template, EndPoint endPointId) {
-        return template.getPath();
-    }
-
-    @Override
-    public boolean revokeAccess(long templateId, long endPointId) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean deleteTemplate(TemplateInfo template) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
new file mode 100644
index 0000000..e5a6863
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
@@ -0,0 +1,30 @@
+/*
+ * 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.image.manager;
+
+import org.apache.cloudstack.storage.image.TemplateEvent;
+import org.apache.cloudstack.storage.image.TemplateState;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
+
+import com.cloud.utils.fsm.StateMachine2;
+
+public interface ImageDataManager {
+    StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
new file mode 100644
index 0000000..09303aa
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
@@ -0,0 +1,48 @@
+/*
+ * 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.image.manager;
+
+import org.apache.cloudstack.storage.image.TemplateEvent;
+import org.apache.cloudstack.storage.image.TemplateState;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
+
+import com.cloud.utils.fsm.StateMachine2;
+
+public class ImageDataManagerImpl implements ImageDataManager {
+    private final static StateMachine2<TemplateState, TemplateEvent, ImageDataVO> 
+        stateMachine = new StateMachine2<TemplateState, TemplateEvent, ImageDataVO>();
+    
+    public ImageDataManagerImpl() {
+        stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.CreateRequested, TemplateState.Creating);
+        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.CreateRequested, TemplateState.Creating);
+        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationSucceeded, TemplateState.Ready);
+        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationFailed, TemplateState.Allocated);
+        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.DestroyRequested, TemplateState.Destroying);
+        stateMachine.addTransition(TemplateState.Ready, TemplateEvent.DestroyRequested, TemplateState.Destroying);
+        stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.DestroyRequested, TemplateState.Destroying);
+        stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.DestroyRequested, TemplateState.Destroying);
+        stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationFailed, TemplateState.Destroying);
+        stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationSucceeded, TemplateState.Destroyed);
+    }
+    
+    @Override
+    public StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine() {
+        return stateMachine;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java
deleted file mode 100644
index e1dce50..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.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.image.manager;
-
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
-
-public interface ImageDataStoreManager {
-    ImageDataStore getImageDataStore(long dataStoreId);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
index 8183958..2a24f9b 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
@@ -18,24 +18,52 @@
  */
 package org.apache.cloudstack.storage.image.manager;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.inject.Inject;
 
-import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
+import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
 import org.apache.cloudstack.storage.image.db.ImageDataDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
 import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.storage.image.store.ImageDataStoreImpl;
+import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
+import org.springframework.stereotype.Component;
 
+@Component
 public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
     @Inject
     ImageDataStoreDao dataStoreDao;
     @Inject
     ImageDataDao imageDataDao;
+    @Inject
+    DataStoreProviderManager providerManager;
+    Map<String, ImageDataStoreDriver> driverMaps = new HashMap<String, ImageDataStoreDriver>();
 
     @Override
     public ImageDataStore getImageDataStore(long dataStoreId) {
         ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
+        long providerId = dataStore.getProvider();
+        DataStoreProvider provider = providerManager.getDataStoreProviderById(providerId);
+        ImageDataStore imgStore = new ImageDataStoreImpl(dataStore, 
+                driverMaps.get(provider.getUuid())
+                );
         // TODO Auto-generated method stub
-        return null;
+        return imgStore;
+    }
+
+    @Override
+    public boolean registerDriver(String uuid, ImageDataStoreDriver driver) {
+        if (driverMaps.containsKey(uuid)) {
+            return false;
+        }
+        driverMaps.put(uuid, driver);
+        return true;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
deleted file mode 100644
index 363ed5f..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
+++ /dev/null
@@ -1,75 +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.image.provider;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderDao;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderVO;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
-import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriverImpl;
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
-import org.apache.cloudstack.storage.image.store.ImageDataStoreImpl;
-import org.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.component.ComponentContext;
-
-@Component
-public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
-    private final String providerName = "DefaultProvider";
-    @Inject
-    ImageDataStoreProviderDao providerDao;
-    @Inject
-    ImageDataStoreDao imageStoreDao;
-    ImageDataStoreProviderVO provider;
-
-    @Override
-    public ImageDataStore getImageDataStore(long imageStoreId) {
-        ImageDataStoreVO idsv = imageStoreDao.findById(imageStoreId);
-        ImageDataStoreDriver driver = new ImageDataStoreDriverImpl();
-        ImageDataStore ids = new ImageDataStoreImpl(idsv, driver, false);
-        ids = ComponentContext.inject(ids);
-        return ids;
-    }
-
-    @Override
-    public String getName() {
-        return providerName;
-    }
-
-    @Override
-    public boolean register(long providerId) {
-        return true;
-    }
-
-    @Override
-    public boolean init() {
-        provider = providerDao.findByName(providerName);
-        return true;
-    }
-
-    @Override
-    public ImageDataStoreLifeCycle getLifeCycle() {
-        return new DefaultImageDataStoreLifeCycle(this, provider, imageStoreDao);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
deleted file mode 100644
index 710153a..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
+++ /dev/null
@@ -1,34 +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.image.provider;
-
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-
-public interface ImageDataStoreProvider {
-    ImageDataStore getImageDataStore(long imageStoreId);
-    boolean register(long providerId);
-    public String getName();
-    ImageDataStoreLifeCycle getLifeCycle();
-    /**
-     * @param providerId
-     * @return
-     */
-    boolean init();
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8af85b04/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java
deleted file mode 100644
index f03a0e1..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java
+++ /dev/null
@@ -1,39 +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.image.provider;
-
-import java.util.List;
-
-import org.apache.cloudstack.storage.image.TemplateObject;
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
-
-import com.cloud.utils.component.Manager;
-
-public interface ImageDataStoreProviderManager extends Manager {
-    public ImageDataStoreProvider getProvider(long providerId);
-    public List<ImageDataStoreProvider> listProvider();
-    public ImageDataStore getDataStore(Long dataStoreId);
-
-    public ImageDataStore getDataStoreFromTemplateId(long templateId);
-    /**
-     * @param name
-     * @return
-     */
-    ImageDataStoreProvider getProvider(String name);
-}


Mime
View raw message