Search in sources :

Example 1 with DeviceControllerException

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

the class NetworkDeviceController method zoneRollback.

/**
 * Rollback any of the zoning operations.
 *
 * @param exportGroupURI
 *            -- The ExportGroup URI
 * @param contextKey
 *            -- The context which indicates what zones were configured on the device.
 * @param taskId
 *            -- String task identifier for WorkflowTaskCompleter.
 * @return
 * @throws DeviceControllerException
 */
public boolean zoneRollback(URI exportGroupURI, String contextKey, String taskId) throws DeviceControllerException {
    TaskCompleter taskCompleter = null;
    try {
        NetworkFCContext context = (NetworkFCContext) WorkflowService.getInstance().loadStepData(contextKey);
        if (context == null) {
            _log.warn("No zone rollback information for Step: " + contextKey + " , Export Group: " + exportGroupURI.toString() + ", and Task: " + taskId + ". The zoning step either did not complete or encountered an error.");
            WorkflowStepCompleter.stepSucceded(taskId);
            return true;
        }
        logZones(context.getZoneInfos());
        WorkflowStepCompleter.stepExecuting(taskId);
        _log.info("Beginning zone rollback");
        _log.info("context.isAddingZones -{}", context.isAddingZones());
        // Determine what needs to be rolled back.
        List<NetworkFCZoneInfo> lastReferenceZoneInfo = new ArrayList<NetworkFCZoneInfo>();
        List<NetworkFCZoneInfo> rollbackList = new ArrayList<NetworkFCZoneInfo>();
        for (NetworkFCZoneInfo info : context.getZoneInfos()) {
            if (info.canBeRolledBack()) {
                // We should not blindly set last reference to true, removed code which does that earlier.
                rollbackList.add(info);
            } else {
                // Even though we cannot rollback the zone (because we didn't create it, it previously existed,
                // must remove the FCZoneReference that we created.
                deleteFCZoneReference(info);
            }
        }
        // Update the zone infos with the correct lastRef setting for those zones that can be rolled back
        _networkScheduler.determineIfLastZoneReferences(rollbackList);
        taskCompleter = new ZoneReferencesRemoveCompleter(NetworkUtil.getFCZoneReferences(rollbackList), context.isAddingZones(), taskId);
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_020);
        // Changed this parameter to true, so that the last reference validation runs all the time in placeZones()
        BiosCommandResult result = addRemoveZones(exportGroupURI, rollbackList, true);
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_021);
        if (result.isCommandSuccess() && !lastReferenceZoneInfo.isEmpty()) {
            _log.info("There seems to be last reference zones that were removed, clean those zones from the zoning map.");
            updateZoningMap(lastReferenceZoneInfo, exportGroupURI, null);
        }
        completeWorkflowState(taskCompleter, taskId, "ZoneRollback", result, null);
        return result.isCommandSuccess();
    } catch (Exception ex) {
        _log.error("Exception occurred while doing zone rollback", ex);
        ServiceError svcError = NetworkDeviceControllerException.errors.zoneRollbackFailedExc(exportGroupURI.toString(), ex);
        taskCompleter.error(_dbClient, svcError);
        WorkflowStepCompleter.stepFailed(taskId, svcError);
        return false;
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NetworkFCContext(com.emc.storageos.networkcontroller.NetworkFCContext) ZoneReferencesRemoveCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ZoneReferencesRemoveCompleter) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 2 with DeviceControllerException

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

the class AbstractBasicMaskingOrchestrator method exportGroupCreate.

/**
 * Create storage level masking components to support the requested
 * ExportGroup object. This operation will be flexible enough to take into
 * account initiators that are in some already existent in some
 * StorageGroup. In such a case, the underlying masking component will be
 * "adopted" by the ExportGroup. Further operations against the "adopted"
 * mask will only allow for addition and removal of those initiators/volumes
 * that were added by a Bourne request. Existing initiators/volumes will be
 * maintained.
 *
 * @param storageURI - URI referencing underlying storage array
 * @param exportGroupURI - URI referencing Bourne-level masking, ExportGroup
 * @param initiatorURIs - List of Initiator URIs
 * @param volumeMap - Map of Volume URIs to requested Integer URI
 * @param token - Identifier for operation
 * @throws Exception
 */
