Search in sources :

Example 16 with Ovm3ResourceException

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;
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Network(com.cloud.hypervisor.ovm3.objects.Network) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Example 17 with Ovm3ResourceException

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);
    }
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) DataTO(com.cloud.agent.api.to.DataTO) Linux(com.cloud.hypervisor.ovm3.objects.Linux) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin) StoragePlugin(com.cloud.hypervisor.ovm3.objects.StoragePlugin) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer)

Example 18 with Ovm3ResourceException

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());
    }
}
Also used : SnapshotObjectTO(org.apache.cloudstack.storage.to.SnapshotObjectTO) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) DataTO(com.cloud.agent.api.to.DataTO) Linux(com.cloud.hypervisor.ovm3.objects.Linux) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) NfsTO(com.cloud.agent.api.to.NfsTO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer)

Example 19 with Ovm3ResourceException

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);
}
Also used : CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) ResignatureAnswer(org.apache.cloudstack.storage.command.ResignatureAnswer) Answer(com.cloud.agent.api.Answer) CreatePrivateTemplateAnswer(com.cloud.agent.api.storage.CreatePrivateTemplateAnswer) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) SnapshotAndCopyAnswer(org.apache.cloudstack.storage.command.SnapshotAndCopyAnswer) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) DataTO(com.cloud.agent.api.to.DataTO) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) StoragePlugin(com.cloud.hypervisor.ovm3.objects.StoragePlugin)

Example 20 with Ovm3ResourceException

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());
}
Also used : Answer(com.cloud.agent.api.Answer) PrepareForMigrationCommand(com.cloud.agent.api.PrepareForMigrationCommand) Test(org.junit.Test) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) CloudStackPluginTest(com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) Ovm3HypervisorResourceTest(com.cloud.hypervisor.ovm3.resources.Ovm3HypervisorResourceTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest)

Aggregations

Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)41 Linux (com.cloud.hypervisor.ovm3.objects.Linux)13 Test (org.junit.Test)10 Answer (com.cloud.agent.api.Answer)9 DataTO (com.cloud.agent.api.to.DataTO)9 CloudstackPlugin (com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)9 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)8 StoragePlugin (com.cloud.hypervisor.ovm3.objects.StoragePlugin)7 Xen (com.cloud.hypervisor.ovm3.objects.Xen)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)7 ConfigurationException (javax.naming.ConfigurationException)6 ConnectionTest (com.cloud.hypervisor.ovm3.objects.ConnectionTest)5 Pool (com.cloud.hypervisor.ovm3.objects.Pool)5 XenTest (com.cloud.hypervisor.ovm3.objects.XenTest)5 XmlTestResultTest (com.cloud.hypervisor.ovm3.objects.XmlTestResultTest)5 Ovm3SupportTest (com.cloud.hypervisor.ovm3.support.Ovm3SupportTest)5 CreateObjectAnswer (org.apache.cloudstack.storage.command.CreateObjectAnswer)5 SnapshotObjectTO (org.apache.cloudstack.storage.to.SnapshotObjectTO)5 CopyVolumeAnswer (com.cloud.agent.api.storage.CopyVolumeAnswer)4 VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)4