cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [3/3] git commit: refs/heads/master - move default primary storage plugin into its own pom
Date Thu, 21 Mar 2013 00:30:03 GMT
move default primary storage plugin into its own pom


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

Branch: refs/heads/master
Commit: 3ed6200ef8cce4c00600bf9567e52f9787a2c296
Parents: 9270b43
Author: Edison Su <sudison@gmail.com>
Authored: Wed Mar 20 17:20:17 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Mar 20 17:21:40 2013 -0700

----------------------------------------------------------------------
 .../cloud/storage/DataStoreProviderApiService.java |   28 +
 api/src/com/cloud/storage/StoragePool.java         |    2 +-
 api/src/org/apache/cloudstack/api/BaseCmd.java     |    2 +
 .../admin/storage/CreateStoragePoolCmd.java        |    8 +-
 .../admin/storage/ListStorageProvidersCmd.java     |   72 ++
 .../api/response/StorageProviderResponse.java      |   62 +
 .../api/agent/test/BackupSnapshotCommandTest.java  |    2 +-
 .../api/agent/test/SnapshotCommandTest.java        |    2 +-
 .../agent/api/test/ResizeVolumeCommandTest.java    |    2 +-
 client/pom.xml                                     |    5 +
 client/tomcatconf/commands.properties.in           |    1 +
 client/tomcatconf/componentContext.xml.in          |    3 +
 .../datacenter/entity/api/StorageEntity.java       |    1 +
 .../subsystem/api/storage/DataStoreLifeCycle.java  |    6 +-
 .../subsystem/api/storage/DataStoreProvider.java   |   13 +-
 .../api/storage/DataStoreProviderManager.java      |    6 +-
 .../api/storage/ImageDataStoreProvider.java        |   24 +
 .../api/storage/PrimaryDataStoreParameters.java    |  220 ++++
 .../api/storage/PrimaryDataStoreProvider.java      |    4 +
 .../storage/datastore/db/StoragePoolVO.java        |   12 +-
 .../image/manager/ImageDataStoreManagerImpl.java   |   14 +-
 .../image/store/AncientImageDataStoreProvider.java |   47 +-
 .../image/store/DefaultImageDataStoreImpl.java     |    2 +-
 .../image/store/DefaultImageDataStoreProvider.java |   35 +-
 .../lifecycle/DefaultImageDataStoreLifeCycle.java  |   11 +-
 .../storage/allocator/StorageAllocatorTest.java    |    4 +-
 .../cloudstack/storage/test/volumeServiceTest.java |   12 +-
 .../datastore/PrimaryDataStoreEntityImpl.java      |    8 +-
 .../datastore/PrimaryDataStoreProviderManager.java |    4 +-
 .../provider/DataStoreProviderManagerImpl.java     |  108 +-
 .../datastore/provider/ImageDataStoreProvider.java |   25 -
 .../provider/PrimaryDataStoreProvider.java         |   23 -
 .../image/datastore/ImageDataStoreHelper.java      |    4 +-
 .../storage/image/db/ImageDataStoreVO.java         |   12 +-
 .../volume/datastore/PrimaryDataStoreHelper.java   |  172 +++-
 .../storage/datastore/DefaultPrimaryDataStore.java |    8 +-
 .../driver/AncientPrimaryDataStoreDriverImpl.java  |  362 ------
 .../AncientPrimaryDataStoreLifeCycleImpl.java      |  963 ---------------
 .../DefaultPrimaryDataStoreLifeCycleImpl.java      |   18 +-
 ...DefaultPrimaryDataStoreProviderManagerImpl.java |   16 +-
 .../AncientPrimaryDataStoreProviderImpl.java       |   78 --
 .../DefaultPrimaryDatastoreProviderImpl.java       |   32 +-
 .../storage/volume/test/ConfiguratorTest.java      |    2 +-
 plugins/pom.xml                                    |    1 +
 plugins/storage/volume/default/pom.xml             |   56 +
 .../CloudStackPrimaryDataStoreDriverImpl.java      |  362 ++++++
 .../CloudStackPrimaryDataStoreLifeCycleImpl.java   |  542 ++++++++
 .../CloudStackPrimaryDataStoreProviderImpl.java    |   80 ++
 .../apache/cloudstack/storage/test/VolumeTest.java |    2 +-
 .../src/com/cloud/server/ManagementServerImpl.java |    1 +
 .../src/com/cloud/storage/StorageManagerImpl.java  |   68 +-
 .../com/cloud/storage/StoragePoolAutomation.java   |   26 +
 .../cloud/storage/StoragePoolAutomationImpl.java   |  456 +++++++
 setup/db/db/schema-410to420.sql                    |    6 +-
 tools/apidoc/gen_toc.py                            |    1 +
 55 files changed, 2349 insertions(+), 1687 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/src/com/cloud/storage/StoragePool.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StoragePool.java b/api/src/com/cloud/storage/StoragePool.java
