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

[2/4] Removed schema from the dependency of many components

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
deleted file mode 100644
index 698465f..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
+++ /dev/null
@@ -1,43 +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 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 VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
-StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
-
-    List<VolumeDataStoreVO> listByStoreId(long id);
-
-    List<VolumeDataStoreVO> listActiveOnCache(long id);
-
-    void deletePrimaryRecordsForStore(long id);
-
-    VolumeDataStoreVO findByVolume(long volumeId);
-
-    VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
-
-    VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
-
-    List<VolumeDataStoreVO> listDestroyed(long storeId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
deleted file mode 100755
index a5d0830..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
+++ /dev/null
@@ -1,348 +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.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
-
-import com.cloud.storage.Storage;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.fsm.StateObject;
-
-/**
- * Join table for image_data_store and volumes
- * 
- */
-@Entity
-@Table(name = "volume_store_ref")
-public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
-
-    @Column(name = "store_id")
-    private long dataStoreId;
-
-    @Column(name = "volume_id")
-    private long volumeId;
-
-    @Column(name = "zone_id")
-    private long zoneId;
-
-    @Column(name = GenericDaoBase.CREATED_COLUMN)
-    private Date created = null;
-
-    @Column(name = "last_updated")
-    @Temporal(value = TemporalType.TIMESTAMP)
-    private Date lastUpdated = null;
-
-    @Column(name = "download_pct")
-    private int downloadPercent;
-
-    @Column(name = "size")
-    private long size;
-
-    @Column(name = "physical_size")
-    private long physicalSize;
-
-    @Column(name = "download_state")
-    @Enumerated(EnumType.STRING)
-    private Status downloadState;
-
-    @Column(name = "checksum")
-    private String checksum;
-
-    @Column(name = "local_path")
-    private String localDownloadPath;
-
-    @Column(name = "error_str")
-    private String errorString;
-
-    @Column(name = "job_id")
-    private String jobId;
-
-    @Column(name = "install_path")
-    private String installPath;
-
-    @Column(name = "url")
-    private String downloadUrl;
-
-    @Column(name = "destroyed")
-    boolean destroyed = false;
-
-    @Column(name = "update_count", updatable = true, nullable = false)
-    protected long updatedCount;
-
-    @Column(name = "updated")
-    @Temporal(value = TemporalType.TIMESTAMP)
-    Date updated;
-
-    @Column(name = "state")
-    @Enumerated(EnumType.STRING)
-    ObjectInDataStoreStateMachine.State state;
-
-    @Column(name = "ref_cnt")
-    Long refCnt = 0L;
-
-    public String getInstallPath() {
-        return installPath;
-    }
-
-    @Override
-    public long getDataStoreId() {
-        return dataStoreId;
-    }
-
-    public void setDataStoreId(long storeId) {
-        this.dataStoreId = storeId;
-    }
-
-    public long getVolumeId() {
-        return volumeId;
-    }
-
-    public void setVolumeId(long volumeId) {
-        this.volumeId = volumeId;
-    }
-
-    public long getZoneId() {
-        return zoneId;
-    }
-
-    public void setZoneId(long zoneId) {
-        this.zoneId = zoneId;
-    }
-
-    public int getDownloadPercent() {
-        return downloadPercent;
-    }
-
-    public void setDownloadPercent(int downloadPercent) {
-        this.downloadPercent = downloadPercent;
-    }
-
-    public void setDownloadState(Status downloadState) {
-        this.downloadState = downloadState;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public Date getCreated() {
-        return created;
-    }
-
-    public Date getLastUpdated() {
-        return lastUpdated;
-    }
-
-    public void setLastUpdated(Date date) {
-        lastUpdated = date;
-    }
-
-    public void setInstallPath(String installPath) {
-        this.installPath = installPath;
-    }
-
-    public Status getDownloadState() {
-        return downloadState;
-    }
-
-    public String getChecksum() {
-        return checksum;
-    }
-
-    public void setChecksum(String checksum) {
-        this.checksum = checksum;
-    }
-
-    public VolumeDataStoreVO(long hostId, long volumeId) {
-        super();
-        this.dataStoreId = hostId;
-        this.volumeId = volumeId;
-        this.state = ObjectInDataStoreStateMachine.State.Allocated;
-        this.refCnt = 0L;
-    }
-
-    public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState,
-            String localDownloadPath, String errorString, String jobId, String installPath, String downloadUrl,
-            String checksum) {
-        // super();
-        this.dataStoreId = hostId;
-        this.volumeId = volumeId;
-        // this.zoneId = zoneId;
-        this.lastUpdated = lastUpdated;
-        this.downloadPercent = downloadPercent;
-        this.downloadState = downloadState;
-        this.localDownloadPath = localDownloadPath;
-        this.errorString = errorString;
-        this.jobId = jobId;
-        this.installPath = installPath;
-        this.setDownloadUrl(downloadUrl);
-        this.checksum = checksum;
-        this.refCnt = 0L;
-    }
-
-    public VolumeDataStoreVO() {
-        this.refCnt = 0L;
-    }
-
-    public void setLocalDownloadPath(String localPath) {
-        this.localDownloadPath = localPath;
-    }
-
-    public String getLocalDownloadPath() {
-        return localDownloadPath;
-    }
-
-    public void setErrorString(String errorString) {
-        this.errorString = errorString;
-    }
-
-    public String getErrorString() {
-        return errorString;
-    }
-
-    public void setJobId(String jobId) {
-        this.jobId = jobId;
-    }
-
-    public String getJobId() {
-        return jobId;
-    }
-
-    public boolean equals(Object obj) {
-        if (obj instanceof VolumeDataStoreVO) {
-            VolumeDataStoreVO other = (VolumeDataStoreVO) obj;
-            return (this.volumeId == other.getVolumeId() && this.dataStoreId == other.getDataStoreId());
-        }
-        return false;
-    }
-
-    public int hashCode() {
-        Long tid = new Long(volumeId);
-        Long hid = new Long(dataStoreId);
-        return tid.hashCode() + hid.hashCode();
-    }
-
-    public void setSize(long size) {
-        this.size = size;
-    }
-
-    public long getSize() {
-        return size;
-    }
-
-    public void setPhysicalSize(long physicalSize) {
-        this.physicalSize = physicalSize;
-    }
-
-    public long getPhysicalSize() {
-        return physicalSize;
-    }
-
-    public void setDestroyed(boolean destroyed) {
-        this.destroyed = destroyed;
-    }
-
-    public boolean getDestroyed() {
-        return destroyed;
-    }
-
-    public void setDownloadUrl(String downloadUrl) {
-        this.downloadUrl = downloadUrl;
-    }
-
-    public String getDownloadUrl() {
-        return downloadUrl;
-    }
-
-    public long getVolumeSize() {
-        return -1;
-    }
-
-    public String toString() {
-        return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(dataStoreId)
-                .append(installPath).append("]").toString();
-    }
-
-    public long getUpdatedCount() {
-        return this.updatedCount;
-    }
-
-    public void incrUpdatedCount() {
-        this.updatedCount++;
-    }
-
-    public void decrUpdatedCount() {
-        this.updatedCount--;
-    }
-
-    public Date getUpdated() {
-        return updated;
-    }
-
-    @Override
-    public ObjectInDataStoreStateMachine.State getState() {
-        // TODO Auto-generated method stub
-        return this.state;
-    }
-
-    public void setState(ObjectInDataStoreStateMachine.State state) {
-        this.state = state;
-    }
-
-    @Override
-    public long getObjectId() {
-        return this.getVolumeId();
-    }
-
-    @Override
-    public State getObjectInStoreState() {
-        return this.state;
-    }
-
-    public Long getRefCnt() {
-        return refCnt;
-    }
-
-    public void incrRefCnt() {
-        this.refCnt++;
-    }
-
-    public void decrRefCnt() {
-        this.refCnt--;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java b/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
deleted file mode 100644
index 0037ea5..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.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.to;
-
-import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
-
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.storage.DataStoreRole;
-
-public class ImageStoreTO implements DataStoreTO {
-    private String type;
-    private String uri;
-    private String providerName;
-    private DataStoreRole role;
-
-    public ImageStoreTO() {
-
-    }
-
-    public ImageStoreTO(ImageStoreInfo dataStore) {
-        this.type = dataStore.getType();
-        this.uri = dataStore.getUri();
-        this.providerName = null;
-        this.role = dataStore.getRole();
-    }
-
-    public String getProtocol() {
-        return this.type;
-    }
-
-    public String getUri() {
-        return this.uri;
-    }
-
-    public String getProviderName() {
-        return providerName;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public void setUri(String uri) {
-        this.uri = uri;
-    }
-
-    public void setProviderName(String providerName) {
-        this.providerName = providerName;
-    }
-
-    public void setRole(DataStoreRole role) {
-        this.role = role;
-    }
-
-    @Override
-    public DataStoreRole getRole() {
-        return this.role;
-    }
-
-    @Override
-    public String toString() {
-        return new StringBuilder("ImageStoreTO[type=").append(type).append("|provider=").append(providerName)
-                .append("|role=").append(role).append("|uri=").append(uri).append("]").toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
deleted file mode 100644
index 5e870df..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
+++ /dev/null
@@ -1,103 +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.to;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
-
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.Storage.StoragePoolType;
-
-public class PrimaryDataStoreTO implements DataStoreTO {
-    private final String uuid;
-    private final String name;
-    private String type;
-    private final long id;
-    private StoragePoolType poolType;
-    private String host;
-    private String path;
-    private int port;
-
-    public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
-        this.uuid = dataStore.getUuid();
-        this.name = dataStore.getName();
-        this.id = dataStore.getId();
-        this.setPoolType(dataStore.getPoolType());
-        this.setHost(dataStore.getHostAddress());
-        this.setPath(dataStore.getPath());
-        this.setPort(dataStore.getPort());
-    }
-
-    public long getId() {
-        return this.id;
-    }
-
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    public String getName() {
-        return this.name;
-    }
-
-    public String getType() {
-        return this.type;
-    }
-
-    @Override
-    public DataStoreRole getRole() {
-        return DataStoreRole.Primary;
-    }
-
-    public StoragePoolType getPoolType() {
-        return poolType;
-    }
-
-    public void setPoolType(StoragePoolType poolType) {
-        this.poolType = poolType;
-    }
-
-    public String getHost() {
-        return host;
-    }
-
-    public void setHost(String host) {
-        this.host = host;
-    }
-
-    public String getPath() {
-        return path;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public void setPort(int port) {
-        this.port = port;
-    }
-
-    @Override
-    public String toString() {
-        return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid).append("|name=").append(name)
-                .append("|id=").append(id).append("|pooltype=").append(poolType).append("]").toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
deleted file mode 100644
index d2cb72a..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
+++ /dev/null
@@ -1,128 +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.to;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
-
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-
-public class SnapshotObjectTO implements DataTO {
-    private String path;
-    private VolumeObjectTO volume;
-    private String parentSnapshotPath;
-    private DataStoreTO dataStore;
-    private String vmName;
-    private String name;
-    private HypervisorType hypervisorType;
-    private long id;
-
-    public SnapshotObjectTO() {
-
-    }
-
-    public SnapshotObjectTO(SnapshotInfo snapshot) {
-        this.path = snapshot.getPath();
-        this.setId(snapshot.getId());
-        this.volume = (VolumeObjectTO) snapshot.getBaseVolume().getTO();
-        this.setVmName(snapshot.getBaseVolume().getAttachedVmName());
-        SnapshotInfo parentSnapshot = snapshot.getParent();
-        if (parentSnapshot != null) {
-            this.parentSnapshotPath = parentSnapshot.getPath();
-        }
-        this.dataStore = snapshot.getDataStore().getTO();
-        this.setName(snapshot.getName());
-        this.hypervisorType = snapshot.getHypervisorType();
-    }
-
-    @Override
-    public DataObjectType getObjectType() {
-        return DataObjectType.SNAPSHOT;
-    }
-
-    @Override
-    public DataStoreTO getDataStore() {
-        return this.dataStore;
-    }
-
-    @Override
-    public String getPath() {
-        return this.path;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public VolumeObjectTO getVolume() {
-        return volume;
-    }
-
-    public void setVolume(VolumeObjectTO volume) {
-        this.volume = volume;
-    }
-
-    public String getParentSnapshotPath() {
-        return parentSnapshotPath;
-    }
-
-    public void setParentSnapshotPath(String parentSnapshotPath) {
-        this.parentSnapshotPath = parentSnapshotPath;
-    }
-
-    public String getVmName() {
-        return vmName;
-    }
-
-    public void setVmName(String vmName) {
-        this.vmName = vmName;
-    }
-
-    @Override
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Override
-    public HypervisorType getHypervisorType() {
-        return hypervisorType;
-    }
-
-    public void setHypervisorType(HypervisorType hypervisorType) {
-        this.hypervisorType = hypervisorType;
-    }
-
-    @Override
-    public String toString() {
-        return new StringBuilder("SnapshotTO[datastore=").append(dataStore).append("|volume=").append(volume).append("|path")
-                .append(path).append("]").toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
deleted file mode 100644
index 2347de3..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
+++ /dev/null
@@ -1,208 +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.to;
-
-import com.cloud.hypervisor.Hypervisor;
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
-
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.template.VirtualMachineTemplate;
-
-public class TemplateObjectTO implements DataTO {
-    private String path;
-    private String origUrl;
-    private String uuid;
-    private long id;
-    private ImageFormat format;
-    private long accountId;
-    private String checksum;
-    private boolean hvm;
-    private String displayText;
-    private DataStoreTO imageDataStore;
-    private String name;
-    private String guestOsType;
-    private Long size;
-    private Hypervisor.HypervisorType hypervisorType;
-
-    public TemplateObjectTO() {
-
-    }
-
-    public TemplateObjectTO(VirtualMachineTemplate template) {
-        this.uuid = template.getUuid();
-        this.id = template.getId();
-        this.origUrl = template.getUrl();
-        this.displayText = template.getDisplayText();
-        this.checksum = template.getChecksum();
-        this.hvm = template.isRequiresHvm();
-        this.accountId = template.getAccountId();
-        this.name = template.getUniqueName();
-        this.format = template.getFormat();
-        this.hypervisorType = template.getHypervisorType();
-    }
-
-    public TemplateObjectTO(TemplateInfo template) {
-        this.path = template.getInstallPath();
-        this.uuid = template.getUuid();
-        this.id = template.getId();
-        this.origUrl = template.getUrl();
-        this.displayText = template.getDisplayText();
-        this.checksum = template.getChecksum();
-        this.hvm = template.isRequiresHvm();
-        this.accountId = template.getAccountId();
-        this.name = template.getUniqueName();
-        this.format = template.getFormat();
-        if (template.getDataStore() != null) {
-            this.imageDataStore = template.getDataStore().getTO();
-        }
-        this.hypervisorType = template.getHypervisorType();
-    }
-
-    @Override
-    public String getPath() {
-        return this.path;
-    }
-
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    @Override
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id){
-        this.id = id;
-    }
-
-    public ImageFormat getFormat() {
-        return format;
-    }
-
-    public long getAccountId() {
-        return accountId;
-    }
-
-    public String getChecksum() {
-        return checksum;
-    }
-
-    public boolean isRequiresHvm() {
-        return hvm;
-    }
-
-    public void setRequiresHvm(boolean hvm) {
-        this.hvm = hvm;
-    }
-
-    public String getDescription() {
-        return displayText;
-    }
-
-    public void setDescription(String desc) {
-        this.displayText = desc;
-    }
-
-
-    @Override
-    public DataObjectType getObjectType() {
-        return DataObjectType.TEMPLATE;
-    }
-
-    @Override
-    public DataStoreTO getDataStore() {
-        return this.imageDataStore;
-    }
-
-    @Override
-    public Hypervisor.HypervisorType getHypervisorType() {
-        return this.hypervisorType;
-    }
-
-    public void setDataStore(DataStoreTO store){
-        this.imageDataStore = store;
-    }
-
-    /**
-     * @return the name
-     */
-    public String getName() {
-        return name;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getOrigUrl() {
-        return origUrl;
-    }
-
-    public void setOrigUrl(String origUrl) {
-        this.origUrl = origUrl;
-    }
-
-    public void setFormat(ImageFormat format) {
-        this.format = format;
-    }
-
-    public void setAccountId(long accountId) {
-        this.accountId = accountId;
-    }
-
-    public void setChecksum(String checksum) {
-        this.checksum = checksum;
-    }
-
-    public void setImageDataStore(DataStoreTO imageDataStore) {
-        this.imageDataStore = imageDataStore;
-    }
-
-    public String getGuestOsType() {
-        return guestOsType;
-    }
-
-    public void setGuestOsType(String guestOsType) {
-        this.guestOsType = guestOsType;
-    }
-
-    public Long getSize() {
-        return size;
-    }
-
-    public void setSize(Long size) {
-        this.size = size;
-    }
-
-    @Override
-    public String toString() {
-        return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)
-                .append("|name").append(name).append("]").toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
deleted file mode 100644
index 9f466ae..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
+++ /dev/null
@@ -1,223 +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.to;
-
-import com.cloud.hypervisor.Hypervisor;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.storage.Storage;
-import com.cloud.storage.Volume;
-
-public class VolumeObjectTO implements DataTO {
-    private String uuid;
-    private Volume.Type volumeType;
-    private DataStoreTO dataStore;
-    private String name;
-    private long size;
-    private String path;
-    private Long volumeId;
-    private String vmName;
-    private long accountId;
-    private String chainInfo;
-    private Storage.ImageFormat format;
-    private long id;
-    private Long bytesReadRate;
-    private Long bytesWriteRate;
-    private Long iopsReadRate;
-    private Long iopsWriteRate;
-    private Hypervisor.HypervisorType hypervisorType;
-
-    public VolumeObjectTO() {
-
-    }
-
-    public VolumeObjectTO(VolumeInfo volume) {
-        this.uuid = volume.getUuid();
-        this.path = volume.getPath();
-        this.accountId = volume.getAccountId();
-        if (volume.getDataStore() != null) {
-            this.dataStore = volume.getDataStore().getTO();
-        } else {
-            this.dataStore = null;
-        }
-        this.vmName = volume.getAttachedVmName();
-        this.size = volume.getSize();
-        this.setVolumeId(volume.getId());
-        this.chainInfo = volume.getChainInfo();
-        this.volumeType = volume.getVolumeType();
-        this.name = volume.getName();
-        this.setId(volume.getId());
-        this.format = volume.getFormat();
-        this.bytesReadRate = volume.getBytesReadRate();
-        this.bytesWriteRate = volume.getBytesWriteRate();
-        this.iopsReadRate = volume.getIopsReadRate();
-        this.iopsWriteRate = volume.getIopsWriteRate();
-        this.hypervisorType = volume.getHypervisorType();
-    }
-
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    @Override
-    public String getPath() {
-        return this.path;
-    }
-
-    public Volume.Type getVolumeType() {
-        return this.volumeType;
-    }
-
-    @Override
-    public DataStoreTO getDataStore() {
-        return this.dataStore;
-    }
-
-    @Override
-    public Hypervisor.HypervisorType getHypervisorType() {
-        return this.hypervisorType;
-    }
-
-
-    public void setDataStore(DataStoreTO store){
-        this.dataStore = store;
-    }
-
-    public void setDataStore(PrimaryDataStoreTO dataStore) {
-        this.dataStore = dataStore;
-    }
-
-    public String getName() {
-        return this.name;
-    }
-
-    public long getSize() {
-        return this.size;
-    }
-
-    @Override
-    public DataObjectType getObjectType() {
-        return DataObjectType.VOLUME;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public void setSize(long size) {
-        this.size = size;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
-    public Long getVolumeId() {
-        return volumeId;
-    }
-
-    public void setVolumeId(Long volumeId) {
-        this.volumeId = volumeId;
-    }
-
-    public long getAccountId() {
-        return accountId;
-    }
-
-    public void setAccountId(long accountId) {
-        this.accountId = accountId;
-    }
-
-    public String getVmName() {
-        return vmName;
-    }
-
-    public void setVmName(String vmName) {
-        this.vmName = vmName;
-    }
-
-    public String getChainInfo() {
-        return chainInfo;
-    }
-
-    public void setChainInfo(String chainInfo) {
-        this.chainInfo = chainInfo;
-    }
-
-    @Override
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public Storage.ImageFormat getFormat() {
-        return format;
-    }
-
-    public void setFormat(Storage.ImageFormat format) {
-        this.format = format;
-    }
-
-    @Override
-    public String toString() {
-        return new StringBuilder("volumeTO[uuid=").append(uuid).append("|path=").append(path)
-                .append("|datastore=").append(dataStore).append("]").toString();
-    }
-
-    public void setBytesReadRate(Long bytesReadRate) {
-        this.bytesReadRate = bytesReadRate;
-    }
-
-    public Long getBytesReadRate() {
-        return bytesReadRate;
-    }
-
-    public void setBytesWriteRate(Long bytesWriteRate) {
-        this.bytesWriteRate = bytesWriteRate;
-    }
-
-    public Long getBytesWriteRate() {
-        return bytesWriteRate;
-    }
-
-    public void setIopsReadRate(Long iopsReadRate) {
-        this.iopsReadRate = iopsReadRate;
-    }
-
-    public Long getIopsReadRate() {
-        return iopsReadRate;
-    }
-
-    public void setIopsWriteRate(Long iopsWriteRate) {
-        this.iopsWriteRate = iopsWriteRate;
-    }
-
-    public Long getIopsWriteRate() {
-        return iopsWriteRate;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java b/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java
new file mode 100644
index 0000000..5ab3480
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java
@@ -0,0 +1,73 @@
+// 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 com.cloud.storage;
+
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="guest_os_hypervisor")
+public class GuestOSHypervisorVO implements GuestOSHypervisor {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+    @Column(name="guest_os_id")
+    private long guestOsId;
+
+    @Column(name="guest_os_name")
+    String guestOsName;
+
+    @Column(name="hypervisor_type")
+    String hypervisorType;
+
+
+    @Override
+    public long getId() {
+    	return id;
+    }
+
+
+    @Override
+    public String getHypervisorType() {
+        return hypervisorType;
+    }
+
+
+    @Override
+    public String getGuestOsName() {
+        return guestOsName;
+    }
+
+
+    @Override
+    public long getGuestOsId() {
+        return guestOsId;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/com/cloud/storage/VolumeDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VolumeDetailVO.java b/engine/schema/src/com/cloud/storage/VolumeDetailVO.java
new file mode 100644
index 0000000..b0c8c1d
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/VolumeDetailVO.java
@@ -0,0 +1,85 @@
+// 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 com.cloud.storage;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+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="volume_details")
+public class VolumeDetailVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="volume_id")
+    private long volumeId;
+
+    @Column(name="name")
+    private String name;
+
+    @Column(name="value", length=1024)
+    private String value;
+
+    public VolumeDetailVO() {}
+
+    public VolumeDetailVO(long volumeId, String name, String value) {
+        this.volumeId = volumeId;
+        this.name = name;
+        this.value = value;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getVolumeId() {
+        return volumeId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public void setVolumeId(long volumeId) {
+        this.volumeId = volumeId;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
new file mode 100644
index 0000000..70e9bb3
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
@@ -0,0 +1,37 @@
+/*
+ * 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 org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
+    ImageStoreVO findByName(String name);
+
+    List<ImageStoreVO> findByProvider(String provider);
+
+    List<ImageStoreVO> findByScope(ZoneScope scope);
+
+    List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
+
+    List<ImageStoreVO> listImageStores();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
new file mode 100644
index 0000000..b922148
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
@@ -0,0 +1,82 @@
+// 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.apache.cloudstack.api.InternalIdentity;
+
+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 = "image_store_details")
+public class ImageStoreDetailVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    long id;
+
+    @Column(name = "store_id")
+    long storeId;
+
+    @Column(name = "name")
+    String name;
+
+    @Column(name = "value")
+    String value;
+
+    public ImageStoreDetailVO() {
+    }
+
+    public ImageStoreDetailVO(long storeId, String name, String value) {
+        this.storeId = storeId;
+        this.name = name;
+        this.value = value;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(long storeId) {
+        this.storeId = storeId;
+    }
+
+    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;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
new file mode 100644
index 0000000..91fff28
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.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.datastore.db;
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ImageStoreDetailsDao extends GenericDao<ImageStoreDetailVO, Long> {
+
+    void update(long storeId, Map<String, String> details);
+
+    Map<String, String> getDetails(long storeId);
+
+    void deleteDetails(long storeId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
new file mode 100644
index 0000000..5ed48a3
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
@@ -0,0 +1,193 @@
+/*
+ * 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 com.cloud.storage.DataStoreRole;
+import com.cloud.storage.ImageStore;
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "image_store")
+public class ImageStoreVO implements ImageStore {
+    @Id
+    @TableGenerator(name = "image_store_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
+            pkColumnValue = "image_store_seq", allocationSize = 1)
+    @Column(name = "id", nullable = false)
+    private long id;
+
+    @Column(name = "name", nullable = false)
+    private String name;
+
+    @Column(name = "uuid", nullable = false)
+    private String uuid;
+
+    @Column(name = "protocol", nullable = false)
+    private String protocol;
+
+    @Column(name = "url", nullable = false)
+    private String url;
+
+    @Column(name = "image_provider_name", nullable = false)
+    private String providerName;
+
+    @Column(name = "data_center_id")
+    private Long dcId;
+
+    @Column(name = "scope")
+    @Enumerated(value = EnumType.STRING)
+    private ScopeType scope;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = "role")
+    @Enumerated(value = EnumType.STRING)
+    private DataStoreRole role;
+
+    @Column(name = "parent")
+    private String parent;
+
+    @Column(name = "total_size")
+    private Long totalSize;
+
+    @Column(name = "used_bytes")
+    private Long usedBytes;
+
+    public DataStoreRole getRole() {
+        return role;
+    }
+
+    public void setRole(DataStoreRole role) {
+        this.role = role;
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getProviderName() {
+        return this.providerName;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setProviderName(String provider) {
+        this.providerName = provider;
+    }
+
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
+    public String getProtocol() {
+        return this.protocol;
+    }
+
+    public void setDataCenterId(Long dcId) {
+        this.dcId = dcId;
+    }
+
+    public Long getDataCenterId() {
+        return this.dcId;
+    }
+
+    public ScopeType getScope() {
+        return this.scope;
+    }
+
+    public void setScope(ScopeType scope) {
+        this.scope = scope;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getUuid() {
+        return this.uuid;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+
+    public String getParent() {
+        return parent;
+    }
+
+    public void setParent(String parent) {
+        this.parent = parent;
+    }
+
+    public Long getTotalSize() {
+        return totalSize;
+    }
+
+    public void setTotalSize(Long totalSize) {
+        this.totalSize = totalSize;
+    }
+
+    public Long getUsedBytes() {
+        return usedBytes;
+    }
+
+    public void setUsedBytes(Long usedBytes) {
+        this.usedBytes = usedBytes;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
new file mode 100644
index 0000000..669dd25
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -0,0 +1,120 @@
+// 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 com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.utils.db.GenericDao;
+
+/**
+ * Data Access Object for storage_pool table
+ */
+public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
+
+    /**
+     * @param datacenterId -- the id of the datacenter (availability zone)
+     */
+    List<StoragePoolVO> listByDataCenterId(long datacenterId);
+
+    /**
+     * @param datacenterId -- the id of the datacenter (availability zone)
+     */
+    List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope);
+
+    /**
+     * 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);
+
+    StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details);
+
+    /**
+     * Find pool by name.
+     *
+     * @param name
+     *            name of pool.
+     * @return the single StoragePoolVO
+     */
+    List<StoragePoolVO> 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<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
+                                           ScopeType scope);
+
+    List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
+
+    /**
+     * Find pool by UUID.
+     *
+     * @param uuid
+     *            uuid of pool.
+     * @return the single StoragePoolVO
+     */
+    StoragePoolVO findPoolByUUID(String uuid);
+
+    List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
+
+    StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
+
+    List<StoragePoolVO> 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<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
+
+    List<StoragePoolVO> listByStatus(StoragePoolStatus status);
+
+    long countPoolsByStatus(StoragePoolStatus... statuses);
+
+    List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status);
+
+    List<StoragePoolVO> listPoolsByCluster(long clusterId);
+
+    List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
+
+    List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
+
+    List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
new file mode 100644
index 0000000..1032526
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -0,0 +1,432 @@
+// 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.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import com.cloud.host.Status;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePoolStatus;
+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.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Local(value = { PrimaryDataStoreDao.class })
+@DB(txn = false)
+public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
+    protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
+    protected final SearchBuilder<StoragePoolVO> DcPodSearch;
+    protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
+    protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
+    protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
+
+    @Inject
+    protected StoragePoolDetailsDao _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.status = 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and storage_pool.scope = ? and (";
+    private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
+    private final String ZoneWideDetailsSqlPrefix = "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.status = 'Up' and storage_pool.data_center_id = ? and storage_pool.scope = ? and (";
+    private final String ZoneWideDetailsSqlSuffix = ") 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("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+        DcPodSearch.and("scope", DcPodSearch.entity().getScope(), 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("status", DcPodAnyClusterSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+        DcPodAnyClusterSearch.and("scope", DcPodAnyClusterSearch.entity().getScope(), 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<StoragePoolVO> findPoolByName(String name) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("name", name);
+        return listIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public StoragePoolVO findPoolByUUID(String uuid) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("uuid", uuid);
+        return findOneIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("uuid", uuid);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("datacenterId", datacenterId);
+        return listBy(sc);
+    }
+
+    @Override
+    public void updateAvailable(long id, long available) {
+        StoragePoolVO pool = createForUpdate(id);
+        pool.setUsedBytes(available);
+        update(id, pool);
+    }
+
+    @Override
+    public void updateCapacity(long id, long capacity) {
+        StoragePoolVO pool = createForUpdate(id);
+        pool.setCapacityBytes(capacity);
+        update(id, pool);
+
+    }
+
+    @Override
+    public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("hostAddress", hostFqdnOrIp);
+        return listIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolVO> listByStatus(StoragePoolStatus status) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("status", status);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("status", status);
+        sc.setParameters("datacenterId", dcId);
+        return listBy(sc);
+    }
+
+    @Override
+    public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
+        SearchCriteria<StoragePoolVO> 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<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope) {
+        if (clusterId != null) {
+            SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
+            sc.setParameters("datacenterId", datacenterId);
+            sc.setParameters("podId", podId);
+            sc.setParameters("status", Status.Up);
+            sc.setParameters("scope", scope);
+
+            sc.setParameters("cluster", clusterId);
+            return listBy(sc);
+        } else {
+            SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
+            sc.setParameters("datacenterId", datacenterId);
+            sc.setParameters("podId", podId);
+            sc.setParameters("status", Status.Up);
+            sc.setParameters("scope", scope);
+            return listBy(sc);
+        }
+    }
+
+    @Override
+    public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("hostAddress", host);
+        sc.setParameters("path", path);
+
+        return listBy(sc);
+    }
+
+    public StoragePoolVO listById(Integer id) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("id", id);
+
+        return findOneIncludingRemovedBy(sc);
+    }
+
+    @Override
+    @DB
+    public StoragePoolVO persist(StoragePoolVO 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()) {
+                StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
+                _detailsDao.persist(vo);
+            }
+        }
+        txn.commit();
+        return pool;
+    }
+
+    @DB
+    @Override
+    public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
+                                                  ScopeType scope) {
+        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);
+            pstmt.setString(i++, scope.toString());
+            if (clusterId != null) {
+                pstmt.setLong(i++, clusterId);
+            }
+            pstmt.setInt(i++, details.size());
+            ResultSet rs = pstmt.executeQuery();
+            List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
+            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<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
+        List<StoragePoolVO> storagePools = null;
+        if (tags == null || tags.length == 0) {
+            storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER);
+        } else {
+            Map<String, String> details = tagsToDetails(tags);
+            storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.CLUSTER);
+        }
+
+        return storagePools;
+    }
+
+    @Override
+    public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
+        List<StoragePoolVO> storagePools = null;
+        if (tags == null || tags.length == 0) {
+            storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST);
+        } else {
+            Map<String, String> details = tagsToDetails(tags);
+            storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.HOST);
+        }
+
+        return storagePools;
+    }
+
+    @Override
+    public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags) {
+        List<StoragePoolVO> storagePools = null;
+        if (tags == null || tags.length == 0) {
+            SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
+            sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
+            sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+            sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
+            return sc.list();
+        } else {
+            Map<String, String> details = tagsToDetails(tags);
+
+            StringBuilder sql = new StringBuilder(ZoneWideDetailsSqlPrefix);
+
+            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(ZoneWideDetailsSqlSuffix);
+            Transaction txn = Transaction.currentTxn();
+            PreparedStatement pstmt = null;
+            try {
+                pstmt = txn.prepareAutoCloseStatement(sql.toString());
+                int i = 1;
+                pstmt.setLong(i++, dcId);
+                pstmt.setString(i++, ScopeType.ZONE.toString());
+                pstmt.setInt(i++, details.size());
+                ResultSet rs = pstmt.executeQuery();
+                List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
+                while (rs.next()) {
+                    pools.add(toEntityBean(rs, false));
+                }
+                return pools;
+            } catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to execute " + pstmt, e);
+            }
+        }
+    }
+
+    @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(StoragePoolStatus... 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<StoragePoolVO> listPoolsByCluster(long clusterId) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("clusterId", clusterId);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) {
+        SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc =  SearchCriteria2.create(StoragePoolVO.class);
+        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId);
+        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+        sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
+        sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType);
+        return sc.list();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
new file mode 100644
index 0000000..0d9af4b
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
@@ -0,0 +1,79 @@
+// 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/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
new file mode 100644
index 0000000..18e2f1c
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
@@ -0,0 +1,28 @@
+// 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.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/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
new file mode 100644
index 0000000..f903715
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
@@ -0,0 +1,43 @@
+// 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 org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>,
+StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
+
+    List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
+
+    List<SnapshotDataStoreVO> listActiveOnCache(long id);
+
+    void deletePrimaryRecordsForStore(long id, DataStoreRole role);
+
+    SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId);
+    SnapshotDataStoreVO findParent(DataStoreRole role, Long storeId, Long volumeId);
+
+    SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role);
+
+    List<SnapshotDataStoreVO> listDestroyed(long storeId);
+}