cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [01/17] clean up storage related coded
Date Thu, 30 May 2013 01:06:21 GMT
Updated Branches:
  refs/heads/object_store 2616115ff -> 0a5228922


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
index e801429..4c2f389 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
@@ -60,185 +60,186 @@ import com.cloud.storage.snapshot.SnapshotManager;
 import com.cloud.vm.dao.VMInstanceDao;
 
 public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
-	private static final Logger s_logger = Logger
-			.getLogger(CloudStackPrimaryDataStoreDriverImpl.class);
-	@Inject DiskOfferingDao diskOfferingDao;
-	@Inject VMTemplateDao templateDao;
-	@Inject VolumeDao volumeDao;
-	@Inject HostDao hostDao;
-	@Inject StorageManager storageMgr;
-	@Inject VolumeManager volumeMgr;
-	@Inject VMInstanceDao vmDao;
-	@Inject SnapshotDao snapshotDao;
-	@Inject PrimaryDataStoreDao primaryStoreDao;
-	@Inject SnapshotManager snapshotMgr;
-	@Inject EndPointSelector epSelector;
-	@Override
-	public String grantAccess(DataObject data, EndPoint ep) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-    public DataTO getTO(DataObject data) {
+    private static final Logger s_logger = Logger.getLogger(CloudStackPrimaryDataStoreDriverImpl.class);
+    @Inject
+    DiskOfferingDao diskOfferingDao;
+    @Inject
+    VMTemplateDao templateDao;
+    @Inject
+    VolumeDao volumeDao;
+    @Inject
+    HostDao hostDao;
+    @Inject
+    StorageManager storageMgr;
+    @Inject
+    VolumeManager volumeMgr;
+    @Inject
+    VMInstanceDao vmDao;
+    @Inject
+    SnapshotDao snapshotDao;
+    @Inject
+    PrimaryDataStoreDao primaryStoreDao;
+    @Inject
+    SnapshotManager snapshotMgr;
+    @Inject
+    EndPointSelector epSelector;
+
+    @Override
+    public String grantAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
+    public DataTO getTO(DataObject data) {
+        return null;
+    }
 
-	@Override
+    @Override
     public DataStoreTO getStoreTO(DataStore store) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-	public boolean revokeAccess(DataObject data, EndPoint ep) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public Set<DataObject> listObjects(DataStore store) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	public Answer createVolume(
-			VolumeInfo volume) throws StorageUnavailableException {
-		if (s_logger.isDebugEnabled()) {
-			s_logger.debug("Creating volume: " + volume);
-		}
-
-		CreateObjectCommand cmd = new CreateObjectCommand(volume.getTO());
-		EndPoint ep = epSelector.select(volume);
-		Answer answer = ep.sendMessage(cmd);
-		return answer;
-	}
-
-	@Override
-	public void createAsync(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
-		String errMsg = null;
-		Answer answer = null;
-		if (data.getType() == DataObjectType.VOLUME) {
-			try {
-				answer = createVolume((VolumeInfo)data);
-			} catch (StorageUnavailableException e) {
-				s_logger.debug("failed to create volume", e);
-				errMsg = e.toString();
-			} catch (Exception e) {
-				s_logger.debug("failed to create volume", e);
-				errMsg = e.toString();
-			}
-		}
-		CreateCmdResult result = new CreateCmdResult(null, answer);
-		if (errMsg != null) {
-			result.setResult(errMsg);
-		}
-
-		callback.complete(result);
-	}
-
-	@Override
-	public void deleteAsync(DataObject data,
-			AsyncCompletionCallback<CommandResult> callback) {
-		DeleteCommand cmd = new DeleteCommand(data.getTO());
-
-		CommandResult result = new CommandResult();
-		try {
-		    EndPoint ep = epSelector.select(data);
-			Answer answer = ep.sendMessage(cmd);
-			if (answer != null && !answer.getResult()) {
-				result.setResult(answer.getDetails());
-			}
-		} catch (Exception ex) {
-			s_logger.debug("Unable to destoy volume" + data.getId(), ex);
-			result.setResult(ex.toString());
-		}
-		callback.complete(result);
-	}
-
-	@Override
-	public void copyAsync(DataObject srcdata, DataObject destData,
-			AsyncCompletionCallback<CopyCommandResult> callback) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public boolean canCopy(DataObject srcData, DataObject destData) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public void takeSnapshot(SnapshotInfo snapshot,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-	    CreateCmdResult result = null;
-	    try {
-	        DataTO snapshotTO = snapshot.getTO();
-
-	        CreateObjectCommand cmd = new CreateObjectCommand(snapshotTO);
-	        EndPoint ep = this.epSelector.select(snapshot);
-	        Answer answer = ep.sendMessage(cmd);
-
-	        result = new CreateCmdResult(null, answer);
-	        if (answer != null && !answer.getResult()) {
-	            result.setResult(answer.getDetails());
-	        }
-
-	        callback.complete(result);
-	        return;
-	    } catch (Exception e) {
-	        s_logger.debug("Failed to take snapshot: " + snapshot.getId(), e);
-	        result = new CreateCmdResult(null, null);
-	        result.setResult(e.toString());
-	    }
+    public boolean revokeAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Answer createVolume(VolumeInfo volume) throws StorageUnavailableException {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Creating volume: " + volume);
+        }
+
+        CreateObjectCommand cmd = new CreateObjectCommand(volume.getTO());
+        EndPoint ep = epSelector.select(volume);
+        Answer answer = ep.sendMessage(cmd);
+        return answer;
+    }
+
+    @Override
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
+        String errMsg = null;
+        Answer answer = null;
+        if (data.getType() == DataObjectType.VOLUME) {
+            try {
+                answer = createVolume((VolumeInfo) data);
+            } catch (StorageUnavailableException e) {
+                s_logger.debug("failed to create volume", e);
+                errMsg = e.toString();
+            } catch (Exception e) {
+                s_logger.debug("failed to create volume", e);
+                errMsg = e.toString();
+            }
+        }
+        CreateCmdResult result = new CreateCmdResult(null, answer);
+        if (errMsg != null) {
+            result.setResult(errMsg);
+        }
+
         callback.complete(result);
-	}
-
-	@Override
-	public void revertSnapshot(SnapshotInfo snapshot,
-			AsyncCompletionCallback<CommandResult> callback) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		VolumeObject vol = (VolumeObject)data;
-		StoragePool pool = (StoragePool)data.getDataStore();
-		ResizeVolumePayload resizeParameter = (ResizeVolumePayload)vol.getpayload();
-
-		ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(
-				vol.getPath(), new StorageFilerTO(pool), vol.getSize(),
-				resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName);
-		CreateCmdResult result = new CreateCmdResult(null, null);
-		try {
-			ResizeVolumeAnswer answer = (ResizeVolumeAnswer) this.storageMgr.sendToPool(pool,
-					resizeParameter.hosts, resizeCmd);
-			if (answer != null && answer.getResult()) {
-				long finalSize = answer.getNewSize();
-				s_logger.debug("Resize: volume started at size " + vol.getSize()
-						+ " and ended at size " + finalSize);
-
-				vol.setSize(finalSize);
-				vol.update();
-			} else if (answer != null) {
-				result.setResult(answer.getDetails());
-			} else {
-				s_logger.debug("return a null answer, mark it as failed for unknown reason");
-				result.setResult("return a null answer, mark it as failed for unknown reason");
-			}
-
-		} catch (Exception e) {
-			s_logger.debug("sending resize command failed", e);
-			result.setResult(e.toString());
-		}
-
-		callback.complete(result);
-	}
+    }
+
+    @Override
+    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+        DeleteCommand cmd = new DeleteCommand(data.getTO());
+
+        CommandResult result = new CommandResult();
+        try {
+            EndPoint ep = epSelector.select(data);
+            Answer answer = ep.sendMessage(cmd);
+            if (answer != null && !answer.getResult()) {
+                result.setResult(answer.getDetails());
+            }
+        } catch (Exception ex) {
+            s_logger.debug("Unable to destoy volume" + data.getId(), ex);
+            result.setResult(ex.toString());
+        }
+        callback.complete(result);
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
+        CreateCmdResult result = null;
+        try {
+            DataTO snapshotTO = snapshot.getTO();
+
+            CreateObjectCommand cmd = new CreateObjectCommand(snapshotTO);
+            EndPoint ep = this.epSelector.select(snapshot);
+            Answer answer = ep.sendMessage(cmd);
+
+            result = new CreateCmdResult(null, answer);
+            if (answer != null && !answer.getResult()) {
+                result.setResult(answer.getDetails());
+            }
+
+            callback.complete(result);
+            return;
+        } catch (Exception e) {
+            s_logger.debug("Failed to take snapshot: " + snapshot.getId(), e);
+            result = new CreateCmdResult(null, null);
+            result.setResult(e.toString());
+        }
+        callback.complete(result);
+    }
+
+    @Override
+    public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        VolumeObject vol = (VolumeObject) data;
+        StoragePool pool = (StoragePool) data.getDataStore();
+        ResizeVolumePayload resizeParameter = (ResizeVolumePayload) vol.getpayload();
+
+        ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(),
+                resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName);
+        CreateCmdResult result = new CreateCmdResult(null, null);
+        try {
+            ResizeVolumeAnswer answer = (ResizeVolumeAnswer) this.storageMgr.sendToPool(pool, resizeParameter.hosts,
+                    resizeCmd);
+            if (answer != null && answer.getResult()) {
+                long finalSize = answer.getNewSize();
+                s_logger.debug("Resize: volume started at size " + vol.getSize() + " and ended at size " + finalSize);
+
+                vol.setSize(finalSize);
+                vol.update();
+            } else if (answer != null) {
+                result.setResult(answer.getDetails());
+            } else {
+                s_logger.debug("return a null answer, mark it as failed for unknown reason");
+                result.setResult("return a null answer, mark it as failed for unknown reason");
+            }
+
+        } catch (Exception e) {
+            s_logger.debug("sending resize command failed", e);
+            result.setResult(e.toString());
+        }
+
+        callback.complete(result);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
index e6bdaed..693ab01 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
@@ -55,8 +55,6 @@ import com.cloud.resource.ResourceManager;
 import com.cloud.server.ManagementServer;
 import com.cloud.storage.OCFS2Manager;
 import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.ScopeType;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolAutomation;
