incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [1/2] git commit: so many traps in rpc call: you can't use aop in a thread, you need to intercept finalize call etc
Date Mon, 24 Dec 2012 10:38:14 GMT
Updated Branches:
  refs/heads/javelin 4b2d9f441 -> d99161399


so many traps in rpc call: you can't use aop in a thread, you need to intercept finalize call etc


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

Branch: refs/heads/javelin
Commit: d99161399e47529656a3622f837adef037587d27
Parents: 4b2d9f4
Author: Edison Su <edison.su@citrix.com>
Authored: Mon Dec 24 02:37:32 2012 -0800
Committer: Edison Su <edison.su@citrix.com>
Committed: Mon Dec 24 02:37:32 2012 -0800

----------------------------------------------------------------------
 .../api/storage/PrimaryDataStoreInfo.java          |    1 +
 .../storage/test/ChildTestConfiguration.java       |    2 +-
 .../storage/test/CloudStackTestNGBase.java         |   24 +++-
 ...ockHostEndpointRpcServerDirectCallResource.java |   30 +---
 .../cloudstack/storage/test/MockRpcCallBack.java   |   46 ++++++
 .../cloudstack/storage/test/volumeServiceTest.java |  123 ++++++++------
 .../integration-test/test/resource/testng.xml      |    2 +-
 .../storage/command/AttachPrimaryDataStoreCmd.java |    5 +-
 .../storage/command/CreatePrimaryDataStoreCmd.java |    1 +
 .../storage/datastore/PrimaryDataStore.java        |    6 +
 .../datastore/protocol/DataStoreProtocol.java      |   16 ++
 .../storage/to/ImageOnPrimayDataStoreTO.java       |    2 +-
 .../storage/to/NfsPrimaryDataStoreTO.java          |   28 ++++
 .../cloudstack/storage/to/PrimaryDataStoreTO.java  |    6 +
 .../storage/datastore/DataStoreStatus.java         |    2 +-
 .../storage/datastore/DefaultPrimaryDataStore.java |   45 ++++--
 .../AbstractPrimaryDataStoreConfigurator.java      |   17 +--
 .../configurator/PrimaryDataStoreConfigurator.java |    4 +-
 .../configurator/kvm/KvmCLVMConfigurator.java      |   10 +-
 .../configurator/kvm/KvmNfsConfigurator.java       |   20 ++-
 .../configurator/kvm/KvmRBDConfigurator.java       |   11 +-
 .../configurator/validator/CLVMValidator.java      |   22 +++-
 .../validator/FileSystemValidator.java             |   22 +++-
 .../configurator/validator/ISCSIValiator.java      |   23 +++-
 .../validator/NfsProtocolTransformer.java          |   95 +++++++++++
 .../configurator/validator/NfsValidator.java       |   68 --------
 .../configurator/validator/ProtocolValidator.java  |   27 ---
 .../configurator/validator/RBDValidator.java       |   21 +++-
 .../validator/StorageProtocolTransformer.java      |   34 ++++
 .../configurator/validator/VMFSValidator.java      |   21 +++-
 .../vmware/VmwareIsciConfigurator.java             |   11 +-
 .../configurator/vmware/VmwareNfsConfigurator.java |   19 ++-
 .../vmware/VmwareVMFSConfigurator.java             |   10 +-
 .../configurator/xen/AbstractXenConfigurator.java  |   24 ---
 .../configurator/xen/XenIscsiConfigurator.java     |    9 +-
 .../configurator/xen/XenNfsConfigurator.java       |   20 ++-
 .../driver/DefaultPrimaryDataStoreDriverImpl.java  |    2 +-
 .../DefaultPrimaryDataStoreLifeCycleImpl.java      |   13 +-
 .../DefaultXenPrimaryDataStoreLifeCycle.java       |   10 +-
 .../DefaultPrimaryDatastoreProviderImpl.java       |   28 +---
 .../volume/TemplateOnPrimaryDataStoreObject.java   |    4 +
 .../storage/volume/VolumeServiceImpl.java          |    2 -
 .../framework/async/AsyncCallbackDispatcher.java   |   37 ++++-
 .../xen/resource/CitrixResourceBase.java           |    3 +
 .../xen/resource/XenServerStorageResource.java     |   56 ++++---
 45 files changed, 657 insertions(+), 325 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
