Search in sources :

Example 26 with Ovm3ResourceException

use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.

the class Ovm3StoragePool method prepareForPool.

/**
     * Prepare a host to become part of a pool, the roles and ownership are
     * important here.
     *
     * @return
     * @throws ConfigurationException
     */
public boolean prepareForPool() throws ConfigurationException {
    /* need single master uuid */
    try {
        Linux host = new Linux(c);
        Pool pool = new Pool(c);
        /* setup pool and role, needs utility to be able to do things */
        if (host.getServerRoles().contentEquals(pool.getValidRoles().toString())) {
            LOGGER.info("Server role for host " + config.getAgentHostname() + " is ok");
        } else {
            setRoles(pool);
        }
        if (host.getMembershipState().contentEquals("Unowned")) {
            if (host.getOvmVersion().startsWith("3.2.")) {
                takeOwnership(pool);
            } else if (host.getOvmVersion().startsWith("3.3.")) {
                takeOwnership33x(pool);
            }
        } else {
            if (host.getManagerUuid().equals(config.getAgentOwnedByUuid())) {
                String msg = "Host " + config.getAgentHostname() + " owned by us";
                LOGGER.debug(msg);
                return true;
            } else {
                String msg = "Host " + config.getAgentHostname() + " already part of a pool, and not owned by us";
                LOGGER.error(msg);
                throw new ConfigurationException(msg);
            }
        }
    } catch (ConfigurationException | Ovm3ResourceException es) {
        String msg = "Failed to prepare " + config.getAgentHostname() + " for pool: " + es.getMessage();
        LOGGER.error(msg);
        throw new ConfigurationException(msg);
    }
    return true;
}
Also used : Linux(com.cloud.hypervisor.ovm3.objects.Linux) ConfigurationException(javax.naming.ConfigurationException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) Pool(com.cloud.hypervisor.ovm3.objects.Pool)

Example 27 with Ovm3ResourceException

use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.

the class Ovm3StoragePool method takeOwnership.

/**
     * If you don't own the host you can't fiddle with it.
     *
     * @param pool
     * @throws ConfigurationException
     */
private void takeOwnership(Pool pool) throws ConfigurationException {
    try {
        LOGGER.debug("Take ownership of host " + config.getAgentHostname());
        pool.takeOwnership(config.getAgentOwnedByUuid(), "");
    } catch (Ovm3ResourceException e) {
        String msg = "Failed to take ownership of host " + config.getAgentHostname();
        LOGGER.error(msg);
        throw new ConfigurationException(msg);
    }
}
Also used : ConfigurationException(javax.naming.ConfigurationException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Example 28 with Ovm3ResourceException

use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.

the class Ovm3StoragePool method execute.

/**
     * Get a host out of a pool/cluster, this should unmount all FSs though.
     *
     * @param cmd
     * @return
     */
public Answer execute(DeleteStoragePoolCommand cmd) {
    try {
        Pool pool = new Pool(c);
        pool.leaveServerPool(cmd.getPool().getUuid());
    /* also connect to the master and update the pool list ? */
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("Delete storage pool on host " + config.getAgentHostname() + " failed, however, we leave to user for cleanup and tell managment server it succeeded", e);
    }
    return new Answer(cmd);
}
Also used : ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) Answer(com.cloud.agent.api.Answer) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) Pool(com.cloud.hypervisor.ovm3.objects.Pool)

Example 29 with Ovm3ResourceException

use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.

the class StoragePluginTest method testNFSStorageMountCreation.

@Test
public void testNFSStorageMountCreation() throws Ovm3ResourceException {
    con.setResult(results.simpleResponseWrapWrapper(NFSMOUNTRESPONSEXML));
    StorageDetails sd = sPt.storagePluginMountNFS(NFSHOST, NFSPATH, FSMNTUUID, NFSMNT);
    con.setResult(results.simpleResponseWrapWrapper(NFSMOUNTRESPONSEXML));
    NFSMNT = NFSMNT + "/" + FSMNTUUID;
    sd = sPt.storagePluginMountNFS(NFSHOST, NFSPATH, FSMNTUUID, NFSMNT);
    results.basicLongTest(Long.valueOf(sd.getSize()), 263166853120L);
    results.basicLongTest(Long.valueOf(sd.getFreeSize()), 259377299456L);
    results.basicStringTest(sd.getName(), "nfs:" + NFSPATH);
    results.basicStringTest(sd.getUuid(), FSPROPUUID);
    results.basicStringTest(sd.getDetailsRelationalUuid(), FSMNTUUID);
}
Also used : StorageDetails(com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails) Test(org.junit.Test)

Example 30 with Ovm3ResourceException

use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.

the class Ovm3HypervisorResourceTest method createVm.

public VirtualMachineTO createVm(String vmName) throws Ovm3ResourceException {
    con = support.prepConnectionResults();
    Xen vdata = new Xen(con);
    Xen.Vm vm = vdata.getVmConfig(vmName);
    vdata.listVm(xen.getRepoId(), xen.getVmId());
    // Ovm3VmGuestTypes types = new Ovm3VmGuestTypes();
    Long id = 1L;
    String instanceName = vm.getVmName();
    VirtualMachine.Type type = Type.User;
    // vm.getVmCpus();
    int cpus = 1;
    Integer speed = 0;
    long minRam = vm.getVmMemory();
    long maxRam = vm.getVmMemory();
    BootloaderType bootloader = BootloaderType.PyGrub;
    String os = "Oracle Enterprise Linux 6.0 (64-bit)";
    boolean enableHA = true;
    boolean limitCpuUse = false;
    String vncPassword = "gobbeldygoo";
    // public StartCommand(VirtualMachineTO vm, Host host, boolean
    // executeInSequence) {
    // ./api/src/com/cloud/agent/api/to/VirtualMachineTO.java
    VirtualMachineTO vmspec = new VirtualMachineTO(id, instanceName, type, cpus, speed, minRam, maxRam, bootloader, os, enableHA, limitCpuUse, vncPassword);
    vmspec.setBootArgs("");
    addDisksToSpec(vmspec, vm.getVmDisks());
    addNicsToSpec(vmspec, vm.getVmVifs());
    return vmspec;
}
Also used : Xen(com.cloud.hypervisor.ovm3.objects.Xen) Type(com.cloud.vm.VirtualMachine.Type) BootloaderType(com.cloud.template.VirtualMachineTemplate.BootloaderType) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) VirtualMachine(com.cloud.vm.VirtualMachine)

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