@Override
public void exportGroupCreate(URI storageURI, URI exportGroupURI, List<URI> initiatorURIs, Map<URI, Integer> volumeMap, String token) throws Exception {
    ExportOrchestrationTask taskCompleter = null;
    try {
        BlockStorageDevice device = getDevice();
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
        logExportGroup(exportGroup, storageURI);
        if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
            _log.info("export_create: initiator list non-empty");
            // Set up workflow steps.
            Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupCreate", true, token);
            // Create two steps, one for Zoning, one for the ExportGroup actions.
            // This step is for zoning. It is not specific to a single
            // NetworkSystem, as it will look at all the initiators and targets and compute
            // the zones required (which might be on multiple NetworkSystems.)
            String zoningStep = generateDeviceSpecificZoningCreateWorkflow(workflow, null, exportGroup, null, volumeMap);
            boolean createdSteps = determineExportGroupCreateSteps(workflow, zoningStep, device, storage, exportGroup, initiatorURIs, volumeMap, false, token);
            if (createdSteps) {
                // Execute the plan and allow the WorkflowExecutor to fire the
                // taskCompleter.
                String successMessage = String.format("ExportGroup successfully applied for StorageArray %s", storage.getLabel());
                workflow.executePlan(taskCompleter, successMessage);
            } else {
                _log.info("export_create: no steps created");
                taskCompleter.ready(_dbClient);
            }
        } else {
            _log.info("export_create: initiator list empty, no steps to create");
            taskCompleter.ready(_dbClient);
        }
    } catch (DeviceControllerException dex) {
        if (taskCompleter != null) {
            taskCompleter.error(_dbClient, DeviceControllerException.errors.vmaxExportGroupCreateError(dex.getMessage()));
        }
    } catch (Exception ex) {
        _log.error("ExportGroup Orchestration failed.", ex);
        // TODO add service code here
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(ex.getMessage(), ex);
            taskCompleter.error(_dbClient, serviceError);
        }
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Workflow(com.emc.storageos.workflow.Workflow) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with DeviceControllerException

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

the class AbstractMaskingFirstOrchestrator method exportGroupCreate.

/**
 * Create storage level masking components to support the requested
 * ExportGroup object. This operation will be flexible enough to take into
 * account initiators that are in some already existent in some
 * StorageGroup. In such a case, the underlying masking component will be
 * "adopted" by the ExportGroup. Further operations against the "adopted"
 * mask will only allow for addition and removal of those initiators/volumes
 * that were added by a Bourne request. Existing initiators/volumes will be
 * maintained.
 *
 * @param storageURI - URI referencing underlying storage array
 * @param exportGroupURI - URI referencing Bourne-level masking, ExportGroup
 * @param initiatorURIs - List of Initiator URIs
 * @param volumeMap - Map of Volume URIs to requested Integer URI
 * @param token - Identifier for operation
 * @throws Exception
 */
@Override
public void exportGroupCreate(URI storageURI, URI exportGroupURI, List<URI> initiatorURIs, Map<URI, Integer> volumeMap, String token) throws Exception {
    ExportOrchestrationTask taskCompleter = null;
    try {
        BlockStorageDevice device = getDevice();
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
        if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
            _log.info("export_create: initiator list non-empty");
            createWorkFlowAndSubmitForExportGroupCreate(initiatorURIs, volumeMap, token, taskCompleter, device, exportGroup, storage);
        } else {
            _log.info("export_create: initiator list is empty");
            taskCompleter.ready(_dbClient);
        }
    } catch (DeviceControllerException dex) {
        if (taskCompleter != null) {
            taskCompleter.error(_dbClient, DeviceControllerException.errors.vmaxExportGroupCreateError(dex.getMessage()));
        }
    } catch (Exception ex) {
        _log.error("ExportGroup Orchestration failed.", ex);
        // TODO add service code here
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(ex.getMessage(), ex);
            taskCompleter.error(_dbClient, serviceError);
        }
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with DeviceControllerException

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

the class DCNMDialog method addZonesStrategy.

/**
 * Given a dialog, add one or more zones to the active zoneset of the specified vsan.
 * This method is callable from with Bourne or from MDSDialogTest for stand-alone testing.
 * For now the only type of zone members supported are pwwn.
 *
 * @param zones - List of zones to be created. Zone names will be overwritten.
 * @param vsanId - Integer vsanId
 * @return list of zone names that were added
 * @throws ControllerException
 */
public List<String> addZonesStrategy(List<Zone> zones, Integer vsanId) throws Exception {
    List<String> addedZoneNames = new ArrayList<String>();
    boolean inSession = false;
    boolean commit = true;
    CIMObjectPath zonesetServicePath = getZoneService(vsanId.toString());
    if (zonesetServicePath == null) {
        throw new DeviceControllerException("Couldn't locate ZoneSetService vsan: " + vsanId);
    }
    CIMInstance zonesetService = _client.getInstance(zonesetServicePath, false, false, null);
    try {
        // Start a session.
        inSession = startSession(_client, zonesetService);
        // Get the existing zones in the active zoneset.
        // XXX FIXME: Need to account for creating the zoneset if none exists.
        List<Zoneset> zonesets = getZonesets(vsanId);
        if (zonesets == null || zonesets.isEmpty()) {
            throw new DeviceControllerException("no zonesets");
        }
        Zoneset activeZoneset = zonesets.get(0);
        if (activeZoneset.getActive() != true) {
            throw new DeviceControllerException("no active zoneset");
        }
        for (Zone zone : zones) {
            CIMObjectPath zonePath = addZone(_client, zonesetService, ((CIMObjectPath) activeZoneset.getCimObjectPath()), zone.getName());
        }
    } finally {
        // Commit session.
        if (inSession) {
            endSession(_client, zonesetService, commit);
        }
    }
    return addedZoneNames;
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMInstance(javax.cim.CIMInstance)

Example 5 with DeviceControllerException

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

the class AixHostDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    AixSystem aix = getCli(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : aix.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 : aix.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) AixSystem(com.emc.aix.AixSystem) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CommandException(com.iwave.ext.command.CommandException) JSchException(com.jcraft.jsch.JSchException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

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