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());
}
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;
}
}
Aggregations