Search in sources :

Example 11 with CloudstackPlugin

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

the class Ovm3HypervisorSupport method primaryCheck.

/**
 * primaryCheck
 *
 * @return
 */
public boolean primaryCheck() {
    if ("".equals(config.getOvm3PoolVip())) {
        LOGGER.debug("No cluster vip, not checking for primary");
        return false;
    }
    try {
        CloudstackPlugin cSp = new CloudstackPlugin(c);
        if (cSp.dom0HasIp(config.getOvm3PoolVip())) {
            LOGGER.debug(config.getAgentHostname() + " is a primary, already has vip " + config.getOvm3PoolVip());
            config.setAgentIsPrimary(true);
        } else if (cSp.ping(config.getOvm3PoolVip())) {
            LOGGER.debug(config.getAgentHostname() + " has a primary, someone has vip " + config.getOvm3PoolVip());
            config.setAgentHasPrimary(true);
        } else {
            LOGGER.debug(config.getAgentHostname() + " becomes a primary, no one has vip " + config.getOvm3PoolVip());
            config.setAgentIsPrimary(true);
        }
    } catch (Ovm3ResourceException e) {
        LOGGER.debug(config.getAgentHostname() + " can't reach primary: " + e.getMessage());
        config.setAgentHasPrimary(false);
    }
    return config.getAgentIsPrimary();
}
Also used : Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)

Example 12 with CloudstackPlugin

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

the class Ovm3HypervisorResource method getCurrentStatus.

@Override
public PingCommand getCurrentStatus(long id) {
    try {
        /* feels useless somehow */
        Common test = new Common(c);
        String ping = "put";
        String pong = test.echo(ping);
        if (pong.contains(ping)) {
            hypervisorsupport.syncState();
            CloudstackPlugin cSp = new CloudstackPlugin(c);
            if (!cSp.dom0CheckStorageHealthCheck(configuration.getAgentScriptsDir(), configuration.getAgentCheckStorageScript(), configuration.getCsHostGuid(), configuration.getAgentStorageCheckTimeout(), configuration.getAgentStorageCheckInterval()) && !cSp.dom0CheckStorageHealthCheck()) {
                LOGGER.error("Storage health check not running on " + configuration.getAgentHostname());
            } else if (cSp.dom0CheckStorageHealthCheck()) {
                LOGGER.error("Storage health check started on " + configuration.getAgentHostname());
            } else {
                LOGGER.debug("Storage health check running on " + configuration.getAgentHostname());
            }
            return new PingRoutingCommand(getType(), id, hypervisorsupport.hostVmStateReport());
        } else {
            LOGGER.debug("Agent did not respond correctly: " + ping + " but got " + pong);
        }
    } catch (Ovm3ResourceException | NullPointerException e) {
        LOGGER.debug("Check agent status failed", e);
        return null;
    }
    return null;
}
Also used : PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin) Common(com.cloud.hypervisor.ovm3.objects.Common)

Example 13 with CloudstackPlugin

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

the class Ovm3VirtualRoutingResource method createFileInVR.

@Override
public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
    String error = null;
    logger.debug("createFileInVR via " + agentName + " on " + routerIp + ": " + path + "/" + filename + ", content: " + content);
    try {
        CloudstackPlugin cSp = new CloudstackPlugin(c);
        boolean result = cSp.ovsDomrUploadFile(routerIp, path, filename, content);
        return new ExecutionResult(result, "");
    } catch (Exception e) {
        error = e.getMessage();
        logger.warn("createFileInVR failed for " + path + "/" + filename + " in VR " + routerIp + " via " + agentName + ": " + error, e);
    }
    return new ExecutionResult(error == null, error);
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)

Example 14 with CloudstackPlugin

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

the class Ovm3HypervisorNetwork method configureNetworking.

public void configureNetworking() throws ConfigurationException {
    /* TODO: setup meta tags for the management interface (probably
        * required with multiple interfaces)?
        */
    try {
        Network net = new Network(c);
        String controlIface = config.getAgentControlNetworkName();
        if (controlIface != null && net.getInterfaceByName(controlIface) == null) {
            LOGGER.debug("starting " + controlIface);
            net.startOvsLocalConfig(controlIface);
            /* ovs replies too "fast" so the bridge can be "busy" */
            int contCount = 0;
            while (net.getInterfaceByName(controlIface) == null) {
                LOGGER.debug("waiting for " + controlIface);
                Thread.sleep(1 * 1000);
                if (contCount > 9) {
                    throw new ConfigurationException("Unable to configure " + controlIface + " on host " + config.getAgentHostname());
                }
                contCount++;
            }
        } else {
            LOGGER.debug("already have " + controlIface);
        }
        /*
            * The bridge is remembered upon reboot, but not the IP or the
            * config. Zeroconf also adds the route again by default.
            */
        net.ovsIpConfig(controlIface, "static", NetUtils.getLinkLocalGateway(), NetUtils.getLinkLocalNetMask());
        CloudstackPlugin cSp = new CloudstackPlugin(c);
        cSp.ovsControlInterface(controlIface, NetUtils.getLinkLocalCIDR());
    } catch (InterruptedException e) {
        LOGGER.error("interrupted?", e);
    } catch (Ovm3ResourceException e) {
        String msg = "Basic configuration failed on " + config.getAgentHostname();
        LOGGER.error(msg, e);
        throw new ConfigurationException(msg + ", " + e.getMessage());
    }
}
Also used : ConfigurationException(javax.naming.ConfigurationException) Network(com.cloud.hypervisor.ovm3.objects.Network) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)

Example 15 with CloudstackPlugin

use of com.cloud.hypervisor.ovm3.objects.CloudstackPlugin 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.getAgentIsPrimary()) {
        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.getAgentHasPrimary()) {
        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)16 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)13 ConfigurationException (javax.naming.ConfigurationException)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 CheckOnHostAnswer (com.cloud.agent.api.CheckOnHostAnswer)2 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)2 DataTO (com.cloud.agent.api.to.DataTO)2 Linux (com.cloud.hypervisor.ovm3.objects.Linux)2 ExecutionResult (com.cloud.utils.ExecutionResult)2 State (com.cloud.vm.VirtualMachine.State)2 IOException (java.io.IOException)2 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)2 SnapshotObjectTO (org.apache.cloudstack.storage.to.SnapshotObjectTO)2 Answer (com.cloud.agent.api.Answer)1 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)1 FenceAnswer (com.cloud.agent.api.FenceAnswer)1 GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)1 HostStatsEntry (com.cloud.agent.api.HostStatsEntry)1 MaintainAnswer (com.cloud.agent.api.MaintainAnswer)1 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)1