Updated Branches:
  refs/heads/javelin 13542fd87 -> 60758785b

Add more storage code


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

Branch: refs/heads/javelin
Commit: 60758785b7b1f42504dbeecb2d3c1670f273be78
Parents: 13542fd
Author: Edison Su <[email protected]>
Authored: Mon Aug 27 18:07:54 2012 -0700
Committer: Edison Su <[email protected]>
Committed: Mon Aug 27 18:07:54 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/storage/StoragePool.java         |   10 ++
 api/src/com/cloud/storage/StoragePoolStatus.java   |    1 +
 core/src/com/cloud/storage/StoragePoolVO.java      |   48 +++++--
 platform/api/.classpath                            |    9 +-
 platform/api/.project                              |    6 +
 platform/api/pom.xml                               |   27 +++-
 .../platform/subsystem/api/storage/DataStore.java  |    5 +-
 .../subsystem/api/storage/DataStoreDriver.java     |    4 +
 .../subsystem/api/storage/DataStoreEndPoint.java   |   18 ++-
 .../api/storage/DataStoreEndPointSelector.java     |    2 +-
 .../subsystem/api/storage/DataStoreLifeCycle.java  |    2 +-
 .../subsystem/api/storage/StorageProvider.java     |    5 +-
 platform/storage/pom.xml                           |   36 +++++-
 .../storage/DefaultPrimaryStorageProvider.java     |  107 +++++++--------
 .../storage/datastore/XenDataStoreDriver.java      |    6 +-
 .../NfsDataStoreConfigurator.java                  |   20 +--
 .../XenNfsDataStoreConfigurator.java               |   22 ++-
 .../epselector/DefaultPrimaryEndpointSelector.java |   27 +++-
 .../lifecycle/DefaultDataStoreLifeCycle.java       |   38 -----
 .../storage/strategy/XenBackupStrategy.java        |    6 +-
 .../storage/strategy/XenSnapshotStrategy.java      |    6 +-
 .../storage/strategy/XenVolumeStrategy.java        |    7 +-
 22 files changed, 254 insertions(+), 158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/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 497523d..4b7fe3a 100644
