Search in sources :

Example 6 with DeviceControllerException

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

the class AixVioDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    AixVioCLI cli = getCli(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : cli.listInitiators()) {
            Initiator initiator;
            String wwpn = SanUtils.normalizeWWN(hba.getWwpn());
            if (findInitiatorByPort(oldInitiators, wwpn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
            }
            discoverFCInitiator(host, initiator, hba);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list FC Ports, skipping");
    }
    try {
        for (String iqn : cli.listIQNs()) {
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, iqn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
            }
            discoverISCSIInitiator(host, initiator, iqn);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list iSCSI Ports, skipping");
    }
    // update export groups with new initiators if host is in use.
    if (!addedInitiators.isEmpty()) {
        Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
        changes.setNewInitiators(addedInitiatorIds);
    }
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) Initiator(com.emc.storageos.db.client.model.Initiator) AixVioCLI(com.emc.aix.AixVioCLI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CommandException(com.iwave.ext.command.CommandException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 7 with DeviceControllerException

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

the class CephMaskingOrchestrator method exportGroupDelete.

@Override
public void exportGroupDelete(URI storageURI, URI exportGroupURI, String token) throws Exception {
    ExportOrchestrationTask taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
    try {
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        List<ExportMask> masks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storageURI);
        if (masks != null && !masks.isEmpty()) {
            Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupDelete", true, token, taskCompleter);
            Map<URI, Integer> volumeMap = ExportUtils.getExportGroupVolumeMap(_dbClient, storage, exportGroup);
            List<URI> volumeURIs = new ArrayList<>(volumeMap.keySet());
            List<URI> initiatorURIs = StringSetUtil.stringSetToUriList(exportGroup.getInitiators());
            Map<URI, Map<URI, Integer>> exportMaskToVolumeCount = ExportMaskUtils.mapExportMaskToVolumeShareCount(_dbClient, volumeURIs, initiatorURIs);
            for (ExportMask exportMask : masks) {
                List<URI> exportGroupURIs = new ArrayList<>();
                if (!ExportUtils.isExportMaskShared(_dbClient, exportMask.getId(), exportGroupURIs)) {
                    _log.info(String.format("Adding step to delete ExportMask %s", exportMask.getMaskName()));
                    generateExportMaskDeleteWorkflow(workflow, null, storage, exportGroup, exportMask, null, null, taskCompleter);
                } else {
                    Map<URI, Integer> volumeToExportGroupCount = exportMaskToVolumeCount.get(exportMask.getId());
                    List<URI> volumesToRemove = new ArrayList<>();
                    for (URI uri : volumeMap.keySet()) {
                        if (volumeToExportGroupCount == null) {
                            continue;
                        }
                        // Remove the volume only if it is not shared with
                        // more than 1 ExportGroup
                        Integer numExportGroupsVolumeIsIn = volumeToExportGroupCount.get(uri);
                        if (numExportGroupsVolumeIsIn != null && numExportGroupsVolumeIsIn == 1) {
                            volumesToRemove.add(uri);
                        }
                    }
                    if (!volumesToRemove.isEmpty()) {
                        _log.info(String.format("Adding step to remove volumes %s from ExportMask %s", Joiner.on(',').join(volumesToRemove), exportMask.getMaskName()));
                        generateExportMaskRemoveVolumesWorkflow(workflow, null, storage, exportGroup, exportMask, volumesToRemove, null, taskCompleter);
                    }
                }
            }
            String successMessage = String.format("ExportGroup delete successfully completed for StorageArray %s", storage.getLabel());
            workflow.executePlan(taskCompleter, successMessage);
        } else {
            taskCompleter.ready(_dbClient);
        }
    } catch (DeviceControllerException dex) {
        taskCompleter.error(_dbClient, DeviceControllerErrors.ceph.operationFailed("exportGroupDelete", dex.getMessage()));
    } catch (Exception ex) {
        _log.error("ExportGroup Orchestration failed.", ex);
        taskCompleter.error(_dbClient, DeviceControllerErrors.ceph.operationFailed("exportGroupDelete", ex.getMessage()));
    }
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) HashMap(java.util.HashMap) Map(java.util.Map) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 8 with DeviceControllerException

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

the class ExternalDeviceExportOperations method removeVolumes.

@Override
public void removeVolumes(StorageSystem storage, URI exportMaskUri, List<URI> volumeUris, List<com.emc.storageos.db.client.model.Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} removeVolumes START...", storage.getSerialNumber());
    try {
        log.info("removeVolumes: Export mask id: {}", exportMaskUri);
        log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumeUris));
        if (initiatorList != null) {
            log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
        }
        BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
        ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
        StringSet maskInitiators = exportMask.getInitiators();
        List<String> maskInitiatorList = new ArrayList<>();
        for (String initiatorUri : maskInitiators) {
            maskInitiatorList.add(initiatorUri);
        }
        log.info("Export mask existing initiators: {} ", Joiner.on(",").join(maskInitiatorList));
        // Prepare volumes. We send to driver only new volumes for the export mask.
        List<StorageVolume> driverVolumes = new ArrayList<>();
        prepareVolumes(storage, volumeUris, driverVolumes);
        // Prepare initiators
        Set<com.emc.storageos.db.client.model.Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(dbClient, exportMask, null);
        List<Initiator> driverInitiators = new ArrayList<>();
        // Get export group uri from task completer
        URI exportGroupUri = taskCompleter.getId();
        ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
        prepareInitiators(initiators, exportGroup.forCluster(), driverInitiators);
        // Ready to call driver
        DriverTask task = driver.unexportVolumesFromInitiators(driverInitiators, driverVolumes);
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("Removed volumes from export: %s.", task.getMessage());
            log.info(msg);
            taskCompleter.ready(dbClient);
        } else {
            String errorMsg = String.format("Failed to remove volumes from export mask: %s .", task.getMessage());
            log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.deleteVolumesFromExportMaskFailed("removeVolumes", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception ex) {
        log.error("Problem in removeVolumes: ", ex);
        String errorMsg = String.format("Failed to remove volumes from export mask: %s .", ex.getMessage());
        log.error(errorMsg);
        ServiceError serviceError = ExternalDeviceException.errors.deleteVolumesFromExportMaskFailed("removeVolumes", errorMsg);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} removeVolumes END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 9 with DeviceControllerException

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

the class MirrorFileFailbackTaskCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        setDbClient(dbClient);
        recordMirrorOperation(dbClient, OperationTypeEnum.FAILBACK_FILE_MIRROR, status, getId());
    } catch (Exception e) {
        _log.error("Failed updating status. MirrorSessionFailback {}, for task " + getOpId(), getId(), e);
    } finally {
        if (Operation.Status.error.equals(status)) {
            FileShare fileshare = dbClient.queryObject(FileShare.class, getId());
            fileshare.setMirrorStatus(MirrorStatus.FAILED_OVER.name());
            dbClient.updateObject(fileshare);
        }
        super.complete(dbClient, status, coded);
    }
}
Also used : FileShare(com.emc.storageos.db.client.model.FileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 10 with DeviceControllerException

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

the class HDSExportOperations method removeInitiators.

@Override
public void removeInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<Initiator> initiators, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
    long startTime = System.currentTimeMillis();
    log.info("{} removeInitiator START...", storage.getSerialNumber());
    try {
        log.info("removeInitiator: Export mask id: {}", exportMaskURI);
        if (volumeURIList != null) {
            log.info("removeInitiator: volumes : {}", Joiner.on(',').join(volumeURIList));
        }
        log.info("removeInitiator: initiators : {}", Joiner.on(',').join(initiators));
        log.info("removeInitiator: targets : {}", Joiner.on(',').join(targets));
        if (null == initiators || initiators.isEmpty()) {
            log.info("No initiators found to remove {}", exportMaskURI);
            taskCompleter.ready(dbClient);
            return;
        }
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        // Get the context from the task completer, in case this is a rollback.
        boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
        ExportMaskValidationContext ctx = new ExportMaskValidationContext();
        ctx.setStorage(storage);
        ctx.setExportMask(exportMask);
        ctx.setBlockObjects(volumeURIList, dbClient);
        ctx.setInitiators(initiators);
        // Allow exceptions to be thrown when not rolling back
        ctx.setAllowExceptions(!isRollback);
        AbstractHDSValidator removeInitiatorFromMaskValidator = (AbstractHDSValidator) validator.removeInitiators(ctx);
        removeInitiatorFromMaskValidator.validate();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
        String systemObjectID = HDSUtils.getSystemObjectID(storage);
        StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
        if (null != deviceDataMap && !deviceDataMap.isEmpty()) {
            Set<String> hsdObjectIDSet = deviceDataMap.keySet();
            for (String hsdObjectID : hsdObjectIDSet) {
                HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectID);
                if (null == hsd) {
                    log.warn("Not able to remove initiators as HSD {} couldn't find on array.", hsdObjectID);
                    continue;
                }
                List<String> fcInitiators = getFCInitiatorsExistOnHSD(hsd, initiators);
                List<String> iSCSIInitiators = getISCSIInitiatorsExistOnHSD(hsd, initiators);
                boolean isLastFCInitiator = (fcInitiators.size() == 1 && null != hsd.getWwnList() && hsd.getWwnList().size() == fcInitiators.size());
                boolean isLastISCSIInitiator = (iSCSIInitiators.size() == 1 && null != hsd.getIscsiList() && hsd.getIscsiList().size() == iSCSIInitiators.size());
                // If Initiator is last one, remove the HSD
                if (isLastFCInitiator || isLastISCSIInitiator) {
                    exportMgr.deleteHostStorageDomain(systemObjectID, hsd.getObjectID(), storage.getModel());
                    exportMask.getDeviceDataMap().remove(hsd.getObjectID());
                } else {
                    if (null != fcInitiators && !fcInitiators.isEmpty()) {
                        // remove FC initiators from HSD.
                        exportMgr.deleteWWNsFromHostStorageDomain(systemObjectID, hsd.getObjectID(), fcInitiators, storage.getModel());
                    }
                    if (null != iSCSIInitiators && !iSCSIInitiators.isEmpty()) {
                        // remove ISCSInames from HSD.
                        exportMgr.deleteISCSIsFromHostStorageDomain(systemObjectID, hsd.getObjectID(), iSCSIInitiators, storage.getModel());
                    }
                }
            }
            dbClient.updateObject(exportMask);
            // update the task status after processing all HSD's.
            taskCompleter.ready(dbClient);
        } else {
            log.info("No Host groups found on exportMask {}", exportMaskURI);
            // No HSD's found in exportMask.
            taskCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error(String.format("removeInitiator failed - maskURI: %s", exportMaskURI.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailedOpMsg(ResourceOperationTypeEnum.DELETE_EXPORT_INITIATOR.getName(), e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        long totalTime = System.currentTimeMillis() - startTime;
        log.info(String.format("findExportMasks took %f seconds", (double) totalTime / (double) 1000));
    }
    log.info("{} removeInitiator END...", storage.getSerialNumber());
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) AbstractHDSValidator(com.emc.storageos.volumecontroller.impl.validators.hds.AbstractHDSValidator) ExportMask(com.emc.storageos.db.client.model.ExportMask) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)393 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 URI (java.net.URI)157 Volume (com.emc.storageos.db.client.model.Volume)115 ArrayList (java.util.ArrayList)115 WBEMException (javax.wbem.WBEMException)113 CIMObjectPath (javax.cim.CIMObjectPath)104 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)85 ExportMask (com.emc.storageos.db.client.model.ExportMask)83 CIMArgument (javax.cim.CIMArgument)81 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)75 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)63 BlockObject (com.emc.storageos.db.client.model.BlockObject)55 HashMap (java.util.HashMap)54 Initiator (com.emc.storageos.db.client.model.Initiator)52 HashSet (java.util.HashSet)52 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)48 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)46 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)46 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)43