Search in sources :

Example 6 with NetworkFCContext

use of com.emc.storageos.networkcontroller.NetworkFCContext in project coprhd-controller by CoprHD.

the class NetworkDeviceController method doZoneExportMasksCreate.

/**
 * Handles ExportGroup / ExportMask create, as well as add volume
 *
 * @param exportGroup
 * @param exportMaskURIs
 * @param volumeURIs
 * @param token
 * @param checkZones Flag to enable or disable zoning check on a Network System
 * @return
 */
private boolean doZoneExportMasksCreate(ExportGroup exportGroup, List<URI> exportMaskURIs, Collection<URI> volumeURIs, String token, boolean checkZones) {
    BiosCommandResult result = null;
    NetworkFCContext context = new NetworkFCContext();
    try {
        if (!checkZoningRequired(token, exportGroup.getVirtualArray())) {
            return true;
        }
        volumeURIs = removeDuplicateURIs(volumeURIs);
        // to update any at all, in which case we can success out.
        if (exportMaskURIs == null || exportMaskURIs.isEmpty()) {
            WorkflowStepCompleter.stepSucceded(token);
            return true;
        }
        // Compute the zones for the ExportGroup
        // [hala] make sure we do not rollback existing zones
        Map<String, List<Zone>> zonesMap = new HashMap<String, List<Zone>>();
        if (checkZones) {
            zonesMap = getExistingZonesMap(exportMaskURIs, token);
        }
        List<NetworkFCZoneInfo> zones = _networkScheduler.getZoningTargetsForExportMasks(exportGroup, exportMaskURIs, volumeURIs, zonesMap, checkZones, _dbClient);
        context.getZoneInfos().addAll(zones);
        logZones(zones);
        // If there are no zones to do, we were successful.
        if (!checkZones) {
            if (!context.getZoneInfos().isEmpty()) {
                String[] newOrExisting = new String[1];
                for (NetworkFCZoneInfo zoneInfo : context.getZoneInfos()) {
                    addZoneReference(exportGroup.getId(), zoneInfo, newOrExisting);
                }
            }
            result = BiosCommandResult.createSuccessfulResult();
        } else {
            // Now call addZones to add all the required zones.
            InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_047);
            result = addRemoveZones(exportGroup.getId(), context.getZoneInfos(), false);
            InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_048);
        }
        // Save our zone infos in case we want to rollback.
        WorkflowService.getInstance().storeStepData(token, context);
        // Update the workflow state.
        completeWorkflowState(null, token, "zoneExportMaskCreate", result, null);
    } catch (Exception ex) {
        _log.error("Exception zoning Export Masks", ex);
        // Save our zone infos in case we want to rollback.
        WorkflowService.getInstance().storeStepData(token, context);
        ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportGroupCreateFailed(ex.getMessage(), ex);
        WorkflowStepCompleter.stepFailed(token, svcError);
    }
    return (result != null && result.isCommandSuccess());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) HashMap(java.util.HashMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetworkFCContext(com.emc.storageos.networkcontroller.NetworkFCContext) 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 7 with NetworkFCContext

use of com.emc.storageos.networkcontroller.NetworkFCContext in project coprhd-controller by CoprHD.

the class NetworkDeviceController method zoneExportAddInitiators.

/**
 * Handles zoning for ExportGroup.exportAddInitiator() call.
 * This call adds zones for each of the initiators in the exportMasksToInitiators map.
 * The ports are determined from the ExportMask:
 * 1) if the ExportMask.zoningMap has an entry for an initiator, the ports are taken
 * from there, otherwise
 * 2) the ports are taken from ExportMask.storagePorts.
 * Note: these arguments (except token) must match zoneExportAddInitiatorsMethod above.
 * This routine executes as a Workflow Step.
 *
 * @param exportGroup -- Used for the zone references.
 * @param exportMasksToInitiators - Map of ExportMap URI to list of Initiator URIs
 * @param token Workflow step id
 * @return true if success, false otherwise
 * @throws ControllerException
 */
public boolean zoneExportAddInitiators(URI exportGroupURI, Map<URI, List<URI>> exportMasksToInitiators, String token) throws ControllerException {
    NetworkFCContext context = new NetworkFCContext();
    boolean status = false;
    ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
    _log.info(String.format("Entering zoneExportAddInitiators for ExportGroup: %s (%s)", exportGroup.getLabel(), exportGroup.getId()));
    try {
        if (!checkZoningRequired(token, exportGroup.getVirtualArray())) {
            return true;
        }
        // get existing zones on the switch
        Map<String, List<Zone>> zonesMap = getExistingZonesMap(exportMasksToInitiators.keySet(), token);
        // Compute zones that are required.
        List<NetworkFCZoneInfo> zoneInfos = _networkScheduler.getZoningTargetsForInitiators(exportGroup, exportMasksToInitiators, zonesMap, _dbClient);
        context.getZoneInfos().addAll(zoneInfos);
        logZones(zoneInfos);
        // If there are no zones to do, we were successful.
        if (context.getZoneInfos().isEmpty()) {
            WorkflowStepCompleter.stepSucceded(token);
            return true;
        }
        // Now call addZones to add all the required zones.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_058);
        BiosCommandResult result = addRemoveZones(exportGroup.getId(), context.getZoneInfos(), false);
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_059);
        status = result.isCommandSuccess();
        // Save our zone infos in case we want to rollback.
        WorkflowService.getInstance().storeStepData(token, context);
        // Update the workflow state.
        completeWorkflowState(null, token, "zoneExportAddInitiators", result, null);
        return status;
    } catch (Exception ex) {
        _log.error("Exception zoning add initiators", ex);
        ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportAddInitiatorsFailed(ex.getMessage(), ex);
        WorkflowStepCompleter.stepFailed(token, svcError);
        return status;
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetworkFCContext(com.emc.storageos.networkcontroller.NetworkFCContext) 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)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 NetworkFCContext (com.emc.storageos.networkcontroller.NetworkFCContext)7 NetworkFCZoneInfo (com.emc.storageos.networkcontroller.NetworkFCZoneInfo)7 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)7 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)7 ArrayList (java.util.ArrayList)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)3 ZoneReferencesRemoveCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ZoneReferencesRemoveCompleter)3 URI (java.net.URI)3 List (java.util.List)3 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)2 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)1 HashMap (java.util.HashMap)1