Search in sources :

Example 1 with Ovm3ResourceException

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

the class Ovm3HypervisorSupport method masterCheck.

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

Example 2 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 3 with Ovm3ResourceException

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

the class Ovm3HypervisorNetwork method isNetworkSetupByName.

/**/
private boolean isNetworkSetupByName(String nameTag) {
    if (nameTag != null) {
        LOGGER.debug("Looking for network setup by name " + nameTag);
        try {
            Network net = new Network(c);
            net.getInterfaceList();
            if (net.getBridgeByName(nameTag) != null) {
                LOGGER.debug("Found bridge with name: " + nameTag);
                return true;
            }
        } catch (Ovm3ResourceException e) {
            LOGGER.debug("Unxpected error looking for name: " + nameTag, e);
            return false;
        }
    }
    LOGGER.debug("No bridge with name: " + nameTag);
    return false;
}
Also used : Network(com.cloud.hypervisor.ovm3.objects.Network) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Example 4 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 5 with Ovm3ResourceException

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

the class Ovm3StoragePool method execute.

/**
 * Gets statistics for storage.
 *
 * @param cmd
 * @return
 */
public GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
    LOGGER.debug("Getting stats for: " + cmd.getStorageId());
    try {
        Linux host = new Linux(c);
        Linux.FileSystem fs = host.getFileSystemByUuid(cmd.getStorageId(), "nfs");
        StoragePlugin store = new StoragePlugin(c);
        String propUuid = store.deDash(cmd.getStorageId());
        String mntUuid = cmd.getStorageId();
        if (store == null || propUuid == null || mntUuid == null || fs == null) {
            String msg = "Null returned when retrieving stats for " + cmd.getStorageId();
            LOGGER.error(msg);
            return new GetStorageStatsAnswer(cmd, msg);
        }
        /* or is it mntUuid ish ? */
        StorageDetails sd = store.storagePluginGetFileSystemInfo(propUuid, mntUuid, fs.getHost(), fs.getDevice());
        /*
             * FIXME: cure me or kill me, this needs to trigger a reinit of
             * primary storage, actually the problem is more deeprooted, as when
             * the hypervisor reboots it looses partial context and needs to be
             * reinitiated.... actually a full configure round... how to trigger
             * that ?
             */
        if ("".equals(sd.getSize())) {
            String msg = "No size when retrieving stats for " + cmd.getStorageId();
            LOGGER.debug(msg);
            return new GetStorageStatsAnswer(cmd, msg);
        }
        long total = Long.parseLong(sd.getSize());
        long used = total - Long.parseLong(sd.getFreeSize());
        return new GetStorageStatsAnswer(cmd, total, used);
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("GetStorageStatsCommand for " + cmd.getStorageId() + " failed", e);
        return new GetStorageStatsAnswer(cmd, e.getMessage());
    }
}
Also used : GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) Linux(com.cloud.hypervisor.ovm3.objects.Linux) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) StorageDetails(com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails) StoragePlugin(com.cloud.hypervisor.ovm3.objects.StoragePlugin)

Aggregations

Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)42 Linux (com.cloud.hypervisor.ovm3.objects.Linux)13 CloudstackPlugin (com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)10 Test (org.junit.Test)10 Answer (com.cloud.agent.api.Answer)9 DataTO (com.cloud.agent.api.to.DataTO)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