incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [1/2] git commit: add lifecycle on primarydatastore
Date Sat, 08 Dec 2012 02:23:20 GMT
Updated Branches:
  refs/heads/javelin 57c9b4c6b -> 7652a44be


add lifecycle on primarydatastore


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

Branch: refs/heads/javelin
Commit: ae59bf6c3bd29b8319167230bad913f34abbc786
Parents: 57c9b4c
Author: Edison Su <sudison@gmail.com>
Authored: Thu Dec 6 19:01:06 2012 -0800
Committer: Edison Su <sudison@gmail.com>
Committed: Fri Dec 7 18:23:08 2012 -0800

----------------------------------------------------------------------
 .../subsystem/api/storage/DataStoreLifeCycle.java  |   13 ----
 .../api/storage/PrimaryDataStoreInfo.java          |    2 +
 .../api/storage/PrimaryDataStoreLifeCycle.java     |   37 ++++++++++++
 .../api/storage/PrimaryDataStoreProvider.java      |   18 ++++++
 .../engine/subsystem/api/storage/Scope.java        |   24 ++++++++
 .../engine/subsystem/api/storage/ScopeType.java    |   25 ++++++++
 .../cloudstack/storage/test/volumeServiceTest.java |    4 +-
 .../storage/datastore/PrimaryDataStore.java        |    1 -
 .../cloudstack/storage/scope/ClusterScope.java     |   42 +++++++++++++
 .../apache/cloudstack/storage/scope/HostScope.java |   39 ++++++++++++
 .../apache/cloudstack/storage/scope/ZoneScope.java |   42 +++++++++++++
 .../storage/datastore/DataStoreStatus.java         |    2 +-
 .../storage/datastore/DefaultPrimaryDataStore.java |   34 +++++++++--
 .../storage/datastore/db/PrimaryDataStoreVO.java   |    2 +-
 .../driver/DefaultPrimaryDataStoreDriverImpl.java  |   27 ++++++++-
 .../datastore/driver/PrimaryDataStoreDriver.java   |    9 +++
 .../DefaultPrimaryDataStoreLifeCycleImpl.java      |   41 +++++++------
 .../lifecycle/PrimaryDataStoreLifeCycle.java       |   39 ------------
 .../DefaultPrimaryDataStoreManagerImpl.java        |   14 +---
 .../datastore/manager/PrimaryDataStoreManager.java |    3 +-
 .../DefaultPrimaryDatastoreProviderImpl.java       |   46 +++++++++------
 .../provider/PrimaryDataStoreProvider.java         |   17 -----
 .../provider/PrimaryDataStoreProviderManager.java  |    2 +
 .../PrimaryDataStoreProviderManagerImpl.java       |    6 +-
 .../TemplatePrimaryDataStoreManagerImpl.java       |   32 +++++++---
 .../driver/SolidfirePrimaryDataStoreDriver.java    |   20 ++++++
 .../SolidfirePrimaryDataStoreProvider.java         |   22 ++++---
 .../apache/cloudstack/storage/test/VolumeTest.java |    7 +-
 28 files changed, 413 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/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
