Search in sources :

Example 1 with ComputeSystemControllerException

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

the class LinuxMountUtils method unmountPath.

public void unmountPath(String path) throws InternalException {
    UnmountCommand command = new UnmountCommand(STD_TIMEOUT);
    command.setPath(path);
    command.addArgument("; if [ $? -eq 124 ] ; then >&2 echo TIMEOUT ; else >&2 echo SUCCESSFUL ; fi");
    _log.info("unmount command:" + command.getResolvedCommandLine());
    cli.executeCommand(command);
    CommandOutput output = command.getOutput();
    if (output.getStderr().contains("TIMEOUT")) {
        ComputeSystemControllerException exception = ComputeSystemControllerException.exceptions.commandTimedOut(host.getHostName());
        throw exception;
    } else {
        String errMessage = output.getStderr().replace("SUCCESSFUL", "").replace("\n", "");
        if (!errMessage.isEmpty()) {
            ComputeSystemControllerException exception = ComputeSystemControllerException.exceptions.unableToUnmount(host.getHostName(), new Exception(errMessage));
            throw exception;
        }
    }
}
Also used : ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) UnmountCommand(com.iwave.ext.linux.command.UnmountCommand) CommandOutput(com.iwave.ext.command.CommandOutput) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 2 with ComputeSystemControllerException

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

the class EsxHostDiscoveryAdapter method checkDuplicateHost.

/**
 * Check if the host already exists in VIPR
 *
 * @param host - {@link Host} instance being discovered / added.
 * @param targetHost {@link Host} instance from VIPR DB.
 */
private void checkDuplicateHost(Host host, Host targetHost) {
    if (targetHost != null && !(host.getId().equals(targetHost.getId()))) {
        ComputeSystemControllerException ex = ComputeSystemControllerException.exceptions.duplicateSystem("Host", targetHost.getLabel());
        DiscoveryStatusUtils.markAsFailed(modelClient, host, ex.getMessage(), ex);
        throw ex;
    }
}
Also used : ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 3 with ComputeSystemControllerException

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

the class UcsDiscoveryWorker method discoverComputeSystem.

