use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorNetwork method createVlanBridge.
private String createVlanBridge(String networkName, Integer vlanId) throws Ovm3ResourceException {
if (vlanId < 1 || vlanId > 4094) {
String msg = "Incorrect vlan " + vlanId + ", needs to be between 1 and 4094";
LOGGER.error(msg);
throw new CloudRuntimeException(msg);
}
Network net = new Network(c);
/* figure out if our bridged vlan exists, if not then create */
String brName = networkName + "." + vlanId.toString();
try {
String physInterface = net.getPhysicalByBridgeName(networkName);
if (net.getInterfaceByName(brName) == null) {
net.startOvsVlanBridge(brName, physInterface, vlanId);
} else {
LOGGER.debug("Interface " + brName + " already exists");
}
} catch (Ovm3ResourceException e) {
String msg = "Unable to create vlan " + vlanId.toString() + " bridge for " + networkName;
LOGGER.warn(msg + ": " + e);
throw new CloudRuntimeException(msg + ":" + e.getMessage());
}
return brName;
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3StorageProcessor method backupSnapshot.
/**
* use the cache, or the normal nfs, also delete the leftovers for us
* also contains object store storage in xenserver.
*/
@Override
public CopyCmdAnswer backupSnapshot(CopyCommand cmd) {
LOGGER.debug("execute backupSnapshot: " + cmd.getClass());
try {
DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO();
SnapshotObjectTO src = (SnapshotObjectTO) srcData;
SnapshotObjectTO dest = (SnapshotObjectTO) destData;
// src.getPath contains the uuid of the snapshot.
String srcFile = getVirtualDiskPath(src.getPath(), src.getDataStore().getUuid());
// destination
String storeUrl = dest.getDataStore().getUrl();
String secPoolUuid = pool.setupSecondaryStorage(storeUrl);
String destDir = config.getAgentSecStoragePath() + "/" + secPoolUuid + "/" + dest.getPath();
String destFile = destDir + "/" + src.getPath();
destFile = destFile.concat(".raw");
// copy
Linux host = new Linux(c);
CloudstackPlugin csp = new CloudstackPlugin(c);
csp.ovsMkdirs(destDir);
LOGGER.debug("CopyFrom: " + srcData.getObjectType() + "," + srcFile + " to " + destData.getObjectType() + "," + destFile);
host.copyFile(srcFile, destFile);
StoragePlugin sp = new StoragePlugin(c);
sp.storagePluginDestroy(secPoolUuid, srcFile);
SnapshotObjectTO newSnap = new SnapshotObjectTO();
// newSnap.setPath(destFile);
// damnit frickin crap, no reference whatsoever... could use parent ?
newSnap.setPath(dest.getPath() + "/" + src.getPath() + ".raw");
newSnap.setParentSnapshotPath(null);
return new CopyCmdAnswer(newSnap);
} catch (Ovm3ResourceException e) {
String msg = "Error backupSnapshot: " + e.getMessage();
LOGGER.info(msg);
return new CopyCmdAnswer(msg);
}
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3StorageProcessor method createVolumeFromSnapshot.
/**
* SnapshotObjectTO secondary to VolumeObjectTO primary in xenserver,
*/
@Override
public Answer createVolumeFromSnapshot(CopyCommand cmd) {
LOGGER.debug("execute createVolumeFromSnapshot: " + cmd.getClass());
try {
DataTO srcData = cmd.getSrcTO();
DataStoreTO srcStore = srcData.getDataStore();
NfsTO srcImageStore = (NfsTO) srcStore;
// source, should contain snap dir/filename
SnapshotObjectTO srcSnap = (SnapshotObjectTO) srcData;
String secPoolUuid = pool.setupSecondaryStorage(srcImageStore.getUrl());
String srcFile = config.getAgentSecStoragePath() + "/" + secPoolUuid + "/" + srcSnap.getPath();
// dest
DataTO destData = cmd.getDestTO();
VolumeObjectTO destVol = (VolumeObjectTO) destData;
String primaryPoolUuid = destData.getDataStore().getUuid();
String destFile = getVirtualDiskPath(destVol.getUuid(), ovmObject.deDash(primaryPoolUuid));
Linux host = new Linux(c);
host.copyFile(srcFile, destFile);
VolumeObjectTO newVol = new VolumeObjectTO();
newVol.setUuid(destVol.getUuid());
// newVol.setPath(destFile);
newVol.setPath(destVol.getUuid());
newVol.setFormat(ImageFormat.RAW);
return new CopyCmdAnswer(newVol);
/* we assume the cache for templates is local */
} catch (Ovm3ResourceException e) {
LOGGER.debug("Failed to createVolumeFromSnapshot: ", e);
return new CopyCmdAnswer(e.toString());
}
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3StorageProcessor method deleteVolume.
@Override
public Answer deleteVolume(DeleteCommand cmd) {
LOGGER.debug("execute deleteVolume: " + cmd.getClass());
DataTO data = cmd.getData();
VolumeObjectTO volume = (VolumeObjectTO) data;
try {
String poolUuid = data.getDataStore().getUuid();
String uuid = volume.getUuid();
String path = getVirtualDiskPath(uuid, poolUuid);
StoragePlugin sp = new StoragePlugin(c);
sp.storagePluginDestroy(poolUuid, path);
LOGGER.debug("Volume deletion success: " + path);
} catch (Ovm3ResourceException e) {
LOGGER.info("Volume deletion failed: " + e.toString(), e);
return new CreateObjectAnswer(e.toString());
}
return new Answer(cmd);
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3VmSupportTest method PrepareForMigrationCommandTest.
@Test
public void PrepareForMigrationCommandTest() throws ConfigurationException, Ovm3ResourceException {
hypervisor = support.prepare(configTest.getParams());
PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(hyperTest.createVm(xen.getVmName()));
Answer ra = hypervisor.executeRequest(cmd);
results.basicBooleanTest(ra.getResult());
}
Aggregations