Search in sources :

Example 51 with Ovm3ResourceException

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

the class Ovm3HypervisorSupport method fillHostInfo.

/**
     * fillHostInfo: Startup the routing for the host.
     *
     * @param cmd
     */
public void fillHostInfo(StartupRoutingCommand cmd) {
    try {
        /* get data we need from parts */
        Linux host = new Linux(c);
        if (!host.getOvmVersion().startsWith("3.2.") && !host.getOvmVersion().startsWith("3.3.")) {
            LOGGER.error("Hypervisor not supported: " + host.getOvmVersion());
            throw new CloudRuntimeException("OVM 3.2. or 3.3. are only supported, not " + host.getOvmVersion());
        } else {
            LOGGER.debug("Hypervisor version: " + host.getOvmVersion());
        }
        cmd.setName(host.getHostName());
        cmd.setSpeed(host.getCpuKhz());
        cmd.setCpus(host.getTotalThreads());
        cmd.setCpuSockets(host.getCpuSockets());
        cmd.setMemory(host.getMemory().longValue());
        BigInteger totalmem = BigInteger.valueOf(host.getMemory().longValue());
        BigInteger freemem = BigInteger.valueOf(host.getFreeMemory().longValue());
        cmd.setDom0MinMemory(totalmem.subtract(freemem).longValue());
        // setPoolSync and setCaps.
        cmd.setGuid(config.getCsHostGuid());
        cmd.setDataCenter(config.getAgentZoneId().toString());
        cmd.setPod(config.getAgentPodId().toString());
        /* TODO: cmd.setOwner(host.getManagerUuid()); */
        cmd.setCluster(config.getAgentClusterId().toString());
        cmd.setHypervisorVersion(host.getOvmVersion());
        cmd.setVersion(host.getAgentVersion());
        cmd.setHypervisorType(HypervisorType.Ovm3);
        cmd.setCaps(host.getCapabilities());
        cmd.setPrivateIpAddress(c.getIp());
        cmd.setStorageIpAddress(c.getIp());
        Network net = new Network(c);
        String defaultBridge = net.getBridgeByIp(c.getIp()).getName();
        if (defaultBridge == null) {
            throw new CloudRuntimeException("Unable to obtain valid bridge with " + c.getIp());
        }
        if (config.getAgentPublicNetworkName() == null) {
            config.setAgentPublicNetworkName(defaultBridge);
        }
        if (config.getAgentPrivateNetworkName() == null) {
            config.setAgentPrivateNetworkName(config.getAgentPublicNetworkName());
        }
        if (config.getAgentGuestNetworkName() == null) {
            config.setAgentGuestNetworkName(config.getAgentPublicNetworkName());
        }
        if (config.getAgentStorageNetworkName() == null) {
            config.setAgentStorageNetworkName(config.getAgentPrivateNetworkName());
        }
        Map<String, String> d = cmd.getHostDetails();
        d.put("public.network.device", config.getAgentPublicNetworkName());
        d.put("private.network.device", config.getAgentPrivateNetworkName());
        d.put("guest.network.device", config.getAgentGuestNetworkName());
        d.put("storage.network.device", config.getAgentStorageNetworkName());
        d.put("ismaster", config.getAgentIsMaster().toString());
        d.put("hasmaster", config.getAgentHasMaster().toString());
        cmd.setHostDetails(d);
        LOGGER.debug("Add an Ovm3 host " + config.getAgentHostname() + ":" + cmd.getHostDetails());
    } catch (Ovm3ResourceException e) {
        throw new CloudRuntimeException("Ovm3ResourceException: " + e.getMessage(), e);
    }
}
Also used : Linux(com.cloud.hypervisor.ovm3.objects.Linux) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Network(com.cloud.hypervisor.ovm3.objects.Network) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) BigInteger(java.math.BigInteger)

Example 52 with Ovm3ResourceException

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

the class Ovm3HypervisorResourceTest method createVmTest.

@Test
public void createVmTest() throws ConfigurationException, Ovm3ResourceException {
    VirtualMachineTO vmspec = createVm(vmName);
    hypervisor = vmActionPreparation();
    StartCommand cmd = new StartCommand(vmspec, getHost(hypervisor.getName()), true);
    Answer ra = hypervisor.executeRequest(cmd);
    results.basicBooleanTest(ra.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) StartCommand(com.cloud.agent.api.StartCommand) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) Test(org.junit.Test) CloudStackPluginTest(com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest) NetworkTest(com.cloud.hypervisor.ovm3.objects.NetworkTest) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 53 with Ovm3ResourceException

use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException 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)

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