@@ -77,10 +75,8 @@ import com.cloud.vm.dao.SecondaryStorageVmDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
-public class CloudStackPrimaryDataStoreLifeCycleImpl implements
-        PrimaryDataStoreLifeCycle {
-    private static final Logger s_logger = Logger
-            .getLogger(CloudStackPrimaryDataStoreLifeCycleImpl.class);
+public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
+    private static final Logger s_logger = Logger.getLogger(CloudStackPrimaryDataStoreLifeCycleImpl.class);
     @Inject
     protected ResourceManager _resourceMgr;
     protected List<StoragePoolDiscoverer> _discoverers;
@@ -95,7 +91,6 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
     @Inject
     StorageManager storageMgr;
 
-
     @Inject
     VolumeDao volumeDao;
     @Inject
@@ -126,16 +121,16 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
     @Inject
     StoragePoolAutomation storagePoolAutmation;
 
+    @SuppressWarnings("unchecked")
     @Override
     public DataStore initialize(Map<String, Object> dsInfos) {
         Long clusterId = (Long) dsInfos.get("clusterId");
         Long podId = (Long) dsInfos.get("podId");
         Long zoneId = (Long) dsInfos.get("zoneId");
         String url = (String) dsInfos.get("url");
-        String providerName = (String)dsInfos.get("providerName");
+        String providerName = (String) dsInfos.get("providerName");
         if (clusterId != null && podId == null) {
-            throw new InvalidParameterValueException(
-                    "Cluster id requires pod id");
+            throw new InvalidParameterValueException("Cluster id requires pod id");
         }
 
         PrimaryDataStoreParameters parameters = new PrimaryDataStoreParameters();
@@ -144,15 +139,12 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
         try {
             uri = new URI(UriUtils.encodeURIComponent(url));
             if (uri.getScheme() == null) {
-                throw new InvalidParameterValueException("scheme is null "
-                        + url + ", add nfs:// as a prefix");
+                throw new InvalidParameterValueException("scheme is null " + url + ", add nfs:// as a prefix");
             } else if (uri.getScheme().equalsIgnoreCase("nfs")) {
                 String uriHost = uri.getHost();
                 String uriPath = uri.getPath();
-                if (uriHost == null || uriPath == null
-                        || uriHost.trim().isEmpty() || uriPath.trim().isEmpty()) {
-                    throw new InvalidParameterValueException(
-                            "host or path is null, should be nfs://hostname/path");
+                if (uriHost == null || uriPath == null || uriHost.trim().isEmpty() || uriPath.trim().isEmpty()) {
+                    throw new InvalidParameterValueException("host or path is null, should be nfs://hostname/path");
                 }
             } else if (uri.getScheme().equalsIgnoreCase("sharedMountPoint")) {
                 String uriPath = uri.getPath();
@@ -163,18 +155,15 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
             } else if (uri.getScheme().equalsIgnoreCase("rbd")) {
                 String uriPath = uri.getPath();
                 if (uriPath == null) {
-                    throw new InvalidParameterValueException(
-                            "host or path is null, should be rbd://hostname/pool");
+                    throw new InvalidParameterValueException("host or path is null, should be rbd://hostname/pool");
                 }
             }
         } catch (URISyntaxException e) {
-            throw new InvalidParameterValueException(url
-                    + " is not a valid uri");
+            throw new InvalidParameterValueException(url + " is not a valid uri");
         }
 
         String tags = (String) dsInfos.get("tags");
-        Map<String, String> details = (Map<String, String>) dsInfos
-                .get("details");
+        Map<String, String> details = (Map<String, String>) dsInfos.get("details");
 
         parameters.setTags(tags);
         parameters.setDetails(details);
@@ -188,10 +177,8 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
         }
         String userInfo = uri.getUserInfo();
         int port = uri.getPort();
-        StoragePool pool = null;
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("createPool Params @ scheme - " + scheme
-                    + " storageHost - " + storageHost + " hostPath - "
+            s_logger.debug("createPool Params @ scheme - " + scheme + " storageHost - " + storageHost + " hostPath - "
                     + hostPath + " port - " + port);
         }
         if (scheme.equalsIgnoreCase("nfs")) {
@@ -242,8 +229,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
             }
             if (lun != -1) {
                 if (clusterId == null) {
-                    throw new IllegalArgumentException(
-                            "IscsiLUN need to have clusters specified");
+                    throw new IllegalArgumentException("IscsiLUN need to have clusters specified");
                 }
                 hostPath.replaceFirst("/", "");
                 parameters.setType(StoragePoolType.IscsiLUN);
@@ -256,14 +242,11 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
                     try {
                         pools = discoverer.find(zoneId, podId, uri, details);
                     } catch (DiscoveryException e) {
-                        throw new IllegalArgumentException(
-                                "Not enough information for discovery " + uri,
-                                e);
+                        throw new IllegalArgumentException("Not enough information for discovery " + uri, e);
                     }
                     if (pools != null) {
-                        Map.Entry<? extends StoragePool, Map<String, String>> entry = pools
-                                .entrySet().iterator().next();
-                        pool = entry.getKey();
+                        Map.Entry<? extends StoragePool, Map<String, String>> entry = pools.entrySet().iterator()
+                                .next();
                         details = entry.getValue();
                         break;
                     }
@@ -297,19 +280,17 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
                 parameters.setPort(0);
                 parameters.setPath(hostPath);
             } else {
-            s_logger.warn("Unable to figure out the scheme for URI: " + uri);
-            throw new IllegalArgumentException(
-                    "Unable to figure out the scheme for URI: " + uri);
+                s_logger.warn("Unable to figure out the scheme for URI: " + uri);
+                throw new IllegalArgumentException("Unable to figure out the scheme for URI: " + uri);
             }
         }
 
         if (localStorage == null) {
-            List<StoragePoolVO> pools = primaryDataStoreDao
-                    .listPoolByHostPath(storageHost, hostPath);
+            List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(storageHost, hostPath);
             if (!pools.isEmpty() && !scheme.equalsIgnoreCase("sharedmountpoint")) {
                 Long oldPodId = pools.get(0).getPodId();
-                throw new CloudRuntimeException("Storage pool " + uri
-                        + " already in use by another pod (id=" + oldPodId + ")");
+                throw new CloudRuntimeException("Storage pool " + uri + " already in use by another pod (id="
+                        + oldPodId + ")");
             }
         }
 
@@ -317,29 +298,23 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
         String uuid = null;
 
         if (existingUuid != null) {
-            uuid = (String)existingUuid;
-        } else if (scheme.equalsIgnoreCase("sharedmountpoint")
-                || scheme.equalsIgnoreCase("clvm")) {
+            uuid = (String) existingUuid;
+        } else if (scheme.equalsIgnoreCase("sharedmountpoint") || scheme.equalsIgnoreCase("clvm")) {
             uuid = UUID.randomUUID().toString();
         } else if (scheme.equalsIgnoreCase("PreSetup")) {
             uuid = hostPath.replace("/", "");
         } else {
-            uuid = UUID.nameUUIDFromBytes(
-                    new String(storageHost + hostPath).getBytes()).toString();
+            uuid = UUID.nameUUIDFromBytes(new String(storageHost + hostPath).getBytes()).toString();
         }
 
-
-        List<StoragePoolVO> spHandles = primaryDataStoreDao
-                .findIfDuplicatePoolsExistByUUID(uuid);
+        List<StoragePoolVO> spHandles = primaryDataStoreDao.findIfDuplicatePoolsExistByUUID(uuid);
         if ((spHandles != null) && (spHandles.size() > 0)) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Another active pool with the same uuid already exists");
             }
