cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: add create volume from base image command
Date Fri, 28 Dec 2012 00:32:23 GMT
Updated Branches:
  refs/heads/javelin d99161399 -> 9de3a1fae


add create volume from base image command


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

Branch: refs/heads/javelin
Commit: 9de3a1fae4ceaf91baac2a550be3794fb9e99b79
Parents: d991613
Author: Edison Su <sudison@gmail.com>
Authored: Thu Dec 27 16:31:59 2012 -0800
Committer: Edison Su <sudison@gmail.com>
Committed: Thu Dec 27 16:31:59 2012 -0800

----------------------------------------------------------------------
 .../engine/subsystem/api/storage/VolumeInfo.java   |    1 +
 .../cloudstack/storage/test/volumeServiceTest.java |    7 +-
 .../org/apache/cloudstack/storage/to/VolumeTO.java |   12 +++-
 .../configurator/kvm/KvmCLVMConfigurator.java      |    4 +-
 .../validator/CLVMProtocolTransformer.java         |   56 +++++++++++++++
 .../configurator/validator/CLVMValidator.java      |   56 ---------------
 .../validator/ISCSIProtocolTransformer.java        |   55 ++++++++++++++
 .../configurator/validator/ISCSIValiator.java      |   55 --------------
 .../validator/NfsProtocolTransformer.java          |    5 +-
 .../vmware/VmwareIsciConfigurator.java             |    4 +-
 .../configurator/xen/XenIscsiConfigurator.java     |    4 +-
 .../driver/DefaultPrimaryDataStoreDriverImpl.java  |    2 +-
 .../cloudstack/storage/volume/VolumeObject.java    |    5 ++
 .../xen/resource/XenServerStorageResource.java     |   18 +++++-
 14 files changed, 159 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
index 347ae6c..00e8eb0 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
@@ -41,4 +41,5 @@ public interface VolumeInfo {
 	public Date getCreatedDate();
 	public Date getUpdatedDate();
 	public String getOwner();
+	public String getName();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/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 7451f36..f1610b4 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
@@ -270,8 +270,9 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 		}
 	}
 