index 091eef1..8b95383 100644
--- a/api/src/com/cloud/storage/StoragePool.java
+++ b/api/src/com/cloud/storage/StoragePool.java
@@ -99,7 +99,7 @@ public interface StoragePool extends Identity, InternalIdentity {
 	/**
 	 * @return
 	 */
-	Long getStorageProviderId();
+	String getStorageProviderName();
 	
 	boolean isInMaintenance();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 816b6de..8b7f43f 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -61,6 +61,7 @@ import com.cloud.projects.ProjectService;
 import com.cloud.resource.ResourceService;
 import com.cloud.server.ManagementService;
 import com.cloud.server.TaggedResourceService;
+import com.cloud.storage.DataStoreProviderApiService;
 import com.cloud.storage.StorageService;
 import com.cloud.storage.VolumeApiService;
 import com.cloud.storage.snapshot.SnapshotService;
@@ -131,6 +132,7 @@ public abstract class BaseCmd {
     @Inject public UsageService _usageService;
     @Inject public NetworkUsageService _networkUsageService;
     @Inject public VMSnapshotService _vmSnapshotService;
+    @Inject public DataStoreProviderApiService dataStoreProviderApiService;
 
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
index b86784e..5178d68 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
@@ -73,8 +73,8 @@ public class CreateStoragePoolCmd extends BaseCmd {
     private Long zoneId;
     
     @Parameter(name=ApiConstants.PROVIDER, type=CommandType.STRING,
-            required=false, description="the storage provider uuid")
-    private String storageProviderUuid;
+            required=false, description="the storage provider name")
+    private String storageProviderName;
     
     @Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING,
             required=false, description="the scope of the storage: cluster or zone")
@@ -112,8 +112,8 @@ public class CreateStoragePoolCmd extends BaseCmd {
         return zoneId;
     }
     
-    public String getStorageProviderUuid() {
-        return this.storageProviderUuid;
+    public String getStorageProviderName() {
+        return this.storageProviderName;
     }
     
     public String getScope() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java
new file mode 100644
index 0000000..0dfc663
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java
@@ -0,0 +1,72 @@
+/*
+ * 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.api.command.admin.storage;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.StorageProviderResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+
+@APICommand(name = "listStorageProviders", description="Lists storage providers.", responseObject=StorageProviderResponse.class)
+public class ListStorageProvidersCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListStorageProvidersCmd.class.getName());
+    private static final String s_name = "liststorageprovidersresponse";
+    
+    @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the type of storage provider: either primary or image", required = true)
+    private String type;
+    
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+    
+    public String getType() {
+        return this.type;
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException,
+            NetworkRuleConflictException {
+        if (getType() == null) {
+            throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "need to specify type: either primary or image");
+        }
+       
+        List<StorageProviderResponse> providers = this.dataStoreProviderApiService.getDataStoreProviders(getType());
+        ListResponse<StorageProviderResponse> responses = new ListResponse<StorageProviderResponse>();
+        for (StorageProviderResponse provider : providers) {
+            provider.setObjectName("dataStoreProvider");
+        }
+        responses.setResponses(providers);
+        responses.setResponseName(this.getCommandName());
+        this.setResponseObject(responses);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/src/org/apache/cloudstack/api/response/StorageProviderResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/StorageProviderResponse.java b/api/src/org/apache/cloudstack/api/response/StorageProviderResponse.java
new file mode 100644
index 0000000..4baf486
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/StorageProviderResponse.java
@@ -0,0 +1,62 @@
+/*
+ * 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.api.response;
+
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+public class StorageProviderResponse extends BaseResponse {
+    @SerializedName("name") @Param(description="the name of the storage provider")
+    private String name;
+    
+    @SerializedName("type") @Param(description="the type of the storage provider: primary or image provider")
+    private String type;
+    
+    /**
+     * @return the type
+     */
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * @param type the type to set
+     */
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java b/api/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
index 06697c4..44d53aa 100644
--- a/api/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
+++ b/api/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
@@ -133,7 +133,7 @@ public class BackupSnapshotCommandTest {
         }
 
         @Override
-        public Long getStorageProviderId() {
+        public String getStorageProviderName() {
             // TODO Auto-generated method stub
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java b/api/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
index 767d7c3..c2d69c0 100644
--- a/api/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
+++ b/api/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java
@@ -115,7 +115,7 @@ public class SnapshotCommandTest {
         }
 
 		@Override
-		public Long getStorageProviderId() {
+		public String getStorageProviderName() {
 			// TODO Auto-generated method stub
 			return null;
 		}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/api/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java b/api/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
index 852e52b..02085f5 100644
--- a/api/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
+++ b/api/test/src/com/cloud/agent/api/test/ResizeVolumeCommandTest.java
@@ -134,7 +134,7 @@ public class ResizeVolumeCommandTest {
         }
 
         @Override
-        public Long getStorageProviderId() {
+        public String getStorageProviderName() {
             // TODO Auto-generated method stub
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 302fe6b..7ad2eff 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -224,6 +224,11 @@
       <artifactId>cloud-plugin-hypervisor-simulator</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+        <groupId>org.apache.cloudstack</groupId>
+        <artifactId>cloud-plugin-storage-volume-default</artifactId>
+        <version>${project.version}</version>
+    </dependency>
   </dependencies>
   <build>
     <defaultGoal>install</defaultGoal>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 382573b..492f7f9 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -278,6 +278,7 @@ listAsyncJobs=15
 
 #### storage pools commands
 listStoragePools=3
+listStorageProviders=3
 createStoragePool=1
 updateStoragePool=1
 deleteStoragePool=1

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index 2535c77..a98a41f 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -329,5 +329,8 @@
   <bean id="BaremetalGuru" class="com.cloud.baremetal.manager.BareMetalGuru">
     <property name="name" value="BaremetalGuru"/>
   </bean>
+
+  <bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl">
+  </bean>
   
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/StorageEntity.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/StorageEntity.java b/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/StorageEntity.java
index 2c7f443..872931b 100755
--- a/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/StorageEntity.java
+++ b/engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/StorageEntity.java
@@ -21,4 +21,5 @@ package org.apache.cloudstack.engine.datacenter.entity.api;
 import com.cloud.storage.StoragePool;
 
 public interface StorageEntity extends DataCenterResourceEntity, StoragePool {
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/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 95e3d0b..280e02e 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
@@ -34,9 +34,9 @@ public interface DataStoreLifeCycle {
 
     public boolean unmanaged();
 
-    public boolean maintain(long storeId);
+    public boolean maintain(DataStore store);
 
-    public boolean cancelMaintain(long storeId);
+    public boolean cancelMaintain(DataStore store);
 
-    public boolean deleteDataStore(long storeId);
+    public boolean deleteDataStore(DataStore store);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
index d29c482..115a52f 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProvider.java
@@ -19,12 +19,19 @@
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
 import java.util.Map;
+import java.util.Set;
 
 
 public interface DataStoreProvider {
-    public DataStoreLifeCycle getLifeCycle();
+    public static enum DataStoreProviderType {
+        PRIMARY,
+        IMAGE
+    }
+    public DataStoreLifeCycle getDataStoreLifeCycle();
+    public DataStoreDriver getDataStoreDriver();
+    public HypervisorHostListener getHostListener();
     public String getName();
-    public String getUuid();
-    public long getId();
     public boolean configure(Map<String, Object> params);
+    public Set<DataStoreProviderType> getTypes();
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
index 9499813..906720a 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
@@ -20,12 +20,12 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 
 import java.util.List;
 
+import com.cloud.storage.DataStoreProviderApiService;
 import com.cloud.utils.component.Manager;
 
-public interface DataStoreProviderManager extends Manager {
-    public DataStoreProvider getDataStoreProviderByUuid(String uuid);
-    public DataStoreProvider getDataStoreProviderById(long id);
+public interface DataStoreProviderManager extends Manager, DataStoreProviderApiService {
     public DataStoreProvider getDataStoreProvider(String name);
     public DataStoreProvider getDefaultPrimaryDataStoreProvider();
     public List<DataStoreProvider> getDataStoreProviders();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageDataStoreProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageDataStoreProvider.java
new file mode 100644
index 0000000..1fb987e
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ImageDataStoreProvider.java
@@ -0,0 +1,24 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+
+public interface ImageDataStoreProvider extends DataStoreProvider {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreParameters.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreParameters.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreParameters.java
new file mode 100644
index 0000000..b2b787c
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreParameters.java
@@ -0,0 +1,220 @@
+/*
+ * 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.engine.subsystem.api.storage;
+
+import java.util.Map;
+
+import com.cloud.storage.Storage.StoragePoolType;
+
+public class PrimaryDataStoreParameters {
+    private Long zoneId;
+    private Long podId;
+    private Long clusterId;
+    private String providerName;
+    private Map<String, String> details;
+    private String tags;
+    private StoragePoolType type;
+    private String host;
+    private String path;
+    private int port;
+    private String uuid;
+    private String name;
+    private String userInfo;
+    /**
+     * @return the userInfo
+     */
+    public String getUserInfo() {
+        return userInfo;
+    }
+
+    /**
+     * @param userInfo the userInfo to set
+     */
+    public void setUserInfo(String userInfo) {
+        this.userInfo = userInfo;
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @return the uuid
+     */
+    public String getUuid() {
+        return uuid;
+    }
+
+    /**
+     * @param uuid the uuid to set
+     */
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    /**
+     * @return the port
+     */
+    public int getPort() {
+        return port;
+    }
+
+    /**
+     * @param port the port to set
+     */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    /**
+     * @return the path
+     */
+    public String getPath() {
+        return path;
+    }
+
+    /**
+     * @param path the path to set
+     */
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    /**
+     * @return the host
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * @param host the host to set
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * @return the type
+     */
+    public StoragePoolType getType() {
+        return type;
+    }
+
+    /**
+     * @param type the type to set
+     */
+    public void setType(StoragePoolType type) {
+        this.type = type;
+    }
+
+    /**
+     * @return the tags
+     */
+    public String getTags() {
+        return tags;
+    }
+
+    /**
+     * @param tags the tags to set
+     */
+    public void setTags(String tags) {
+        this.tags = tags;
+    }
+
+    /**
+     * @return the details
+     */
+    public Map<String, String> getDetails() {
+        return details;
+    }
+
+    /**
+     * @param details the details to set
+     */
+    public void setDetails(Map<String, String> details) {
+        this.details = details;
+    }
+
+    /**
+     * @return the providerName
+     */
+    public String getProviderName() {
+        return providerName;
+    }
+
+    /**
+     * @param providerName the providerName to set
+     */
+    public void setProviderName(String providerName) {
+        this.providerName = providerName;
+    }
+
+    /**
+     * @return the clusterId
+     */
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    /**
+     * @param clusterId the clusterId to set
+     */
+    public void setClusterId(Long clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    /**
+     * @return the podId
+     */
+    public Long getPodId() {
+        return podId;
+    }
+
+    /**
+     * @param podId the podId to set
+     */
+    public void setPodId(Long podId) {
+        this.podId = podId;
+    }
+
+    /**
+     * @return the zoneId
+     */
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    /**
+     * @param zoneId the zoneId to set
+     */
+    public void setZoneId(Long zoneId) {
+        this.zoneId = zoneId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
index b248758..b349ac9 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
@@ -14,3 +14,7 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
+package org.apache.cloudstack.engine.subsystem.api.storage;
+
+public interface PrimaryDataStoreProvider extends DataStoreProvider {
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
index 579eaef..55b2314 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
@@ -80,8 +80,8 @@ public class StoragePoolVO implements StoragePool{
     @Enumerated(value = EnumType.STRING)
     private StoragePoolStatus status;
 
-    @Column(name = "storage_provider_id", updatable = true, nullable = false)
-    private Long storageProviderId;
+    @Column(name = "storage_provider_name", updatable = true, nullable = false)
+    private String storageProviderName;
 
     @Column(name = "host_address")
     private String hostAddress;
@@ -180,12 +180,12 @@ public class StoragePoolVO implements StoragePool{
         return availableBytes;
     }
 
-    public Long getStorageProviderId() {
-        return storageProviderId;
+    public String getStorageProviderName() {
+        return storageProviderName;
     }
 
-    public void setStorageProviderId(Long provider) {
-        storageProviderId = provider;
+    public void setStorageProviderName(String providerName) {
+        storageProviderName = providerName;
     }
 
     public long getCapacityBytes() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
index 2771f78..bc546f8 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
@@ -28,7 +28,7 @@ import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
-import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
 import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
@@ -57,21 +57,21 @@ public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
     @Override
     public ImageDataStore getImageDataStore(long dataStoreId) {
         ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
-        long providerId = dataStore.getProvider();
-        ImageDataStoreProvider provider = (ImageDataStoreProvider)providerManager.getDataStoreProviderById(providerId);
+        String providerName = dataStore.getProviderName();
+        ImageDataStoreProvider provider = (ImageDataStoreProvider)providerManager.getDataStoreProvider(providerName);
         ImageDataStore imgStore = DefaultImageDataStoreImpl.getDataStore(dataStore, 
-                driverMaps.get(provider.getUuid()), provider
+                driverMaps.get(provider.getName()), provider
                 );
         // TODO Auto-generated method stub
         return imgStore;
     }
 
     @Override
-    public boolean registerDriver(String uuid, ImageDataStoreDriver driver) {
-        if (driverMaps.containsKey(uuid)) {
+    public boolean registerDriver(String providerName, ImageDataStoreDriver driver) {
+        if (driverMaps.containsKey(providerName)) {
             return false;
         }
-        driverMaps.put(uuid, driver);
+        driverMaps.put(providerName, driver);
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java
index b2ee9ab..2715dc7 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java
@@ -19,14 +19,18 @@
 package org.apache.cloudstack.storage.image.store;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
-import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
 import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
@@ -47,10 +51,9 @@ public class AncientImageDataStoreProvider implements ImageDataStoreProvider {
     ImageDataStoreManager storeMgr;
     @Inject
     ImageDataStoreHelper helper;
-    long id;
-    String uuid;
+
     @Override
-    public DataStoreLifeCycle getLifeCycle() {
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
         return lifeCycle;
     }
 
@@ -60,22 +63,11 @@ public class AncientImageDataStoreProvider implements ImageDataStoreProvider {
     }
 
     @Override
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    @Override
-    public long getId() {
-        return this.id;
-    }
-
-    @Override
     public boolean configure(Map<String, Object> params) {
         lifeCycle = ComponentContext.inject(DefaultImageDataStoreLifeCycle.class);
         driver = ComponentContext.inject(AncientImageDataStoreDriverImpl.class);
-        uuid = (String)params.get("uuid");
-        id = (Long)params.get("id");
-        storeMgr.registerDriver(uuid, driver);
+
+        storeMgr.registerDriver(this.getName(), driver);
         
         Map<String, Object> infos = new HashMap<String, Object>();
         String dataStoreName = UUID.nameUUIDFromBytes(this.name.getBytes()).toString();
@@ -83,10 +75,27 @@ public class AncientImageDataStoreProvider implements ImageDataStoreProvider {
         infos.put("uuid", dataStoreName);
         infos.put("protocol", "http");
         infos.put("scope", ScopeType.GLOBAL);
-        infos.put("provider", this.getId());
-        DataStoreLifeCycle lifeCycle = this.getLifeCycle();
+        infos.put("providerName", this.getName());
+        DataStoreLifeCycle lifeCycle = this.getDataStoreLifeCycle();
         lifeCycle.initialize(infos);
         return true;
     }
 
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
index a6e961a..6eefc6f 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
@@ -25,13 +25,13 @@ import javax.inject.Inject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
-import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
 import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
 import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
index efbb999..0b5de85 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
@@ -18,12 +18,16 @@
  */
 package org.apache.cloudstack.storage.image.store;
 
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
 import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
 import org.apache.cloudstack.storage.image.driver.DefaultImageDataStoreDriverImpl;
@@ -41,7 +45,7 @@ public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
     long id;
     String uuid;
     @Override
-    public DataStoreLifeCycle getLifeCycle() {
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
         return lifeCycle;
     }
 
@@ -51,23 +55,28 @@ public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
     }
 
     @Override
-    public String getUuid() {
-        return this.uuid;
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(DefaultImageDataStoreLifeCycle.class);
+        driver = ComponentContext.inject(DefaultImageDataStoreDriverImpl.class);
+
+        storeMgr.registerDriver(this.getName(), driver);
+        return true;
     }
 
     @Override
-    public long getId() {
-        return this.id;
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
     }
 
     @Override
-    public boolean configure(Map<String, Object> params) {
-        lifeCycle = ComponentContext.inject(DefaultImageDataStoreLifeCycle.class);
-        driver = ComponentContext.inject(DefaultImageDataStoreDriverImpl.class);
-        uuid = (String)params.get("uuid");
-        id = (Long)params.get("id");
-        storeMgr.registerDriver(uuid, driver);
-        return true;
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
     }
 
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/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 17aabca..ba29c1a 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
@@ -86,27 +86,22 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
 
 
     @Override
-    public boolean maintain(long storeId) {
+    public boolean maintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
 
     @Override
-    public boolean cancelMaintain(long storeId) {
+    public boolean cancelMaintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
 
     @Override
-    public boolean deleteDataStore(long storeId) {
+    public boolean deleteDataStore(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
-
-
-  
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
index 414e231..9444fa5 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
@@ -133,7 +133,7 @@ public class StorageAllocatorTest {
 		storage.setCapacityBytes(20000);
 		storage.setHostAddress(UUID.randomUUID().toString());
 		storage.setPath(UUID.randomUUID().toString());
-		storage.setStorageProviderId(provider.getId());
+		storage.setStorageProviderName(provider.getName());
 		storage = storagePoolDao.persist(storage);
 		storagePoolId = storage.getId();
 
@@ -176,7 +176,7 @@ public class StorageAllocatorTest {
 			storage.setCapacityBytes(20000);
 			storage.setHostAddress(UUID.randomUUID().toString());
 			storage.setPath(UUID.randomUUID().toString());
-			storage.setStorageProviderId(provider.getId());
+			storage.setStorageProviderName(provider.getName());
 			StoragePoolVO newStorage = storagePoolDao.persist(storage);
 			newStorageId = newStorage.getId();
 			

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/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 d8d187c..35a1790 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
@@ -281,9 +281,9 @@ public class volumeServiceTest extends CloudStackTestNGBase {
         params.put("port", "1");
         params.put("roles", DataStoreRole.Primary.toString());
         params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
-        params.put("providerId", String.valueOf(provider.getId()));
+        params.put("providerName", String.valueOf(provider.getName()));
         
-        DataStoreLifeCycle lifeCycle = provider.getLifeCycle();
+        DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
         this.primaryStore  = lifeCycle.initialize(params);
         ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
         lifeCycle.attachCluster(this.primaryStore, scope);
@@ -297,8 +297,8 @@ public class volumeServiceTest extends CloudStackTestNGBase {
         params.put("uuid", name);
         params.put("protocol", "http");
         params.put("scope", ScopeType.GLOBAL.toString());
-        params.put("provider", Long.toString(provider.getId()));
-        DataStoreLifeCycle lifeCycle = provider.getLifeCycle();
+        params.put("providerName", name);
+        DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
         DataStore store = lifeCycle.initialize(params);
         return store;
 	}
@@ -323,9 +323,9 @@ public class volumeServiceTest extends CloudStackTestNGBase {
             params.put("port", "1");
             params.put("roles", DataStoreRole.Primary.toString());
             params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
-            params.put("providerId", String.valueOf(provider.getId()));
+            params.put("providerName", String.valueOf(provider.getName()));
 		    
-		    DataStoreLifeCycle lifeCycle = provider.getLifeCycle();
+		    DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
 		    DataStore store = lifeCycle.initialize(params);
 		    ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
 		    lifeCycle.attachCluster(store, scope);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
index e70f803..2dc3e25 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreEntityImpl.java
@@ -243,15 +243,15 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
 	}
 
     @Override
-    public Long getStorageProviderId() {
+    public boolean isInMaintenance() {
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override
-    public boolean isInMaintenance() {
+    public String getStorageProviderName() {
         // TODO Auto-generated method stub
-        return false;
+        return null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
index d1c26e1..b3ed0aa 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreProviderManager.java
@@ -26,6 +26,6 @@ public interface PrimaryDataStoreProviderManager {
     public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
     public PrimaryDataStore getPrimaryDataStore(String uuid);
 
-    boolean registerDriver(String uuid, PrimaryDataStoreDriver driver);
-    boolean registerHostListener(String uuid, HypervisorHostListener listener);
+    boolean registerDriver(String providerName, PrimaryDataStoreDriver driver);
+    boolean registerHostListener(String providerName, HypervisorHostListener listener);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
index 96d2da3..91b6c63 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
@@ -18,21 +18,28 @@
  */
 package org.apache.cloudstack.storage.datastore.provider;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
+import java.util.Set;
 
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.response.StorageProviderResponse;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider.DataStoreProviderType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.DataStoreProviderDao;
-import org.apache.cloudstack.storage.datastore.db.DataStoreProviderVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.utils.component.ManagerBase;
 
 @Component
@@ -44,15 +51,11 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
     @Inject
     DataStoreProviderDao providerDao;
     protected Map<String, DataStoreProvider> providerMap = new HashMap<String, DataStoreProvider>();
-    @Override
-    public DataStoreProvider getDataStoreProviderByUuid(String uuid) {
-        return providerMap.get(uuid);
-    }
-
+    @Inject
+    PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
     @Override
     public DataStoreProvider getDataStoreProvider(String name) {
-        DataStoreProviderVO dspv = providerDao.findByName(name);
-        return providerMap.get(dspv.getUuid());
+        return providerMap.get(name);
     }
 
     @Override
@@ -60,45 +63,64 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
         // TODO Auto-generated method stub
         return null;
     }
+    
+    public List<StorageProviderResponse> getPrimayrDataStoreProviders() {
+        List<StorageProviderResponse> providers = new ArrayList<StorageProviderResponse>();
+        for (DataStoreProvider provider : providerMap.values()) {
+            if (provider instanceof PrimaryDataStoreProvider) {
+                StorageProviderResponse response = new StorageProviderResponse();
+                response.setName(provider.getName());
+                response.setType(DataStoreProvider.DataStoreProviderType.PRIMARY.toString());
+                providers.add(response);
+            }
+        }
+        return providers;
+    }
+    
+    public List<StorageProviderResponse> getImageDataStoreProviders() {
+        List<StorageProviderResponse> providers = new ArrayList<StorageProviderResponse>();
+        for (DataStoreProvider provider : providerMap.values()) {
+            if (provider instanceof ImageDataStoreProvider) {
+                StorageProviderResponse response = new StorageProviderResponse();
+                response.setName(provider.getName());
+                response.setType(DataStoreProvider.DataStoreProviderType.IMAGE.toString());
+                providers.add(response);
+            }
+        }
+        return providers;
+    }
 
     @Override
     public boolean configure(String name, Map<String, Object> params)
     		throws ConfigurationException {
         Map<String, Object> copyParams = new HashMap<String, Object>(params);
 
-    	//TODO: hold global lock
-        List<DataStoreProviderVO> providerVos = providerDao.listAll();
         for (DataStoreProvider provider : providers) {
-            boolean existingProvider = false;
-            DataStoreProviderVO providerVO = null;
-            for (DataStoreProviderVO prov : providerVos) {
-                if (prov.getName().equalsIgnoreCase(provider.getName())) {
-                    existingProvider = true;
-                    providerVO = prov;
-                    break;
-                }
-            }
-            String uuid = null;
-            if (!existingProvider) {
-                uuid = UUID.nameUUIDFromBytes(provider.getName().getBytes()).toString();
-                providerVO = new DataStoreProviderVO();
-                providerVO.setName(provider.getName());
-                providerVO.setUuid(uuid);
-                providerVO = providerDao.persist(providerVO);
-            } else {
-                uuid = providerVO.getUuid();
+            String providerName = provider.getName();
+            if (providerMap.get(providerName) != null) {
+                s_logger.debug("Failed to register data store provider, provider name: " + providerName + " is not unique");
+                return false;
             }
-            copyParams.put("uuid", uuid);
-            copyParams.put("id", providerVO.getId());
-            providerMap.put(uuid, provider);
+            
+            s_logger.debug("registering data store provider:" + provider.getName());
+            
+            providerMap.put(providerName, provider);
             try {
                 boolean registrationResult = provider.configure(copyParams);
                 if (!registrationResult) {
-                    providerMap.remove(uuid);
+                    providerMap.remove(providerName);
+                    s_logger.debug("Failed to register data store provider: " + providerName);
+                    return false;
+                }
+                
+                Set<DataStoreProviderType> types = provider.getTypes();
+                if (types.contains(DataStoreProviderType.PRIMARY)) {
+                    primaryDataStoreProviderMgr.registerDriver(provider.getName(), (PrimaryDataStoreDriver)provider.getDataStoreDriver());
+                    primaryDataStoreProviderMgr.registerHostListener(provider.getName(), provider.getHostListener());
                 }
             } catch(Exception e) {
                 s_logger.debug("configure provider failed", e);
-                providerMap.remove(uuid);
+                providerMap.remove(providerName);
             }
         }
   
@@ -106,13 +128,21 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
     }
 
     @Override
-    public DataStoreProvider getDataStoreProviderById(long id) {
-        DataStoreProviderVO provider = providerDao.findById(id);
-        return providerMap.get(provider.getUuid());
+    public DataStoreProvider getDefaultPrimaryDataStoreProvider() {
+        return this.getDataStoreProvider("ancient primary data store provider");
     }
 
     @Override
-    public DataStoreProvider getDefaultPrimaryDataStoreProvider() {
-        return this.getDataStoreProvider("ancient primary data store provider");
+    public List<StorageProviderResponse> getDataStoreProviders(String type) {
+        if (type == null) {
+            throw new InvalidParameterValueException("Invalid parameter, need to specify type: either primary or image");
+        }
+        if (type.equalsIgnoreCase(DataStoreProvider.DataStoreProviderType.PRIMARY.toString())) {
+            return this.getPrimayrDataStoreProviders();
+        } else if (type.equalsIgnoreCase(DataStoreProvider.DataStoreProviderType.IMAGE.toString())) {
+            return this.getImageDataStoreProviders();
+        } else {
+            throw new InvalidParameterValueException("Invalid parameter: " + type);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
deleted file mode 100644
index d44a40e..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/ImageDataStoreProvider.java
+++ /dev/null
@@ -1,25 +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.provider;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
-
-public interface ImageDataStoreProvider extends DataStoreProvider {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
deleted file mode 100644
index fdf5958..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
+++ /dev/null
@@ -1,23 +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.provider;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
-
-
-public interface PrimaryDataStoreProvider extends DataStoreProvider {
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
index ba267af..3f1632c 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
@@ -34,14 +34,14 @@ public class ImageDataStoreHelper {
     @Inject
     ImageDataStoreDao imageStoreDao;
     public ImageDataStoreVO createImageDataStore(Map<String, Object> params) {
-        ImageDataStoreVO store = imageStoreDao.findByUuid((String)params.get("uuid"));
+        ImageDataStoreVO store = imageStoreDao.findByName((String)params.get("name"));
         if (store != null) {
             return store;
         }
         store = new ImageDataStoreVO();
         store.setName((String)params.get("name"));
         store.setProtocol((String)params.get("protocol"));
-        store.setProvider((Long)params.get("provider"));
+        store.setProviderName((String)params.get("providerName"));
         store.setScope((ScopeType)params.get("scope"));
         store.setUuid((String)params.get("uuid"));
         store = imageStoreDao.persist(store);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
index c7b8e2d..4cb402a 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
@@ -45,8 +45,8 @@ public class ImageDataStoreVO {
     @Column(name = "protocol", nullable = false)
     private String protocol;
 
-    @Column(name = "image_provider_id", nullable = false)
-    private long provider;
+    @Column(name = "image_provider_name", nullable = false)
+    private String providerName;
     
     @Column(name = "data_center_id")
     private long dcId;
@@ -64,16 +64,16 @@ public class ImageDataStoreVO {
         return this.name;
     }
 
-    public long getProvider() {
-        return this.provider;
+    public String getProviderName() {
+        return this.providerName;
     }
 
     public void setName(String name) {
         this.name = name;
     }
 
-    public void setProvider(long provider) {
-        this.provider = provider;
+    public void setProviderName(String provider) {
+        this.providerName = provider;
     }
     
     public void setProtocol(String protocol) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
index c6ca90d..5f8daf4 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
@@ -18,57 +18,181 @@
  */
 package org.apache.cloudstack.storage.volume.datastore;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreParameters;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
 import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
-import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.DeleteStoragePoolCommand;
+import com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.alert.AlertManager;
+import com.cloud.capacity.Capacity;
+import com.cloud.capacity.CapacityVO;
+import com.cloud.capacity.dao.CapacityDao;
+import com.cloud.storage.StorageManager;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolHostVO;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.storage.dao.StoragePoolHostDao;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @Component
 public class PrimaryDataStoreHelper {
+    private static final Logger s_logger = Logger
+            .getLogger(PrimaryDataStoreHelper.class);
     @Inject
     private PrimaryDataStoreDao dataStoreDao;
-    public StoragePoolVO createPrimaryDataStore(Map<String, Object> params) {
-        StoragePoolVO dataStoreVO = dataStoreDao.findPoolByUUID((String)params.get("uuid"));
+    @Inject
+    DataStoreManager dataStoreMgr;
+    @Inject
+    StorageManager storageMgr;
+    @Inject
+    protected CapacityDao _capacityDao;
+    @Inject
+    protected StoragePoolHostDao storagePoolHostDao;
+    public DataStore createPrimaryDataStore(PrimaryDataStoreParameters params) {
+        StoragePoolVO dataStoreVO = dataStoreDao.findPoolByUUID(params.getUuid());
         if (dataStoreVO != null) {
-            throw new CloudRuntimeException("duplicate uuid: " + params.get("uuid"));
+            throw new CloudRuntimeException("duplicate uuid: " + params.getUuid());
         }
         
         dataStoreVO = new StoragePoolVO();
-        dataStoreVO.setStorageProviderId(Long.parseLong((String)params.get("providerId")));
-        dataStoreVO.setHostAddress((String)params.get("server"));
-        dataStoreVO.setPath((String)params.get("path"));
-        dataStoreVO.setPoolType((StoragePoolType)params.get("protocol"));
-        dataStoreVO.setPort(Integer.parseInt((String)params.get("port")));
-        dataStoreVO.setName((String)params.get("name"));
-        dataStoreVO.setUuid((String)params.get("uuid"));
-        dataStoreVO = dataStoreDao.persist(dataStoreVO);
-        return dataStoreVO;
+        dataStoreVO.setStorageProviderName(params.getProviderName());
+        dataStoreVO.setHostAddress(params.getHost());
+        dataStoreVO.setPath(params.getPath());
+        dataStoreVO.setPoolType(params.getType());
+        dataStoreVO.setPort(params.getPort());
+        dataStoreVO.setName(params.getName());
+        dataStoreVO.setUuid(params.getUuid());
+        dataStoreVO.setDataCenterId(params.getZoneId());
+        dataStoreVO.setPodId(params.getPodId());
+        dataStoreVO.setClusterId(params.getClusterId());
+        dataStoreVO.setStatus(StoragePoolStatus.Initialized);
+        dataStoreVO.setUserInfo(params.getUserInfo());
+        
+        Map<String, String> details = params.getDetails();
+        String tags = params.getTags();
+        if (tags != null) {
+            String[] tokens = tags.split(",");
+
+            for (String tag : tokens) {
+                tag = tag.trim();
+                if (tag.length() == 0) {
+                    continue;
+                }
+                details.put(tag, "true");
+            }
+        }
+        
+        dataStoreVO = dataStoreDao.persist(dataStoreVO, details);
+
+        return dataStoreMgr.getDataStore(dataStoreVO.getId(), DataStoreRole.Primary);
     }
     
-    public boolean deletePrimaryDataStore(long id) {
-        StoragePoolVO dataStoreVO = dataStoreDao.findById(id);
-        if (dataStoreVO == null) {
-            throw new CloudRuntimeException("can't find store: " + id);
+    public DataStore attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
+        StoragePoolHostVO poolHost = storagePoolHostDao.findByPoolHost(store.getId(), scope.getScopeId());
+        if (poolHost == null) {
+            poolHost = new StoragePoolHostVO(store.getId(), scope.getScopeId(), existingInfo.getLocalPath());
+            storagePoolHostDao.persist(poolHost);
         }
-        dataStoreDao.remove(id);
+       
+        StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
+        pool.setScope(scope.getScopeType());
+        pool.setAvailableBytes(existingInfo.getAvailableBytes());
+        pool.setCapacityBytes(existingInfo.getCapacityBytes());
+        pool.setStatus(StoragePoolStatus.Up);
+        this.dataStoreDao.update(pool.getId(), pool);
+        this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, pool.getCapacityBytes() - pool.getAvailableBytes());
+        return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
+    }
+    
+    public DataStore attachCluster(DataStore store) {
+        StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
+        
+        storageMgr.createCapacityEntry(pool.getId());
+        
+        pool.setScope(ScopeType.CLUSTER);
+        pool.setStatus(StoragePoolStatus.Up);
+        this.dataStoreDao.update(pool.getId(), pool);
+        return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
+    }
+    
+    public DataStore attachZone(DataStore store) {
+        StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
+        pool.setScope(ScopeType.ZONE);
+        pool.setStatus(StoragePoolStatus.Up);
+        this.dataStoreDao.update(pool.getId(), pool);
+        return dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
+    }
+    
+    public boolean maintain(DataStore store) {
+        StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
+        pool.setStatus(StoragePoolStatus.Maintenance);
+        this.dataStoreDao.update(pool.getId(), pool);
         return true;
     }
     
-    public void attachCluster(DataStore dataStore) {
-        //send down AttachPrimaryDataStoreCmd command to all the hosts in the cluster
-        AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(dataStore.getUri());
-        /*for (EndPoint ep : dataStore.getEndPoints()) {
-            ep.sendMessage(cmd);
-        } */
+    public boolean cancelMaintain(DataStore store) {
+        StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
+        pool.setStatus(StoragePoolStatus.Up);
+        dataStoreDao.update(store.getId(), pool);
+        return true;
     }
     
+
+    protected boolean deletePoolStats(Long poolId) {
+        CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId,
+                CapacityVO.CAPACITY_TYPE_STORAGE);
+        CapacityVO capacity2 = _capacityDao.findByHostIdType(poolId,
+                CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED);
+        if (capacity1 != null) {
+            _capacityDao.remove(capacity1.getId());
+        }
+
+        if (capacity2 != null) {
+            _capacityDao.remove(capacity2.getId());
+        }
+       
+        return true;
+    }
     
+    public boolean deletePrimaryDataStore(DataStore store) {
+        List<StoragePoolHostVO> hostPoolRecords = this.storagePoolHostDao
+                .listByPoolId(store.getId());
+        StoragePoolVO poolVO = this.dataStoreDao.findById(store.getId());
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        for (StoragePoolHostVO host : hostPoolRecords) {
+            storagePoolHostDao.deleteStoragePoolHostDetails(
+                    host.getHostId(), host.getPoolId());
+        }
+        poolVO.setUuid(null);
+        this.dataStoreDao.update(poolVO.getId(), poolVO);
+        dataStoreDao.remove(poolVO.getId());
+        deletePoolStats(poolVO.getId());
+        // Delete op_host_capacity entries
+        this._capacityDao.removeBy(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED,
+                null, null, null, poolVO.getId());
+        txn.commit();
+
+        s_logger.debug("Storage pool id=" + poolVO.getId()
+                + " is removed successfully");
+        return true;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ed6200e/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 7b8741c..31e6908 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
@@ -332,12 +332,12 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     }
 
     @Override
-    public Long getStorageProviderId() {
-        return this.pdsv.getStorageProviderId();
+    public boolean isInMaintenance() {
+        return this.getStatus() == StoragePoolStatus.Maintenance ? true : false;
     }
 
     @Override
-    public boolean isInMaintenance() {
-        return this.getStatus() == StoragePoolStatus.Maintenance ? true : false;
+    public String getStorageProviderName() {
+        return this.pdsv.getStorageProviderName();
     }
 }


Mime
View raw message