public void discoverComputeSystem(URI computeSystemURI) {
    String ucsmVersion;
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemURI);
    _log.info("Inside discoverComputeSystems of class : " + getClass().toString());
    URL ucsmURL = getUcsmURL(cs);
    List<ComputeBlade> computeBlades;
    List<LsServer> allServiceProfiles;
    Map<String, LsServer> associatedLsServers;
    List<LsServer> serviceProfileTemplates;
    List<VnicLanConnTempl> vnicTemplates;
    List<VnicSanConnTempl> vhbaTemplates;
    Map<String, FcPIo> uplinkMap;
    Map<String, SwFcSanEp> fcInterfaceMap;
    List<SwVsan> vsanList;
    Map<String, SwFcSanPc> portChannelMap;
    List<FabricVlan> vlanList;
    List<FabricVsan> vsanFabricList;
    List<com.emc.cloud.platform.ucs.out.model.LsbootPolicy> bootPolicies;
    try {
        ucsmVersion = ucsmService.getDeviceVersion(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        verifyVersion(cs, ucsmVersion);
        computeBlades = ucsmService.getComputeBlades(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        allServiceProfiles = ucsmService.getAllServiceProfiles(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        associatedLsServers = ucsmService.getAllAssociatedLsServers(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        serviceProfileTemplates = ucsmService.getServiceProfileTemplates(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        bootPolicies = ucsmService.getBootPolicies(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vnicTemplates = ucsmService.getVnicTemplates(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vhbaTemplates = ucsmService.getVhbaTemplates(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        uplinkMap = ucsmService.getFICUplinkPorts(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        fcInterfaceMap = ucsmService.getSwitchFCInterfaces(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vsanList = ucsmService.getUcsSwitchVSans(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        portChannelMap = ucsmService.getUplinkPortChannels(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vlanList = ucsmService.getUcsVlans(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vsanFabricList = ucsmService.getUcsFabricVsans(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
    } catch (Exception e) {
        _log.error("Failed to pull device data: " + cs.getId(), e);
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            cs.setLastDiscoveryStatusMessage(e.getCause().getMessage());
        } else {
            cs.setLastDiscoveryStatusMessage(e.getMessage());
        }
        _dbClient.updateObject(cs);
        throw ComputeSystemControllerException.exceptions.discoverFailed(computeSystemURI.toString(), e);
    }
    try {
        reconcileServiceProfileTemplates(cs, serviceProfileTemplates);
        reconcileServiceProfiles(cs, allServiceProfiles);
        reconcileComputeBlades(cs, computeBlades, associatedLsServers);
        reconcileVhbas(cs, associatedLsServers, new VhbaHelper(vsanFabricList));
        reconcileServiceProfileTemplatesHBAs(cs, serviceProfileTemplates, new VhbaHelper(vsanFabricList));
        reconcileServiceProfileTemplatesVnics(cs, serviceProfileTemplates);
        reconcileServiceProfileTemplatesBootDefinitions(cs, serviceProfileTemplates);
        reconcileBootPolicies(cs, bootPolicies);
        reconcileVnicTemplates(cs, vnicTemplates);
        reconcileVhbaTemplates(cs, vhbaTemplates);
        Map<String, Set<String>> unpinnedVsans = getUnpinnedVSans(vsanList, fcInterfaceMap);
        reconcileUplinkPorts(cs, uplinkMap, fcInterfaceMap, unpinnedVsans);
        reconcileUplinkPortChannels(cs, portChannelMap, unpinnedVsans);
        reconcileVlans(cs, vlanList);
        associateComputeImageServer(cs);
        matchComputeBladesToHosts(cs);
        cs.setLastDiscoveryRunTime(Calendar.getInstance().getTimeInMillis());
        cs.setSuccessDiscoveryTime(Calendar.getInstance().getTimeInMillis());
        cs.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.name());
    } catch (ComputeSystemControllerException e) {
        cs.setLastDiscoveryStatusMessage(e.getMessage());
        throw ComputeSystemControllerException.exceptions.discoverFailed(cs.getId().toString(), e);
    } finally {
        _dbClient.persistObject(cs);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) ComputeBlade(com.emc.cloud.platform.ucs.out.model.ComputeBlade) FabricVsan(com.emc.cloud.platform.ucs.out.model.FabricVsan) FabricVlan(com.emc.cloud.platform.ucs.out.model.FabricVlan) URL(java.net.URL) FcPIo(com.emc.cloud.platform.ucs.out.model.FcPIo) VnicLanConnTempl(com.emc.cloud.platform.ucs.out.model.VnicLanConnTempl) SwVsan(com.emc.cloud.platform.ucs.out.model.SwVsan) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) LsbootPolicy(com.emc.cloud.platform.ucs.out.model.LsbootPolicy) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) VnicSanConnTempl(com.emc.cloud.platform.ucs.out.model.VnicSanConnTempl) SwFcSanPc(com.emc.cloud.platform.ucs.out.model.SwFcSanPc) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) MalformedURLException(java.net.MalformedURLException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) SwFcSanEp(com.emc.cloud.platform.ucs.out.model.SwFcSanEp)

Example 4 with ComputeSystemControllerException

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

the class LinuxMountUtils method mountPath.

public void mountPath(String path) throws InternalException {
    MountCommand command = new MountCommand(STD_TIMEOUT);
    command.setPath(path);
    command.addArgument("; if [ $? -eq 124 ] ; then >&2 echo TIMEOUT ; else >&2 echo SUCCESSFUL ; fi");
    _log.info("mount command:" + command.getResolvedCommandLine());
    cli.executeCommand(command);
    CommandOutput output = command.getOutput();
    if (output.getStderr().contains("TIMEOUT")) {
        ComputeSystemControllerException exception = ComputeSystemControllerException.exceptions.commandTimedOut(host.getHostName());
        throw exception;
    } else {
        String errMessage = output.getStderr().replace("SUCCESSFUL", "").replace("\n", "");
        if (!errMessage.isEmpty()) {
            ComputeSystemControllerException exception = ComputeSystemControllerException.exceptions.unableToMount(host.getHostName(), new Exception(errMessage));
            throw exception;
        }
    }
}
Also used : ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) MountCommand(com.iwave.ext.linux.command.MountCommand) CommandOutput(com.iwave.ext.command.CommandOutput) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 5 with ComputeSystemControllerException

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

the class AbstractHostDiscoveryAdapter method checkDuplicateHost.

protected void checkDuplicateHost(Host host, String nativeGuid) {
    if (nativeGuid != null && !nativeGuid.isEmpty()) {
        for (Host existingHost : modelClient.hosts().findByNativeGuid(nativeGuid, true)) {
            if (!existingHost.getId().equals(host.getId())) {
                ComputeSystemControllerException ex = ComputeSystemControllerException.exceptions.duplicateSystem("Host", existingHost.getLabel());
                DiscoveryStatusUtils.markAsFailed(modelClient, host, ex.getMessage(), ex);
                throw ex;
            }
        }
    }
}
Also used : ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) Host(com.emc.storageos.db.client.model.Host)

Aggregations

ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)8 Host (com.emc.storageos.db.client.model.Host)3 HostDeviceInputOutput (com.emc.storageos.computesystemcontroller.hostmountadapters.HostDeviceInputOutput)2 MountCompleter (com.emc.storageos.computesystemcontroller.hostmountadapters.MountCompleter)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 Workflow (com.emc.storageos.workflow.Workflow)2 CommandOutput (com.iwave.ext.command.CommandOutput)2 ComputeBlade (com.emc.cloud.platform.ucs.out.model.ComputeBlade)1 FabricVlan (com.emc.cloud.platform.ucs.out.model.FabricVlan)1 FabricVsan (com.emc.cloud.platform.ucs.out.model.FabricVsan)1 FcPIo (com.emc.cloud.platform.ucs.out.model.FcPIo)1 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)1 LsbootPolicy (com.emc.cloud.platform.ucs.out.model.LsbootPolicy)1 SwFcSanEp (com.emc.cloud.platform.ucs.out.model.SwFcSanEp)1 SwFcSanPc (com.emc.cloud.platform.ucs.out.model.SwFcSanPc)1 SwVsan (com.emc.cloud.platform.ucs.out.model.SwVsan)1 VnicLanConnTempl (com.emc.cloud.platform.ucs.out.model.VnicLanConnTempl)1 VnicSanConnTempl (com.emc.cloud.platform.ucs.out.model.VnicSanConnTempl)1 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)1