-	private VolumeVO createVolume(long templateId) {
+	private VolumeVO createVolume(long templateId, long dataStoreId) {
 		VolumeVO volume = new VolumeVO(1000, new RootDisk().toString(), UUID.randomUUID().toString(),
templateId);
+		volume.setPoolId(dataStoreId);
 		volume = volumeDao.persist(volume);
 		return volume;
 
@@ -281,12 +282,12 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	public void createVolumeFromTemplate() {
 		TemplateEntity te = createTemplate();
 		PrimaryDataStoreInfo dataStoreInfo = createPrimaryDataStore();
-		VolumeVO volume = createVolume(te.getId());
+		VolumeVO volume = createVolume(te.getId(), dataStoreInfo.getId());
 		VolumeEntity ve = volumeService.getVolumeEntity(volume.getId());
 		ve.createVolumeFromTemplate(dataStoreInfo.getId(), new VHD(), te);
 	}
 	
-	@Test(priority=3)
+	//@Test(priority=3)
 	public void tearDown() {
 	    List<PrimaryDataStoreVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
 	    for (int i = 0; i < ds.size(); i++) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
index ed7f2be..6b8ab75 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
@@ -9,7 +9,8 @@ public class VolumeTO {
     private final String path;
     private final VolumeType volumeType;
     private final VolumeDiskType diskType;
-    private final PrimaryDataStoreTO dataStore;
+    private PrimaryDataStoreTO dataStore;
+    private final String name;
     public VolumeTO(VolumeInfo volume) {
         this.uuid = volume.getUuid();
         this.path = volume.getPath();
@@ -20,6 +21,7 @@ public class VolumeTO {
         } else {
             this.dataStore = null;
         }
+        this.name = volume.getName();
     }
     
     public String getUuid() {
@@ -41,4 +43,12 @@ public class VolumeTO {
     public PrimaryDataStoreTO getDataStore() {
         return this.dataStore;
     }
+    
+    public void setDataStore(PrimaryDataStoreTO dataStore) {
+        this.dataStore = dataStore;
+    }
+    
+    public String getName() {
+        return this.name;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
index b5e9db3..f0b581f 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.kvm;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.CLVMValidator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.CLVMProtocolTransformer;
 import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
@@ -34,7 +34,7 @@ public class KvmCLVMConfigurator extends AbstractKvmConfigurator {
 
     @Override
     public StorageProtocolTransformer getProtocolTransformer() {
-        return new CLVMValidator();
+        return new CLVMProtocolTransformer();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMProtocolTransformer.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMProtocolTransformer.java
new file mode 100644
index 0000000..4dd19d2
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/CLVMProtocolTransformer.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.configurator.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class CLVMProtocolTransformer implements StorageProtocolTransformer {
+
+    @Override
+    public boolean normalizeUserInput(Map<String, String> params) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public List<String> getInputParamNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+}

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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
new file mode 100644
index 0000000..44bdba9
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.configurator.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class ISCSIProtocolTransformer implements StorageProtocolTransformer {
+
+    @Override
+    public List<String> getInputParamNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean normalizeUserInput(Map<String, String> params) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeTO getVolumeTO(VolumeInfo volume) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
index f812ffb..67ec5e8 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
@@ -88,8 +88,9 @@ public class NfsProtocolTransformer implements StorageProtocolTransformer
{
 
     @Override
     public VolumeTO getVolumeTO(VolumeInfo volume) {
-        // TODO Auto-generated method stub
-        return null;
+        VolumeTO vol = new VolumeTO(volume);
+        vol.setDataStore(this.getDataStoreTO(volume.getDataStore()));
+        return vol;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
index 2a47e03..4e59656 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.vmware;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIValiator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIProtocolTransformer;
 import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
@@ -33,7 +33,7 @@ public class VmwareIsciConfigurator extends AbstractVmwareConfigurator {
 
     @Override
     public StorageProtocolTransformer getProtocolTransformer() {
-        return new ISCSIValiator();
+        return new ISCSIProtocolTransformer();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
index a447756..1120ec2 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cloudstack.storage.datastore.configurator.xen;
 
-import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIValiator;
+import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIProtocolTransformer;
 import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
@@ -34,7 +34,7 @@ public class XenIscsiConfigurator extends AbstractXenConfigurator {
 
 	@Override
 	public StorageProtocolTransformer getProtocolTransformer() {
-		return new ISCSIValiator();
+		return new ISCSIProtocolTransformer();
 	}
 
     protected boolean isLocalStorageSupported() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/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 012d006..9506d7c 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
@@ -118,7 +118,7 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
     }
     @Override
     public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateOnPrimaryDataStoreInfo
template, AsyncCompletionCallback<CommandResult> callback) {
-        VolumeTO vol = new VolumeTO(volume);
+        VolumeTO vol = this.dataStore.getVolumeTO(volume);
         ImageOnPrimayDataStoreTO image = new ImageOnPrimayDataStoreTO(template);
         CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol,
image);
         List<EndPoint> endPoints = template.getPrimaryDataStore().getEndPoints();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index 38cc159..e25dd87 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -153,4 +153,9 @@ public class VolumeObject implements VolumeInfo {
         // TODO Auto-generated method stub
         return null;
     }
+    
+    @Override
+    public String getName() {
+        return this.volumeVO.getName();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9de3a1fa/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
index af6f80d..031d0e0 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
@@ -42,6 +42,7 @@ import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
 import org.apache.cloudstack.storage.to.NfsPrimaryDataStoreTO;
 import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
 import org.apache.cloudstack.storage.to.TemplateTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
@@ -97,7 +98,22 @@ public class XenServerStorageResource {
     }
     
     public Answer execute(CreateVolumeFromBaseImageCommand cmd) {
-        return new CreateVolumeAnswer(cmd, UUID.randomUUID().toString());
+        VolumeTO volume = cmd.getVolume();
+        ImageOnPrimayDataStoreTO baseImage = cmd.getImage();
+        Connection conn = hypervisorResource.getConnection();
+        
+        try {
+            VDI baseVdi = VDI.getByUuid(conn, baseImage.getPathOnPrimaryDataStore());
+            VDI newVol = baseVdi.createClone(conn, new HashMap<String, String>());
+            newVol.setNameLabel(conn, volume.getName());
+            return new CreateVolumeAnswer(cmd, newVol.getUuid(conn));
+        } catch (BadServerResponse e) {
+            return new Answer(cmd, false, e.toString());
+        } catch (XenAPIException e) {
+            return new Answer(cmd, false, e.toString());
+        } catch (XmlRpcException e) {
+            return new Answer(cmd, false, e.toString());
+        }
     }
     
     protected SR getNfsSR(Connection conn, NfsPrimaryDataStoreTO pool) {


Mime
View raw message