cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [2/7] git commit: add test case for create storage pool
Date Tue, 22 Jan 2013 01:02:21 GMT
add test case for create storage pool


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

Branch: refs/heads/javelin
Commit: 3251cd665bae05ba16b93b94c5f5997f9a1f9fd7
Parents: b4988e8
Author: Edison Su <sudison@gmail.com>
Authored: Fri Jan 18 19:44:07 2013 -0800
Committer: Edison Su <edison.su@citrix.com>
Committed: Mon Jan 21 16:59:51 2013 -0800

----------------------------------------------------------------------
 .../subsystem/api/storage/DataStoreLifeCycle.java  |    2 +-
 .../lifecycle/DefaultImageDataStoreLifeCycle.java  |    4 +-
 .../cloudstack/storage/test/volumeServiceTest.java |   26 +++-
 .../storage/datastore/DataStoreManagerImpl.java    |    2 +-
 .../datastore/DefaultDatastoreLifeCyle.java        |  109 ---------------
 .../DefaultPrimaryDataStoreLifeCycleImpl.java      |   14 ++-
 6 files changed, 38 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3251cd66/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
index cc13c3a..ef578a7 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
@@ -22,7 +22,7 @@ import java.util.Map;
 
 
 public interface DataStoreLifeCycle {
-    public boolean initialize(DataStore store, Map<String, String> dsInfos);
+    public DataStore initialize(Map<String, String> dsInfos);
 
     public boolean attachCluster(DataStore store, ClusterScope scope);
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3251cd66/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
index 0309aef..9189963 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
@@ -34,9 +34,9 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle
{
 
 
     @Override
-    public boolean initialize(DataStore store, Map<String, String> dsInfos) {
+    public DataStore initialize(Map<String, String> dsInfos) {
         // TODO Auto-generated method stub
-        return false;
+        return null;
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3251cd66/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 842b805..0a69247 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
@@ -21,6 +21,7 @@ package org.apache.cloudstack.storage.test;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import javax.inject.Inject;
@@ -28,10 +29,15 @@ import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
+import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
 import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
 import org.apache.cloudstack.storage.image.ImageService;
 import org.apache.cloudstack.storage.image.db.ImageDataDao;
@@ -215,9 +221,23 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 		createTemplate();
 	}
 
-	private PrimaryDataStoreInfo createPrimaryDataStore() {
+	@Test
+	public PrimaryDataStoreInfo createPrimaryDataStore() {
 		try {
+		    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary
data store provider");
+		    Map<String, String> params = new HashMap<String, String>();
+            params.put("url", this.getPrimaryStorageUrl());
+            params.put("dcId", dcId.toString());
+            params.put("clusterId", clusterId.toString());
+            params.put("name", this.primaryName);
+            params.put("roles", DataStoreRole.Primary.toString());
+            params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
+            params.put("providerId", String.valueOf(provider.getId()));
 		    
+		    DataStoreLifeCycle lifeCycle = provider.getLifeCycle();
+		    DataStore store = lifeCycle.initialize(params);
+		    ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
+		    lifeCycle.attachCluster(store, scope);
 		    /*
 		    PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("default
primary data store provider");
 		    primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String,
Object>());
@@ -255,7 +275,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 		return volume;
 	}
 
-	@Test(priority=2)
+	//@Test(priority=2)
 	public void createVolumeFromTemplate() {
 	    primaryStore = createPrimaryDataStore();
 		TemplateEntity te = createTemplate();
@@ -265,7 +285,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 		ve.destroy();
 	}
 	
-	@Test(priority=3) 
+	//@Test(priority=3) 
 	public void createDataDisk() {
 	    primaryStore = createPrimaryDataStore();
 	    VolumeVO volume = createVolume(null, primaryStore.getId());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3251cd66/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
index 6e7df92..f857ac5 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
@@ -35,6 +35,7 @@ public class DataStoreManagerImpl implements DataStoreManager {
     PrimaryDataStoreProviderManager primaryStorMgr;
     @Inject
     ImageDataStoreManager imageDataStoreMgr;
+
     @Override
     public DataStore getDataStore(long storeId, DataStoreRole role) {
         if (role == DataStoreRole.Primary) {
@@ -47,7 +48,6 @@ public class DataStoreManagerImpl implements DataStoreManager {
     @Override
     public DataStore registerDataStore(Map<String, String> params,
             String providerUuid) {
-        // TODO Auto-generated method stub
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3251cd66/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDatastoreLifeCyle.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDatastoreLifeCyle.java
b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDatastoreLifeCyle.java
deleted file mode 100644
index 910c071..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDatastoreLifeCyle.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
-import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
-import org.springframework.stereotype.Component;
-
-import edu.emory.mathcs.backport.java.util.Arrays;
-
-public class DefaultDatastoreLifeCyle implements DataStoreLifeCycle {
-    @Inject
-    PrimaryDataStoreHelper primaryStoreHelper;
-    @Inject
-    ImageDataStoreHelper imageStoreHelper;
-    @Override
-    public boolean initialize(DataStore store, Map<String, String> dsInfos) {
-        String roles = dsInfos.get("roles");
-        List<String> roleArry = Arrays.asList(roles.split(";"));
-        List<DataStoreRole> storeRoles = new ArrayList<DataStoreRole>();
-        for (String role : roleArry) {
-            storeRoles.add(DataStoreRole.getRole(role));
-        }
-
-        if (storeRoles.contains(DataStoreRole.Primary)) {
-            primaryStoreHelper.createPrimaryDataStore(dsInfos); 
-        }
-        
-        if (storeRoles.contains(DataStoreRole.Image)) {
-            imageStoreHelper.createImageDataStore(dsInfos);
-        }
-        
-        //TODO: add more roles
-       
-        return true;
-    }
-
-    @Override
-    public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
-        if (dataStore.getRole() == DataStoreRole.Primary) {
-            primaryStoreHelper.attachCluster(dataStore);
-        }
-        // TODO Auto-generated method stub
-        return true;
-    }
-    
-    @Override
-    public boolean attachZone(DataStore dataStore, ZoneScope scope) {
-        return false;
-    }
-
-    @Override
-    public boolean dettach() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean unmanaged() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean maintain() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean cancelMaintain() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean deleteDataStore() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3251cd66/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 455943a..709c51a 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
@@ -32,9 +32,12 @@ import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
 import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
 import org.apache.cloudstack.storage.datastore.DataStoreStatus;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
 import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
+import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
 
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
@@ -48,13 +51,18 @@ public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLif
     PrimaryDataStoreDao dataStoreDao;
     @Inject
     HostDao hostDao;
+    @Inject
+    PrimaryDataStoreHelper primaryStoreHelper;
+    @Inject
+    PrimaryDataStoreProviderManager providerMgr;
     public DefaultPrimaryDataStoreLifeCycleImpl() {
     }
     
     @Override
-    public boolean initialize(DataStore store, Map<String, String> dsInfos) {
-        //TODO: add extension point for each data store
-        return true;
+    public DataStore initialize(Map<String, String> dsInfos) {
+        
+        PrimaryDataStoreVO storeVO = primaryStoreHelper.createPrimaryDataStore(dsInfos);

+        return providerMgr.getPrimaryDataStore(storeVO.getId());
     }
 
     protected void attachCluster(DataStore store) {


Mime
View raw message