diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml
index 56d36ad3a53..8a9dc15579c 100644
--- a/engine/storage/integration-test/pom.xml
+++ b/engine/storage/integration-test/pom.xml
@@ -67,6 +67,12 @@
cloud-plugin-hypervisor-vmware
${project.version}
test
+
+
+ org.apache.cloudstack
+ cloud-plugin-hypervisor-kvm
+ ${project.version}
+ test
org.apache.cloudstack
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
index 77b6ec302cc..726ea010c66 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
@@ -24,6 +24,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
@@ -38,6 +39,7 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
private String secondaryStorage;
private String imageInstallPath;
private String scriptPath;
+ private HypervisorType hypervisor;
private Transaction txn;
private String s3AccessKey;
@@ -72,11 +74,14 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
@Parameters({"devcloud-host-uuid", "devcloud-host-gateway", "devcloud-host-cidr",
"devcloud-host-ip", "template-url", "devcloud-local-storage-uuid",
- "primary-storage-want-to-add", "devcloud-secondary-storage", "s3-accesskey", "s3-secretkey", "s3-endpoint", "s3-template-bucket", "s3-usehttps", "image-install-path", "primary-storage-uuid-want-to-add", "script-path"})
+ "primary-storage-want-to-add", "devcloud-secondary-storage", "s3-accesskey", "s3-secretkey", "s3-endpoint",
+ "s3-template-bucket", "s3-usehttps", "image-install-path", "primary-storage-uuid-want-to-add", "script-path",
+ "hypervisor"})
protected void setup(String hostuuid, String gateway, String cidr,
String hostIp, String templateUrl, String localStorageUuid,
String primaryStorage, String secondaryStorage, String s3_accessKey, String s3_secretKey, String s3_endpoint, String s3_template_bucket,
- String s3_usehttps, String imageInstallPath, String primaryStorageUuid, String scriptPath) {
+ String s3_usehttps, String imageInstallPath, String primaryStorageUuid, String scriptPath,
+ String hypervisor) {
this.hostGuid = hostuuid;
this.hostGateway = gateway;
this.hostCidr = cidr;
@@ -86,6 +91,7 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
this.primaryStorageUrl = primaryStorage;
this.primaryStorageUuid = primaryStorageUuid;
this.imageInstallPath = imageInstallPath;
+ this.hypervisor = HypervisorType.getType(hypervisor);
this.setSecondaryStorage(secondaryStorage);
// set S3 parameters
this.s3AccessKey = s3_accessKey;
@@ -180,5 +186,13 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
this.scriptPath = scriptPath;
}
+ public HypervisorType getHypervisor() {
+ return hypervisor;
+ }
+
+ public void setHypervisor(HypervisorType hypervisor) {
+ this.hypervisor = hypervisor;
+ }
+
}
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
index ac5a69d413e..c11da3d8078 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
@@ -50,6 +50,7 @@ import com.cloud.host.HostVO;
import com.cloud.host.Status.Event;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
import com.cloud.hypervisor.vmware.VmwareServerDiscoverer;
import com.cloud.hypervisor.xen.resource.XcpOssResource;
import com.cloud.resource.ServerResource;
@@ -122,6 +123,16 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
} catch (ConfigurationException e) {
logger.debug("Failed to load resource:" + e.toString());
}
+ } else if (host.getHypervisorType() == HypervisorType.KVM) {
+ resource = new LibvirtComputingResource();
+ try {
+ params.put("public.network.device", "cloudbr0");
+ params.put("private.network.device", "cloudbr0");
+ resource.configure(host.getName(), params);
+ } catch (ConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
} else if (host.getHypervisorType() == HypervisorType.VMware) {
ClusterVO cluster = clusterDao.findById(host.getClusterId());
String url = clusterDetailsDao.findDetail(cluster.getId(), "url").getValue();
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
index e772c821d83..d667a787353 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SnapshotTest.java
@@ -179,7 +179,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
podId = pod.getId();
//create xen cluster
ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
- cluster.setHypervisorType(HypervisorType.XenServer.toString());
+ cluster.setHypervisorType(this.getHypervisor().toString());
cluster.setClusterType(ClusterType.CloudManaged);
cluster.setManagedState(ManagedState.Managed);
cluster = clusterDao.persist(cluster);
@@ -197,7 +197,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
host.setPodId(podId);
host.setLastPinged(0);
host.setResourceState(ResourceState.Enabled);
- host.setHypervisorType(HypervisorType.XenServer);
+ host.setHypervisorType(this.getHypervisor());
host.setClusterId(cluster.getId());
host = hostDao.persist(host);
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
index c610e505367..76ce4044fb3 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
@@ -171,7 +171,7 @@ public class VolumeTest extends CloudStackTestNGBase {
podId = pod.getId();
//create xen cluster
ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
- cluster.setHypervisorType(HypervisorType.XenServer.toString());
+ cluster.setHypervisorType(this.getHypervisor().toString());
cluster.setClusterType(ClusterType.CloudManaged);
cluster.setManagedState(ManagedState.Managed);
cluster = clusterDao.persist(cluster);
@@ -189,7 +189,7 @@ public class VolumeTest extends CloudStackTestNGBase {
host.setPodId(podId);
host.setLastPinged(0);
host.setResourceState(ResourceState.Enabled);
- host.setHypervisorType(HypervisorType.XenServer);
+ host.setHypervisorType(this.getHypervisor());
host.setClusterId(cluster.getId());
host = hostDao.persist(host);
@@ -320,7 +320,7 @@ public class VolumeTest extends CloudStackTestNGBase {
return volume;
}
- //@Test
+ @Test
public void testCopyBaseImage() {
DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId();
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index 171de4c603c..072d14bf07a 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -209,10 +209,6 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
@Override
public boolean canHandle(Snapshot snapshot) {
- if (snapshot.getHypervisorType() == HypervisorType.XenServer) {
- return true;
- } else {
- return false;
- }
+ return true;
}
}
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index a32d0cce22e..747f337bafb 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -461,7 +461,7 @@ ServerResource {
}
protected String getDefaultDomrScriptsDir() {
- return "scripts/network/domr/kvm";
+ return "scripts/network/domr";
}
protected String getNetworkDirectSourceMode() {
@@ -682,7 +682,7 @@ ServerResource {
_localStorageUUID = (String) params.get("local.storage.uuid");
if (_localStorageUUID == null) {
- throw new ConfigurationException("local.storage.uuid is not set! Please set this to a valid UUID");
+ _localStorageUUID = UUID.nameUUIDFromBytes(_localStoragePath.getBytes()).toString();
}
value = (String) params.get("scripts.timeout");
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index c3fc0ec22a4..3bdf4287db0 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -142,7 +142,7 @@ public class KVMStorageProcessor implements StorageProcessor {
DataTO destData = cmd.getDestTO();
TemplateObjectTO template = (TemplateObjectTO)srcData;
DataStoreTO imageStore = template.getDataStore();
- VolumeObjectTO volume = (VolumeObjectTO)destData;
+ TemplateObjectTO volume = (TemplateObjectTO)destData;
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore();
if (!(imageStore instanceof NfsTO)) {
@@ -195,10 +195,10 @@ public class KVMStorageProcessor implements StorageProcessor {
KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(
tmplVol, UUID.randomUUID().toString(), primaryPool);
- VolumeObjectTO newVol = new VolumeObjectTO();
- newVol.setPath(primaryVol.getName());
- newVol.setSize(primaryVol.getSize());
- return new CopyCmdAnswer(newVol);
+ TemplateObjectTO newTemplate = new TemplateObjectTO();
+ newTemplate.setPath(primaryVol.getName());
+ newTemplate.setFormat(ImageFormat.QCOW2);
+ return new CopyCmdAnswer(newTemplate);
} catch (CloudRuntimeException e) {
return new CopyCmdAnswer(e.toString());
} finally {
@@ -273,14 +273,7 @@ public class KVMStorageProcessor implements StorageProcessor {
primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
primaryStore.getUuid());
- String templatePath = null;
- if (imageStore instanceof NfsTO) {
- NfsTO nfsImageStore = (NfsTO)imageStore;
- templatePath = nfsImageStore.getUrl();
- } else {
- s_logger.debug("Failed to create volume: ");
- return new CopyCmdAnswer("Unsupported protocol");
- }
+ String templatePath = template.getPath();
if(primaryPool.getType() == StoragePoolType.CLVM) {
vol = templateToPrimaryDownload(templatePath, primaryPool);
@@ -321,9 +314,9 @@ public class KVMStorageProcessor implements StorageProcessor {
DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO();
int wait = cmd.getWait();
- TemplateObjectTO template = (TemplateObjectTO)srcData;
+ TemplateObjectTO template = (TemplateObjectTO)destData;
DataStoreTO imageStore = template.getDataStore();
- VolumeObjectTO volume = (VolumeObjectTO)destData;
+ VolumeObjectTO volume = (VolumeObjectTO)srcData;
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore();
if (!(imageStore instanceof NfsTO)) {
@@ -425,7 +418,7 @@ public class KVMStorageProcessor implements StorageProcessor {
loc.save();
TemplateObjectTO newTemplate = new TemplateObjectTO();
- newTemplate.setPath(templateFolder + templateName + ".qcow2");
+ newTemplate.setPath(templateFolder + File.separator + templateName + ".qcow2");
return new CopyCmdAnswer(newTemplate);
} catch (Exception e) {
s_logger.debug("Failed to create template from volume: " + e.toString());
@@ -783,8 +776,9 @@ public class KVMStorageProcessor implements StorageProcessor {
@Override
public Answer createSnapshot(CreateObjectCommand cmd) {
- VolumeObjectTO volume = (VolumeObjectTO)cmd.getData();
- PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore();
+ SnapshotObjectTO snapshotTO = (SnapshotObjectTO)cmd.getData();
+ PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)snapshotTO.getDataStore();
+ VolumeObjectTO volume = snapshotTO.getVolume();
String snapshotName = UUID.randomUUID().toString();
String vmName = volume.getVmName();
try {
diff --git a/scripts/storage/qcow2/managesnapshot.sh b/scripts/storage/qcow2/managesnapshot.sh
index 29b7081290d..30148de66e7 100755
--- a/scripts/storage/qcow2/managesnapshot.sh
+++ b/scripts/storage/qcow2/managesnapshot.sh
@@ -48,7 +48,7 @@ is_lv() {
# And a logical volume
lvm lvs "${1}" > /dev/null 2>&1 && return 0
fi
- return 1
+ return 0
}
get_vg() {
diff --git a/utils/src/com/cloud/utils/script/Script.java b/utils/src/com/cloud/utils/script/Script.java
index 3632bf5ad1b..d3a35916eaf 100755
--- a/utils/src/com/cloud/utils/script/Script.java
+++ b/utils/src/com/cloud/utils/script/Script.java
@@ -450,7 +450,15 @@ public class Script implements Callable {
}
- file = new File(System.getProperty("paths.script") + File.separator + path + File.separator + script);
+ search = System.getProperty("paths.script");
+
+ search += File.separatorChar + path + File.separator;
+ do {
+ search = search.substring(0, search.lastIndexOf(File.separator));
+ file = new File(search + File.separator + script);
+ s_logger.debug("Looking for " + script + " in " + file.getAbsolutePath());
+ } while (!file.exists() && search.lastIndexOf(File.separator) != -1);
+
if (file.exists()) {
return file.getAbsolutePath();
}