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 2012/11/05 18:23:42 UTC

[7/18] Added engine

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java
new file mode 100644
index 0000000..0e7bb60
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java
@@ -0,0 +1,229 @@
+package org.apache.cloudstack.storage.datastore;
+
+import org.apache.cloudstack.platform.subsystem.api.storage.BackupStrategy;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPointSelector;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.platform.subsystem.api.storage.FileSystem;
+import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotProfile;
+import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotStrategy;
+import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
+import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
+import org.apache.cloudstack.platform.subsystem.api.storage.TemplateStrategy;
+import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
+import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
+
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.Volume;
+
+public class DefaultDataStore implements DataStore {
+	protected VolumeStrategy _volumeStrategy;
+	protected SnapshotStrategy _snapshotStrategy;
+	protected BackupStrategy _backupStrategy;
+	protected TemplateStrategy _templateStrategy;
+	protected String _uri;
+	protected String _uuid;
+	protected StoreType _type;
+	protected StoreScope _scope;
+	protected long _poolId;
+	protected DataStoreDriver _driverRef;
+	protected DataStoreEndPointSelector _selector;
+	protected FileSystem _fs;
+	protected VolumeStrategy _volumeSt;
+	protected SnapshotStrategy _snapshotSt;
+	protected BackupStrategy _backupSt;
+	protected long _id;
+	protected DataStoreLifeCycle _dslf;
+	
+	public DefaultDataStore(
+	) {
+	}
+
+	public String getURI() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	public void setURI(String uri) {
+		this._uri = uri;
+	}
+
+	public String getUUID() {
+		return this._uuid;
+	}
+	
+	public void setUUID(String uuid) {
+		this._uuid = uuid;
+	}
+
+	public StoreType getType() {
+		return this._type;
+	}
+	
+	public void setType(StoreType type) {
+		this._type = type;
+	}
+
+	public StoreScope getScope() {
+		return this._scope;
+	}
+	
+	public void setScope(StoreScope scope) {
+		this._scope = scope;
+	}
+
+	public Long getId() {
+		return this._id;
+	}
+	
+	public void setId(long id) {
+		this._id = id;
+	}
+
+	public DataStoreDriver getDataStoreDriver() {
+		return this._driverRef;
+	}
+	
+	public void setDataStoreDriver(DataStoreDriver drv) {
+		this._driverRef = drv;
+	}
+
+	public void setEndPointSelector(DataStoreEndPointSelector selector) {
+		this._selector = selector;
+	}
+	
+	public DataStoreEndPointSelector getSelector() {
+		return this._selector;
+	}
+
+	public FileSystem getFileSystem() {
+		return this._fs;
+	}
+	
+	public void setFileSystem(FileSystem fs) {
+		this._fs = fs;
+	}
+
+	public VolumeStrategy getVolumeStrategy() {
+		return this._volumeSt;
+	}
+	
+	public void setVolumeStrategy(VolumeStrategy vs) {
+		this._volumeSt = vs;
+	}
+
+	public SnapshotStrategy getSnapshotStrategy() {
+		return this._snapshotSt;
+	}
+	
+	public void setSnapshotStrategy(SnapshotStrategy ss) {
+		this._snapshotSt = ss;
+	}
+
+	public BackupStrategy getBackupStrategy() {
+		return this._backupSt;
+	}
+	
+	public void setBackupStrategy(BackupStrategy bs) {
+		this._backupSt = bs;
+	}
+	
+	public TemplateStrategy getTemplateStrategy() {
+		return this._templateStrategy;
+	}
+	
+	public void setTemplateStrategy(TemplateStrategy ts) {
+		this._templateStrategy = ts;
+	}
+
+	public DataStoreLifeCycle getLifeCycle() {
+		return this._dslf;
+	}
+	
+	public void setLifeCycle(DataStoreLifeCycle lf) {
+		this._dslf = lf;
+	}
+
+	public long getCluterId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public long getPodId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public long getZoneId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public String getPath() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public StoragePoolType getPoolType() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public boolean isSharedStorage() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public StorageProvider getProvider() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataStoreEndPointSelector getEndPointSelector() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public VolumeProfile prepareVolume(Volume volume, DataStore destStore) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public TemplateProfile prepareTemplate(long templateId, DataStore destStore) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public boolean contains(Volume volume) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public boolean contains(Snapshot snapshot) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public boolean contains(TemplateProfile template) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public TemplateProfile get(TemplateProfile template) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public StorageFilerTO getTO() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStoreImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStoreImpl.java
new file mode 100644
index 0000000..ea22b23
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStoreImpl.java
@@ -0,0 +1,118 @@
+package org.apache.cloudstack.storage.datastore;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.HypervisorHostEndPoint;
+import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
+import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
+import org.apache.cloudstack.storage.volume.Volume;
+import org.apache.cloudstack.storage.volume.VolumeEvent;
+import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeVO;
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
+import org.apache.log4j.Logger;
+
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.utils.component.ComponentInject;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+import edu.emory.mathcs.backport.java.util.Collections;
+
+public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
+	private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreImpl.class);
+	protected PrimaryDataStoreDriver driver;
+	protected DataStoreVO pdsv;
+	protected PrimaryDataStoreInfo pdsInfo;
+	@Inject
+	private VolumeDao volumeDao;
+	@Inject
+	private HostDao hostDao;
+	public DefaultPrimaryDataStoreImpl(PrimaryDataStoreDriver driver, DataStoreVO pdsv, PrimaryDataStoreInfo pdsInfo) {
+		this.driver = driver;
+		this.pdsv = pdsv;
+		this.pdsInfo = pdsInfo;
+	}
+	
+	@Override
+	public Volume getVolume(long id) {
+		VolumeVO volumeVO = volumeDao.findById(id);
+		Volume vol = new Volume(this, volumeVO);
+		return vol;
+	}
+
+	@Override
+	public List<Volume> getVolumes() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean deleteVolume(long id) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public Volume createVolume(long id, VolumeDiskType diskType) {
+		Volume vol = this.getVolume(id);
+		if (vol == null) {
+			return null;
+		}
+		
+		if (!pdsInfo.isVolumeDiskTypeSupported(diskType)) {
+			return null;
+		}
+		
+		boolean result = vol.stateTransit(VolumeEvent.CreateRequested);
+		if (!result) {
+			return null;
+		}
+		
+		try {
+			vol.setVolumeDiskType(diskType);
+			result = this.driver.createVolume(vol);
+			vol.update();
+			return vol;
+		} catch (Exception e) {
+			result = false;
+			s_logger.debug("Failed to create volume: " + e.toString());
+			throw new CloudRuntimeException(e.toString());
+		} finally {
+			if (result == true) {
+				vol.stateTransit(VolumeEvent.OperationSucceeded);
+			} else {
+				vol.stateTransit(VolumeEvent.OperationFailed);
+			}
+		}
+		
+	}
+
+	@Override
+	public List<EndPoint> getEndPoints() {
+		Long clusterId = pdsv.getClusterId();
+		if (clusterId == null) {
+			return null;
+		}
+		List<EndPoint> endpoints = new ArrayList<EndPoint>();
+		List<HostVO> hosts = hostDao.findHypervisorHostInCluster(clusterId);
+		for (HostVO host : hosts) {
+			HypervisorHostEndPoint ep = new HypervisorHostEndPoint(host.getId());
+			ComponentInject.inject(ep);
+			endpoints.add(ep);
+		}
+		Collections.shuffle(endpoints);
+		return endpoints;
+	}
+
+	@Override
+	public PrimaryDataStoreInfo getDataStoreInfo() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/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
new file mode 100644
index 0000000..7efa561
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
@@ -0,0 +1,34 @@
+/*
+ * 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.List;
+
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.volume.Volume;
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
+
+public interface PrimaryDataStore {
+	Volume getVolume(long id);
+	List<Volume> getVolumes();
+	boolean deleteVolume(long id);
+	Volume createVolume(long id, VolumeDiskType diskType);
+	List<EndPoint> getEndPoints();
+	PrimaryDataStoreInfo getDataStoreInfo();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfo.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfo.java
new file mode 100644
index 0000000..d30a5c8
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfo.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore;
+
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+
+public interface PrimaryDataStoreInfo {
+	public boolean isHypervisorSupported(HypervisorType hypervisor);
+	public boolean isLocalStorageSupported();
+	public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType);
+	public long getCapacity();
+	public long getAvailableCapacity();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfoImpl.java
new file mode 100644
index 0000000..c453d33
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreInfoImpl.java
@@ -0,0 +1,68 @@
+/*
+ * 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.List;
+
+import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+
+public class PrimaryDataStoreInfoImpl implements PrimaryDataStoreInfo {
+	protected List<HypervisorType> supportedHypervs;
+	protected List<VolumeDiskType> supportedDiskTypes;
+	protected long caapcity;
+	protected long avail;
+	protected boolean localStorage;
+	
+	public PrimaryDataStoreInfoImpl(List<HypervisorType> hypers, List<VolumeDiskType> diskTypes, 
+			long capacity, long avail, boolean localStorage) {
+		this.avail = avail;
+		this.caapcity = capacity;
+		this.localStorage = localStorage;
+		this.supportedDiskTypes = diskTypes;
+		this.supportedHypervs = hypers;
+	}
+	
+	@Override
+	public boolean isHypervisorSupported(HypervisorType hypervisor) {
+		return this.supportedHypervs.contains(hypervisor) ? true : false;
+	}
+
+	@Override
+	public boolean isLocalStorageSupported() {
+		return this.localStorage;
+	}
+
+	@Override
+	public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType) {
+		return this.supportedDiskTypes.contains(diskType) ? true : false;
+	}
+
+	@Override
+	public long getCapacity() {
+		return this.caapcity;
+	}
+
+	@Override
+	public long getAvailableCapacity() {
+		return this.avail;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreVO.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreVO.java
new file mode 100644
index 0000000..52f3bbf
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/DataStoreVO.java
@@ -0,0 +1,258 @@
+/*
+ * 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 java.util.UUID;
+
+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 javax.persistence.Transient;
+
+import org.apache.cloudstack.storage.datastore.DataStoreStatus;
+
+import com.cloud.api.Identity;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name="storage_pool")
+public class DataStoreVO 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 protocol;
+    
+    @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", updatable=true, nullable=false)
+    private Long storageProvider;
+    
+    @Column(name="storage_type", nullable=false)
+    private String storageType;
+    
+    @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;
+    
+    public long getId() {
+		return id;
+	}
+	
+	public DataStoreStatus getStatus() {
+		return status;
+	}
+
+	public DataStoreVO() {
+		// TODO Auto-generated constructor stub
+	}
+
+    public String getName() {
+		return name;
+	}
+
+    public String getUuid() {
+		return uuid;
+	}
+	
+
+    public String getPoolType() {
+		return 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 storageProvider;
+	}
+	
+	public void setStorageProviderId(Long provider) {
+		storageProvider = provider;
+	}
+	
+	public String getStorageType() {
+		return storageType;
+	}
+	
+	public void setStorageType(String type) {
+		storageType = type;
+	}
+
+    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 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 Long getPodId() {
+		return podId;
+	}
+	
+	public void setName(String name) {
+	    this.name = name;
+	}
+	
+	@Override
+    public boolean equals(Object obj) {
+	    if (!(obj instanceof DataStoreVO) || obj == null) {
+	        return false;
+	    }
+	    DataStoreVO that = (DataStoreVO)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(protocol).append("]").toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/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
new file mode 100644
index 0000000..8016559
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -0,0 +1,106 @@
+/*
+ * 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<DataStoreVO, Long> {
+
+	/**
+	 * @param datacenterId -- the id of the datacenter (availability zone)
+	 */
+	List<DataStoreVO> listByDataCenterId(long datacenterId);
+	
+	/**
+	 * @param datacenterId -- the id of the datacenter (availability zone)
+	 */
+	List<DataStoreVO> 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);
+        
+    
+    DataStoreVO persist(DataStoreVO pool, Map<String, String> details);
+    
+    /**
+     * Find pool by name.
+     * 
+     * @param name name of pool.
+     * @return the single  StoragePoolVO
+     */
+    List<DataStoreVO> 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<DataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
+    
+    List<DataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
+    
+    /**
+     * Find pool by UUID.
+     * 
+     * @param uuid uuid of pool.
+     * @return the single  StoragePoolVO
+     */
+    DataStoreVO findPoolByUUID(String uuid);
+
+    List<DataStoreVO> listByStorageHost(String hostFqdnOrIp);
+
+    DataStoreVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
+    
+    List<DataStoreVO> 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<DataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid);
+
+    List<DataStoreVO> listByStatus(DataStoreStatus status);
+
+    long countPoolsByStatus(DataStoreStatus... statuses);
+
+	List<DataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status);
+    
+    List<DataStoreVO> listPoolsByCluster(long clusterId);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/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
new file mode 100644
index 0000000..4429499
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -0,0 +1,377 @@
+/*
+ * 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.naming.ConfigurationException;
+
+import org.apache.cloudstack.storage.datastore.DataStoreStatus;
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.StoragePoolDetailVO;
+import com.cloud.storage.dao.StoragePoolDetailsDao;
+import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
+import com.cloud.utils.component.ComponentLocator;
+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.Transaction;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>  implements PrimaryDataStoreDao {
+    protected final SearchBuilder<DataStoreVO> AllFieldSearch;
+	protected final SearchBuilder<DataStoreVO> DcPodSearch;
+    protected final SearchBuilder<DataStoreVO> DcPodAnyClusterSearch;
+    protected final SearchBuilder<DataStoreVO> DeleteLvmSearch;
+    protected final GenericSearchBuilder<DataStoreVO, Long> StatusCountSearch;
+
+    
+    
+    protected final 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.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 = ?";
+	
+    protected 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();
+
+        _detailsDao = ComponentLocator.inject(StoragePoolDetailsDaoImpl.class);
+    }
+    
+	@Override
+	public List<DataStoreVO> findPoolByName(String name) {
+		SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("name", name);
+        return listIncludingRemovedBy(sc);
+	}
+
+
+	@Override
+	public DataStoreVO findPoolByUUID(String uuid) {
+		SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("uuid", uuid);
+        return findOneIncludingRemovedBy(sc);
+	}
+	
+	
+
+	@Override
+	public List<DataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
+		SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("uuid", uuid);
+        return listBy(sc);
+	}
+
+
+	@Override
+	public List<DataStoreVO> listByDataCenterId(long datacenterId) {
+		SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("datacenterId", datacenterId);
+        return listBy(sc);
+	}
+
+
+	@Override
+	public void updateAvailable(long id, long available) {
+		DataStoreVO pool = createForUpdate(id);
+		pool.setAvailableBytes(available);
+		update(id, pool);
+	}
+
+
+	@Override
+	public void updateCapacity(long id, long capacity) {
+		DataStoreVO pool = createForUpdate(id);
+		pool.setCapacityBytes(capacity);
+		update(id, pool);
+
+	}
+	
+    @Override
+    public List<DataStoreVO> listByStorageHost(String hostFqdnOrIp) {
+        SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("hostAddress", hostFqdnOrIp);
+        return listIncludingRemovedBy(sc);
+    }
+    
+    @Override
+    public List<DataStoreVO> listByStatus(DataStoreStatus status){
+        SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+    	sc.setParameters("status", status);
+    	return listBy(sc);
+    }
+    
+    @Override
+    public List<DataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status){
+        SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+    	sc.setParameters("status", status);
+    	sc.setParameters("datacenterId", dcId);
+    	return listBy(sc);
+    }
+
+    @Override
+    public DataStoreVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
+        SearchCriteria<DataStoreVO> 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<DataStoreVO> listBy(long datacenterId, long podId, Long clusterId) {
+	    if (clusterId != null) {
+    		SearchCriteria<DataStoreVO> sc = DcPodSearch.create();
+            sc.setParameters("datacenterId", datacenterId);
+            sc.setParameters("podId", podId);
+           
+            sc.setParameters("cluster", clusterId);
+            return listBy(sc);
+	    } else {
+	        SearchCriteria<DataStoreVO> sc = DcPodAnyClusterSearch.create();
+	        sc.setParameters("datacenterId", datacenterId);
+	        sc.setParameters("podId", podId);
+	        return listBy(sc);
+	    }
+	}
+
+	@Override
+	public List<DataStoreVO> listPoolByHostPath(String host, String path) {
+        SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("hostAddress", host);
+        sc.setParameters("path", path);
+        
+        return listBy(sc);
+	}
+	
+	public DataStoreVO listById(Integer id)
+	{
+        SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("id", id);
+        
+        return findOneIncludingRemovedBy(sc);
+	}
+	
+	@Override @DB
+	public DataStoreVO persist(DataStoreVO 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<DataStoreVO> 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<DataStoreVO> pools = new ArrayList<DataStoreVO>();
+	        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<DataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared) {
+		List<DataStoreVO> 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<DataStoreVO> filteredStoragePools = new ArrayList<DataStoreVO>(storagePools);
+	    	for (DataStoreVO 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<DataStoreVO> listPoolsByCluster(long clusterId) {
+        SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
+        sc.setParameters("clusterId", clusterId);
+        
+        return listBy(sc);
+    }
+}

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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java
new file mode 100644
index 0000000..bd0571d
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.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 org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+
+@Component
+class PrimaryDataStoreProviderDaoImpl extends GenericDaoBase<PrimaryDataStoreProviderVO, Long> implements PrimaryDataStoreProviderDao {
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java
new file mode 100644
index 0000000..0d15580
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java
@@ -0,0 +1,38 @@
+/*
+ * 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 PrimaryDataStoreProviderVO {
+    @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;
+    
+    public long getId() {
+    	return id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
new file mode 100644
index 0000000..935f214
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
@@ -0,0 +1,65 @@
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.util.List;
+
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
+import org.apache.cloudstack.storage.command.CreateVolumeCommand;
+import org.apache.cloudstack.storage.volume.Volume;
+import org.apache.cloudstack.storage.volume.VolumeInfo;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.agent.api.Answer;
+
+@Component
+public class DefaultPrimaryDataStoreDriverImpl implements
+		PrimaryDataStoreDriver {
+	private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
+	@Override
+	public boolean createVolume(Volume vol) {
+		//The default driver will send createvolume command to one of hosts which can access its datastore
+		List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
+		int retries = 3;
+		VolumeInfo volInfo = new VolumeInfo(vol);
+		CreateVolumeCommand createCmd = new CreateVolumeCommand(volInfo);
+		Answer answer = null;
+		int i = 0;
+		boolean result = false;
+		
+		for (EndPoint ep : endPoints) {
+			answer = ep.sendMessage(createCmd);
+			if (answer == null) {
+				if (i < retries) {
+					s_logger.debug("create volume failed, retrying: " + i);
+				}
+				i++;
+			} else {
+				CreateVolumeAnswer volAnswer = (CreateVolumeAnswer)answer;
+				vol.setUuid(volAnswer.getVolumeUuid());
+				result = true;
+			}
+		}
+		
+		return result;
+	}
+
+	@Override
+	public boolean deleteVolume(Volume vo) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public String grantAccess(Volume vol, EndPoint ep) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean revokeAccess(Volume vol, EndPoint ep) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
new file mode 100644
index 0000000..a35118a
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
@@ -0,0 +1,11 @@
+package org.apache.cloudstack.storage.datastore.driver;
+
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.volume.Volume;
+
+public interface PrimaryDataStoreDriver {
+	boolean createVolume(Volume vol);
+	boolean deleteVolume(Volume vo);
+	String grantAccess(Volume vol,  EndPoint ep);
+	boolean revokeAccess(Volume vol, EndPoint ep);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
new file mode 100644
index 0000000..fe4562c
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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.lifecycle;
+
+import java.util.Map;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
+
+	@Override
+	public boolean registerDataStore(Map<String, String> dsInfos) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean attach(long scope) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean dettach(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean unmanaged(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean maintain(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean cancelMaintain(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean deleteDataStore(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java
new file mode 100644
index 0000000..2e41a62
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.lifecycle;
+
+import java.util.Map;
+
+public interface PrimaryDataStoreLifeCycle {
+	public boolean registerDataStore(Map<String, String> dsInfos);
+	public boolean attach(long scope);
+	public boolean dettach(long dataStoreId);
+	public boolean unmanaged(long dataStoreId);
+	public boolean maintain(long dataStoreId);
+	public boolean cancelMaintain(long dataStoreId);
+	public boolean deleteDataStore(long dataStoreId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
new file mode 100644
index 0000000..4949b2f
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
@@ -0,0 +1,55 @@
+/*
+ * 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.manager;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
+import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
+import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DefaultPrimaryDataStoreManagerImpl implements PrimaryDataStoreManager {
+	@Inject
+	PrimaryDataStoreProviderDao dataStoreProviderDao;
+	@Inject
+	PrimaryDataStoreProviderManager providerManager;
+	@Inject
+	PrimaryDataStoreDao dataStoreDao;
+	@Override
+	public PrimaryDataStore getPrimaryDataStore(long dataStoreId) {
+		DataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
+		Long providerId = dataStoreVO.getStorageProviderId();
+		PrimaryDataStoreProvider provider = providerManager.getDataStoreProvider(providerId);
+		PrimaryDataStore dataStore = provider.getDataStore(dataStoreId);
+		return dataStore;
+	}
+
+	@Override
+	public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
new file mode 100644
index 0000000..b6ac34d
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
@@ -0,0 +1,27 @@
+/*
+ * 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.manager;
+
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
+
+public interface PrimaryDataStoreManager {
+	public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
+	public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
new file mode 100644
index 0000000..7ca9000
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
@@ -0,0 +1,44 @@
+package org.apache.cloudstack.storage.datastore.provider;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.component.ComponentInject;
+
+@Component
+public class DefaultPrimaryDatastoreProviderImpl implements
+		PrimaryDataStoreProvider {
+	protected PrimaryDataStoreDriver driver;
+	@Inject
+	public PrimaryDataStoreDao dataStoreDao;
+
+	public DefaultPrimaryDatastoreProviderImpl() {
+		this.driver = new DefaultPrimaryDataStoreDriverImpl();
+	}
+	@Override
+	public PrimaryDataStore getDataStore(long dataStoreId) {
+		DataStoreVO dsv = dataStoreDao.findById(dataStoreId);
+		if (dsv == null) {
+			return null;
+		}
+		
+		PrimaryDataStore pds = new DefaultPrimaryDataStoreImpl(driver, dsv, null);
+		pds = ComponentInject.inject(pds);
+		return pds;
+	}
+	
+	@Override
+	public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/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
new file mode 100644
index 0000000..a346d32
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
@@ -0,0 +1,9 @@
+package org.apache.cloudstack.storage.datastore.provider;
+
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
+
+public interface PrimaryDataStoreProvider {
+	public PrimaryDataStore getDataStore(long dataStoreId);
+	public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
new file mode 100644
index 0000000..4ef9a5c
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
@@ -0,0 +1,5 @@
+package org.apache.cloudstack.storage.datastore.provider;
+
+public interface PrimaryDataStoreProviderManager {
+	public PrimaryDataStoreProvider getDataStoreProvider(Long providerId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
new file mode 100644
index 0000000..0875553
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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 org.springframework.stereotype.Component;
+
+@Component
+public class PrimaryDataStoreProviderManagerImpl implements PrimaryDataStoreProviderManager {
+
+	@Override
+	public PrimaryDataStoreProvider getDataStoreProvider(Long providerId) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/DataStoreType.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/type/DataStoreType.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/DataStoreType.java
new file mode 100644
index 0000000..8f3fe8c
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/DataStoreType.java
@@ -0,0 +1,23 @@
+/*
+ * 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.type;
+
+public interface DataStoreType {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/ISCSI.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/type/ISCSI.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/ISCSI.java
new file mode 100644
index 0000000..26d36de
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/ISCSI.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.type;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ISCSI extends BaseType implements DataStoreType {
+	private final String type = "iscsi";
+	@Override
+	public String toString() {
+		return type;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/NetworkFileSystem.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/type/NetworkFileSystem.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/NetworkFileSystem.java
new file mode 100644
index 0000000..9340975
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/NetworkFileSystem.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.type;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NetworkFileSystem extends BaseType implements DataStoreType {
+	private final String type = "nfs";
+	@Override
+	public String toString() {
+		return type;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/SharedMount.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/type/SharedMount.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/SharedMount.java
new file mode 100644
index 0000000..c97a893
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/type/SharedMount.java
@@ -0,0 +1,29 @@
+/*
+ * 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.type;
+
+import org.apache.cloudstack.storage.BaseType;
+
+public class SharedMount extends BaseType implements DataStoreType {
+	private final String type = "SharedMountPoint";
+	@Override
+	public String toString() {
+		return type;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java b/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java
new file mode 100644
index 0000000..245af06
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java
@@ -0,0 +1,76 @@
+/*
+ * 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.driver;
+
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPoint;
+import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
+
+import org.apache.cloudstack.platform.subsystem.api.storage.TemplateStrategy;
+import com.cloud.agent.api.storage.DownloadProgressCommand;
+import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType;
+import com.cloud.agent.api.storage.DownloadCommand;
+import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
+import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
+
+public abstract class AbstractStorageDriver implements DataStoreDriver {
+	protected DataStore _ds;
+	protected TemplateStrategy _ts;
+	
+	public AbstractStorageDriver(DataStore ds) {
+		_ds = ds;
+		_ts = ds.getTemplateStrategy();
+	}
+	
+	public TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep) {
+		PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(tp.getName(), tp.getUrl(), tp.getFormat(), 
+				0, _ds.getId(), _ds.getUUID(), _ts.getDownloadWait());
+		dcmd.setSecondaryStorageUrl(tp.getImageStorageUri());
+		dcmd.setPrimaryStorageUrl(_ds.getURI());
+		PrimaryStorageDownloadAnswer asw = (PrimaryStorageDownloadAnswer)ep.sendCommand(dcmd);
+
+		tp.setLocalPath(asw.getInstallPath());
+		return tp;
+	}
+	
+	public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep, boolean freshDownload) {
+		
+		DownloadCommand dcmd =
+				new DownloadCommand(_ds.getURI(), tp.getTemplate(), _ts.getMaxTemplateSizeInBytes());
+		dcmd.setProxy(_ts.getHttpProxy());
+		if (!freshDownload) {
+			dcmd = new DownloadProgressCommand(dcmd, tp.getJobId(), RequestType.GET_OR_RESTART);
+		}
+		
+		ep.sendCommand(dcmd);
+		return tp;
+	}
+	/*
+	public VolumeProfile createVolumeFromTemplate(VolumeProfile volProfile, TemplateProfile tp, DataStoreEndPoint ep) {
+		CreateCommand cmd = new CreateCommand(volProfile, tp.getLocalPath(), _ds.getTO());
+		CreateAnswer ans = (CreateAnswer)ep.sendCommand(cmd);
+		VolumeTO created = ans.getVolume();
+		DiskProfile diskProfile = new VolumeProfile(volProfile);
+		diskProfile.setPath(created.getPath());
+		diskProfile.setSize(created.getSize());
+		return diskProfile;
+		return null;
+	}*/
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java b/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java
new file mode 100644
index 0000000..8e6fa1d
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java
@@ -0,0 +1,90 @@
+/*
+ * 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.driver;
+
+import org.apache.cloudstack.platform.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPoint;
+import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.storage.TemplateProfile;
+
+public class DefaultNfsSecondaryDriver extends AbstractStorageDriver {
+
+	/**
+	 * @param ds
+	 */
+	public DefaultNfsSecondaryDriver(DataStore ds) {
+		super(ds);
+		// TODO Auto-generated constructor stub
+	}
+
+	public String getDriverType() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject create(DataObject obj) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject copy(DataObject src, DataStore dest) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject copy(DataObject src, DataObject dest) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject move(DataObject src, DataObject dest) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public Answer sendMessage(DataStoreEndPoint dsep, Command cmd) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public boolean delete(DataObject obj) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile register(org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint ep) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public VolumeProfile createVolumeFromTemplate(VolumeProfile vol, org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint dp) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a6df8a5b/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java b/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java
new file mode 100644
index 0000000..811b4c7
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.driver;
+
+import org.apache.cloudstack.platform.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPoint;
+import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+
+public class XenServerStorageDriver extends AbstractStorageDriver {
+	protected DataStore _ds;
+	public XenServerStorageDriver(DataStore ds) {
+		super(ds);
+		_ds = ds;
+	}
+	
+	public String getDriverType() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject create(DataObject obj) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject copy(DataObject src, DataStore dest) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject copy(DataObject src, DataObject dest) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public DataObject move(DataObject src, DataObject dest) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public Answer sendMessage(DataStoreEndPoint dsep, Command cmd) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public boolean delete(DataObject obj) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile register(org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint ep) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public VolumeProfile createVolumeFromTemplate(VolumeProfile vol, org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint dp) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

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