-            throw new CloudRuntimeException(
-                    "Another active pool with the same uuid already exists");
+            throw new CloudRuntimeException("Another active pool with the same uuid already exists");
         }
 
-
         String poolName = (String) dsInfos.get("name");
 
         parameters.setUuid(uuid);
@@ -353,20 +328,13 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
     }
 
     protected boolean createStoragePool(long hostId, StoragePool pool) {
-        s_logger.debug("creating pool " + pool.getName() + " on  host "
-                + hostId);
-        if (pool.getPoolType() != StoragePoolType.NetworkFilesystem
-                && pool.getPoolType() != StoragePoolType.Filesystem
-                && pool.getPoolType() != StoragePoolType.IscsiLUN
-                && pool.getPoolType() != StoragePoolType.Iscsi
-                && pool.getPoolType() != StoragePoolType.VMFS
-                && pool.getPoolType() != StoragePoolType.SharedMountPoint
-                && pool.getPoolType() != StoragePoolType.PreSetup
-                && pool.getPoolType() != StoragePoolType.OCFS2
-                && pool.getPoolType() != StoragePoolType.RBD
-                && pool.getPoolType() != StoragePoolType.CLVM) {
-            s_logger.warn(" Doesn't support storage pool type "
-                    + pool.getPoolType());
+        s_logger.debug("creating pool " + pool.getName() + " on  host " + hostId);
+        if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem
+                && pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi
+                && pool.getPoolType() != StoragePoolType.VMFS && pool.getPoolType() != StoragePoolType.SharedMountPoint
+                && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2
+                && pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM) {
+            s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
             return false;
         }
         CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
@@ -377,8 +345,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
             primaryDataStoreDao.expunge(pool.getId());
             String msg = "";
             if (answer != null) {
-                msg = "Can not create storage pool through host " + hostId
-                        + " due to " + answer.getDetails();
+                msg = "Can not create storage pool through host " + hostId + " due to " + answer.getDetails();
                 s_logger.warn(msg);
             } else {
                 msg = "Can not create storage pool through host " + hostId
@@ -393,19 +360,15 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
     public boolean attachCluster(DataStore store, ClusterScope scope) {
         PrimaryDataStoreInfo primarystore = (PrimaryDataStoreInfo) store;
         // Check if there is host up in this cluster
-        List<HostVO> allHosts = _resourceMgr.listAllUpAndEnabledHosts(
-                Host.Type.Routing, primarystore.getClusterId(),
+        List<HostVO> allHosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, primarystore.getClusterId(),
                 primarystore.getPodId(), primarystore.getDataCenterId());
         if (allHosts.isEmpty()) {
-            throw new CloudRuntimeException(
-                    "No host up to associate a storage pool with in cluster "
-                            + primarystore.getClusterId());
+            throw new CloudRuntimeException("No host up to associate a storage pool with in cluster "
+                    + primarystore.getClusterId());
         }
 
-        if (primarystore.getPoolType() == StoragePoolType.OCFS2
-                && !_ocfs2Mgr.prepareNodes(allHosts, primarystore)) {
-            s_logger.warn("Can not create storage pool " + primarystore
-                    + " on cluster " + primarystore.getClusterId());
+        if (primarystore.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(allHosts, primarystore)) {
+            s_logger.warn("Can not create storage pool " + primarystore + " on cluster " + primarystore.getClusterId());
             primaryDataStoreDao.expunge(primarystore.getId());
             return false;
         }
@@ -422,18 +385,16 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
         List<HostVO> poolHosts = new ArrayList<HostVO>();
         for (HostVO h : allHosts) {
             try {
-                this.storageMgr.connectHostToSharedPool(h.getId(),
-                        primarystore.getId());
+                this.storageMgr.connectHostToSharedPool(h.getId(), primarystore.getId());
                 poolHosts.add(h);
             } catch (Exception e) {
-                s_logger.warn("Unable to establish a connection between " + h
-                        + " and " + primarystore, e);
+                s_logger.warn("Unable to establish a connection between " + h + " and " + primarystore, e);
             }
         }
 
         if (poolHosts.isEmpty()) {
-            s_logger.warn("No host can access storage pool " + primarystore
-                    + " on cluster " + primarystore.getClusterId());
+            s_logger.warn("No host can access storage pool " + primarystore + " on cluster "
+                    + primarystore.getClusterId());
             primaryDataStoreDao.expunge(primarystore.getId());
             return false;
         }
@@ -444,17 +405,16 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
 
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope) {
-    	List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType.KVM, scope.getScopeId());
-    	for (HostVO host : hosts) {
-    		try {
-    			this.storageMgr.connectHostToSharedPool(host.getId(),
-    					dataStore.getId());
-    		} catch (Exception e) {
-    			s_logger.warn("Unable to establish a connection between " + host
-    					+ " and " + dataStore, e);
-    		}
-    	}
-    	this.dataStoreHelper.attachZone(dataStore);
+        List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType.KVM,
+                scope.getScopeId());
+        for (HostVO host : hosts) {
+            try {
+                this.storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId());
+            } catch (Exception e) {
+                s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
+            }
+        }
+        this.dataStoreHelper.attachZone(dataStore);
         return true;
     }
 
