incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [12/58] [abbrv] squash changes into one giant patch
Date Fri, 22 Feb 2013 14:01:12 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/DataObjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataObjectManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataObjectManagerImpl.java
index 657d32c..218f901 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataObjectManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataObjectManagerImpl.java
@@ -24,14 +24,14 @@ 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.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
 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.db.ObjectInDataStoreVO;
 import org.apache.cloudstack.storage.motion.DataMotionService;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -52,7 +52,7 @@ public class DataObjectManagerImpl implements DataObjectManager {
     protected DataObject waitingForCreated(DataObject dataObj,
             DataStore dataStore) {
         long retries = this.waitingRetries;
-        ObjectInDataStoreVO obj = null;
+        DataObjectInStore obj = null;
         do {
             try {
                 Thread.sleep(waitingTime);
@@ -61,8 +61,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
                 throw new CloudRuntimeException("sleep interrupted", e);
             }
 
-            obj = objectInDataStoreMgr.findObject(dataObj.getId(),
-                    dataObj.getType(), dataStore.getId(), dataStore.getRole());
+            obj = objectInDataStoreMgr.findObject(dataObj,
+                    dataStore);
             if (obj == null) {
                 s_logger.debug("can't find object in db, maybe it's cleaned up already, exit waiting");
                 break;
@@ -92,11 +92,10 @@ public class DataObjectManagerImpl implements DataObjectManager {
     }
     
     @Override
-    public void createAsync(DataObject data, DataStore store,
+    public void createAsync(DataObject data, DataStore store, 
             AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy) {
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                data.getId(), data.getType(), store.getId(),
-                store.getRole());
+        DataObjectInStore obj = objectInDataStoreMgr.findObject(
+                data, store);
         DataObject objInStore = null;
         boolean freshNewTemplate = false;
         if (obj == null) {
@@ -105,8 +104,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
                         data, store);
                 freshNewTemplate = true;
             } catch (Throwable e) {
-                obj = objectInDataStoreMgr.findObject(data.getId(),
-                        data.getType(), store.getId(), store.getRole());
+                obj = objectInDataStoreMgr.findObject(data,
+                        store);
                 if (obj == null) {
                     CreateCmdResult result = new CreateCmdResult(
                             null, null);
@@ -184,20 +183,12 @@ public class DataObjectManagerImpl implements DataObjectManager {
             return null;
         }
 
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                objInStrore.getId(), objInStrore
-                        .getType(), objInStrore.getDataStore()
-                        .getId(), objInStrore.getDataStore()
-                        .getRole());
-
-        obj.setInstallPath(result.getPath());
-        obj.setSize(result.getSize());
         try {
-            objectInDataStoreMgr.update(obj,
+            objectInDataStoreMgr.update(objInStrore,
                     ObjectInDataStoreStateMachine.Event.OperationSuccessed);
         } catch (NoTransitionException e) {
             try {
-                objectInDataStoreMgr.update(obj,
+                objectInDataStoreMgr.update(objInStrore,
                         ObjectInDataStoreStateMachine.Event.OperationFailed);
             } catch (NoTransitionException e1) {
                 s_logger.debug("failed to change state", e1);
@@ -259,14 +250,10 @@ public class DataObjectManagerImpl implements DataObjectManager {
             CopyContext<CreateCmdResult> context) {
         CopyCommandResult result = callback.getResult();
         DataObject destObj = context.destObj;
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                destObj.getId(), destObj
-                        .getType(), destObj.getDataStore()
-                        .getId(), destObj.getDataStore()
-                        .getRole());
+
         if (result.isFailed()) {
             try {
-                objectInDataStoreMgr.update(obj, Event.OperationFailed);
+                objectInDataStoreMgr.update(destObj, Event.OperationFailed);
             } catch (NoTransitionException e) {
                 s_logger.debug("Failed to update copying state", e);
             }
@@ -276,10 +263,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
             context.getParentCallback().complete(res);
         }
 
-        obj.setInstallPath(result.getPath());
-
         try {
-            objectInDataStoreMgr.update(obj,
+            objectInDataStoreMgr.update(destObj,
                     ObjectInDataStoreStateMachine.Event.OperationSuccessed);
         } catch (NoTransitionException e) {
             s_logger.debug("Failed to update copying state: ", e);
@@ -311,11 +296,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
     @Override
     public void deleteAsync(DataObject data,
             AsyncCompletionCallback<CommandResult> callback) {
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                data.getId(), data.getType(), data.getDataStore().getId(),
-                data.getDataStore().getRole());
         try {
-            objectInDataStoreMgr.update(obj, Event.DestroyRequested);
+            objectInDataStoreMgr.update(data, Event.DestroyRequested);
         } catch (NoTransitionException e) {
             s_logger.debug("destroy failed", e);
             CreateCmdResult res = new CreateCmdResult(
@@ -338,23 +320,18 @@ public class DataObjectManagerImpl implements DataObjectManager {
     protected Void deleteAsynCallback(AsyncCallbackDispatcher<DataObjectManagerImpl, CommandResult> callback,
             DeleteContext<CommandResult> context) {
         DataObject destObj = context.obj;
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                destObj.getId(), destObj
-                        .getType(), destObj.getDataStore()
-                        .getId(), destObj.getDataStore()
-                        .getRole());
-        
+
         CommandResult res = callback.getResult();
         if (res.isFailed()) {
             try {
-                objectInDataStoreMgr.update(obj, Event.OperationFailed);
+                objectInDataStoreMgr.update(destObj, Event.OperationFailed);
             } catch (NoTransitionException e) {
                s_logger.debug("delete failed", e);
             }
             
         } else {
             try {
-                objectInDataStoreMgr.update(obj, Event.OperationSuccessed);
+                objectInDataStoreMgr.update(destObj, Event.OperationSuccessed);
             } catch (NoTransitionException e) {
                s_logger.debug("delete failed", e);
             }
@@ -366,9 +343,8 @@ public class DataObjectManagerImpl implements DataObjectManager {
 
     @Override
     public DataObject createInternalStateOnly(DataObject data, DataStore store) {
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                data.getId(), data.getType(), store.getId(),
-                store.getRole());
+        DataObjectInStore obj = objectInDataStoreMgr.findObject(
+                data, store);
         DataObject objInStore = null;
         if (obj == null) {
             objInStore = objectInDataStoreMgr.create(
@@ -391,12 +367,6 @@ public class DataObjectManagerImpl implements DataObjectManager {
 
     @Override
     public void update(DataObject data, String path, Long size) {
-        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
-                data.getId(), data.getType(), data.getDataStore().getId(),
-                data.getDataStore().getRole());
-        
-        obj.setInstallPath(path);
-        obj.setSize(size);
-        objectInDataStoreMgr.update(obj);
+       throw new CloudRuntimeException("not implemented");
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java
deleted file mode 100644
index 829be50..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java
+++ /dev/null
@@ -1,29 +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.datastore;
-
-import java.util.Map;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
-
-public interface DataStoreManager {
-    public DataStore getDataStore(long storeId, DataStoreRole role);
-    public DataStore registerDataStore(Map<String, String> params, String providerUuid);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
index f857ac5..a2fd08d 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
@@ -18,12 +18,15 @@
  */
 package org.apache.cloudstack.storage.datastore;
 
+import java.util.List;
 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.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
 import org.springframework.stereotype.Component;
 
@@ -50,5 +53,22 @@ public class DataStoreManagerImpl implements DataStoreManager {
             String providerUuid) {
         return null;
     }
+    @Override
+    public DataStore getDataStore(String uuid, DataStoreRole role) {
+        if (role == DataStoreRole.Primary) {
+            return primaryStorMgr.getPrimaryDataStore(uuid);
+        } else if (role == DataStoreRole.Image) {
+            return imageDataStoreMgr.getImageDataStore(uuid);
+        }
+        throw new CloudRuntimeException("un recognized type" + role);
+    }
+    @Override
+    public List<DataStore> getImageStores(Scope scope) {
+        return imageDataStoreMgr.getList();
+    }
+    @Override
+    public DataStore getPrimaryDataStore(long storeId) {
+        return primaryStorMgr.getPrimaryDataStore(storeId);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
deleted file mode 100644
index 23551e4..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
+++ /dev/null
@@ -1,23 +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.datastore;
-
-public enum DataStoreStatus {
-    Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManager.java
index e707de6..d170f5c 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManager.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManager.java
@@ -17,26 +17,20 @@
 package org.apache.cloudstack.storage.datastore;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 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.DataStoreRole;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
 
 import com.cloud.utils.fsm.NoTransitionException;
 
 public interface ObjectInDataStoreManager {
     public DataObject create(DataObject template, DataStore dataStore);
-    public VolumeInfo create(VolumeInfo volume, DataStore dataStore);
-    public SnapshotInfo create(SnapshotInfo snapshot, DataStore dataStore);
-    public ObjectInDataStoreVO findObject(long objectId, DataObjectType type,
-            long dataStoreId, DataStoreRole role);
     public DataObject get(DataObject dataObj, DataStore store);
     public boolean update(DataObject vo, Event event) throws NoTransitionException;
-    boolean update(ObjectInDataStoreVO obj, Event event)
-            throws NoTransitionException;
-    
-    boolean update(ObjectInDataStoreVO obj);
+    DataObjectInStore findObject(String uuid, DataObjectType type,
+            String dataStoreUuid, DataStoreRole role);
+    DataObjectInStore findObject(DataObject obj, DataStore store);
+    DataStore findStore(String objUuid, DataObjectType type,  DataStoreRole role);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
index 7eb4932..87ba1d2 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
@@ -19,19 +19,25 @@ package org.apache.cloudstack.storage.datastore;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 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.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.storage.db.ObjectInDataStoreDao;
 import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
-import org.apache.cloudstack.storage.image.ImageDataFactory;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-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.log4j.Logger;
 import org.springframework.stereotype.Component;
 
+import com.cloud.storage.VMTemplateStoragePoolVO;
+import com.cloud.storage.dao.VMTemplateHostDao;
+import com.cloud.storage.dao.VMTemplatePoolDao;
+import com.cloud.storage.dao.VolumeHostDao;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.SearchCriteria2;
 import com.cloud.utils.db.SearchCriteriaService;
@@ -41,16 +47,28 @@ import com.cloud.utils.fsm.StateMachine2;
 
 @Component
 public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
+    private static final Logger s_logger = Logger
+            .getLogger(ObjectInDataStoreManagerImpl.class);
     @Inject
     ImageDataFactory imageFactory;
     @Inject
+    DataStoreManager storeMgr;
+    @Inject
     VolumeDataFactory volumeFactory;
     @Inject
     ObjectInDataStoreDao objectDataStoreDao;
-    protected StateMachine2<State, Event, ObjectInDataStoreVO> stateMachines;
+    @Inject
+    VolumeHostDao volumeHostDao;
+    @Inject
+    VMTemplateHostDao templateHostDao;
+    @Inject
+    VMTemplatePoolDao templatePoolDao;
+    @Inject
+    SnapshotDataFactory snapshotFactory;
+    protected StateMachine2<State, Event, DataObjectInStore> stateMachines;
 
     public ObjectInDataStoreManagerImpl() {
-        stateMachines = new StateMachine2<State, Event, ObjectInDataStoreVO>();
+        stateMachines = new StateMachine2<State, Event, DataObjectInStore>();
         stateMachines.addTransition(State.Allocated, Event.CreateRequested,
                 State.Creating);
         stateMachines.addTransition(State.Creating, Event.OperationSuccessed,
@@ -76,101 +94,122 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
         stateMachines.addTransition(State.Allocated, Event.CreateOnlyRequested,
                 State.Creating2);
         stateMachines.addTransition(State.Creating2, Event.OperationFailed,
-                State.Failed);
+                State.Allocated);
         stateMachines.addTransition(State.Creating2, Event.OperationSuccessed,
                 State.Ready);
     }
 
     @Override
     public DataObject create(DataObject obj, DataStore dataStore) {
-        
-        ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
-        vo.setDataStoreId(dataStore.getId());
-        vo.setDataStoreRole(dataStore.getRole());
-        vo.setObjectId(obj.getId());
-        vo.setSize(obj.getSize());
-
-        vo.setObjectType(obj.getType());
-        vo = objectDataStoreDao.persist(vo);
+        if (obj.getType() == DataObjectType.TEMPLATE && dataStore.getRole() == DataStoreRole.Primary) {
+            VMTemplateStoragePoolVO vo = new VMTemplateStoragePoolVO(dataStore.getId(), obj.getId());
+            vo = templatePoolDao.persist(vo);
+        } else {
+            ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
+            vo.setDataStoreRole(dataStore.getRole());
+            vo.setDataStoreUuid(dataStore.getUuid());
+            vo.setObjectType(obj.getType());
+            vo.setObjectUuid(obj.getUuid());
+            vo = objectDataStoreDao.persist(vo);
+        }
 
         if (obj.getType() == DataObjectType.TEMPLATE) {
-            return imageFactory.getTemplate(obj.getId(), dataStore);
+            return imageFactory.getTemplate(obj, dataStore);
         } else if (obj.getType() == DataObjectType.VOLUME) {
-            return volumeFactory.getVolume(obj.getId(), dataStore); 
+            return volumeFactory.getVolume(obj, dataStore); 
+        } else if (obj.getType() == DataObjectType.SNAPSHOT) {
+            return snapshotFactory.getSnapshot(obj, dataStore);
         }
         throw new CloudRuntimeException("unknown type");
     }
-
-    @Override
-    public VolumeInfo create(VolumeInfo volume, DataStore dataStore) {
-        ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
-        vo.setDataStoreId(dataStore.getId());
-        vo.setDataStoreRole(dataStore.getRole());
-        vo.setObjectId(volume.getId());
-        vo.setObjectType(volume.getType());
-        vo = objectDataStoreDao.persist(vo);
-
-        return volumeFactory.getVolume(volume.getId(), dataStore);
-    }
-
-    @Override
-    public SnapshotInfo create(SnapshotInfo snapshot, DataStore dataStore) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public ObjectInDataStoreVO findObject(long objectId, DataObjectType type,
-            long dataStoreId, DataStoreRole role) {
-        SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2
-                .create(ObjectInDataStoreVO.class);
-        sc.addAnd(sc.getEntity().getObjectId(), Op.EQ, objectId);
-        sc.addAnd(sc.getEntity().getDataStoreId(), Op.EQ, dataStoreId);
-        sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
-        sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
-        sc.addAnd(sc.getEntity().getState(), Op.NIN,
-                ObjectInDataStoreStateMachine.State.Destroyed,
-                ObjectInDataStoreStateMachine.State.Failed);
-        ObjectInDataStoreVO objectStoreVO = sc.find();
-        return objectStoreVO;
-
-    }
-
+    
     @Override
     public boolean update(DataObject data, Event event)
             throws NoTransitionException {
-        ObjectInDataStoreVO obj = this.findObject(data.getId(), data.getType(),
-                data.getDataStore().getId(), data.getDataStore().getRole());
+        DataObjectInStore obj = this.findObject(data, data.getDataStore());
         if (obj == null) {
             throw new CloudRuntimeException(
                     "can't find mapping in ObjectInDataStore table for: "
                             + data);
         }
-        return this.stateMachines.transitTo(obj, event, null,
-                objectDataStoreDao);
-
-    }
-    
-    @Override
-    public boolean update(ObjectInDataStoreVO obj, Event event)
-            throws NoTransitionException {
-        return this.stateMachines.transitTo(obj, event, null,
-                objectDataStoreDao);
-
+        
+        if (data.getType() == DataObjectType.TEMPLATE && data.getDataStore().getRole() == DataStoreRole.Primary) {
+            try {
+            this.stateMachines.transitTo(obj, event, null,
+                    templatePoolDao);
+            } catch (NoTransitionException e) {
+                if (event == Event.CreateOnlyRequested || event == Event.OperationSuccessed) {
+                    s_logger.debug("allow muliple create requests");
+                } else {
+                    throw e;
+                }
+            }
+        } else {
+            this.stateMachines.transitTo(obj, event, null, objectDataStoreDao);
+        }
+        return true;
     }
 
     @Override
     public DataObject get(DataObject dataObj, DataStore store) {
         if (dataObj.getType() == DataObjectType.TEMPLATE) {
-            return imageFactory.getTemplate(dataObj.getId(), store);
+            return imageFactory.getTemplate(dataObj, store);
         } else if (dataObj.getType() == DataObjectType.VOLUME) {
-            return volumeFactory.getVolume(dataObj.getId(), store); 
+            return volumeFactory.getVolume(dataObj, store); 
         }
         throw new CloudRuntimeException("unknown type");
     }
 
     @Override
-    public boolean update(ObjectInDataStoreVO obj) {
-        return objectDataStoreDao.update(obj.getId(), obj);
+    public DataObjectInStore findObject(DataObject obj, DataStore store) {
+        DataObjectInStore vo = null;
+        SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
+        
+        if (store.getRole() == DataStoreRole.Image) {
+            sc.addAnd(sc.getEntity().getDataStoreUuid(), Op.EQ, store.getUuid());
+            sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, store.getRole());
+            sc.addAnd(sc.getEntity().getObjectUuid(), Op.EQ, obj.getUuid());
+            sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, obj.getType());
+            vo = sc.find();
+        } else if (obj.getType() == DataObjectType.TEMPLATE && store.getRole() == DataStoreRole.Primary) {
+            vo = templatePoolDao.findByPoolTemplate(store.getId(), obj.getId());
+        } else {
+            s_logger.debug("unknown type: " + obj.getType() + " " + store.getRole());
+            throw new CloudRuntimeException("unknown type");
+        }
+        return vo;
     }
+
+    @Override
+    public DataObjectInStore findObject(String uuid, DataObjectType type,
+            String dataStoreUuid, DataStoreRole role) {
+        DataObjectInStore vo = null;
+        SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
+        
+        if (role == DataStoreRole.Image) {
+            sc.addAnd(sc.getEntity().getDataStoreUuid(), Op.EQ, dataStoreUuid);
+            sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
+            sc.addAnd(sc.getEntity().getObjectUuid(), Op.EQ, uuid);
+            sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
+            vo = sc.find();
+        }
+        return vo;
+    }
+    
+    @Override
+    public DataStore findStore(String objUuid, DataObjectType type,  DataStoreRole role) {
+        DataStore store = null;
+        if (role == DataStoreRole.Image) {
+            SearchCriteriaService<ObjectInDataStoreVO, ObjectInDataStoreVO> sc = SearchCriteria2.create(ObjectInDataStoreVO.class);
+            sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
+            sc.addAnd(sc.getEntity().getObjectUuid(), Op.EQ, objUuid);
+            sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
+            ObjectInDataStoreVO vo = sc.find();
+            if (vo != null) {
+                store = this.storeMgr.getDataStore(vo.getDataStoreUuid(), vo.getDataStoreRole());
+            }
+        }
+        return store;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
index a6ba9bc..fdaaace 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
@@ -20,31 +20,19 @@ package org.apache.cloudstack.storage.datastore;
 
 import java.util.List;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
 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.PrimaryDataStoreInfo;
+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.disktype.DiskFormat;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
-import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
 
 public interface PrimaryDataStore extends DataStore, PrimaryDataStoreInfo {
     VolumeInfo getVolume(long id);
 
     List<VolumeInfo> getVolumes();
 
-/*    void deleteVolumeAsync(VolumeInfo volume, AsyncCompletionCallback<CommandResult> callback);
-
-    void createVolumeAsync(VolumeInfo vo, VolumeDiskType diskType, AsyncCompletionCallback<CommandResult> callback);
-
-    void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateInfo templateStore, AsyncCompletionCallback<CommandResult> callback);
- */   
-
     boolean exists(DataObject data);
 
     TemplateInfo getTemplate(long templateId);
@@ -53,13 +41,4 @@ public interface PrimaryDataStore extends DataStore, PrimaryDataStoreInfo {
 
 
     DiskFormat getDefaultDiskType();
-
-/*    void takeSnapshot(SnapshotInfo snapshot,
-            AsyncCompletionCallback<CommandResult> callback);
-
-    void revertSnapshot(SnapshotInfo snapshot,
-            AsyncCompletionCallback<CommandResult> callback);
-
-    void deleteSnapshot(SnapshotInfo snapshot,
-            AsyncCompletionCallback<CommandResult> callback);*/
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
index 0ac57f4..e70f803 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
@@ -26,8 +26,8 @@ import java.util.Map;
 import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 
-import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.StoragePoolStatus;
 
 public class PrimaryDataStoreEntityImpl implements StorageEntity {
     private PrimaryDataStoreInfo dataStore;
@@ -132,7 +132,8 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
 
     @Override
     public State getState() {
-        return this.dataStore.getManagedState();
+        //return this.dataStore.getManagedState();
+        return null;
     }
 
     @Override
@@ -229,13 +230,7 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
         return null;
     }
 
-    @Override
-    public String getStorageProvider() {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
-    @Override
     public String getStorageType() {
         // TODO Auto-generated method stub
         return null;
@@ -247,4 +242,16 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
 		
 	}
 
+    @Override
+    public Long getStorageProviderId() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean isInMaintenance() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
index a60ec7a..664c2d1 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
@@ -18,11 +18,14 @@
  */
 package org.apache.cloudstack.storage.datastore;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
 import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
 
 
 public interface PrimaryDataStoreProviderManager {
     public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
+    public PrimaryDataStore getPrimaryDataStore(String uuid);
 
     boolean registerDriver(String uuid, PrimaryDataStoreDriver driver);
+    boolean registerHostListener(String uuid, HypervisorHostListener listener);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/VolumeDataFactory.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/VolumeDataFactory.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/VolumeDataFactory.java
deleted file mode 100644
index 0cffc05..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/VolumeDataFactory.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.datastore;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-
-public interface VolumeDataFactory {
-    VolumeInfo getVolume(long volumeId, DataStore store);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDao.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDao.java
deleted file mode 100644
index dca83ce..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDao.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.datastore.db;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface DataStoreProviderDao extends GenericDao<DataStoreProviderVO, Long> {
-    public DataStoreProviderVO findByName(String name);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDaoImpl.java
deleted file mode 100644
index ccb6b48..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderDaoImpl.java
+++ /dev/null
@@ -1,38 +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.datastore.db;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Component
-class DataStoreProviderDaoImpl extends GenericDaoBase<DataStoreProviderVO, Long> implements DataStoreProviderDao {
-
-    @Override
-    public DataStoreProviderVO findByName(String name) {
-        SearchCriteriaService<DataStoreProviderVO, DataStoreProviderVO> sc = SearchCriteria2.create(DataStoreProviderVO.class);
-        sc.addAnd(sc.getEntity().getName(), Op.EQ, name);
-        return sc.find();
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderVO.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderVO.java
deleted file mode 100644
index dcdafdd..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreProviderVO.java
+++ /dev/null
@@ -1,60 +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.datastore.db;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-
-@Entity
-@Table(name = "data_store_provider")
-public class DataStoreProviderVO {
-    @Id
-    @TableGenerator(name = "data_store_provider_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "data_store_provider_seq", allocationSize = 1)
-    @Column(name = "id", updatable = false, nullable = false)
-    private long id;
-
-    @Column(name = "name", nullable = false)
-    private String name;
-    
-    @Column(name = "uuid", nullable = false)
-    private String uuid;
-    
-    public long getId() {
-        return id;
-    }
-    
-    public String getName() {
-        return this.name;
-    }
-    
-    public void setName(String name) {
-        this.name = name;
-    }
-    
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-    
-    public String getUuid() {
-        return this.uuid;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
deleted file mode 100644
index 24a5c79..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
+++ /dev/null
@@ -1,116 +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.datastore.db;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cloudstack.storage.datastore.DataStoreStatus;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long> {
-
-    /**
-     * @param datacenterId
-     *            -- the id of the datacenter (availability zone)
-     */
-    List<PrimaryDataStoreVO> listByDataCenterId(long datacenterId);
-
-    /**
-     * @param datacenterId
-     *            -- the id of the datacenter (availability zone)
-     */
-    List<PrimaryDataStoreVO> listBy(long datacenterId, long podId, Long clusterId);
-
-    /**
-     * Set capacity of storage pool in bytes
-     * 
-     * @param id
-     *            pool id.
-     * @param capacity
-     *            capacity in bytes
-     */
-    void updateCapacity(long id, long capacity);
-
-    /**
-     * Set available bytes of storage pool in bytes
-     * 
-     * @param id
-     *            pool id.
-     * @param available
-     *            available capacity in bytes
-     */
-    void updateAvailable(long id, long available);
-
-    PrimaryDataStoreVO persist(PrimaryDataStoreVO pool, Map<String, String> details);
-
-    /**
-     * Find pool by name.
-     * 
-     * @param name
-     *            name of pool.
-     * @return the single StoragePoolVO
-     */
-    List<PrimaryDataStoreVO> findPoolByName(String name);
-
-    /**
-     * Find pools by the pod that matches the details.
-     * 
-     * @param podId
-     *            pod id to find the pools in.
-     * @param details
-     *            details to match. All must match for the pool to be returned.
-     * @return List of StoragePoolVO
-     */
-    List<PrimaryDataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
-
-    List<PrimaryDataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
-
-    /**
-     * Find pool by UUID.
-     * 
-     * @param uuid
-     *            uuid of pool.
-     * @return the single StoragePoolVO
-     */
-    PrimaryDataStoreVO findPoolByUUID(String uuid);
-
-    List<PrimaryDataStoreVO> listByStorageHost(String hostFqdnOrIp);
-
-    PrimaryDataStoreVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
-
-    List<PrimaryDataStoreVO> listPoolByHostPath(String host, String path);
-
-    void updateDetails(long poolId, Map<String, String> details);
-
-    Map<String, String> getDetails(long poolId);
-
-    List<String> searchForStoragePoolDetails(long poolId, String value);
-
-    List<PrimaryDataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid);
-
-    List<PrimaryDataStoreVO> listByStatus(DataStoreStatus status);
-
-    long countPoolsByStatus(DataStoreStatus... statuses);
-
-    List<PrimaryDataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status);
-
-    List<PrimaryDataStoreVO> listPoolsByCluster(long clusterId);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
deleted file mode 100644
index faca54b..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ /dev/null
@@ -1,360 +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.datastore.db;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.cloudstack.storage.datastore.DataStoreStatus;
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Component
-public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO, Long> implements PrimaryDataStoreDao {
-    protected final SearchBuilder<PrimaryDataStoreVO> AllFieldSearch;
-    protected final SearchBuilder<PrimaryDataStoreVO> DcPodSearch;
-    protected final SearchBuilder<PrimaryDataStoreVO> DcPodAnyClusterSearch;
-    protected final SearchBuilder<PrimaryDataStoreVO> DeleteLvmSearch;
-    protected final GenericSearchBuilder<PrimaryDataStoreVO, Long> StatusCountSearch;
-
-    @Inject protected PrimaryDataStoreDetailsDao _detailsDao;
-
-    private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
-    private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
-    private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
-
-    public PrimaryDataStoreDaoImpl() {
-        AllFieldSearch = createSearchBuilder();
-        AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
-        AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
-        AllFieldSearch.done();
-
-        DcPodSearch = createSearchBuilder();
-        DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
-        DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
-        DcPodSearch.cp();
-        DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
-        DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
-        DcPodSearch.cp();
-        DcPodSearch.done();
-
-        DcPodAnyClusterSearch = createSearchBuilder();
-        DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
-        DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
-        DcPodAnyClusterSearch.cp();
-        DcPodAnyClusterSearch.done();
-
-        DeleteLvmSearch = createSearchBuilder();
-        DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
-        DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
-        DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
-        DeleteLvmSearch.cp();
-        DeleteLvmSearch.done();
-
-        StatusCountSearch = createSearchBuilder(Long.class);
-        StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
-        StatusCountSearch.select(null, Func.COUNT, null);
-        StatusCountSearch.done();
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> findPoolByName(String name) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("name", name);
-        return listIncludingRemovedBy(sc);
-    }
-
-    @Override
-    public PrimaryDataStoreVO findPoolByUUID(String uuid) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("uuid", uuid);
-        return findOneIncludingRemovedBy(sc);
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("uuid", uuid);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listByDataCenterId(long datacenterId) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("datacenterId", datacenterId);
-        return listBy(sc);
-    }
-
-    @Override
-    public void updateAvailable(long id, long available) {
-        PrimaryDataStoreVO pool = createForUpdate(id);
-        pool.setAvailableBytes(available);
-        update(id, pool);
-    }
-
-    @Override
-    public void updateCapacity(long id, long capacity) {
-        PrimaryDataStoreVO pool = createForUpdate(id);
-        pool.setCapacityBytes(capacity);
-        update(id, pool);
-
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listByStorageHost(String hostFqdnOrIp) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("hostAddress", hostFqdnOrIp);
-        return listIncludingRemovedBy(sc);
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listByStatus(DataStoreStatus status) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("status", status);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("status", status);
-        sc.setParameters("datacenterId", dcId);
-        return listBy(sc);
-    }
-
-    @Override
-    public PrimaryDataStoreVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("hostAddress", host);
-        sc.setParameters("path", path);
-        sc.setParameters("datacenterId", datacenterId);
-        sc.setParameters("podId", podId);
-        sc.setParameters("uuid", uuid);
-
-        return findOneBy(sc);
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listBy(long datacenterId, long podId, Long clusterId) {
-        if (clusterId != null) {
-            SearchCriteria<PrimaryDataStoreVO> sc = DcPodSearch.create();
-            sc.setParameters("datacenterId", datacenterId);
-            sc.setParameters("podId", podId);
-
-            sc.setParameters("cluster", clusterId);
-            return listBy(sc);
-        } else {
-            SearchCriteria<PrimaryDataStoreVO> sc = DcPodAnyClusterSearch.create();
-            sc.setParameters("datacenterId", datacenterId);
-            sc.setParameters("podId", podId);
-            return listBy(sc);
-        }
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listPoolByHostPath(String host, String path) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("hostAddress", host);
-        sc.setParameters("path", path);
-
-        return listBy(sc);
-    }
-
-    public PrimaryDataStoreVO listById(Integer id) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("id", id);
-
-        return findOneIncludingRemovedBy(sc);
-    }
-
-    @Override
-    @DB
-    public PrimaryDataStoreVO persist(PrimaryDataStoreVO pool, Map<String, String> details) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        pool = super.persist(pool);
-        if (details != null) {
-            for (Map.Entry<String, String> detail : details.entrySet()) {
-                PrimaryDataStoreDetailVO vo = new PrimaryDataStoreDetailVO(pool.getId(), detail.getKey(), detail.getValue());
-                _detailsDao.persist(vo);
-            }
-        }
-        txn.commit();
-        return pool;
-    }
-
-    @DB
-    @Override
-    public List<PrimaryDataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details) {
-        StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
-        if (clusterId != null) {
-            sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
-        }
-        for (Map.Entry<String, String> detail : details.entrySet()) {
-            sql.append("((storage_pool_details.name='").append(detail.getKey()).append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
-        }
-        sql.delete(sql.length() - 4, sql.length());
-        sql.append(DetailsSqlSuffix);
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = txn.prepareAutoCloseStatement(sql.toString());
-            int i = 1;
-            pstmt.setLong(i++, dcId);
-            pstmt.setLong(i++, podId);
-            if (clusterId != null) {
-                pstmt.setLong(i++, clusterId);
-            }
-            pstmt.setInt(i++, details.size());
-            ResultSet rs = pstmt.executeQuery();
-            List<PrimaryDataStoreVO> pools = new ArrayList<PrimaryDataStoreVO>();
-            while (rs.next()) {
-                pools.add(toEntityBean(rs, false));
-            }
-            return pools;
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable to execute " + pstmt, e);
-        }
-    }
-
-    protected Map<String, String> tagsToDetails(String[] tags) {
-        Map<String, String> details = new HashMap<String, String>(tags.length);
-        for (String tag : tags) {
-            details.put(tag, "true");
-        }
-        return details;
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared) {
-        List<PrimaryDataStoreVO> storagePools = null;
-        if (tags == null || tags.length == 0) {
-            storagePools = listBy(dcId, podId, clusterId);
-        } else {
-            Map<String, String> details = tagsToDetails(tags);
-            storagePools = findPoolsByDetails(dcId, podId, clusterId, details);
-        }
-
-        if (shared == null) {
-            return storagePools;
-        } else {
-            List<PrimaryDataStoreVO> filteredStoragePools = new ArrayList<PrimaryDataStoreVO>(storagePools);
-            for (PrimaryDataStoreVO pool : storagePools) {
-                /*
-                 * if (shared != pool.isShared()) {
-                 * filteredStoragePools.remove(pool); }
-                 */
-            }
-
-            return filteredStoragePools;
-        }
-    }
-
-    @Override
-    @DB
-    public List<String> searchForStoragePoolDetails(long poolId, String value) {
-
-        StringBuilder sql = new StringBuilder(FindPoolTagDetails);
-
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = txn.prepareAutoCloseStatement(sql.toString());
-            pstmt.setLong(1, poolId);
-            pstmt.setString(2, value);
-
-            ResultSet rs = pstmt.executeQuery();
-            List<String> tags = new ArrayList<String>();
-
-            while (rs.next()) {
-                tags.add(rs.getString("name"));
-            }
-            return tags;
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
-        }
-
-    }
-
-    @Override
-    public void updateDetails(long poolId, Map<String, String> details) {
-        if (details != null) {
-            _detailsDao.update(poolId, details);
-        }
-    }
-
-    @Override
-    public Map<String, String> getDetails(long poolId) {
-        return _detailsDao.getDetails(poolId);
-    }
-
-    @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
-        super.configure(name, params);
-        _detailsDao.configure("DetailsDao", params);
-        return true;
-    }
-
-    @Override
-    public long countPoolsByStatus(DataStoreStatus... statuses) {
-        SearchCriteria<Long> sc = StatusCountSearch.create();
-
-        sc.setParameters("status", (Object[]) statuses);
-
-        List<Long> rs = customSearchIncludingRemoved(sc, null);
-        if (rs.size() == 0) {
-            return 0;
-        }
-
-        return rs.get(0);
-    }
-
-    @Override
-    public List<PrimaryDataStoreVO> listPoolsByCluster(long clusterId) {
-        SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
-        sc.setParameters("clusterId", clusterId);
-
-        return listBy(sc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
deleted file mode 100644
index d1f802d..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
+++ /dev/null
@@ -1,79 +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.datastore.db;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="storage_pool_details")
-public class PrimaryDataStoreDetailVO {
-    @Id
-    @GeneratedValue(strategy=GenerationType.IDENTITY)
-    @Column(name="id")
-    long id;
-    
-    @Column(name="pool_id")
-    long poolId;
-    
-    @Column(name="name")
-    String name;
-    
-    @Column(name="value")
-    String value;
-    
-    public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
-        this.poolId = poolId;
-        this.name = name;
-        this.value = value;
-    }
-   
-    public long getId() {
-        return id;
-    }
-
-    public long getPoolId() {
-        return poolId;
-    }
-
-    public void setPoolId(long poolId) {
-        this.poolId = poolId;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-
-    protected PrimaryDataStoreDetailVO() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
deleted file mode 100644
index 906742b..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
+++ /dev/null
@@ -1,28 +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.datastore.db;
-
-import java.util.Map;
-
-import com.cloud.storage.StoragePoolDetailVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
-    
-    void update(long poolId, Map<String, String> details);
-    Map<String, String> getDetails(long poolId);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java
deleted file mode 100644
index 59c488c..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java
+++ /dev/null
@@ -1,71 +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.datastore.db;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-
-@Component
-public class PrimaryDataStoreDetailsDaoImpl extends GenericDaoBase<PrimaryDataStoreDetailVO, Long> implements PrimaryDataStoreDetailsDao {
-    
-    protected final SearchBuilder<PrimaryDataStoreDetailVO> PoolSearch = null;
-    
-    protected PrimaryDataStoreDetailsDaoImpl() {
-        /*
-        super();
-        PoolSearch = createSearchBuilder();
-        PoolSearch.and("pool", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
-        PoolSearch.done();
-        */
-    }
-    
-    @Override
-    public void update(long poolId, Map<String, String> details) {
-        Transaction txn = Transaction.currentTxn();
-        SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
-        sc.setParameters("pool", poolId);
-        
-        txn.start();
-        expunge(sc);
-        for (Map.Entry<String, String> entry : details.entrySet()) {
-            PrimaryDataStoreDetailVO detail = new PrimaryDataStoreDetailVO(poolId, entry.getKey(), entry.getValue());
-            persist(detail);
-        }
-        txn.commit();
-    }
-    
-    @Override
-    public Map<String, String> getDetails(long poolId) {
-    	SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
-    	sc.setParameters("pool", poolId);
-    	
-    	List<PrimaryDataStoreDetailVO> details = listBy(sc);
-    	Map<String, String> detailsMap = new HashMap<String, String>();
-    	for (PrimaryDataStoreDetailVO detail : details) {
-    		detailsMap.put(detail.getName(), detail.getValue());
-    	}
-    	
-    	return detailsMap;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
deleted file mode 100644
index 3e37ec7..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
+++ /dev/null
@@ -1,267 +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.datastore.db;
-
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
-import org.apache.cloudstack.storage.datastore.DataStoreStatus;
-
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name = "storage_pool")
-public class PrimaryDataStoreVO implements Identity {
-    @Id
-    @TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "storage_pool_seq", allocationSize = 1)
-    @Column(name = "id", updatable = false, nullable = false)
-    private long id;
-
-    @Column(name = "name", updatable = false, nullable = false, length = 255)
-    private String name = null;
-
-    @Column(name = "uuid", length = 255)
-    private String uuid = null;
-
-    @Column(name = "pool_type", updatable = false, nullable = false, length = 32)
-    private String poolType;
-
-    @Column(name = GenericDao.CREATED_COLUMN)
-    Date created;
-
-    @Column(name = GenericDao.REMOVED_COLUMN)
-    private Date removed;
-
-    @Column(name = "update_time", updatable = true)
-    @Temporal(value = TemporalType.TIMESTAMP)
-    private Date updateTime;
-
-    @Column(name = "data_center_id", updatable = true, nullable = false)
-    private long dataCenterId;
-
-    @Column(name = "pod_id", updatable = true)
-    private Long podId;
-
-    @Column(name = "available_bytes", updatable = true, nullable = true)
-    private long availableBytes;
-
-    @Column(name = "capacity_bytes", updatable = true, nullable = true)
-    private long capacityBytes;
-
-    @Column(name = "status", updatable = true, nullable = false)
-    @Enumerated(value = EnumType.STRING)
-    private DataStoreStatus status;
-
-    @Column(name = "storage_provider_id", updatable = true, nullable = false)
-    private Long storageProviderId;
-
-    @Column(name = "host_address")
-    private String hostAddress;
-
-    @Column(name = "path")
-    private String path;
-
-    @Column(name = "port")
-    private int port;
-
-    @Column(name = "user_info")
-    private String userInfo;
-
-    @Column(name = "cluster_id")
-    private Long clusterId;
-
-    @Column(name = "scope")
-    @Enumerated(value = EnumType.STRING)
-    private ScopeType scope;
-
-    public long getId() {
-        return id;
-    }
-
-    public DataStoreStatus getStatus() {
-        return status;
-    }
-
-    public PrimaryDataStoreVO() {
-        this.status = DataStoreStatus.Initial;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public String getUuid() {
-        return uuid;
-    }
-
-    public String getPoolType() {
-        return poolType;
-    }
-
-    public void setPoolType(String protocol) {
-        this.poolType = protocol;
-    }
-
-    public Date getCreated() {
-        return created;
-    }
-
-    public Date getRemoved() {
-        return removed;
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public long getDataCenterId() {
-        return dataCenterId;
-    }
-
-    public long getAvailableBytes() {
-        return availableBytes;
-    }
-
-    public Long getStorageProviderId() {
-        return storageProviderId;
-    }
-
-    public void setStorageProviderId(Long provider) {
-        storageProviderId = provider;
-    }
-
-    public long getCapacityBytes() {
-        return capacityBytes;
-    }
-
-    public void setAvailableBytes(long available) {
-        availableBytes = available;
-    }
-
-    public void setCapacityBytes(long capacity) {
-        capacityBytes = capacity;
-    }
-
-    public Long getClusterId() {
-        return clusterId;
-    }
-
-    public void setClusterId(Long clusterId) {
-        this.clusterId = clusterId;
-    }
-
-    public String getHostAddress() {
-        return hostAddress;
-    }
-
-    public void setHostAddress(String host) {
-        this.hostAddress = host;
-    }
-
-    public String getPath() {
-        return path;
-    }
-
-    public String getUserInfo() {
-        return userInfo;
-    }
-
-    public void setStatus(DataStoreStatus status) {
-        this.status = status;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public void setDataCenterId(long dcId) {
-        this.dataCenterId = dcId;
-    }
-
-    public void setPodId(Long podId) {
-        this.podId = podId;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public void setUserInfo(String userInfo) {
-        this.userInfo = userInfo;
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public void setPort(int port) {
-        this.port = port;
-    }
-
-    public Long getPodId() {
-        return podId;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public void setScope(ScopeType scope) {
-        this.scope = scope;
-    }
-
-    public ScopeType getScope() {
-        return this.scope;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (!(obj instanceof PrimaryDataStoreVO) || obj == null) {
-            return false;
-        }
-        PrimaryDataStoreVO that = (PrimaryDataStoreVO) obj;
-        return this.id == that.id;
-    }
-
-    @Override
-    public int hashCode() {
-        return new Long(id).hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProvider.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProvider.java
deleted file mode 100644
index 0d38f34..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProvider.java
+++ /dev/null
@@ -1,32 +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.datastore.provider;
-
-import java.util.Map;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-
-public interface DataStoreProvider {
-    public DataStoreLifeCycle getLifeCycle();
-    public String getName();
-    public String getUuid();
-    public long getId();
-    public boolean configure(Map<String, Object> params);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManager.java
deleted file mode 100644
index cbe045c..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManager.java
+++ /dev/null
@@ -1,30 +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.datastore.provider;
-
-import java.util.List;
-
-import com.cloud.utils.component.Manager;
-
-public interface DataStoreProviderManager extends Manager {
-    public DataStoreProvider getDataStoreProviderByUuid(String uuid);
-    public DataStoreProvider getDataStoreProviderById(long id);
-    public DataStoreProvider getDataStoreProvider(String name);
-    public List<DataStoreProvider> getDataStoreProviders();
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
index 3634b52..96d2da3 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
@@ -26,14 +26,19 @@ import java.util.UUID;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.DataStoreProviderDao;
 import org.apache.cloudstack.storage.datastore.db.DataStoreProviderVO;
+import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.utils.component.ManagerBase;
 
 @Component
 public class DataStoreProviderManagerImpl extends ManagerBase implements DataStoreProviderManager {
+    private static final Logger s_logger = Logger
+            .getLogger(DataStoreProviderManagerImpl.class);
     @Inject
     List<DataStoreProvider> providers;
     @Inject
@@ -59,8 +64,8 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
     @Override
     public boolean configure(String name, Map<String, Object> params)
     		throws ConfigurationException {
-    	
-/*
+        Map<String, Object> copyParams = new HashMap<String, Object>(params);
+
     	//TODO: hold global lock
         List<DataStoreProviderVO> providerVos = providerDao.listAll();
         for (DataStoreProvider provider : providers) {
@@ -83,12 +88,20 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
             } else {
                 uuid = providerVO.getUuid();
             }
-            params.put("uuid", uuid);
-            params.put("id", providerVO.getId());
-            provider.configure(params);
+            copyParams.put("uuid", uuid);
+            copyParams.put("id", providerVO.getId());
             providerMap.put(uuid, provider);
+            try {
+                boolean registrationResult = provider.configure(copyParams);
+                if (!registrationResult) {
+                    providerMap.remove(uuid);
+                }
+            } catch(Exception e) {
+                s_logger.debug("configure provider failed", e);
+                providerMap.remove(uuid);
+            }
         }
- */    
+  
         return true;
     }
 
@@ -97,4 +110,9 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
         DataStoreProviderVO provider = providerDao.findById(id);
         return providerMap.get(provider.getUuid());
     }
+
+    @Override
+    public DataStoreProvider getDefaultPrimaryDataStoreProvider() {
+        return this.getDataStoreProvider("ancient primary data store provider");
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
index 502158c..d44a40e 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cloudstack.storage.datastore.provider;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+
 public interface ImageDataStoreProvider extends DataStoreProvider {
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
index dbca549..fdf5958 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
@@ -16,6 +16,8 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.provider;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+
 
 public interface PrimaryDataStoreProvider extends DataStoreProvider {
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDao.java b/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDao.java
index 08f9182..fb7dec0 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDao.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/db/ObjectInDataStoreDao.java
@@ -16,10 +16,12 @@
 // under the License.
 package org.apache.cloudstack.storage.db;
 
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.fsm.StateDao;
 
-public interface ObjectInDataStoreDao extends GenericDao<ObjectInDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, ObjectInDataStoreVO>  {
+public interface ObjectInDataStoreDao extends GenericDao<ObjectInDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore>  {
 
 }


Mime
View raw message