Search in sources :

Example 1 with CompatibilityException

use of com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException in project coprhd-controller by CoprHD.

the class LinuxHostDiscoveryAdapter method discoverHost.

@Override
protected void discoverHost(Host host, HostStateChange changes) {
    validateHost(host);
    List<LinuxVersion> versions = getVersions(host);
    LinuxVersion version = findVersion(versions);
    host.setOsVersion(version.toString());
    if (getVersionValidator().isValidLinuxVersion(version)) {
        host.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
        save(host);
        super.discoverHost(host, changes);
        try {
            checkMultipathSoftwareCompatibility(host);
        } catch (CompatibilityException e) {
            host.setCompatibilityStatus(CompatibilityStatus.INCOMPATIBLE.name());
            save(host);
        }
    } else {
        host.setCompatibilityStatus(CompatibilityStatus.INCOMPATIBLE.name());
        save(host);
        throw ComputeSystemControllerException.exceptions.incompatibleLinuxHostVersion(getSupportedType(), version.toString(), getVersionValidator().getSuSELinuxMinimumVersion(false).toString(), getVersionValidator().getRedhatLinuxMinimumVersion(false).toString());
    }
}
Also used : CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) LinuxVersion(com.iwave.ext.linux.model.LinuxVersion)

Example 2 with CompatibilityException

use of com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException in project coprhd-controller by CoprHD.

the class LinuxHostDiscoveryAdapter method checkMultipathSoftwareCompatibility.

private void checkMultipathSoftwareCompatibility(Host host) {
    LinuxSystemCLI cli = createLinuxCLI(host);
    String powerpathMessage = null;
    String multipathMessage = null;
    try {
        PowermtCheckRegistrationCommand command = new PowermtCheckRegistrationCommand();
        cli.executeCommand(command, SecureShellSupport.SHORT_TIMEOUT);
        // powerpath is installed
        LOG.info("PowerPath is installed");
        return;
    } catch (PowerPathException e) {
        powerpathMessage = e.getMessage();
        LOG.info("PowerPath is unavailable: " + powerpathMessage);
    } catch (Exception e) {
        LOG.info("Error while checking for powerpath: " + e.getMessage(), e);
    }
    try {
        MultipathCommand command = new MultipathCommand();
        command.addArgument("-l");
        cli.executeCommand(command, SecureShellSupport.SHORT_TIMEOUT);
        // multipath is installed
        LOG.info("Multipath is installed");
        return;
    } catch (MultipathException e) {
        multipathMessage = e.getMessage();
        LOG.info("Multipath is unavailable: " + multipathMessage);
    } catch (Exception e) {
        LOG.info("Error while checking for multipath: " + e.getMessage(), e);
    }
    throw new CompatibilityException("No multipath software available: \n" + powerpathMessage + "\n" + multipathMessage);
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) PowermtCheckRegistrationCommand(com.iwave.ext.linux.command.powerpath.PowermtCheckRegistrationCommand) MultipathCommand(com.iwave.ext.linux.command.MultipathCommand) MultipathException(com.iwave.ext.linux.command.MultipathException) PowerPathException(com.iwave.ext.linux.command.powerpath.PowerPathException) MultipathException(com.iwave.ext.linux.command.MultipathException) PowerPathException(com.iwave.ext.linux.command.powerpath.PowerPathException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) CommandException(com.iwave.ext.command.CommandException) JSchException(com.jcraft.jsch.JSchException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 3 with CompatibilityException

use of com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException in project coprhd-controller by CoprHD.

the class ComputeSystemDiscoveryEngine method discoverInLock.

/**
 * Performs the discovery, within a lock.
 *
 * @param targetId
 *            the ID of the target to discover.
 */
protected void discoverInLock(String targetId) {
    DiscoveredSystemObject target = modelClient.findById(URI.create(targetId));
    if (target == null) {
        LOG.error("Could not find: " + targetId);
        throw ComputeSystemControllerException.exceptions.targetNotFound(targetId);
    }
    ComputeSystemDiscoveryAdapter adapter = getDiscoveryAdapter(targetId);
    if (adapter != null) {
        if (LOG.isInfoEnabled()) {
            LOG.info("Discovering target " + target.getLabel() + " [" + targetId + "]");
        }
        try {
            adapter.discoverTarget(targetId);
            if (LOG.isInfoEnabled()) {
                LOG.info("Discovery completed for " + target.getLabel() + " [" + targetId + "]");
            }
        } catch (CompatibilityException e) {
            String errorMessage = adapter.getErrorMessage(e);
            LOG.error("Device is incompatible: " + target.getLabel() + " [" + targetId + "]: " + errorMessage);
            adapter.discoveryFailure(target, DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name(), errorMessage);
            throw e;
        } catch (RuntimeException e) {
            String errorMessage = adapter.getErrorMessage(e);
            LOG.error("Discovery failed for " + target.getLabel() + " [" + targetId + "]: " + errorMessage, e);
            adapter.discoveryFailure(target, DiscoveredDataObject.CompatibilityStatus.UNKNOWN.name(), errorMessage);
            throw ComputeSystemControllerException.exceptions.discoverFailed(targetId, e);
        }
    } else {
        LOG.warn("No discovery adapter for target " + target.getLabel() + " [" + targetId + "]");
        target.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.UNKNOWN.name());
        dbClient.persistObject(target);
        throw ComputeSystemControllerException.exceptions.discoveryAdapterNotFound(target.getLabel(), targetId);
    }
}
Also used : CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject)

Aggregations

CompatibilityException (com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException)3 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)1 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 CommandException (com.iwave.ext.command.CommandException)1 LinuxSystemCLI (com.iwave.ext.linux.LinuxSystemCLI)1 MultipathCommand (com.iwave.ext.linux.command.MultipathCommand)1 MultipathException (com.iwave.ext.linux.command.MultipathException)1 PowerPathException (com.iwave.ext.linux.command.powerpath.PowerPathException)1 PowermtCheckRegistrationCommand (com.iwave.ext.linux.command.powerpath.PowermtCheckRegistrationCommand)1 LinuxVersion (com.iwave.ext.linux.model.LinuxVersion)1 JSchException (com.jcraft.jsch.JSchException)1