@@ -487,16 +447,13 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements
     @DB
     @Override
     public boolean deleteDataStore(DataStore store) {
-        List<StoragePoolHostVO> hostPoolRecords = this._storagePoolHostDao
-                .listByPoolId(store.getId());
-        StoragePool pool = (StoragePool)store;
+        List<StoragePoolHostVO> hostPoolRecords = this._storagePoolHostDao.listByPoolId(store.getId());
+        StoragePool pool = (StoragePool) store;
         boolean deleteFlag = false;
         // Remove the SR associated with the Xenserver
         for (StoragePoolHostVO host : hostPoolRecords) {
-            DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(
-                    pool);
-            final Answer answer = agentMgr.easySend(host.getHostId(),
-                    deleteCmd);
+            DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(pool);
+            final Answer answer = agentMgr.easySend(host.getHostId(), deleteCmd);
 
             if (answer != null && answer.getResult()) {
                 deleteFlag = true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
index fed41da..410416c 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
@@ -32,8 +32,7 @@ import org.apache.cloudstack.storage.datastore.lifecycle.CloudStackPrimaryDataSt
 
 import com.cloud.utils.component.ComponentContext;
 
-public class CloudStackPrimaryDataStoreProviderImpl implements
-        PrimaryDataStoreProvider {
+public class CloudStackPrimaryDataStoreProviderImpl implements PrimaryDataStoreProvider {
 
     private final String providerName = DataStoreProvider.DEFAULT_PRIMARY;
     protected PrimaryDataStoreDriver driver;
@@ -74,7 +73,7 @@ public class CloudStackPrimaryDataStoreProviderImpl implements
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
         types.add(DataStoreProviderType.PRIMARY);
         return types;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
index 31be988..ad506d1 100644
--- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
@@ -35,7 +35,6 @@ import org.apache.cloudstack.framework.async.AsyncRpcConext;
 import org.apache.cloudstack.storage.command.CommandResult;
 import org.apache.cloudstack.storage.command.CreateObjectAnswer;
 import org.apache.cloudstack.storage.command.CreateObjectCommand;
-import org.apache.cloudstack.storage.command.DeleteCommand;
 import org.apache.cloudstack.storage.datastore.DataObjectManager;
 import org.apache.log4j.Logger;
 
@@ -47,7 +46,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.storage.encoding.DecodedDataObject;
 import com.cloud.utils.storage.encoding.Decoder;
 
-
 public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
     private static final Logger s_logger = Logger.getLogger(SamplePrimaryDataStoreDriverImpl.class);
     @Inject
@@ -56,6 +54,7 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
     StoragePoolHostDao storeHostDao;
     @Inject
     DataObjectManager dataObjMgr;
+
     public SamplePrimaryDataStoreDriverImpl() {
 
     }
@@ -65,16 +64,15 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
         return null;
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
         // TODO Auto-generated method stub
         return null;
     }
 
-
     private class CreateVolumeContext<T> extends AsyncRpcConext<T> {
         private final DataObject volume;
+
         /**
          * @param callback
          */
@@ -89,33 +87,36 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
 
     }
 
-    public Void createAsyncCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeContext<CreateCmdResult> context) {
-        /*CreateCmdResult result = null;
-        CreateObjectAnswer volAnswer = (CreateObjectAnswer) callback.getResult();
-        if (volAnswer.getResult()) {
-            result = new CreateCmdResult(volAnswer.getPath(), volAnswer);
-        } else {
-            result = new CreateCmdResult("", null);
-            result.setResult(volAnswer.getDetails());
-        }
-
-        context.getParentCallback().complete(result);*/
+    public Void createAsyncCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> callback,
+            CreateVolumeContext<CreateCmdResult> context) {
+        /*
+         * CreateCmdResult result = null; CreateObjectAnswer volAnswer =
+         * (CreateObjectAnswer) callback.getResult(); if (volAnswer.getResult())
+         * { result = new CreateCmdResult(volAnswer.getPath(), volAnswer); }
+         * else { result = new CreateCmdResult("", null);
+         * result.setResult(volAnswer.getDetails()); }
+         * 
+         * context.getParentCallback().complete(result);
+         */
         return null;
     }
 
     @Override
     public void deleteAsync(DataObject vo, AsyncCompletionCallback<CommandResult> callback) {
-        /*DeleteCommand cmd = new DeleteCommand(vo.getUri());
-
-        EndPoint ep = selector.select(vo);
-        AsyncRpcConext<CommandResult> context = new AsyncRpcConext<CommandResult>(callback);
-        AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
-        caller.setCallback(caller.getTarget().deleteCallback(null, null))
-            .setContext(context);
-        ep.sendMessageAsync(cmd, caller);*/
+        /*
+         * DeleteCommand cmd = new DeleteCommand(vo.getUri());
+         * 
+         * EndPoint ep = selector.select(vo); AsyncRpcConext<CommandResult>
+         * context = new AsyncRpcConext<CommandResult>(callback);
+         * AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer>
+         * caller = AsyncCallbackDispatcher.create(this);
+         * caller.setCallback(caller.getTarget().deleteCallback(null, null))
+         * .setContext(context); ep.sendMessageAsync(cmd, caller);
+         */
     }
 
-    public Void deleteCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> callback, AsyncRpcConext<CommandResult> context) {
+    public Void deleteCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> callback,
+            AsyncRpcConext<CommandResult> context) {
         CommandResult result = new CommandResult();
         Answer answer = callback.getResult();
         if (!answer.getResult()) {
@@ -124,83 +125,80 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
         context.getParentCallback().complete(result);
         return null;
     }
-    /*
-    private class CreateVolumeFromBaseImageContext<T> extends AsyncRpcConext<T> {
-        private final VolumeObject volume;
 
-        public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T> callback, VolumeObject volume) {
-            super(callback);
-            this.volume = volume;
-        }
-
-        public VolumeObject getVolume() {
-            return this.volume;
-        }
-
-    }
-
-    @Override
-    public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateInfo template, AsyncCompletionCallback<CommandResult> callback) {
-        VolumeTO vol = this.dataStore.getVolumeTO(volume);
-        List<EndPoint> endPoints = this.dataStore.getEndPoints();
-        EndPoint ep = endPoints.get(0);
-        String templateUri = template.getDataStore().grantAccess(template, ep);
-        CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol, templateUri);
-
-        CreateVolumeFromBaseImageContext<CommandResult> context = new CreateVolumeFromBaseImageContext<CommandResult>(callback, volume);
-        AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
-        caller.setContext(context)
-            .setCallback(caller.getTarget().createVolumeFromBaseImageAsyncCallback(null, null));
-
-        ep.sendMessageAsync(cmd, caller);
-    }*/
     /*
-    public Object createVolumeFromBaseImageAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeFromBaseImageContext<CommandResult> context) {
-        CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
-        CommandResult result = new CommandResult();
-        if (answer == null || answer.getDetails() != null) {
-            result.setSuccess(false);
-            if (answer != null) {
-                result.setResult(answer.getDetails());
-            }
-        } else {
-            result.setSuccess(true);
-            VolumeObject volume = context.getVolume();
-            volume.setPath(answer.getVolumeUuid());
-        }
-        AsyncCompletionCallback<CommandResult> parentCall = context.getParentCallback();
-        parentCall.complete(result);
-        return null;
-    }*/
+     * private class CreateVolumeFromBaseImageContext<T> extends
+     * AsyncRpcConext<T> { private final VolumeObject volume;
+     * 
+     * public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T>
+     * callback, VolumeObject volume) { super(callback); this.volume = volume; }
+     * 
+     * public VolumeObject getVolume() { return this.volume; }
+     * 
+     * }
+     * 
+     * @Override public void createVolumeFromBaseImageAsync(VolumeObject volume,
+     * TemplateInfo template, AsyncCompletionCallback<CommandResult> callback) {
+     * VolumeTO vol = this.dataStore.getVolumeTO(volume); List<EndPoint>
+     * endPoints = this.dataStore.getEndPoints(); EndPoint ep =
+     * endPoints.get(0); String templateUri =
+     * template.getDataStore().grantAccess(template, ep);
+     * CreateVolumeFromBaseImageCommand cmd = new
+     * CreateVolumeFromBaseImageCommand(vol, templateUri);
+     * 
+     * CreateVolumeFromBaseImageContext<CommandResult> context = new
+     * CreateVolumeFromBaseImageContext<CommandResult>(callback, volume);
+     * AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller
+     * = AsyncCallbackDispatcher.create(this); caller.setContext(context)
+     * .setCallback
+     * (caller.getTarget().createVolumeFromBaseImageAsyncCallback(null, null));
+     * 
+     * ep.sendMessageAsync(cmd, caller); }
+     */
+    /*
+     * public Object
+     * createVolumeFromBaseImageAsyncCallback(AsyncCallbackDispatcher
+     * <DefaultPrimaryDataStoreDriverImpl, Answer> callback,
+     * CreateVolumeFromBaseImageContext<CommandResult> context) {
+     * CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
+     * CommandResult result = new CommandResult(); if (answer == null ||
+     * answer.getDetails() != null) { result.setSuccess(false); if (answer !=
+     * null) { result.setResult(answer.getDetails()); } } else {
+     * result.setSuccess(true); VolumeObject volume = context.getVolume();
+     * volume.setPath(answer.getVolumeUuid()); }
+     * AsyncCompletionCallback<CommandResult> parentCall =
+     * context.getParentCallback(); parentCall.complete(result); return null; }
+     */
 
     @Override
-    public void createAsync(DataObject vol,
-            AsyncCompletionCallback<CreateCmdResult> callback) {
+    public void createAsync(DataObject vol, AsyncCompletionCallback<CreateCmdResult> callback) {
         EndPoint ep = selector.select(vol);
         CreateObjectCommand createCmd = new CreateObjectCommand(null);
 
         CreateVolumeContext<CreateCmdResult> context = new CreateVolumeContext<CreateCmdResult>(callback, vol);
         AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
-        caller.setContext(context)
-            .setCallback(caller.getTarget().createAsyncCallback(null, null));
+        caller.setContext(context).setCallback(caller.getTarget().createAsyncCallback(null, null));
 
         ep.sendMessageAsync(createCmd, caller);
     }
 
     @Override
     public String grantAccess(DataObject object, EndPoint ep) {
-        //StoragePoolHostVO poolHost = storeHostDao.findByPoolHost(object.getDataStore().getId(), ep.getId());
+        // StoragePoolHostVO poolHost =
+        // storeHostDao.findByPoolHost(object.getDataStore().getId(),
+        // ep.getId());
 
         String uri = object.getUri();
         try {
             DecodedDataObject obj = Decoder.decode(uri);
             if (obj.getPath() == null) {
-                //create an obj
+                // create an obj
                 EndPoint newEp = selector.select(object);
                 CreateObjectCommand createCmd = new CreateObjectCommand(null);
-                CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
+                CreateObjectAnswer answer = (CreateObjectAnswer) ep.sendMessage(createCmd);
                 if (answer.getResult()) {
-                    //dataObjMgr.update(object, answer.getPath(), answer.getSize());
+                    // dataObjMgr.update(object, answer.getPath(),
+                    // answer.getSize());
                 } else {
                     s_logger.debug("failed to create object" + answer.getDetails());
                     throw new CloudRuntimeException("failed to create object" + answer.getDetails());
@@ -209,7 +207,7 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
 
             return object.getUri();
         } catch (URISyntaxException e) {
-           throw new CloudRuntimeException("uri parsed error", e);
+            throw new CloudRuntimeException("uri parsed error", e);
         }
     }
 
@@ -226,14 +224,11 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
     }
 
     @Override
-    public void revertSnapshot(SnapshotInfo snapshot,
-            AsyncCompletionCallback<CommandResult> callback) {
+    public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
         // TODO Auto-generated method stub
 
     }
 
-
-
     @Override
     public boolean canCopy(DataObject srcData, DataObject destData) {
         // TODO Auto-generated method stub
@@ -241,24 +236,21 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
     }
 
     @Override
-    public void copyAsync(DataObject srcdata, DataObject destData,
-            AsyncCompletionCallback<CopyCommandResult> callback) {
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         // TODO Auto-generated method stub
 
     }
 
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
-	@Override
-	public void takeSnapshot(SnapshotInfo snapshot,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    @Override
+    public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
index ddd64e5..504cb9a 100644
--- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
@@ -54,18 +54,20 @@ public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLife
     PrimaryDataStoreHelper primaryStoreHelper;
     @Inject
     PrimaryDataStoreProviderManager providerMgr;
+
     public SamplePrimaryDataStoreLifeCycleImpl() {
     }
-    
+
     @Override
     public DataStore initialize(Map<String, Object> dsInfos) {
-        
-        DataStore store = primaryStoreHelper.createPrimaryDataStore(null); 
+
+        DataStore store = primaryStoreHelper.createPrimaryDataStore(null);
         return providerMgr.getPrimaryDataStore(store.getId());
     }
 
     protected void attachCluster(DataStore store) {
-        //send down AttachPrimaryDataStoreCmd command to all the hosts in the cluster
+        // send down AttachPrimaryDataStoreCmd command to all the hosts in the
+        // cluster
         List<EndPoint> endPoints = selector.selectAll(store);
         CreatePrimaryDataStoreCmd createCmd = new CreatePrimaryDataStoreCmd(store.getUri());
         EndPoint ep = endPoints.get(0);
@@ -73,14 +75,14 @@ public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLife
         if (host.getHypervisorType() == HypervisorType.XenServer) {
             ep.sendMessage(createCmd);
         }
-        
+
         endPoints.get(0).sendMessage(createCmd);
         AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(store.getUri());
         for (EndPoint endp : endPoints) {
             endp.sendMessage(cmd);
         }
     }
-    
+
     @Override
     public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
         StoragePoolVO dataStoreVO = dataStoreDao.findById(dataStore.getId());
@@ -90,14 +92,13 @@ public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLife
         dataStoreVO.setStatus(StoragePoolStatus.Attaching);
         dataStoreVO.setScope(scope.getScopeType());
         dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
-        
-        
+
         attachCluster(dataStore);
-        
+
         dataStoreVO = dataStoreDao.findById(dataStore.getId());
         dataStoreVO.setStatus(StoragePoolStatus.Up);
         dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
-        
+
         return true;
     }
 
@@ -120,8 +121,7 @@ public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLife
     }
 
     @Override
-    public boolean attachHost(DataStore store, HostScope scope,
-            StoragePoolInfo existingInfo) {
+    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
         // TODO Auto-generated method stub
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
index 57424a7..8708821 100644
--- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
@@ -23,18 +23,15 @@ import java.util.Set;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider.DataStoreProviderType;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.driver.SamplePrimaryDataStoreDriverImpl;
 import org.apache.cloudstack.storage.datastore.lifecycle.SamplePrimaryDataStoreLifeCycleImpl;
 
 import com.cloud.utils.component.ComponentContext;
 
-
 public class SamplePrimaryDatastoreProviderImpl implements PrimaryDataStoreProvider {
     private final String providerName = "sample primary data store provider";
     protected PrimaryDataStoreDriver driver;
@@ -45,6 +42,7 @@ public class SamplePrimaryDatastoreProviderImpl implements PrimaryDataStoreProvi
     protected DataStoreLifeCycle lifecycle;
     protected String uuid;
     protected long id;
+
     @Override
     public String getName() {
         return providerName;
@@ -75,7 +73,7 @@ public class SamplePrimaryDatastoreProviderImpl implements PrimaryDataStoreProvi
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
         types.add(DataStoreProviderType.PRIMARY);
         return types;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
index eee9ba5..a296bab 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
@@ -44,7 +44,6 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
         return null;
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
         // TODO Auto-generated method stub
@@ -93,19 +92,16 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
 
     }
 
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
-
-	}
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	@Override
-	public void takeSnapshot(SnapshotInfo snapshot,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    }
 
-	}
+    @Override
+    public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
index 39adf9f..03f241e 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
@@ -27,19 +27,17 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class SolidfirePrimaryDataStoreProvider implements PrimaryDataStoreProvider {
-	private final String name = "Solidfire Primary Data Store Provider";
+    private final String name = "Solidfire Primary Data Store Provider";
 
+    public SolidfirePrimaryDataStoreProvider() {
 
-	public SolidfirePrimaryDataStoreProvider() {
-
-
-		// TODO Auto-generated constructor stub
-	}
+        // TODO Auto-generated constructor stub
+    }
 
-	@Override
-	public String getName() {
-		return name;
-	}
+    @Override
+    public String getName() {
+        return name;
+    }
 
     @Override
     public DataStoreLifeCycle getDataStoreLifeCycle() {
@@ -71,5 +69,4 @@ public class SolidfirePrimaryDataStoreProvider implements PrimaryDataStoreProvid
         return null;
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/AopTestAdvice.java b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
index 63669c4..902f595 100644
--- a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
+++ b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
@@ -21,14 +21,14 @@ import org.aspectj.lang.ProceedingJoinPoint;
 import com.cloud.utils.db.Transaction;
 
 public class AopTestAdvice {
-	public Object AopTestMethod(ProceedingJoinPoint call) throws Throwable {
-		Transaction txn = Transaction.open(call.getSignature().getName());
-		Object ret = null;
-		try {
-			 ret = call.proceed();
-		} finally {
-			txn.close();
-		}
-		return ret;
-	}
+    public Object AopTestMethod(ProceedingJoinPoint call) throws Throwable {
+        Transaction txn = Transaction.open(call.getSignature().getName());
+        Object ret = null;
+        try {
+            ret = call.proceed();
+        } finally {
+            txn.close();
+        }
+        return ret;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
index eb6fe45..7921561 100644
--- a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
+++ b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
@@ -24,28 +24,29 @@ import com.cloud.agent.AgentManager;
 import com.cloud.host.dao.HostDao;
 
 public class ChildTestConfiguration extends TestConfiguration {
-	
-	@Override
-	@Bean
-	public HostDao hostDao() {
-		HostDao dao = super.hostDao();
-		HostDao nDao = Mockito.spy(dao);
-		return nDao;
-	}
-	
-	@Bean
-	public AgentManager agentMgr() {
-		return Mockito.mock(AgentManager.class);
-	}
-	
-	@Bean
-	public ImageMotionService imageMotion() {
-		return Mockito.mock(ImageMotionService.class);
-	}
 
-/*	@Override
-	@Bean
-	public PrimaryDataStoreDao primaryDataStoreDao() {
-		return Mockito.mock(PrimaryDataStoreDaoImpl.class);
-	}*/
+    @Override
+    @Bean
+    public HostDao hostDao() {
+        HostDao dao = super.hostDao();
+        HostDao nDao = Mockito.spy(dao);
+        return nDao;
+    }
+
+    @Bean
+    public AgentManager agentMgr() {
+        return Mockito.mock(AgentManager.class);
+    }
+
+    @Bean
+    public ImageMotionService imageMotion() {
+        return Mockito.mock(ImageMotionService.class);
+    }
+
+    /*
+     * @Override
+     * 
+     * @Bean public PrimaryDataStoreDao primaryDataStoreDao() { return
+     * Mockito.mock(PrimaryDataStoreDaoImpl.class); }
+     */
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/TestConfiguration.java b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/TestConfiguration.java
index 2c6092d..8e98771 100644
--- a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/TestConfiguration.java
+++ b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/TestConfiguration.java
@@ -26,12 +26,13 @@ import com.cloud.host.dao.HostDaoImpl;
 
 @Configuration
 public class TestConfiguration {
-	@Bean
-	public HostDao hostDao() {
-		return new HostDaoImpl();
-	}
-	@Bean
-	public PrimaryDataStoreDao primaryDataStoreDao() {
-		return new PrimaryDataStoreDaoImpl();
-	}
+    @Bean
+    public HostDao hostDao() {
+        return new HostDaoImpl();
+    }
+
+    @Bean
+    public PrimaryDataStoreDao primaryDataStoreDao() {
+        return new PrimaryDataStoreDaoImpl();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
index 5bc929d..a745daf 100644
--- a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
+++ b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
@@ -25,11 +25,11 @@ import java.util.UUID;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
-import org.apache.cloudstack.storage.command.CreateObjectAnswer;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -42,8 +42,6 @@ import com.cloud.dc.HostPodVO;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.exception.OperationTimedoutException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
@@ -52,88 +50,91 @@ import com.cloud.org.Cluster.ClusterType;
 import com.cloud.org.Managed.ManagedState;
 import com.cloud.resource.ResourceState;
 
-
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations="classpath:/resource/storageContext.xml")
+@ContextConfiguration(locations = "classpath:/resource/storageContext.xml")
 public class VolumeTest {
-	@Inject 
-	HostDao hostDao;
-	@Inject
-	HostPodDao podDao;
-	@Inject
-	ClusterDao clusterDao;
-	@Inject
-	DataCenterDao dcDao;
-	@Inject
-	PrimaryDataStoreDao primaryStoreDao;
-	//@Inject
-	//PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
-	@Inject
-	AgentManager agentMgr;
-	Long dcId;
-	Long clusterId;
-	@Before
-	public void setUp() {
-		//create data center
-		DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null,  "10.0.0.1/24", 
-				null, null, NetworkType.Basic, null, null, true,  true, null, null);
-		dc = dcDao.persist(dc);
-		dcId = dc.getId();
-		//create pod
+    @Inject
+    HostDao hostDao;
+    @Inject
+    HostPodDao podDao;
+    @Inject
+    ClusterDao clusterDao;
+    @Inject
+    DataCenterDao dcDao;
+    @Inject
+    PrimaryDataStoreDao primaryStoreDao;
+    // @Inject
+    // PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
+    @Inject
+    AgentManager agentMgr;
+    Long dcId;
+    Long clusterId;
 
-		HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "192.168.56.1", "192.168.56.0/24", 8, "test");
-		pod = podDao.persist(pod);
-		//create xen cluster
-		ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
-		cluster.setHypervisorType(HypervisorType.XenServer.toString());
-		cluster.setClusterType(ClusterType.CloudManaged);
-		cluster.setManagedState(ManagedState.Managed);
-		cluster = clusterDao.persist(cluster);
-		clusterId = cluster.getId();
-		//create xen host
+    @Before
+    public void setUp() {
+        // create data center
+        DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null,
+                "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
+        dc = dcDao.persist(dc);
+        dcId = dc.getId();
+        // create pod
 
-		HostVO host = new HostVO(UUID.randomUUID().toString());
-		host.setName("devcloud xen host");
-		host.setType(Host.Type.Routing);
-		host.setPrivateIpAddress("192.168.56.2");
-		host.setDataCenterId(dc.getId());
-		host.setVersion("6.0.1");
-		host.setAvailable(true);
-		host.setSetup(true);
-		host.setLastPinged(0);
-		host.setResourceState(ResourceState.Enabled);
-		host.setClusterId(cluster.getId());
+        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "192.168.56.1", "192.168.56.0/24", 8,
+                "test");
+        pod = podDao.persist(pod);
+        // create xen cluster
+        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
+        cluster.setHypervisorType(HypervisorType.XenServer.toString());
+        cluster.setClusterType(ClusterType.CloudManaged);
+        cluster.setManagedState(ManagedState.Managed);
+        cluster = clusterDao.persist(cluster);
+        clusterId = cluster.getId();
+        // create xen host
 
-		host = hostDao.persist(host);
-		List<HostVO> results = new ArrayList<HostVO>();
-		results.add(host);
-		Mockito.when(hostDao.listAll()).thenReturn(results);
-		Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results);
-		//CreateObjectAnswer createVolumeFromImageAnswer = new CreateObjectAnswer(null,UUID.randomUUID().toString(), null);
+        HostVO host = new HostVO(UUID.randomUUID().toString());
+        host.setName("devcloud xen host");
+        host.setType(Host.Type.Routing);
+        host.setPrivateIpAddress("192.168.56.2");
+        host.setDataCenterId(dc.getId());
+        host.setVersion("6.0.1");
+        host.setAvailable(true);
+        host.setSetup(true);
+        host.setLastPinged(0);
+        host.setResourceState(ResourceState.Enabled);
+        host.setClusterId(cluster.getId());
 
+        host = hostDao.persist(host);
+        List<HostVO> results = new ArrayList<HostVO>();
+        results.add(host);
+        Mockito.when(hostDao.listAll()).thenReturn(results);
+        Mockito.when(hostDao.findHypervisorHostInCluster(Matchers.anyLong())).thenReturn(results);
+        // CreateObjectAnswer createVolumeFromImageAnswer = new
+        // CreateObjectAnswer(null,UUID.randomUUID().toString(), null);
 
+        // Mockito.when(primaryStoreDao.findById(Mockito.anyLong())).thenReturn(primaryStore);
+    }
 
-		//Mockito.when(primaryStoreDao.findById(Mockito.anyLong())).thenReturn(primaryStore);
-	}
+    private PrimaryDataStoreInfo createPrimaryDataStore() {
+        try {
+            // primaryDataStoreProviderMgr.configure("primary data store mgr",
+            // new HashMap<String, Object>());
+            // PrimaryDataStoreProvider provider =
+            // primaryDataStoreProviderMgr.getDataStoreProvider("Solidfre Primary Data Store Provider");
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("url", "nfs://test/test");
+            params.put("dcId", dcId.toString());
+            params.put("clusterId", clusterId.toString());
+            params.put("name", "my primary data store");
+            // PrimaryDataStoreInfo primaryDataStoreInfo =
+            // provider.registerDataStore(params);
+            return null;
+        } catch (Exception e) {
+            return null;
+        }
+    }
 
-	private PrimaryDataStoreInfo createPrimaryDataStore() {
-		try {
-			//primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String, Object>());
-			//PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("Solidfre Primary Data Store Provider");
-			Map<String, String> params = new HashMap<String, String>();
-			params.put("url", "nfs://test/test");
-			params.put("dcId", dcId.toString());
-			params.put("clusterId", clusterId.toString());
-			params.put("name", "my primary data store");
-			//PrimaryDataStoreInfo primaryDataStoreInfo = provider.registerDataStore(params);
-			return null;
-		} catch (Exception e) {
-			return null;
-		}
-	}
-	
-	@Test
-	public void createPrimaryDataStoreTest() {
-		createPrimaryDataStore();
-	}
+    @Test
+    public void createPrimaryDataStoreTest() {
+        createPrimaryDataStore();
+    }
 }


Mime
View raw message