deleted file mode 100644
index 8a73e63..0000000
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.cloudstack.engine.subsystem.api.storage;
-
-public interface DataStoreLifeCycle {
-	public enum DataStoreEvent {
-		HOSTUP,
-		HOSTDOWN,
-	}
-	void add();
-	void delete();
-	void enable();
-	void disable();
-	void processEvent(DataStoreEvent event, Object... objs);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
index 9995688..27ea41c 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
@@ -38,4 +38,6 @@ public interface PrimaryDataStoreInfo {
 	public State getManagedState();
 	public String getName();
 	public String getType();
+	public PrimaryDataStoreLifeCycle getLifeCycle();
+	PrimaryDataStoreProvider getProvider();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
new file mode 100644
index 0000000..bcd0d85
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+public interface PrimaryDataStoreLifeCycle {
+    public boolean initialize(Map<String, String> dsInfos);
+
+    public boolean attach(Scope scope);
+
+    public boolean dettach();
+
+    public boolean unmanaged();
+
+    public boolean maintain();
+
+    public boolean cancelMaintain();
+
+    public boolean deleteDataStore();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/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
new file mode 100644
index 0000000..c83594e
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreProvider.java
@@ -0,0 +1,18 @@
+package org.apache.cloudstack.engine.subsystem.api.storage;
+
+import java.util.Map;
+
+public interface PrimaryDataStoreProvider {
+    public PrimaryDataStoreInfo getDataStore(long dataStoreId);
+    public long getId();
+    public String getName();
+
+    /**
+     * @param dsInfos
+     * @return
+     */
+    PrimaryDataStoreInfo registerDataStore(Map<String, String> dsInfos);
+    
+    //LifeCycle of provider
+    public boolean configure();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.java
new file mode 100644
index 0000000..a9601a1
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Scope.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 Scope {
+    public ScopeType getScopeType();
+    public long getScopeId();
+}

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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/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 2c24739..09fa3d1 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
@@ -35,6 +35,8 @@ 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.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
@@ -47,9 +49,7 @@ import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
 import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
 import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
-import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.image.ImageService;
 import org.apache.cloudstack.storage.image.db.ImageDataDao;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
index b977a79..befb9d6 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java
@@ -49,5 +49,4 @@ public interface PrimaryDataStore extends PrimaryDataStoreInfo {
     boolean installTemplate(TemplateOnPrimaryDataStoreInfo template);
 
     VolumeDiskType getDefaultDiskType();
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/src/org/apache/cloudstack/storage/scope/ClusterScope.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/scope/ClusterScope.java b/engine/storage/src/org/apache/cloudstack/storage/scope/ClusterScope.java
new file mode 100644
index 0000000..dad2f50
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/scope/ClusterScope.java
@@ -0,0 +1,42 @@
+/*
+ * 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.scope;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+
+public class ClusterScope implements Scope {
+    private ScopeType type = ScopeType.CLUSTER;
+    private long clusterId;
+    
+    public ClusterScope(long clusterId) {
+        this.clusterId = clusterId;
+    }
+    
+    @Override
+    public ScopeType getScopeType() {
+        return this.type;
+    }
+
+    @Override
+    public long getScopeId() {
+        return this.clusterId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/src/org/apache/cloudstack/storage/scope/HostScope.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/scope/HostScope.java b/engine/storage/src/org/apache/cloudstack/storage/scope/HostScope.java
new file mode 100644
index 0000000..a36c98e
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/scope/HostScope.java
@@ -0,0 +1,39 @@
+/*
+ * 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.scope;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+
+public class HostScope implements Scope {
+    private ScopeType type = ScopeType.HOST;
+    private long hostId;
+    public HostScope(long hostId) {
+        this.hostId = hostId;
+    }
+    @Override
+    public ScopeType getScopeType() {
+        return this.type;
+    }
+
+    @Override
+    public long getScopeId() {
+        return this.hostId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/src/org/apache/cloudstack/storage/scope/ZoneScope.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/scope/ZoneScope.java b/engine/storage/src/org/apache/cloudstack/storage/scope/ZoneScope.java
new file mode 100644
index 0000000..23a0ddb
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/scope/ZoneScope.java
@@ -0,0 +1,42 @@
+/*
+ * 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.scope;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+
+public class ZoneScope implements Scope {
+    private ScopeType type = ScopeType.ZONE;
+    private long zoneId;
+    
+    public ZoneScope(long zoneId) {
+        this.zoneId = zoneId;
+    }
+    
+    @Override
+    public ScopeType getScopeType() {
+        return this.type;
+    }
+
+    @Override
+    public long getScopeId() {
+        return this.zoneId;
+    }
+
+}

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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/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 b6350ed..f5e7349 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
@@ -8,10 +8,13 @@ import javax.inject.Inject;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
 import org.apache.cloudstack.storage.HypervisorHostEndPoint;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
+import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
 import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
 import org.apache.cloudstack.storage.image.TemplateInfo;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
@@ -33,6 +36,7 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     protected PrimaryDataStoreDriver driver;
     protected PrimaryDataStoreVO pdsv;
     protected PrimaryDataStoreInfo pdsInfo;
+    protected PrimaryDataStoreLifeCycle lifeCycle;
     @Inject
     private VolumeDao volumeDao;
     @Inject
@@ -40,14 +44,20 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     @Inject
     TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
 
-    private DefaultPrimaryDataStore(PrimaryDataStoreDriver driver, PrimaryDataStoreVO pdsv, PrimaryDataStoreInfo pdsInfo) {
-        this.driver = driver;
+    private DefaultPrimaryDataStore(PrimaryDataStoreVO pdsv) {
         this.pdsv = pdsv;
-        this.pdsInfo = pdsInfo;
     }
     
-    public static DefaultPrimaryDataStore createDataStore(PrimaryDataStoreDriver driver, PrimaryDataStoreVO pdsv, PrimaryDataStoreInfo pdsInfo) {
-        DefaultPrimaryDataStore dataStore = new DefaultPrimaryDataStore(driver, pdsv, pdsInfo);
+    public void setDriver(PrimaryDataStoreDriver driver) {
+        this.driver = driver;
+    }
+    
+    public void setLifeCycle(PrimaryDataStoreLifeCycle lifeCycle) {
+        this.lifeCycle = lifeCycle;
+    }
+    
+    public static DefaultPrimaryDataStore createDataStore(PrimaryDataStoreVO pdsv) {
+        DefaultPrimaryDataStore dataStore = new DefaultPrimaryDataStore(pdsv);
         return ComponentInject.inject(dataStore);
     }
 
@@ -120,7 +130,7 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
 
     @Override
     public VolumeObject createVolume(VolumeInfo vi, VolumeDiskType diskType) {
-        if (!pdsInfo.isVolumeDiskTypeSupported(diskType)) {
+        if (!isVolumeDiskTypeSupported(diskType)) {
             return null;
         }
         VolumeObject vo = (VolumeObject) vi;
@@ -193,4 +203,16 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public PrimaryDataStoreLifeCycle getLifeCycle() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public PrimaryDataStoreProvider getProvider() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
index 6c05d10..5a6b409 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
@@ -108,7 +108,7 @@ public class PrimaryDataStoreVO implements Identity {
     }
 
     public PrimaryDataStoreVO() {
-        // TODO Auto-generated constructor stub
+        this.status = DataStoreStatus.Initial;
     }
 
     public String getName() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
index 97b49cb..db5f7e8 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
@@ -1,6 +1,7 @@
 package org.apache.cloudstack.storage.datastore.driver;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
@@ -8,6 +9,7 @@ import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
 import org.apache.cloudstack.storage.command.CreateVolumeCommand;
 import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
 import org.apache.cloudstack.storage.command.DeleteVolume;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
 import org.apache.cloudstack.storage.to.VolumeTO;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
@@ -19,10 +21,13 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 import com.cloud.utils.exception.CloudRuntimeException;
 
-@Component
 public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
     private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
-
+    protected PrimaryDataStore dataStore;
+    public DefaultPrimaryDataStoreDriverImpl(PrimaryDataStore dataStore) {
+        this.dataStore = dataStore;
+    }
+    
     @Override
     public boolean createVolume(VolumeObject vol) {
         // The default driver will send createvolume command to one of hosts
@@ -110,4 +115,22 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
         // TODO Auto-generated method stub
         return 0;
     }
+
+    @Override
+    public boolean initialize(Map<String, String> params) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean grantAccess(EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean revokeAccess(EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
index 271ec38..a42ec16 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
@@ -1,5 +1,7 @@
 package org.apache.cloudstack.storage.datastore.driver;
 
+import java.util.Map;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.volume.VolumeObject;
@@ -18,4 +20,11 @@ public interface PrimaryDataStoreDriver {
     long getCapacity();
     
     long getAvailableCapacity();
+    
+    
+    //Lifecycle API
+    boolean initialize(Map<String, String> params);
+    boolean grantAccess(EndPoint ep);
+    boolean revokeAccess(EndPoint ep);
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/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 c4c7216..3d611cc 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
@@ -25,18 +25,23 @@ import java.util.Map;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+import org.apache.cloudstack.storage.datastore.DataStoreStatus;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
 import org.springframework.stereotype.Component;
 
 public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
-    private final PrimaryDataStoreProvider provider;
+    protected PrimaryDataStoreInfo dataStore;
     protected PrimaryDataStoreDao dataStoreDao;
-    public DefaultPrimaryDataStoreLifeCycleImpl(PrimaryDataStoreProvider provider, PrimaryDataStoreDao dataStoreDao) {
-        this.provider = provider;
+    public DefaultPrimaryDataStoreLifeCycleImpl(PrimaryDataStoreDao dataStoreDao, PrimaryDataStore dataStore) {
         this.dataStoreDao = dataStoreDao;
+        this.dataStore = dataStore;
     }
     
     protected class DataStoreUrlParser {
@@ -75,54 +80,54 @@ public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLif
     }
     
     @Override
-    public PrimaryDataStoreInfo registerDataStore(Map<String, String> dsInfos) {
+    public boolean initialize(Map<String, String> dsInfos) {
         DataStoreUrlParser parser = new DataStoreUrlParser(dsInfos.get("url"));
-        PrimaryDataStoreVO dataStore = new PrimaryDataStoreVO();
+        PrimaryDataStoreVO dataStore = dataStoreDao.findById(this.dataStore.getId());
         dataStore.setName(dsInfos.get("name"));
         dataStore.setPoolType(parser.getSchema());
         dataStore.setPort(parser.port);
-        dataStore.setDataCenterId(Integer.parseInt(dsInfos.get("dcId")));
         dataStore.setHostAddress(parser.getHost());
         dataStore.setPath(parser.getPath());
-        dataStore.setStorageProviderId(this.provider.getId());
-        dataStore.setClusterId(Long.parseLong(dsInfos.get("clusterId")));
-        dataStore = dataStoreDao.persist(dataStore);
+        dataStore.setStatus(DataStoreStatus.Initialized);
+        dataStoreDao.update(this.dataStore.getId(), dataStore);
         //TODO: add extension point for each data store
-        return this.provider.getDataStore(dataStore.getId());
+        
+        this.dataStore = this.dataStore.getProvider().getDataStore(dataStore.getId());
+        return true;
     }
 
     @Override
-    public boolean attach(long scope) {
-        // TODO Auto-generated method stub
+    public boolean attach(Scope scope) {
+        //if (scope.getScopeType() == ScopeType.CLUSTER) 
         return false;
     }
 
     @Override
-    public boolean dettach(long dataStoreId) {
+    public boolean dettach() {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public boolean unmanaged(long dataStoreId) {
+    public boolean unmanaged() {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public boolean maintain(long dataStoreId) {
+    public boolean maintain() {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public boolean cancelMaintain(long dataStoreId) {
+    public boolean cancelMaintain() {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public boolean deleteDataStore(long dataStoreId) {
+    public boolean deleteDataStore() {
         // TODO Auto-generated method stub
         return false;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java
deleted file mode 100644
index 570a622..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java
+++ /dev/null
@@ -1,39 +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.lifecycle;
-
-import java.util.Map;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
-
-public interface PrimaryDataStoreLifeCycle {
-    public PrimaryDataStoreInfo registerDataStore(Map<String, String> dsInfos);
-
-    public boolean attach(long scope);
-
-    public boolean dettach(long dataStoreId);
-
-    public boolean unmanaged(long dataStoreId);
-
-    public boolean maintain(long dataStoreId);
-
-    public boolean cancelMaintain(long dataStoreId);
-
-    public boolean deleteDataStore(long dataStoreId);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
index 91528ba..139da4d 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/DefaultPrimaryDataStoreManagerImpl.java
@@ -20,12 +20,13 @@ package org.apache.cloudstack.storage.datastore.manager;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
-import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
 import org.springframework.stereotype.Component;
 
@@ -43,14 +44,7 @@ public class DefaultPrimaryDataStoreManagerImpl implements PrimaryDataStoreManag
         PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
         Long providerId = dataStoreVO.getStorageProviderId();
         PrimaryDataStoreProvider provider = providerManager.getDataStoreProvider(providerId);
-        PrimaryDataStore dataStore = provider.getDataStore(dataStoreId);
+        PrimaryDataStore dataStore = (PrimaryDataStore)provider.getDataStore(dataStoreId);
         return dataStore;
     }
-
-    @Override
-    public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
index 7dd0276..f6b3625 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/manager/PrimaryDataStoreManager.java
@@ -18,11 +18,10 @@
  */
 package org.apache.cloudstack.storage.datastore.manager;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
 
 public interface PrimaryDataStoreManager {
     public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
 
-    public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
index 872673e..f1fca31 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
@@ -4,29 +4,31 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
 import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
 import org.apache.cloudstack.storage.datastore.lifecycle.DefaultPrimaryDataStoreLifeCycleImpl;
-import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
 import org.springframework.stereotype.Component;
 
 @Component
 public class DefaultPrimaryDatastoreProviderImpl implements PrimaryDataStoreProvider {
     private final String providerName = "default primary data store provider";
     protected PrimaryDataStoreDriver driver;
-    private PrimaryDataStoreProviderVO provider;
+    private PrimaryDataStoreProviderVO providerVO;
     @Inject
     protected PrimaryDataStoreDao dataStoreDao;
-    protected PrimaryDataStoreLifeCycle dataStoreLifeCycle;
+    @Inject
+    protected PrimaryDataStoreProviderDao providerDao;
 
     public DefaultPrimaryDatastoreProviderImpl() {
-        this.driver = new DefaultPrimaryDataStoreDriverImpl();
-        this.dataStoreLifeCycle = new DefaultPrimaryDataStoreLifeCycleImpl(this, dataStoreDao);
+        
     }
 
     @Override
@@ -36,29 +38,37 @@ public class DefaultPrimaryDatastoreProviderImpl implements PrimaryDataStoreProv
             return null;
         }
 
-        PrimaryDataStore pds = DefaultPrimaryDataStore.createDataStore(driver, dsv, null);
+        DefaultPrimaryDataStore pds = DefaultPrimaryDataStore.createDataStore(dsv);
+        
+        PrimaryDataStoreDriver driver = new DefaultPrimaryDataStoreDriverImpl(pds);
+        pds.setDriver(driver);
+        
+        DefaultPrimaryDataStoreLifeCycleImpl lifeCycle = new DefaultPrimaryDataStoreLifeCycleImpl(dataStoreDao, pds);
+        pds.setLifeCycle(lifeCycle);
+        
         return pds;
     }
-
+    
     @Override
-    public PrimaryDataStoreLifeCycle getDataStoreLifeCycle() {
-        return dataStoreLifeCycle;
+    public PrimaryDataStore registerDataStore(Map<String, String> dsInfos) {
+        PrimaryDataStoreVO dataStoreVO = new PrimaryDataStoreVO();
+        dataStoreVO.setStorageProviderId(this.getId());
+        dataStoreVO = dataStoreDao.persist(dataStoreVO);
+        
+        PrimaryDataStore dataStore = this.getDataStore(dataStoreVO.getId());
+        PrimaryDataStoreLifeCycle lifeCycle = dataStore.getLifeCycle();
+        lifeCycle.initialize(dsInfos);
+        return getDataStore(dataStore.getId());
     }
 
     @Override
     public long getId() {
-        return this.provider.getId();
-    }
-
-    @Override
-    public boolean register(PrimaryDataStoreProviderVO provider, Map<String, Object> params) {
-        this.provider = provider;
-        return true;
+        return this.providerVO.getId();
     }
 
     @Override
-    public boolean init(PrimaryDataStoreProviderVO provider) {
-        this.provider = provider;
+    public boolean configure() {
+        this.providerVO = providerDao.findByName(this.providerName);
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
deleted file mode 100644
index c875426..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProvider.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.cloudstack.storage.datastore.provider;
-
-import java.util.Map;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderVO;
-import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
-
-public interface PrimaryDataStoreProvider {
-    public PrimaryDataStore getDataStore(long dataStoreId);
-    public PrimaryDataStoreLifeCycle getDataStoreLifeCycle();
-    public long getId();
-    public String getName();
-    public boolean register(PrimaryDataStoreProviderVO provider, Map<String, Object> params);
-    public boolean init(PrimaryDataStoreProviderVO provider);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
index 5ede09c..dae9f11 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManager.java
@@ -2,6 +2,8 @@ package org.apache.cloudstack.storage.datastore.provider;
 
 import java.util.List;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
+
 import com.cloud.utils.component.Manager;
 
 public interface PrimaryDataStoreProviderManager extends Manager {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
index c0ad052..d064cce 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/PrimaryDataStoreProviderManagerImpl.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderVO;
 import org.springframework.stereotype.Component;
@@ -60,10 +61,9 @@ public class PrimaryDataStoreProviderManagerImpl implements PrimaryDataStoreProv
                 PrimaryDataStoreProviderVO dataStoreProvider = new PrimaryDataStoreProviderVO();
                 dataStoreProvider.setName(provider.getName());
                 dataStoreProvider = providerDao.persist(dataStoreProvider);
-                provider.register(dataStoreProvider, params);
             }
-            PrimaryDataStoreProviderVO providervo = providerDao.findByName(provider.getName());
-            provider.init(providervo);
+            
+            provider.configure();
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/engine/storage/volume/src/org/apache/cloudstack/storage/volume/TemplatePrimaryDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/TemplatePrimaryDataStoreManagerImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/TemplatePrimaryDataStoreManagerImpl.java
index 5b2d1cb..b197ba1 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/TemplatePrimaryDataStoreManagerImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/TemplatePrimaryDataStoreManagerImpl.java
@@ -72,23 +72,35 @@ public class TemplatePrimaryDataStoreManagerImpl implements TemplatePrimaryDataS
             retries--;
         } while (retries > 0);
         
+        if (templateStoreVO == null) {
+            throw new CloudRuntimeException("waiting too long for template downloading, marked it as failed");
+        }
+        
         return templateStoreVO;
     }
     @Override
     public TemplateOnPrimaryDataStoreObject createTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore) {
-
-        TemplatePrimaryDataStoreVO templateStoreVO = new TemplatePrimaryDataStoreVO(dataStore.getId(), template.getId());
-        try {
-            templateStoreVO = templateStoreDao.persist(templateStoreVO);
-        } catch (Throwable th) {
-            templateStoreVO = templateStoreDao.findByTemplateIdAndPoolId(template.getId(), dataStore.getId());
-            if (templateStoreVO != null) {
-                templateStoreVO = waitingForTemplateDownload(template, dataStore);
-            } else {
-                throw new CloudRuntimeException("Failed create db entry: " + th.toString());
+        TemplatePrimaryDataStoreVO templateStoreVO = null;
+        boolean freshNewTemplate = false;
+        templateStoreVO = templateStoreDao.findByTemplateIdAndPoolId(template.getId(), dataStore.getId());
+        if (templateStoreVO == null) {
+            try {
+                templateStoreVO = new TemplatePrimaryDataStoreVO(dataStore.getId(), template.getId());
+                templateStoreVO = templateStoreDao.persist(templateStoreVO);
+                freshNewTemplate = true;
+            } catch (Throwable th) {
+                templateStoreVO = templateStoreDao.findByTemplateIdAndPoolId(template.getId(), dataStore.getId());
+                if (templateStoreVO == null) {
+                    throw new CloudRuntimeException("Failed create db entry: " + th.toString());
+                }
             }
         }
         
+        //If it's not a fresh template downloading, waiting for other people downloading finished.
+        if (!freshNewTemplate && templateStoreVO.getState() != TemplateOnPrimaryDataStoreStateMachine.State.Ready) {
+            templateStoreVO = waitingForTemplateDownload(template, dataStore);
+        }
+
         TemplateOnPrimaryDataStoreObject templateStoreObject = new TemplateOnPrimaryDataStoreObject(dataStore, template, templateStoreVO, templateStoreDao, this);
         return templateStoreObject;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
index bd3844a..8d96711 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java
@@ -1,5 +1,7 @@
 package org.apache.cloudstack.storage.datastore.driver;
 
+import java.util.Map;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.volume.VolumeObject;
@@ -49,4 +51,22 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
         return 0;
     }
 
+    @Override
+    public boolean initialize(Map<String, String> params) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean grantAccess(EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean revokeAccess(EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
index a66fac2..2fbcc2c 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
@@ -1,24 +1,21 @@
 package org.apache.cloudstack.storage.datastore.provider;
 
-import javax.inject.Inject;
-
 import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
 import org.apache.cloudstack.storage.datastore.driver.SolidfirePrimaryDataStoreDriver;
+import org.apache.cloudstack.storage.datastore.lifecycle.DefaultPrimaryDataStoreLifeCycleImpl;
 import org.springframework.stereotype.Component;
 
 @Component
 public class SolidfirePrimaryDataStoreProvider extends
 	DefaultPrimaryDatastoreProviderImpl {
 	private final String name = "Solidfre Primary Data Store Provider";
-	private SolidfirePrimaryDataStoreDriver driver;
-	
-	@Inject
-	public SolidfirePrimaryDataStoreProvider(PrimaryDataStoreDao dataStoreDao) {
-		super(dataStoreDao);
-		driver = new SolidfirePrimaryDataStoreDriver();
+
+
+	public SolidfirePrimaryDataStoreProvider() {
+	    super();
+		
 		// TODO Auto-generated constructor stub
 	}
 	
@@ -34,7 +31,12 @@ public class SolidfirePrimaryDataStoreProvider extends
             return null;
         }
 
-        PrimaryDataStore pds = DefaultPrimaryDataStore.createDataStore(driver, dsv, null);
+        DefaultPrimaryDataStore pds = DefaultPrimaryDataStore.createDataStore(dsv);
+        SolidfirePrimaryDataStoreDriver driver = new SolidfirePrimaryDataStoreDriver();
+        pds.setDriver(driver);
+        
+        DefaultPrimaryDataStoreLifeCycleImpl lifeCycle = new DefaultPrimaryDataStoreLifeCycleImpl(super.dataStoreDao, pds);
+        pds.setLifeCycle(lifeCycle);
         return pds;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ae59bf6c/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
index 39ecc0c..eb0550a 100644
--- a/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
+++ b/plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java
@@ -12,11 +12,11 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
 import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
 import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
 import org.junit.Before;
 import org.junit.Test;
@@ -120,13 +120,12 @@ public class VolumeTest {
 		try {
 			primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String, Object>());
 			PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("Solidfre Primary Data Store Provider");
-			PrimaryDataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
 			Map<String, String> params = new HashMap<String, String>();
 			params.put("url", "nfs://test/test");
 			params.put("dcId", dcId.toString());
 			params.put("clusterId", clusterId.toString());
 			params.put("name", "my primary data store");
-			PrimaryDataStoreInfo primaryDataStoreInfo = lifeCycle.registerDataStore(params);
+			PrimaryDataStoreInfo primaryDataStoreInfo = provider.registerDataStore(params);
 			return primaryDataStoreInfo;
 		} catch (ConfigurationException e) {
 			return null;


Mime
View raw message