Search in sources :

Example 1 with PoolOCFS2

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

the class Ovm3StoragePool method setupPool.

/**
     * Setup a pool in general, this creates a repo if it doesn't exist yet, if
     * it does however we mount it.
     *
     * @param cmd
     * @return
     * @throws Ovm3ResourceException
     */
private Boolean setupPool(StorageFilerTO cmd) throws Ovm3ResourceException {
    String primUuid = cmd.getUuid();
    String ssUuid = ovmObject.deDash(primUuid);
    String fsType = "nfs";
    String clusterUuid = config.getAgentOwnedByUuid().substring(0, 15);
    String managerId = config.getAgentOwnedByUuid();
    String poolAlias = cmd.getHost() + ":" + cmd.getPath();
    String mountPoint = String.format("%1$s:%2$s", cmd.getHost(), cmd.getPath()) + "/VirtualMachines";
    Integer poolSize = 0;
    Pool poolHost = new Pool(c);
    PoolOCFS2 poolFs = new PoolOCFS2(c);
    if (config.getAgentIsMaster()) {
        try {
            LOGGER.debug("Create poolfs on " + config.getAgentHostname() + " for repo " + primUuid);
            /* double check if we're not overwritting anything here!@ */
            poolFs.createPoolFs(fsType, mountPoint, clusterUuid, primUuid, ssUuid, managerId);
        } catch (Ovm3ResourceException e) {
            throw e;
        }
        try {
            poolHost.createServerPool(poolAlias, primUuid, config.getOvm3PoolVip(), poolSize + 1, config.getAgentHostname(), c.getIp());
        } catch (Ovm3ResourceException e) {
            throw e;
        }
    } else if (config.getAgentHasMaster()) {
        try {
            poolHost.joinServerPool(poolAlias, primUuid, config.getOvm3PoolVip(), poolSize + 1, config.getAgentHostname(), c.getIp());
        } catch (Ovm3ResourceException e) {
            throw e;
        }
    }
    try {
        /* should contain check if we're in an OVM pool or not */
        CloudstackPlugin csp = new CloudstackPlugin(c);
        Boolean vip = csp.dom0CheckPort(config.getOvm3PoolVip(), 22, 60, 1);
        if (!vip) {
            throw new Ovm3ResourceException("Unable to reach Ovm3 Pool VIP " + config.getOvm3PoolVip());
        }
        /*
             * should also throw exception, we need to stop pool creation here,
             * or is the manual addition fine?
             */
        if (!addMembers()) {
            return false;
        }
    } catch (Ovm3ResourceException e) {
        throw new Ovm3ResourceException("Unable to add members to pool" + e.getMessage());
    }
    return true;
}
Also used : Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) PoolOCFS2(com.cloud.hypervisor.ovm3.objects.PoolOCFS2) Pool(com.cloud.hypervisor.ovm3.objects.Pool) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)

Aggregations

CloudstackPlugin (com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)1 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)1 Pool (com.cloud.hypervisor.ovm3.objects.Pool)1 PoolOCFS2 (com.cloud.hypervisor.ovm3.objects.PoolOCFS2)1