CLOUDSTACK-2970: wait is in seconds in command

This commit is contained in:
Edison Su 2013-06-14 17:57:34 -07:00
parent 619ec12f61
commit 34f6538454
3 changed files with 14 additions and 18 deletions

View File

@ -16,19 +16,18 @@
// under the License.
package com.cloud.hypervisor.kvm.resource;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.libvirt.Connect;
import org.libvirt.LibvirtException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
public class LibvirtConnection {
private static final Logger s_logger = Logger
.getLogger(LibvirtConnection.class);
private static final Logger s_logger = Logger.getLogger(LibvirtConnection.class);
static private Map<String, Connect> _connections = new HashMap<String, Connect>();
static private Connect _connection;
@ -48,8 +47,7 @@ public class LibvirtConnection {
try {
conn.getVersion();
} catch (LibvirtException e) {
s_logger.debug("Connection with libvirtd is broken, due to "
+ e.getMessage());
s_logger.debug("Connection with libvirtd is broken, due to " + e.getMessage());
conn = new Connect(hypervisorURI, false);
_connections.put(hypervisorURI, conn);
}
@ -59,17 +57,16 @@ public class LibvirtConnection {
}
static public Connect getConnectionByVmName(String vmName) throws LibvirtException {
HypervisorType[] hypervisors = new HypervisorType[] {HypervisorType.KVM, Hypervisor.HypervisorType.LXC};
HypervisorType[] hypervisors = new HypervisorType[] { HypervisorType.KVM, Hypervisor.HypervisorType.LXC };
for (HypervisorType hypervisor : hypervisors) {
try {
Connect conn = LibvirtConnection.getConnectionByType(hypervisor.toString());
if (conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName.getBytes())) != null) {
if (conn.domainLookupByName(vmName) != null) {
return conn;
}
} catch (Exception e) {
s_logger.debug("can't find connection: " + hypervisor.toString() + ", for vm: " + vmName + ", continue");
s_logger.debug("can't find connection: " + hypervisor.toString() + ", for vm: " + vmName + ", continue");
}
}

View File

@ -329,7 +329,7 @@ public class KVMStorageProcessor implements StorageProcessor {
String templateName = UUID.randomUUID().toString();
if (primary.getType() != StoragePoolType.RBD) {
Script command = new Script(_createTmplPath, wait, s_logger);
Script command = new Script(_createTmplPath, wait * 1000, s_logger);
command.add("-f", disk.getPath());
command.add("-t", tmpltPath);
command.add("-n", templateName + ".qcow2");
@ -407,7 +407,6 @@ public class KVMStorageProcessor implements StorageProcessor {
public Answer backupSnasphot(CopyCommand cmd) {
DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO();
int wait = cmd.getWait();
SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO) snapshot.getDataStore();
SnapshotObjectTO destSnapshot = (SnapshotObjectTO) destData;
@ -440,7 +439,7 @@ public class KVMStorageProcessor implements StorageProcessor {
KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
primaryStore.getUuid());
KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(volumePath);
Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger);
Script command = new Script(_manageSnapshotPath, cmd.getWait() * 1000, s_logger);
command.add("-b", snapshotDisk.getPath());
command.add("-n", snapshotName);
command.add("-p", snapshotDestPath);

View File

@ -27,10 +27,10 @@ usage() {
#set -x
qemu_img="cloud-qemu-img"
which $qemu_img
which $qemu_img >& /dev/null
if [ $? -gt 0 ]
then
which qemu-img
which qemu-img >& /dev/null
if [ $? -eq 0 ]
then
qemu_img="qemu-img"