index c818522..11bc26b 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
@@ -41,4 +41,5 @@ public interface PrimaryDataStoreInfo {
 	public String getType();
 	public PrimaryDataStoreLifeCycle getLifeCycle();
 	PrimaryDataStoreProvider getProvider();
+	
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
index 27a8513..69907bc 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
@@ -24,7 +24,7 @@ public class ChildTestConfiguration extends TestConfiguration {
 	
     @Bean
     public HostEndpointRpcServer rpcServer() {
-        return new MockHypervsiorHostEndPointRpcServer();
+        return new MockHostEndpointRpcServerDirectCallResource();
     }
 /*	@Override
 	@Bean

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
index 94ae208..5bc7c0d 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
@@ -6,6 +6,7 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
 
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
@@ -17,13 +18,23 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
     private String hostGuid;
     private String templateUrl;
     private String localStorageUuid;
+    private String primaryStorageUrl;
     private Transaction txn;
     
+    protected void injectMockito() {
+        
+    }
+    
     @BeforeMethod(alwaysRun = true)
     protected  void injectDB(Method testMethod) throws Exception {
         txn = Transaction.open(testMethod.getName());
     }
     
+    @Test
+    protected  void injectMockitoTest() {
+        injectMockito();
+    }
+    
     @AfterMethod(alwaysRun = true)
     protected void closeDB(Method testMethod) throws Exception {
         if (txn != null) {
@@ -32,14 +43,19 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
     }
     
     @BeforeMethod(alwaysRun = true)
-    @Parameters({"devcloud-host-uuid", "devcloud-host-gateway", "devcloud-host-cidr", "devcloud-host-ip", "template-url", "devcloud-local-storage-uuid"})
-    protected void setup(String hostuuid, String gateway, String cidr, String hostIp, String templateUrl, String localStorageUuid) {
+    @Parameters({"devcloud-host-uuid", "devcloud-host-gateway", "devcloud-host-cidr", 
+        "devcloud-host-ip", "template-url", "devcloud-local-storage-uuid", 
+        "primary-storage-want-to-add"})
+    protected void setup(String hostuuid, String gateway, String cidr, 
+            String hostIp, String templateUrl, String localStorageUuid,
+            String primaryStorage) {
         this.hostGuid = hostuuid;
         this.hostGateway = gateway;
         this.hostCidr = cidr;
         this.hostIp = hostIp;
         this.templateUrl = templateUrl;
         this.localStorageUuid = localStorageUuid;
+        this.primaryStorageUrl = primaryStorage;
     }
     
     protected String getHostGuid() {
@@ -65,4 +81,8 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
     protected String getLocalStorageUuid() {
         return this.localStorageUuid;
     }
+    
+    protected String getPrimaryStorageUrl() {
+        return this.primaryStorageUrl;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java
index f2272ce..a9700ca 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHostEndpointRpcServerDirectCallResource.java
@@ -37,6 +37,9 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.OperationTimedoutException;
+import com.cloud.utils.component.ComponentInject;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
 
 
 public class MockHostEndpointRpcServerDirectCallResource implements HostEndpointRpcServer {
@@ -47,29 +50,14 @@ public class MockHostEndpointRpcServerDirectCallResource implements HostEndpoint
     public MockHostEndpointRpcServerDirectCallResource() {
         executor = Executors.newScheduledThreadPool(10);
     }
-    protected class MockRpcCallBack implements Runnable {
-        private final Command cmd;
-        private final long hostId;
-        private final AsyncCompletionCallback<Answer> callback; 
-        public MockRpcCallBack(long hostId, Command cmd, final AsyncCompletionCallback<Answer> callback) {
-            this.cmd = cmd;
-            this.callback = callback;
-            this.hostId = hostId;
-        }
-        @Override
-        public void run() {
-            try {
-                Answer answer = agentMgr.send(hostId, cmd);
-                callback.complete(answer);
-            } catch (Exception e) {
-                s_logger.debug("send command failed:" + e.toString());
-            }
-        }
-        
-    }
     
     public void sendCommandAsync(HypervisorHostEndPoint host, final Command command, final AsyncCompletionCallback<Answer> callback) {
-        executor.schedule(new MockRpcCallBack(host.getHostId(), command, callback), 10, TimeUnit.SECONDS);
+       // new MockRpcCallBack(host.getHostId(), command, callback);
+        MockRpcCallBack run = ComponentInject.inject(MockRpcCallBack.class);
+        run.setCallback(callback);
+        run.setCmd(command);
+        run.setHostId(host.getHostId());
+        executor.schedule(run, 10, TimeUnit.SECONDS);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
new file mode 100644
index 0000000..294cb1e
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
@@ -0,0 +1,46 @@
+package org.apache.cloudstack.storage.test;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
+
+public class MockRpcCallBack implements Runnable {
+    @Inject
+    AgentManager agentMgr;
+    private Command cmd;
+    private long hostId;
+    private AsyncCompletionCallback<Answer> callback; 
+    
+    public void setCmd(Command cmd) {
+        this.cmd = cmd;
+    }
+    
+    public void setHostId(long hostId) {
+        this.hostId = hostId;
+    }
+    
+    public void setCallback(AsyncCompletionCallback<Answer> callback) {
+        this.callback = callback;
+    }
+    
+    @Override
+    @DB
+    public void run() {
+        try {
+            Answer answer = agentMgr.send(hostId, cmd);
+            
+            callback.complete(answer);
+        } catch (Throwable e) {
+            //s_logger.debug("send command failed:" + e.toString());
+        } finally {
+            int i =1;
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
index cd251b1..7451f36 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
@@ -18,8 +18,9 @@
  */
 package org.apache.cloudstack.storage.test;
 
-import static org.junit.Assert.*;
-
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.testng.AssertJUnit;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -51,7 +52,6 @@ import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
 import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
 import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.image.ImageService;
 import org.apache.cloudstack.storage.image.db.ImageDataDao;
@@ -68,14 +68,7 @@ import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCyc
 import org.apache.cloudstack.storage.volume.VolumeService;
 import org.apache.cloudstack.storage.volume.db.VolumeDao;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.junit.runner.RunWith;
-
 import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.mockito.Mockito;
 import org.mockito.Mockito.*;
 
@@ -100,13 +93,9 @@ import com.cloud.org.Cluster.ClusterType;
 import com.cloud.org.Managed.ManagedState;
 import com.cloud.resource.ResourceState;
 import com.cloud.storage.Storage.TemplateType;
-import com.cloud.utils.component.ComponentInject;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Transaction;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations="classpath:/storageContext.xml")
-public class volumeServiceTest {
+public class volumeServiceTest extends CloudStackTestNGBase {
 	@Inject
 	ImageDataStoreProviderManager imageProviderMgr;
 	@Inject
@@ -134,8 +123,19 @@ public class volumeServiceTest {
 	Long dcId;
 	Long clusterId;
 	Long podId;
-	@Before
+	HostVO host;
+	String primaryName = "my primary data store";
+	
+    @Test(priority = -1)
 	public void setUp() {
+        
+        host = hostDao.findByGuid(this.getHostGuid());
+        if (host != null) {
+            dcId = host.getDataCenterId();
+            clusterId = host.getClusterId();
+            podId = host.getPodId();
+            return;
+        }
 		//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);
@@ -143,7 +143,7 @@ public class volumeServiceTest {
 		dcId = dc.getId();
 		//create pod
 
-		HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "192.168.56.1", "192.168.56.0/24", 8, "test");
+		HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(), this.getHostCidr(), 8, "test");
 		pod = podDao.persist(pod);
 		podId = pod.getId();
 		//create xen cluster
@@ -155,23 +155,23 @@ public class volumeServiceTest {
 		clusterId = cluster.getId();
 		//create xen host
 
-		HostVO host = new HostVO(UUID.randomUUID().toString());
+		host = new HostVO(this.getHostGuid());
 		host.setName("devcloud xen host");
 		host.setType(Host.Type.Routing);
-		host.setPrivateIpAddress("192.168.56.2");
+		host.setPrivateIpAddress(this.getHostIp());
 		host.setDataCenterId(dc.getId());
 		host.setVersion("6.0.1");
 		host.setAvailable(true);
 		host.setSetup(true);
+		host.setPodId(podId);
 		host.setLastPinged(0);
 		host.setResourceState(ResourceState.Enabled);
+		host.setHypervisorType(HypervisorType.XenServer);
 		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(Mockito.anyLong())).thenReturn(results);
+		
+	
 		//CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(UUID.randomUUID().toString());
 
 		/*try {
@@ -187,11 +187,22 @@ public class volumeServiceTest {
 
 		//Mockito.when(primaryStoreDao.findById(Mockito.anyLong())).thenReturn(primaryStore);
 	}
+    
+    @Override
+    protected void injectMockito() {
+        if (host == null) {
+            return;
+        }
+        List<HostVO> results = new ArrayList<HostVO>();
+        results.add(host);
+        Mockito.when(hostDao.listAll()).thenReturn(results);
+        Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results);
+    }
 
 	private ImageDataVO createImageData() {
 		ImageDataVO image = new ImageDataVO();
 		image.setTemplateType(TemplateType.USER);
-		image.setUrl("http://testurl/test.vhd");
+		image.setUrl(this.getTemplateUrl());
 		image.setUniqueName(UUID.randomUUID().toString());
 		image.setName(UUID.randomUUID().toString());
 		image.setPublicTemplate(true);
@@ -226,21 +237,29 @@ public class volumeServiceTest {
 		}
 	}
 
-	@Test
 	public void createTemplateTest() {
 		createTemplate();
 	}
 
 	private PrimaryDataStoreInfo createPrimaryDataStore() {
 		try {
-			primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String, Object>());
-			PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
-
+		    PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
+		    primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String, Object>());
+            
+		    List<PrimaryDataStoreVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
+		    if (ds.size() >= 1) {
+		        PrimaryDataStoreVO store = ds.get(0);
+		        if (store.getRemoved() == null) {
+		            return provider.getDataStore(store.getId());
+		        }
+		    }
+		    
+		
 			Map<String, String> params = new HashMap<String, String>();
-			params.put("url", "nfs://localhost/primarynfs");
+			params.put("url", this.getPrimaryStorageUrl());
 			params.put("dcId", dcId.toString());
 			params.put("clusterId", clusterId.toString());
-			params.put("name", "my primary data store");
+			params.put("name", this.primaryName);
 			PrimaryDataStoreInfo primaryDataStoreInfo = provider.registerDataStore(params);
 			PrimaryDataStoreLifeCycle lc = primaryDataStoreInfo.getLifeCycle();
 			ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
@@ -251,11 +270,6 @@ public class volumeServiceTest {
 		}
 	}
 
-	@Test
-	public void createPrimaryDataStoreTest() {
-		createPrimaryDataStore();
-	}
-
 	private VolumeVO createVolume(long templateId) {
 		VolumeVO volume = new VolumeVO(1000, new RootDisk().toString(), UUID.randomUUID().toString(), templateId);
 		volume = volumeDao.persist(volume);
@@ -263,7 +277,7 @@ public class volumeServiceTest {
 
 	}
 
-	@Test
+	@Test(priority=2)
 	public void createVolumeFromTemplate() {
 		TemplateEntity te = createTemplate();
 		PrimaryDataStoreInfo dataStoreInfo = createPrimaryDataStore();
@@ -271,37 +285,40 @@ public class volumeServiceTest {
 		VolumeEntity ve = volumeService.getVolumeEntity(volume.getId());
 		ve.createVolumeFromTemplate(dataStoreInfo.getId(), new VHD(), te);
 	}
+	
+	@Test(priority=3)
+	public void tearDown() {
+	    List<PrimaryDataStoreVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
+	    for (int i = 0; i < ds.size(); i++) {
+	        PrimaryDataStoreVO store = ds.get(i);
+	        store.setUuid(null);
+	        primaryStoreDao.remove(ds.get(i).getId());
+	        primaryStoreDao.expunge(ds.get(i).getId());
+	    }
+	}
 
 	//@Test
-	public void test1() {
+	@Test
+    public void test1() {
 		System.out.println(VolumeTypeHelper.getType("Root"));
 		System.out.println(VolumeDiskTypeHelper.getDiskType("vmdk"));
 		System.out.println(ImageFormatHelper.getFormat("ova"));
-		assertFalse(new VMDK().equals(new VHD()));
+		AssertJUnit.assertFalse(new VMDK().equals(new VHD()));
 		VMDK vmdk = new VMDK();
-		assertTrue(vmdk.equals(vmdk));
+		AssertJUnit.assertTrue(vmdk.equals(vmdk));
 		VMDK newvmdk = new VMDK();
-		assertTrue(vmdk.equals(newvmdk));
+		AssertJUnit.assertTrue(vmdk.equals(newvmdk));
 
 		ImageFormat ova = new OVA();
 		ImageFormat iso = new ISO();
-		assertTrue(ova.equals(new OVA()));
-		assertFalse(ova.equals(iso));
-		assertTrue(ImageFormatHelper.getFormat("test").equals(new Unknown()));
+		AssertJUnit.assertTrue(ova.equals(new OVA()));
+		AssertJUnit.assertFalse(ova.equals(iso));
+		AssertJUnit.assertTrue(ImageFormatHelper.getFormat("test").equals(new Unknown()));
 
 		VolumeDiskType qcow2 = new QCOW2();
 		ImageFormat qcow2format = new org.apache.cloudstack.storage.image.format.QCOW2();
-		assertFalse(qcow2.equals(qcow2format));
-
-	}
-
-	//@Test
-	public void testStaticBean() {
-		DefaultPrimaryDatastoreProviderImpl provider = ComponentInject.inject(DefaultPrimaryDatastoreProviderImpl.class);
-		//assertNotNull(provider.dataStoreDao);
+		AssertJUnit.assertFalse(qcow2.equals(qcow2format));
 
-		DefaultPrimaryDataStore dpdsi = DefaultPrimaryDataStore.createDataStore(null);
-		//assertNotNull(dpdsi.volumeDao);
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/integration-test/test/resource/testng.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/testng.xml b/engine/storage/integration-test/test/resource/testng.xml
index b2531d1..186c542 100644
--- a/engine/storage/integration-test/test/resource/testng.xml
+++ b/engine/storage/integration-test/test/resource/testng.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite thread-count="1" verbose="1" name="storage test" annotations="JDK" parallel="methods">
+<suite thread-count="1" verbose="1" name="storage test" annotations="JDK" parallel="classes">
   <!--describe your test environment-->
   <parameter name="devcloud-host-ip" value="192.168.56.2"/>
   <parameter name="devcloud-host-gateway" value="192.168.56.1"/>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java b/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
index 53400a3..b0b3299 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
@@ -18,15 +18,14 @@
  */
 package org.apache.cloudstack.storage.command;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
 
 import com.cloud.agent.api.Command;
 
 public class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
     private final PrimaryDataStoreTO dataStore;
-    public AttachPrimaryDataStoreCmd(PrimaryDataStoreInfo dataStore) {
-        this.dataStore = new PrimaryDataStoreTO(dataStore);
+    public AttachPrimaryDataStoreCmd(PrimaryDataStoreTO dataStore) {
+        this.dataStore = dataStore;
     }
     
     public PrimaryDataStoreTO getDataStore() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java b/engine/storage/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
index db5c019..5a64e33 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
@@ -1,5 +1,6 @@
 package org.apache.cloudstack.storage.command;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
 
 import com.cloud.agent.api.Command;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
index 9005bc0..a945e28 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
@@ -27,6 +27,8 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.storage.EndPoint;
 import org.apache.cloudstack.storage.command.CommandResult;
 import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
 
 public interface PrimaryDataStore extends PrimaryDataStoreInfo {
@@ -53,4 +55,8 @@ public interface PrimaryDataStore extends PrimaryDataStoreInfo {
     boolean installTemplate(TemplateOnPrimaryDataStoreInfo template);
 
     VolumeDiskType getDefaultDiskType();
+
+    PrimaryDataStoreTO getDataStoreTO();
+
+    VolumeTO getVolumeTO(VolumeInfo volume);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/datastore/protocol/DataStoreProtocol.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/protocol/DataStoreProtocol.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/protocol/DataStoreProtocol.java
new file mode 100644
index 0000000..54518ae
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/protocol/DataStoreProtocol.java
@@ -0,0 +1,16 @@
+package org.apache.cloudstack.storage.datastore.protocol;
+
+public enum DataStoreProtocol {
+    NFS("nfs"),
+    ISCSI("iscsi");
+    
+    private String name;
+    DataStoreProtocol(String name) {
+        this.name = name;
+    }
+    
+    @Override
+    public String toString() {
+        return this.name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
index 4c040f4..f7c2322 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
@@ -26,7 +26,7 @@ public class ImageOnPrimayDataStoreTO {
     private final TemplateTO template;
     public ImageOnPrimayDataStoreTO(TemplateOnPrimaryDataStoreInfo template) {
         this.pathOnPrimaryDataStore = template.getPath();
-        this.dataStore = new PrimaryDataStoreTO(template.getPrimaryDataStore());
+        this.dataStore = template.getPrimaryDataStore().getDataStoreTO();
         this.template = new TemplateTO(template.getTemplate());
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/to/NfsPrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/NfsPrimaryDataStoreTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/NfsPrimaryDataStoreTO.java
new file mode 100644
index 0000000..06ff16b
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/NfsPrimaryDataStoreTO.java
@@ -0,0 +1,28 @@
+package org.apache.cloudstack.storage.to;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+
+public class NfsPrimaryDataStoreTO extends PrimaryDataStoreTO {
+    private String server;
+    private String path;
+    
+    public NfsPrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        super(dataStore);
+    }
+    
+    public void setServer(String server) {
+        this.server = server;
+    }
+    
+    public String getServer() {
+        return this.server;
+    }
+    
+    public void setPath(String path) {
+        this.path = path;
+    }
+    
+    public String getPath() {
+        return this.path;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
index 7708621..13d51ac 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
@@ -6,10 +6,16 @@ public class PrimaryDataStoreTO {
     private final String uuid;
     private final String name;
     private final String type;
+    private final long id;
     public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
         this.uuid = dataStore.getUuid();
         this.name = dataStore.getName();
         this.type = dataStore.getType();
+        this.id = dataStore.getId();
+    }
+    
+    public long getId() {
+        return this.id;
     }
     
     public String getUuid() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
index a40f6cf..23551e4 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
@@ -19,5 +19,5 @@
 package org.apache.cloudstack.storage.datastore;
 
 public enum DataStoreStatus {
-    Initial, Initialized, Creating, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
+    Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
index a3d1038..347817d 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
@@ -15,9 +15,13 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.storage.EndPoint;
 import org.apache.cloudstack.storage.HypervisorHostEndPoint;
 import org.apache.cloudstack.storage.command.CommandResult;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
 import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
 import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.volume.TemplatePrimaryDataStoreManager;
 import org.apache.cloudstack.storage.volume.VolumeObject;
@@ -36,18 +40,20 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStore.class);
     protected PrimaryDataStoreDriver driver;
     protected PrimaryDataStoreVO pdsv;
-    protected PrimaryDataStoreInfo pdsInfo;
     protected PrimaryDataStoreLifeCycle lifeCycle;
     protected PrimaryDataStoreProvider provider;
+    protected StorageProtocolTransformer protocalTransformer;
     private HypervisorType supportedHypervisor;
     private boolean isLocalStorageSupported = false;
     @Inject
     private VolumeDao volumeDao;
     @Inject
-    HostDao hostDao;
+    private HostDao hostDao;
     @Inject
-    TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
-
+    private PrimaryDataStoreDao dataStoreDao;
+    @Inject
+    private TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
+    
     private DefaultPrimaryDataStore(PrimaryDataStoreVO pdsv) {
         this.pdsv = pdsv;
     }
@@ -66,6 +72,20 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
         this.provider = provider;
     }
     
+    public void setProtocolTransFormer(StorageProtocolTransformer transformer) {
+        this.protocalTransformer = transformer;
+    }
+    
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO() {
+        return this.protocalTransformer.getDataStoreTO(this);
+    }
+    
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        return this.protocalTransformer.getVolumeTO(volume);
+    }
+    
     public static DefaultPrimaryDataStore createDataStore(PrimaryDataStoreVO pdsv) {
         DefaultPrimaryDataStore dataStore = new DefaultPrimaryDataStore(pdsv);
         return ComponentInject.inject(dataStore);
@@ -97,8 +117,13 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     public List<EndPoint> getEndPoints() {
         Long clusterId = pdsv.getClusterId();
         if (clusterId == null) {
-            return null;
+            pdsv = dataStoreDao.findById(pdsv.getId());
+            clusterId = pdsv.getClusterId();
+            if (clusterId == null) {
+                return new ArrayList<EndPoint>();
+            }
         }
+        
         List<EndPoint> endpoints = new ArrayList<EndPoint>();
         List<HostVO> hosts = hostDao.findHypervisorHostInCluster(clusterId);
         for (HostVO host : hosts) {
@@ -206,26 +231,22 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
 
     @Override
     public String getUuid() {
-        // TODO Auto-generated method stub
-        return null;
+        return this.pdsv.getUuid();
     }
 
     @Override
     public DataCenterResourceEntity.State getManagedState() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public String getName() {
-        // TODO Auto-generated method stub
-        return null;
+        return this.pdsv.getName();
     }
 
     @Override
     public String getType() {
-        // TODO Auto-generated method stub
-        return null;
+        return this.pdsv.getPoolType();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
index 1ffe9e6..db1fbde 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
@@ -12,19 +12,13 @@ import com.cloud.utils.exception.CloudRuntimeException;
 
 public abstract class AbstractPrimaryDataStoreConfigurator implements PrimaryDataStoreConfigurator {
     @Inject
-    PrimaryDataStoreDao dataStoreDao;
+    protected PrimaryDataStoreDao dataStoreDao;
     
-    protected PrimaryDataStoreLifeCycle getLifeCycle() {
-        return null;
-    }
+    protected abstract PrimaryDataStoreLifeCycle getLifeCycle();
     
-    protected PrimaryDataStoreDriver getDriver() {
-        return null;
-    }
+    protected abstract PrimaryDataStoreDriver getDriver();
     
-    protected boolean isLocalStorageSupported() {
-        return false;
-    }
+    protected abstract boolean isLocalStorageSupported();
 
     @Override
     public PrimaryDataStore getDataStore(long dataStoreId) {
@@ -34,10 +28,11 @@ public abstract class AbstractPrimaryDataStoreConfigurator implements PrimaryDat
         }
         
         DefaultPrimaryDataStore dataStore = DefaultPrimaryDataStore.createDataStore(dataStoreVO);
-        dataStore.setDriver(this.getDriver());
+        dataStore.setDriver(getDriver());
         dataStore.setLifeCycle(getLifeCycle());
         dataStore.setSupportedHypervisor(getSupportedHypervisor());
         dataStore.setLocalStorageFlag(isLocalStorageSupported());
+        dataStore.setProtocolTransFormer(getProtocolTransformer());
         return dataStore;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
index fa0b76a..e868b4e 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
@@ -19,7 +19,7 @@
 package org.apache.cloudstack.storage.datastore.configurator;
 
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.Storage.StoragePoolType;
@@ -28,5 +28,5 @@ public interface PrimaryDataStoreConfigurator {
     public HypervisorType getSupportedHypervisor();
     public String getSupportedDataStoreType();
     public PrimaryDataStore getDataStore(long dataStoreId);
-    public ProtocolValidator getValidator();
+    public StorageProtocolTransformer getProtocolTransformer();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
index 8ca4df0..b5e9db3 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
@@ -19,7 +19,7 @@
 package org.apache.cloudstack.storage.datastore.configurator.kvm;
 
 import org.apache.cloudstack.storage.datastore.configurator.validator.CLVMValidator;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
@@ -33,9 +33,15 @@ public class KvmCLVMConfigurator extends AbstractKvmConfigurator {
     }
 
     @Override
-    public ProtocolValidator getValidator() {
+    public StorageProtocolTransformer getProtocolTransformer() {
         return new CLVMValidator();
     }
 
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmNfsConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmNfsConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmNfsConfigurator.java
index faed6cc..6897e54 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmNfsConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmNfsConfigurator.java
@@ -18,22 +18,32 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.kvm;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.NfsValidator;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.NfsProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
+import com.cloud.utils.component.Inject;
+
 @Component
 @Qualifier("defaultProvider")
 public class KvmNfsConfigurator extends AbstractKvmConfigurator {
-
+    @Inject
+    PrimaryDataStoreDao dataStoreDao;
     @Override
     public String getSupportedDataStoreType() {
         return "nfs";
     }
 
     @Override
-    public ProtocolValidator getValidator() {
-        return new NfsValidator();
+    public StorageProtocolTransformer getProtocolTransformer() {
+        return new NfsProtocolTransformer(dataStoreDao);
+    }
+
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmRBDConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmRBDConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmRBDConfigurator.java
index cdbbb25..a644239 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmRBDConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmRBDConfigurator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.kvm;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.apache.cloudstack.storage.datastore.configurator.validator.RBDValidator;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
@@ -29,13 +29,18 @@ import com.cloud.storage.Storage.StoragePoolType;
 @Qualifier("defaultProvider")
 public class KvmRBDConfigurator extends AbstractKvmConfigurator {
 
-    @Override
     public String getSupportedDataStoreType() {
         return "rbd";
     }
 
     @Override
-    public ProtocolValidator getValidator() {
+    public StorageProtocolTransformer getProtocolTransformer() {
         return new RBDValidator();
     }
+
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMValidator.java
index e26394d..ea25991 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMValidator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMValidator.java
@@ -21,10 +21,15 @@ package org.apache.cloudstack.storage.datastore.configurator.validator;
 import java.util.List;
 import java.util.Map;
 
-public class CLVMValidator implements ProtocolValidator {
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class CLVMValidator implements StorageProtocolTransformer {
 
     @Override
-    public boolean validate(Map<String, String> params) {
+    public boolean normalizeUserInput(Map<String, String> params) {
         // TODO Auto-generated method stub
         return false;
     }
@@ -35,4 +40,17 @@ public class CLVMValidator implements ProtocolValidator {
         return null;
     }
 
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/FileSystemValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/FileSystemValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/FileSystemValidator.java
index 60532dc..8e1180e 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/FileSystemValidator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/FileSystemValidator.java
@@ -21,10 +21,15 @@ package org.apache.cloudstack.storage.datastore.configurator.validator;
 import java.util.List;
 import java.util.Map;
 
-public class FileSystemValidator implements ProtocolValidator {
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class FileSystemValidator implements StorageProtocolTransformer {
 
     @Override
-    public boolean validate(Map<String, String> params) {
+    public boolean normalizeUserInput(Map<String, String> params) {
         // TODO Auto-generated method stub
         return false;
     }
@@ -35,4 +40,17 @@ public class FileSystemValidator implements ProtocolValidator {
         return null;
     }
 
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIValiator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIValiator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIValiator.java
index 89ecc31..9e56058 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIValiator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIValiator.java
@@ -21,16 +21,33 @@ package org.apache.cloudstack.storage.datastore.configurator.validator;
 import java.util.List;
 import java.util.Map;
 
-public class ISCSIValiator implements ProtocolValidator {
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class ISCSIValiator implements StorageProtocolTransformer {
+
+    @Override
+    public List<String> getInputParamNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
     @Override
-    public boolean validate(Map<String, String> params) {
+    public boolean normalizeUserInput(Map<String, String> params) {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public List<String> getInputParamNames() {
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
new file mode 100644
index 0000000..f812ffb
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
@@ -0,0 +1,95 @@
+/*
+ * 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.configurator.validator;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
+import org.apache.cloudstack.storage.to.NfsPrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class NfsProtocolTransformer implements StorageProtocolTransformer {
+    private final PrimaryDataStoreDao dataStoreDao;
+    
+    public NfsProtocolTransformer(PrimaryDataStoreDao dao) {
+        this.dataStoreDao = dao;
+    }
+    
+    @Override
+    public boolean normalizeUserInput(Map<String, String> params) {
+    	String url = params.get("url");
+    	
+    	try {
+			URI uri = new URI(url);
+			if (!"nfs".equalsIgnoreCase(uri.getScheme())) {
+				throw new CloudRuntimeException("invalid protocol, must starting with nfs");
+			}
+	        String storageHost = uri.getHost();
+	        String hostPath = uri.getPath();
+	        String userInfo = uri.getUserInfo();
+	        int port = uri.getPort();
+	        if (port == -1) {
+                port = 2049;
+            }
+			params.put("server", storageHost);
+			params.put("path", hostPath);
+			params.put("user", userInfo);
+			params.put("port", String.valueOf(port));
+			params.put("uuid", UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString());
+		} catch (URISyntaxException e) {
+			throw new CloudRuntimeException("invalid url: " + e.toString());
+		}
+        return true;
+    }
+
+    @Override
+    public List<String> getInputParamNames() {
+        List<String> paramNames = new ArrayList<String>();
+        paramNames.add("server");
+        paramNames.add("path");
+        return paramNames;
+    }
+
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        NfsPrimaryDataStoreTO dataStoreTO = new NfsPrimaryDataStoreTO(dataStore);
+        PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStore.getId());
+        dataStoreTO.setServer(dataStoreVO.getHostAddress());
+        dataStoreTO.setPath(dataStoreVO.getPath());
+        return dataStoreTO;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsValidator.java
deleted file mode 100644
index 0da4174..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsValidator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore.configurator.validator;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class NfsValidator implements ProtocolValidator {
-
-    @Override
-    public boolean validate(Map<String, String> params) {
-    	String url = params.get("url");
-    	
-    	try {
-			URI uri = new URI(url);
-			if (!"nfs".equalsIgnoreCase(uri.getScheme())) {
-				throw new CloudRuntimeException("invalid protocol, must starting with nfs");
-			}
-	        String storageHost = uri.getHost();
-	        String hostPath = uri.getPath();
-	        String userInfo = uri.getUserInfo();
-	        int port = uri.getPort();
-	        if (port == -1) {
-                port = 2049;
-            }
-			params.put("server", storageHost);
-			params.put("path", hostPath);
-			params.put("user", userInfo);
-			params.put("port", String.valueOf(port));
-			params.put("uuid", UUID.fromString(storageHost + hostPath).toString());
-			
-		} catch (URISyntaxException e) {
-			throw new CloudRuntimeException("invalid url: " + e.toString());
-		}
-        return true;
-    }
-
-    @Override
-    public List<String> getInputParamNames() {
-        List<String> paramNames = new ArrayList<String>();
-        paramNames.add("server");
-        paramNames.add("path");
-        return paramNames;
-    }
-
-}

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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
index fbcf451..e18c861 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
@@ -21,10 +21,15 @@ package org.apache.cloudstack.storage.datastore.configurator.validator;
 import java.util.List;
 import java.util.Map;
 
-public class RBDValidator implements ProtocolValidator {
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class RBDValidator implements StorageProtocolTransformer {
 
     @Override
-    public boolean validate(Map<String, String> params) {
+    public boolean normalizeUserInput(Map<String, String> params) {
         // TODO Auto-generated method stub
         return false;
     }
@@ -35,4 +40,16 @@ public class RBDValidator implements ProtocolValidator {
         return null;
     }
 
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java
new file mode 100644
index 0000000..ab9a613
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.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.configurator.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public interface StorageProtocolTransformer {
+    public boolean normalizeUserInput(Map<String, String> params);
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore);
+    public VolumeTO getVolumeTO(VolumeInfo volume);
+    public List<String> getInputParamNames();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
index 439e047..a0ae1f8 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
@@ -21,10 +21,15 @@ package org.apache.cloudstack.storage.datastore.configurator.validator;
 import java.util.List;
 import java.util.Map;
 
-public class VMFSValidator implements ProtocolValidator {
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class VMFSValidator implements StorageProtocolTransformer {
 
     @Override
-    public boolean validate(Map<String, String> params) {
+    public boolean normalizeUserInput(Map<String, String> params) {
         // TODO Auto-generated method stub
         return false;
     }
@@ -35,4 +40,16 @@ public class VMFSValidator implements ProtocolValidator {
         return null;
     }
 
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
index 55c82ca..2a47e03 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
@@ -19,7 +19,7 @@
 package org.apache.cloudstack.storage.datastore.configurator.vmware;
 
 import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIValiator;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
@@ -27,14 +27,19 @@ import org.springframework.stereotype.Component;
 @Qualifier("defaultProvider")
 public class VmwareIsciConfigurator extends AbstractVmwareConfigurator {
 
-    @Override
     public String getSupportedDataStoreType() {
         return "iscsi";
     }
 
     @Override
-    public ProtocolValidator getValidator() {
+    public StorageProtocolTransformer getProtocolTransformer() {
         return new ISCSIValiator();
     }
+
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
index 23cabb1..c6afc13 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
@@ -18,24 +18,33 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.vmware;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.NfsValidator;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.NfsProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.utils.component.Inject;
 
 @Component
 @Qualifier("defaultProvider")
 public class VmwareNfsConfigurator extends AbstractVmwareConfigurator {
-
+    @Inject
+    PrimaryDataStoreDao dataStoreDao;
     @Override
     public String getSupportedDataStoreType() {
         return "nfs";
     }
 
     @Override
-    public ProtocolValidator getValidator() {
-        return new NfsValidator();
+    public StorageProtocolTransformer getProtocolTransformer() {
+        return new NfsProtocolTransformer(dataStoreDao);
+    }
+
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
index ef0444c..fc8738c 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.vmware;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.apache.cloudstack.storage.datastore.configurator.validator.VMFSValidator;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
@@ -35,7 +35,13 @@ public class VmwareVMFSConfigurator extends AbstractVmwareConfigurator {
     }
 
     @Override
-    public ProtocolValidator getValidator() {
+    public StorageProtocolTransformer getProtocolTransformer() {
         return new VMFSValidator();
     }
+
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
index 9b0d153..b8efb48 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
@@ -1,25 +1,14 @@
 package org.apache.cloudstack.storage.datastore.configurator.xen;
 
-import javax.inject.Inject;
-
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.configurator.AbstractPrimaryDataStoreConfigurator;
-import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
 import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
 import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
 import org.apache.cloudstack.storage.datastore.lifecycle.DefaultXenPrimaryDataStoreLifeCycle;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.exception.CloudRuntimeException;
 
 public abstract class AbstractXenConfigurator extends AbstractPrimaryDataStoreConfigurator {
-    @Inject
-    PrimaryDataStoreDao dataStoreDao;
-    
     @Override
     public HypervisorType getSupportedHypervisor() {
     	return HypervisorType.XenServer;
@@ -32,17 +21,4 @@ public abstract class AbstractXenConfigurator extends AbstractPrimaryDataStoreCo
 	protected PrimaryDataStoreDriver getDriver() {
 		return new DefaultPrimaryDataStoreDriverImpl();
 	}
-    
-	@Override
-    public PrimaryDataStore getDataStore(long dataStoreId) {
-        PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
-        if (dataStoreVO == null) {
-            throw new CloudRuntimeException("Can't find primary data store: " + dataStoreId);
-        }
-        
-        DefaultPrimaryDataStore dataStore = DefaultPrimaryDataStore.createDataStore(dataStoreVO);
-        dataStore.setDriver(this.getDriver());
-        dataStore.setLifeCycle(getLifeCycle());
-        return dataStore;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
index c9546a8..a447756 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
@@ -19,7 +19,7 @@
 package org.apache.cloudstack.storage.datastore.configurator.xen;
 
 import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIValiator;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
@@ -33,8 +33,13 @@ public class XenIscsiConfigurator extends AbstractXenConfigurator {
 	}
 
 	@Override
-	public ProtocolValidator getValidator() {
+	public StorageProtocolTransformer getProtocolTransformer() {
 		return new ISCSIValiator();
 	}
 
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
index 8fb7e88..6ad4b53 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
@@ -18,24 +18,32 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.xen;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.NfsValidator;
-import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.NfsProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.utils.component.Inject;
 
 @Component
 @Qualifier("defaultProvider")
 public class XenNfsConfigurator extends AbstractXenConfigurator {
-
 	@Override
 	public String getSupportedDataStoreType() {
-		return "nfs";
+		return DataStoreProtocol.NFS.toString();
 	}
 
 	@Override
-	public ProtocolValidator getValidator() {
-		return new NfsValidator();
+	public StorageProtocolTransformer getProtocolTransformer() {
+		return new NfsProtocolTransformer(dataStoreDao);
 	}
+
+    @Override
+    protected boolean isLocalStorageSupported() {
+        // TODO Auto-generated method stub
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
index 1a09266..012d006 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
@@ -47,7 +47,7 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
         // which can access its datastore
         List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
         VolumeInfo volInfo = vol;
-        CreateVolumeCommand createCmd = new CreateVolumeCommand(new VolumeTO(volInfo));
+        CreateVolumeCommand createCmd = new CreateVolumeCommand(this.dataStore.getVolumeTO(volInfo));
         Answer answer = sendOutCommand(createCmd, endPoints);
 
         CreateVolumeAnswer volAnswer = (CreateVolumeAnswer) answer;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
index 3826414..658d4db 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
@@ -52,8 +52,8 @@ public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLif
     }
 
     protected void attachCluster() {
-        //send down createStoragePool command to all the hosts in the cluster
-        AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(this.dataStore);
+        //send down AttachPrimaryDataStoreCmd command to all the hosts in the cluster
+        AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(this.dataStore.getDataStoreTO());
         for (EndPoint ep : dataStore.getEndPoints()) {
             ep.sendMessage(cmd);
         } 
@@ -61,14 +61,19 @@ public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLif
     
     @Override
     public boolean attachCluster(ClusterScope scope) {
-        attachCluster();
-        
         PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(this.dataStore.getId());
         dataStoreVO.setDataCenterId(scope.getZoneId());
         dataStoreVO.setPodId(scope.getPodId());
         dataStoreVO.setClusterId(scope.getScopeId());
+        dataStoreVO.setStatus(DataStoreStatus.Attaching);
+        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
+        
+        attachCluster();
+        
+        dataStoreVO = dataStoreDao.findById(this.dataStore.getId());
         dataStoreVO.setStatus(DataStoreStatus.Up);
         dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
+        
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d9916139/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultXenPrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultXenPrimaryDataStoreLifeCycle.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultXenPrimaryDataStoreLifeCycle.java
index d689258..bb255b0 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultXenPrimaryDataStoreLifeCycle.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultXenPrimaryDataStoreLifeCycle.java
@@ -20,6 +20,7 @@ package org.apache.cloudstack.storage.datastore.lifecycle;
 
 import org.apache.cloudstack.storage.EndPoint;
 import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
+import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 
 import com.cloud.agent.api.Answer;
@@ -39,7 +40,7 @@ public class DefaultXenPrimaryDataStoreLifeCycle extends DefaultPrimaryDataStore
     @Override
     public void attachCluster() {
         //send one time is enough, as xenserver is clustered
-        AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(this.dataStore);
+        CreatePrimaryDataStoreCmd cmd = new CreatePrimaryDataStoreCmd(this.dataStore.getDataStoreTO());
         String result = null;
         for (EndPoint ep : dataStore.getEndPoints()) {
             Answer answer = ep.sendMessage(cmd);
@@ -49,8 +50,9 @@ public class DefaultXenPrimaryDataStoreLifeCycle extends DefaultPrimaryDataStore
             result = answer.getDetails();
         }
         
-        throw new CloudRuntimeException("AttachPrimaryDataStoreCmd failed: " + result);
+        if (result != null)
+            throw new CloudRuntimeException("AttachPrimaryDataStoreCmd failed: " + result);
+        
+        super.attachCluster();
     }
-
-    
 }


Mime
View raw message