--- a/api/src/com/cloud/storage/StoragePool.java
+++ b/api/src/com/cloud/storage/StoragePool.java
@@ -103,4 +103,14 @@ public interface StoragePool {
     int getPort();
 
     Long getPodId();
+
+       /**
+        * @return
+        */
+       String getStorageProvider();
+
+       /**
+        * @return
+        */
+       String getStorageType();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/api/src/com/cloud/storage/StoragePoolStatus.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StoragePoolStatus.java 
b/api/src/com/cloud/storage/StoragePoolStatus.java
index 0c94961..94dd686 100644
--- a/api/src/com/cloud/storage/StoragePoolStatus.java
+++ b/api/src/com/cloud/storage/StoragePoolStatus.java
@@ -17,6 +17,7 @@
 package com.cloud.storage;
 
 public enum StoragePoolStatus {
+       Creating,
     Up,
     PrepareForMaintenance,
     ErrorInMaintenance,

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/core/src/com/cloud/storage/StoragePoolVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/StoragePoolVO.java 
b/core/src/com/cloud/storage/StoragePoolVO.java
index 5fecefb..f6bb210 100644
--- a/core/src/com/cloud/storage/StoragePoolVO.java
+++ b/core/src/com/cloud/storage/StoragePoolVO.java
@@ -50,7 +50,7 @@ public class StoragePoolVO implements StoragePool, Identity {
     
     @Column(name="pool_type", updatable=false, nullable=false, length=32)
     @Enumerated(value=EnumType.STRING)
-    private StoragePoolType poolType;
+    private StoragePoolType protocol;
     
     @Column(name=GenericDao.CREATED_COLUMN)
     Date created;
@@ -78,6 +78,12 @@ public class StoragePoolVO implements StoragePool, Identity {
     @Enumerated(value=EnumType.STRING)
     private StoragePoolStatus status;
     
+    @Column(name="storage_provider", updatable=true, nullable=false)
+    private String storageProvider;
+    
+    @Column(name="storage_type", nullable=false)
+    private String storageType;
+    
        @Override
     public long getId() {
                return id;
@@ -104,7 +110,7 @@ public class StoragePoolVO implements StoragePool, Identity 
{
        
        @Override
     public StoragePoolType getPoolType() {
-               return poolType;
+               return protocol;
        }
 
        @Override
@@ -130,6 +136,24 @@ public class StoragePoolVO implements StoragePool, 
Identity {
     public long getAvailableBytes() {
                return availableBytes;
        }
+       
+       @Override
+       public String getStorageProvider() {
+               return storageProvider;
+       }
+       
+       public void setStorageProvider(String provider) {
+               storageProvider = provider;
+       }
+       
+       @Override
+       public String getStorageType() {
+               return storageType;
+       }
+       
+       public void setStorageType(String type) {
+               storageType = type;
+       }
 
        @Override
     public long getCapacityBytes() {
@@ -189,7 +213,7 @@ public class StoragePoolVO implements StoragePool, Identity 
{
         this.name  = name;
         this.id = poolId;
         this.uuid = uuid;
-        this.poolType = type;
+        this.protocol = type;
         this.dataCenterId = dataCenterId;
         this.availableBytes = availableBytes;
         this.capacityBytes = capacityBytes;
@@ -197,29 +221,29 @@ public class StoragePoolVO implements StoragePool, 
Identity {
         this.path = hostPath;
         this.port = port;
         this.podId = podId;
-        this.setStatus(StoragePoolStatus.Up);
+        this.setStatus(StoragePoolStatus.Creating);
     }
     
     public StoragePoolVO(StoragePoolVO that) {
-        this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, 
that.podId, that.availableBytes, that.capacityBytes, that.hostAddress, 
that.port, that.path);
+        this(that.id, that.name, that.uuid, that.protocol, that.dataCenterId, 
that.podId, that.availableBytes, that.capacityBytes, that.hostAddress, 
that.port, that.path);
     }
     
     public StoragePoolVO(StoragePoolType type, String hostAddress, int port, 
String path) {
-        this.poolType = type;
+        this.protocol = type;
         this.hostAddress = hostAddress;
         this.port = port;
         this.path = path;
-        this.setStatus(StoragePoolStatus.Up);
+        this.setStatus(StoragePoolStatus.Creating);
         this.uuid = UUID.randomUUID().toString();
     }
 
     public StoragePoolVO(StoragePoolType type, String hostAddress, int port, 
String path, String userInfo) {
-        this.poolType = type;
+        this.protocol = type;
         this.hostAddress = hostAddress;
         this.port = port;
         this.path = path;
         this.userInfo = userInfo;
-        this.setStatus(StoragePoolStatus.Up);
+        this.setStatus(StoragePoolStatus.Creating);
         this.uuid = UUID.randomUUID().toString();
     }
     
@@ -259,12 +283,12 @@ public class StoragePoolVO implements StoragePool, 
Identity {
     
     @Override
     public boolean isShared() {
-       return poolType.isShared();
+       return protocol.isShared();
     }
     
     @Override
     public boolean isLocal() {
-       return !poolType.isShared();
+       return !protocol.isShared();
     }
     
     @Transient
@@ -315,6 +339,6 @@ public class StoragePoolVO implements StoragePool, Identity 
{
        
     @Override
     public String toString() {
-        return new 
StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
+        return new 
StringBuilder("Pool[").append(id).append("|").append(protocol).append("]").toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/.classpath
----------------------------------------------------------------------
diff --git a/platform/api/.classpath b/platform/api/.classpath
index 1275c98..c914294 100755
--- a/platform/api/.classpath
+++ b/platform/api/.classpath
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry combineaccessrules="false" kind="src" path="/api"/>
-       <classpathentry combineaccessrules="false" kind="src" path="/server"/>
-       <classpathentry kind="output" path="bin"/>
+       <classpathentry including="**/*.java" kind="src" 
output="target/classes" path="src"/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" 
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+       <classpathentry kind="output" path="target/classes"/>
 </classpath>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/.project
----------------------------------------------------------------------
diff --git a/platform/api/.project b/platform/api/.project
index 6515efe..af79ee6 100755
--- a/platform/api/.project
+++ b/platform/api/.project
@@ -10,8 +10,14 @@
                        <arguments>
                        </arguments>
                </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
        </buildSpec>
        <natures>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
 </projectDescription>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/pom.xml
----------------------------------------------------------------------
diff --git a/platform/api/pom.xml b/platform/api/pom.xml
index 9d59e0b..fadb9af 100644
--- a/platform/api/pom.xml
+++ b/platform/api/pom.xml
@@ -1,13 +1,24 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
   <modelVersion>4.0.0</modelVersion>
-  <groupId>cloudstack</groupId>
   <artifactId>cloud-platform-api</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+  <name>Apache CloudStack platform API</name>
+  <parent>
+               <groupId>com.cloud</groupId>
+               <artifactId>cloud-parent</artifactId>
+               <version>4.0.0-SNAPSHOT</version>
+               <relativePath>../../parent/pom.xml</relativePath>
+       </parent>
   <dependencies>
-       <dependency>
-               <groupId>com.cloud</groupId>
-               <artifactId>cloud-api</artifactId>
-               <version>4.0.0-SNAPSHOT</version>
-       </dependency>
+               <dependency>
+                       <groupId>com.cloud</groupId>
+                       <artifactId>cloud-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
   </dependencies>
+  <build>
+               <defaultGoal>install</defaultGoal>
+               <sourceDirectory>src</sourceDirectory>
+               <!-- <testSourceDirectory>test</testSourceDirectory> -->
+       </build>
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStore.java
----------------------------------------------------------------------
diff --git 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStore.java
 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStore.java
index c21c613..899f17f 100644
--- 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStore.java
+++ 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStore.java
@@ -39,11 +39,14 @@ public interface DataStore {
        
        String getURI();
        String getUUID();
+       long getCluterId();
+       long getPodId();
+       long getZoneId();
        StoreType getType();
        StoreScope getScope();
        Long getId();
        DataStoreDriver getDataStoreDriver();
-       void setEndPointSelector(DataStoreEndPointSelector selector);
+       DataStoreEndPointSelector getEndPointSelector();
        FileSystem getFileSystem();
        VolumeStrategy getVolumeStrategy();
        SnapshotStrategy getSnapshotStrategy();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreDriver.java
----------------------------------------------------------------------
diff --git 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreDriver.java
 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreDriver.java
index f8987f7..1b285bb 100644
--- 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreDriver.java
+++ 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreDriver.java
@@ -18,11 +18,15 @@
  */
 package org.apache.cloudstack.platform.subsystem.api.storage;
 
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
 public interface DataStoreDriver {
        String getDriverType();
        DataObject create(DataObject obj);
        DataObject copy(DataObject src, DataStore dest);
        DataObject copy(DataObject src, DataObject dest);
        DataObject move(DataObject src, DataObject dest);
+       Answer sendMessage(DataStoreEndPoint dsep, Command cmd);
        boolean delete(DataObject obj);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPoint.java
----------------------------------------------------------------------
diff --git 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPoint.java
 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPoint.java
index 06bde0d..92f431a 100644
--- 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPoint.java
+++ 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPoint.java
@@ -1,5 +1,19 @@
 package org.apache.cloudstack.platform.subsystem.api.storage;
 
-public interface DataStoreEndPoint {
-
+public class DataStoreEndPoint {
+       protected long hostId;
+       protected String privIp;
+       
+       public DataStoreEndPoint(long host, String ip) {
+               hostId = host;
+               privIp = ip;
+       }
+       
+       public long getHostId() {
+               return hostId;
+       }
+       
+       public String getPrivateIp() {
+               return privIp;
+       }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPointSelector.java
----------------------------------------------------------------------
diff --git 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPointSelector.java
 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPointSelector.java
index 6493baa..df6d96c 100644
--- 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPointSelector.java
+++ 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPointSelector.java
@@ -3,5 +3,5 @@ package org.apache.cloudstack.platform.subsystem.api.storage;
 import java.util.List;
 
 public interface DataStoreEndPointSelector {
-       List<DataStoreEndPoint> getEndPoints(DataStore ds);
+       List<DataStoreEndPoint> getEndPoints();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreLifeCycle.java
 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreLifeCycle.java
index 6d2294e..46be5f5 100644
--- 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreLifeCycle.java
+++ 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreLifeCycle.java
@@ -5,7 +5,7 @@ public interface DataStoreLifeCycle {
                HOSTUP,
                HOSTDOWN,
        }
-       void create();
+       void add();
        void delete();
        void enable();
        void disable();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageProvider.java
----------------------------------------------------------------------
diff --git 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageProvider.java
 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageProvider.java
index 0372f30..95391c3 100644
--- 
a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageProvider.java
+++ 
b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageProvider.java
@@ -7,13 +7,14 @@ import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.StoragePool;
+import com.cloud.utils.component.Adapter;
 
-public interface StorageProvider {
+public interface StorageProvider extends Adapter {
        List<HypervisorType> supportedHypervisors();
        String getProviderName();
        StoreType supportedStoreType();
        void configure(Map<String, String> storeProviderInfo);
-       DataStore createDataStore(HypervisorType hypervisor, 
DataStoreConfigurator dsc);
+       DataStore addDataStore(StoragePool sp, String uri, Map<String, String> 
params);
        DataStore getDataStore(StoragePool pool);
        Map<HypervisorType, Map<String,DataStoreConfigurator>> 
getDataStoreConfigs();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/pom.xml
----------------------------------------------------------------------
diff --git a/platform/storage/pom.xml b/platform/storage/pom.xml
index 49cf6b7..852c7d7 100644
--- a/platform/storage/pom.xml
+++ b/platform/storage/pom.xml
@@ -1,6 +1,38 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
   <modelVersion>4.0.0</modelVersion>
-  <groupId>com.cloud</groupId>
   <artifactId>cloud-platform-storage</artifactId>
-  <version>0.0.1-SNAPSHOT</version>
+  <name>Apache CloudStack Platform Storage</name>
+  <parent>
+       <groupId>com.cloud</groupId>
+       <artifactId>cloud-parent</artifactId>
+       <version>4.0.0-SNAPSHOT</version>
+       <relativePath>../../parent/pom.xml</relativePath>
+       </parent>
+  <dependencies>
+               <dependency>
+                       <groupId>com.cloud</groupId>
+                       <artifactId>cloud-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.cloud</groupId>
+                       <artifactId>cloud-core</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.cloud</groupId>
+                       <artifactId>cloud-server</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.cloud</groupId>
+                       <artifactId>cloud-platform-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+  </dependencies>
+  <build>
+               <defaultGoal>install</defaultGoal>
+               <sourceDirectory>src</sourceDirectory>
+               <!-- <testSourceDirectory>test</testSourceDirectory> -->
+       </build>
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/DefaultPrimaryStorageProvider.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/DefaultPrimaryStorageProvider.java
 
b/platform/storage/src/org/apache/cloudstack/storage/DefaultPrimaryStorageProvider.java
index f7ae5dd..ea2dfe3 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/DefaultPrimaryStorageProvider.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/DefaultPrimaryStorageProvider.java
@@ -7,8 +7,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.naming.ConfigurationException;
+
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStoreConfigurator;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreLifeCycle;
 import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
 import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
 import 
org.apache.cloudstack.storage.datastoreconfigurator.NfsDataStoreConfigurator;
@@ -31,13 +34,8 @@ import com.cloud.utils.component.Inject;
 public class DefaultPrimaryStorageProvider implements StorageProvider {
        private String _name = DefaultPrimaryStorageProvider.class.toString();
        static Map<HypervisorType, Map<String, DataStoreConfigurator>> 
_supportedProtocols;
-       
-       @Inject
-       protected DataCenterDao _dcDao;
        @Inject
        protected ClusterDao _clusterDao;
-       @Inject
-       protected StoragePoolDao _storagePoolDao;
        
        public List<HypervisorType> supportedHypervisors() {
                List<HypervisorType> hypervisors = new 
ArrayList<HypervisorType>();
@@ -61,14 +59,50 @@ public class DefaultPrimaryStorageProvider implements 
StorageProvider {
                // TODO Auto-generated method stub
 
        }
+
+       public Map<HypervisorType, Map<String,DataStoreConfigurator>> 
getDataStoreConfigs() {
+               return _supportedProtocols;
+       }
+
+       public String getProviderName() {
+               return _name;
+       }
+
+       public DataStore createDataStore(HypervisorType hypervisor,
+                       DataStoreConfigurator dsc) {
+               // TODO Auto-generated method stub
+               return null;
+       }
        
-       public DataStore createDataStore(HypervisorType hypervisor, 
-                       long dcId,
-                       long podId,
-                       long clusterId,
-                       String name,
-                       String url,
-                       Map<String, String> extra) {
+       public DataStore getDataStore(StoragePool pool) {
+               ClusterVO clu = _clusterDao.findById(pool.getClusterId());
+               HypervisorType hy = clu.getHypervisorType();
+               Map<String, DataStoreConfigurator> dscs = 
_supportedProtocols.get(hy);
+               DataStoreConfigurator dsc = 
dscs.get(pool.getPoolType().toString());
+               return dsc.getDataStore(pool);
+       }
+
+       public boolean configure(String name, Map<String, Object> params) 
throws ConfigurationException {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public String getName() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public boolean start() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public boolean stop() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public DataStore addDataStore(StoragePool spool, String url, 
Map<String, String> params) {
                URI uri;
                try {
                        uri = new URI(url);
@@ -80,8 +114,10 @@ public class DefaultPrimaryStorageProvider implements 
StorageProvider {
                if (protocol == null) {
                        throw new InvalidParameterValueException("the protocol 
can't be null");
                }
+               
+               ClusterVO cluster = _clusterDao.findById(spool.getClusterId());
 
-               Map<String, DataStoreConfigurator> dscs = 
_supportedProtocols.get(hypervisor);
+               Map<String, DataStoreConfigurator> dscs = 
_supportedProtocols.get(cluster.getHypervisorType());
                if (dscs.isEmpty()) {
                        throw new InvalidParameterValueException("Doesn't 
support this hypervisor");
                }
@@ -91,52 +127,11 @@ public class DefaultPrimaryStorageProvider implements 
StorageProvider {
                        throw new InvalidParameterValueException("Doesn't 
support this protocol");
                }
                
-               Map<String, String> configs = dsc.getConfigs(uri, extra);
+               Map<String, String> configs = dsc.getConfigs(uri, params);
                dsc.validate(configs);
-               StoragePoolVO spool = 
(StoragePoolVO)dsc.getStoragePool(configs);
-               DataCenterVO zone = _dcDao.findById(dcId);
-               if (zone == null) {
-                       throw new InvalidParameterValueException("unable to 
find zone by id " + dcId);
-               }
-               StoragePoolVO existingPool = 
_storagePoolDao.findPoolByUUID(spool.getUuid());
-               if (existingPool != null) {
-                       throw new InvalidParameterValueException("The same 
storage pool was added already");
-               }
-               
-               long poolId = _storagePoolDao.getNextInSequence(Long.class, 
"id");
-        spool.setId(poolId);
-        spool.setDataCenterId(dcId);
-        spool.setPodId(podId);
-        spool.setName(name);
-        spool.setClusterId(clusterId);
-        spool.setStatus(StoragePoolStatus.Up);
-        spool = _storagePoolDao.persist(spool, extra);
+               DataStore ds = dsc.getDataStore(spool);
                
-        DataStore ds = dsc.getDataStore(spool);
-        
                return ds;
        }
 
-       public Map<HypervisorType, Map<String,DataStoreConfigurator>> 
getDataStoreConfigs() {
-               return _supportedProtocols;
-       }
-
-       public String getProviderName() {
-               return _name;
-       }
-
-       public DataStore createDataStore(HypervisorType hypervisor,
-                       DataStoreConfigurator dsc) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public DataStore getDataStore(StoragePool pool) {
-               ClusterVO clu = _clusterDao.findById(pool.getClusterId());
-               HypervisorType hy = clu.getHypervisorType();
-               Map<String, DataStoreConfigurator> dscs = 
_supportedProtocols.get(hy);
-               DataStoreConfigurator dsc = 
dscs.get(pool.getPoolType().toString());
-               return dsc.getDataStore(pool);
-       }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/datastore/XenDataStoreDriver.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/datastore/XenDataStoreDriver.java
 
b/platform/storage/src/org/apache/cloudstack/storage/datastore/XenDataStoreDriver.java
index 479b950..0c2ee37 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/datastore/XenDataStoreDriver.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/datastore/XenDataStoreDriver.java
@@ -5,7 +5,11 @@ import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreDriver;
 
 public class XenDataStoreDriver implements DataStoreDriver {
-
+       protected DataStore _ds;
+       public XenDataStoreDriver(DataStore ds) {
+               _ds = ds;
+       }
+       
        public String getDriverType() {
                // TODO Auto-generated method stub
                return null;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/NfsDataStoreConfigurator.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/NfsDataStoreConfigurator.java
 
b/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/NfsDataStoreConfigurator.java
index c154bd0..6a01834 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/NfsDataStoreConfigurator.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/NfsDataStoreConfigurator.java
@@ -10,6 +10,7 @@ import java.util.UUID;
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStoreConfigurator;
 
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.StoragePoolVO;
 import com.cloud.storage.Storage.StoragePoolType;
@@ -48,19 +49,12 @@ public abstract class NfsDataStoreConfigurator implements 
DataStoreConfigurator
        }
 
        public boolean validate(Map<String, String> configs) {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
-       public StoragePoolVO getStoragePool(Map<String, String> configs) {
-               String nfsServer = configs.get(NfsConfigName.SERVER.toString());
-               String nfsPath = configs.get(NfsConfigName.PATH.toString());
-               String uuid = UUID.nameUUIDFromBytes(new String(nfsServer + 
nfsPath).getBytes()).toString();
-               StoragePoolVO pool = new 
StoragePoolVO(StoragePoolType.NetworkFilesystem, 
-                               nfsServer, -1, 
-                               nfsPath);
-               pool.setUuid(uuid);
-               return pool;
+                 String uriHost = configs.get(NfsConfigName.SERVER.toString());
+          String uriPath = configs.get(NfsConfigName.PATH.toString());
+          if (uriHost == null || uriPath == null || uriHost.trim().isEmpty() 
|| uriPath.trim().isEmpty()) {
+              throw new InvalidParameterValueException("host or path is null, 
should be nfs://hostname/path");
+          }
+          return true;
        }
 
        public DataStore getDataStore(StoragePool pool) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/XenNfsDataStoreConfigurator.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/XenNfsDataStoreConfigurator.java
 
b/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/XenNfsDataStoreConfigurator.java
index dd240d8..beed262 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/XenNfsDataStoreConfigurator.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/datastoreconfigurator/XenNfsDataStoreConfigurator.java
@@ -1,12 +1,14 @@
 package org.apache.cloudstack.storage.datastoreconfigurator;
 
+import java.util.Map;
+
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
 import org.apache.cloudstack.storage.datastore.DefaultDataStore;
 import org.apache.cloudstack.storage.datastore.XenDataStoreDriver;
 import org.apache.cloudstack.storage.epselector.DefaultPrimaryEndpointSelector;
 import org.apache.cloudstack.storage.filesystem.DefaultFileSystem;
-import org.apache.cloudstack.storage.lifecycle.DefaultDataStoreLifeCycle;
+import 
org.apache.cloudstack.storage.lifecycle.DefaultPrimaryDataStoreLifeCycle;
 import org.apache.cloudstack.storage.strategy.XenBackupStrategy;
 import org.apache.cloudstack.storage.strategy.XenSnapshotStrategy;
 import org.apache.cloudstack.storage.strategy.XenVolumeStrategy;
@@ -17,17 +19,21 @@ public class XenNfsDataStoreConfigurator extends 
NfsDataStoreConfigurator {
        @Override
        public DataStore getDataStore(StoragePool pool) {
                DefaultDataStore ds = new DefaultDataStore();
-               ds.setBackupStrategy(new XenBackupStrategy());
-               ds.setVolumeStrategy(new XenVolumeStrategy());
-               ds.setSnapshotStrategy(new XenSnapshotStrategy());
-               ds.setEndPointSelector(new DefaultPrimaryEndpointSelector());
-               ds.setFileSystem(new DefaultFileSystem());
+               ds.setEndPointSelector(new DefaultPrimaryEndpointSelector(ds));
                ds.setId(pool.getId());
                ds.setType(StoreType.Primary);
                ds.setURI(pool.getHostAddress() + "/" + pool.getPath());
                ds.setUUID(pool.getUuid());
-               ds.setDataStoreDriver(new XenDataStoreDriver());
-               ds.setLifeCycle(new DefaultDataStoreLifeCycle(ds));
+               ds.setDataStoreDriver(new XenDataStoreDriver(ds));
+               ds.setBackupStrategy(new XenBackupStrategy(ds));
+               ds.setVolumeStrategy(new XenVolumeStrategy(ds));
+               ds.setSnapshotStrategy(new XenSnapshotStrategy(ds));
+               ds.setLifeCycle(new DefaultPrimaryDataStoreLifeCycle(ds));
                return ds;
        }
+
+       public StoragePool getStoragePool(Map<String, String> configs) {
+               // TODO Auto-generated method stub
+               return null;
+       }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/epselector/DefaultPrimaryEndpointSelector.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/epselector/DefaultPrimaryEndpointSelector.java
 
b/platform/storage/src/org/apache/cloudstack/storage/epselector/DefaultPrimaryEndpointSelector.java
index 9b18f2c..97d7375 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/epselector/DefaultPrimaryEndpointSelector.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/epselector/DefaultPrimaryEndpointSelector.java
@@ -1,17 +1,34 @@
 package org.apache.cloudstack.storage.epselector;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPoint;
 import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStoreEndPointSelector;
 
+import com.cloud.host.Host;
+import com.cloud.host.HostVO;
+import com.cloud.resource.ResourceManager;
+import com.cloud.utils.component.Inject;
+
 public class DefaultPrimaryEndpointSelector implements
                DataStoreEndPointSelector {
-
-       public List<DataStoreEndPoint> getEndPoints(DataStore ds) {
-               // TODO Auto-generated method stub
-               return null;
+       protected DataStore _ds;
+       
+    @Inject
+    protected ResourceManager _resourceMgr;
+       
+    public DefaultPrimaryEndpointSelector(DataStore ds) {
+       _ds = ds;
+    }
+    
+       public List<DataStoreEndPoint> getEndPoints() {
+               List<HostVO> allHosts = 
_resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, _ds.getCluterId(), 
_ds.getPodId(), _ds.getZoneId());
+               List<DataStoreEndPoint> dseps = new 
ArrayList<DataStoreEndPoint>();
+               for (HostVO host : allHosts) {
+                       dseps.add(new DataStoreEndPoint(host.getId(), 
host.getPrivateIpAddress()));
+               }
+               return dseps;
        }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultDataStoreLifeCycle.java
 
b/platform/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultDataStoreLifeCycle.java
deleted file mode 100644
index 723c550..0000000
--- 
a/platform/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultDataStoreLifeCycle.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.cloudstack.storage.lifecycle;
-
-import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreLifeCycle;
-
-public class DefaultDataStoreLifeCycle implements DataStoreLifeCycle {
-       private DataStore _ds;
-       public DefaultDataStoreLifeCycle(DataStore ds) {
-               this._ds = ds;
-       }
-       
-       
-       public void create() {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void delete() {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void enable() {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void disable() {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void processEvent(DataStoreEvent event, Object... objs) {
-               // TODO Auto-generated method stub
-
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java
 
b/platform/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java
index acf125d..5ac839d 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java
@@ -1,7 +1,11 @@
 package org.apache.cloudstack.storage.strategy;
 
 import org.apache.cloudstack.platform.subsystem.api.storage.BackupStrategy;
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 
 public class XenBackupStrategy implements BackupStrategy {
-
+       protected DataStore _ds;
+       public XenBackupStrategy(DataStore ds) {
+               _ds = ds;
+       }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java
 
b/platform/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java
index c78b99e..1b93880 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java
@@ -1,7 +1,11 @@
 package org.apache.cloudstack.storage.strategy;
 
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotStrategy;
 
 public class XenSnapshotStrategy implements SnapshotStrategy {
-
+       protected DataStore _ds;
+       public XenSnapshotStrategy(DataStore ds) {
+               _ds = ds;
+       }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60758785/platform/storage/src/org/apache/cloudstack/storage/strategy/XenVolumeStrategy.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/strategy/XenVolumeStrategy.java
 
b/platform/storage/src/org/apache/cloudstack/storage/strategy/XenVolumeStrategy.java
index 48e7b1a..4015fec 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/strategy/XenVolumeStrategy.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/strategy/XenVolumeStrategy.java
@@ -1,12 +1,17 @@
 package org.apache.cloudstack.storage.strategy;
 
+import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.platform.subsystem.api.storage.Snapshot;
 import org.apache.cloudstack.platform.subsystem.api.storage.Template;
 import org.apache.cloudstack.platform.subsystem.api.storage.Volume;
 import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
 
 public class XenVolumeStrategy implements VolumeStrategy {
-
+       protected DataStore _ds;
+       public XenVolumeStrategy(DataStore ds) {
+               _ds = ds;
+       }
+       
        public Volume createVolume(Volume vol) {
                // TODO Auto-generated method stub
                return null;

Reply via email to