use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.
the class NetworkDeviceController method doZoneExportMasksDelete.
/**
* Remove ExportMasks or delete Volumes from ExportMasks.
*
* @param zoningParamss -- List of NetworkZoningParam block obtained from ExportMask
* @param volumeURIs -- Collection of all volumes being removed
* @param stepId - Step id.
* @return status -- true if success
*/
private boolean doZoneExportMasksDelete(List<NetworkZoningParam> zoningParams, Collection<URI> volumeURIs, String stepId) {
NetworkFCContext context = new NetworkFCContext();
TaskCompleter taskCompleter = null;
boolean status = false;
try {
if (zoningParams.isEmpty()) {
_log.info("zoningParams is empty, returning");
WorkflowStepCompleter.stepSucceded(stepId);
return true;
}
URI exportGroupId = zoningParams.get(0).getExportGroupId();
URI virtualArray = zoningParams.get(0).getVirtualArray();
if (!checkZoningRequired(stepId, virtualArray)) {
return true;
}
volumeURIs = removeDuplicateURIs(volumeURIs);
// Compute the zones for the ExportGroup
context.setAddingZones(false);
List<NetworkFCZoneInfo> zones = _networkScheduler.getZoningRemoveTargets(zoningParams, volumeURIs);
context.getZoneInfos().addAll(zones);
logZones(zones);
// If there are no zones to do, we were successful.
if (context.getZoneInfos().isEmpty()) {
_log.info("No zoning information provided.");
WorkflowStepCompleter.stepSucceded(stepId);
return true;
}
// Generate warning message if required.
String warningMessage = generateExistingZoneWarningMessages(context.getZoneInfos());
// 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()) {
rollbackList.add(info);
}
}
// Create a local completer to handle DB cleanup in the case of failure.
taskCompleter = new ZoneReferencesRemoveCompleter(NetworkUtil.getFCZoneReferences(context.getZoneInfos()), true, stepId);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_007);
// Now call removeZones to remove all the required zones.
BiosCommandResult result = addRemoveZones(exportGroupId, context.getZoneInfos(), true);
status = result.isCommandSuccess();
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_008);
List<URI> exportMaskURIs = new ArrayList<URI>();
for (NetworkZoningParam zoningParam : zoningParams) {
exportMaskURIs.add(zoningParam.getMaskId());
}
// if they still exist.
if (status && !lastReferenceZoneInfo.isEmpty()) {
_log.info("There seems to be last reference zones that were removed, clean those zones from the ExportMask zoning map.");
updateZoningMap(lastReferenceZoneInfo, exportGroupId, exportMaskURIs);
}
// Update the workflow state.
completeWorkflowState(taskCompleter, stepId, "zoneExportMasksDelete", result, warningMessage.toString());
_log.info("Successfully removed zones for ExportGroup: {}", exportGroupId.toString());
} catch (Exception ex) {
_log.error("Exception zoning delete Export Masks", ex);
WorkflowService.getInstance().storeStepData(stepId, context);
ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportGroupDeleteFailed(ex.getMessage(), ex);
if (taskCompleter != null) {
taskCompleter.error(_dbClient, svcError);
} else {
WorkflowStepCompleter.stepFailed(stepId, svcError);
}
}
return status;
}
use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.
the class NetworkDeviceController method zoneExportRemovePaths.
/**
* Handle zoning when removing paths from export masks
* @param zoningParams NetworkZoningParam list
* @param taskCompleter -- Task completer to be called
* @param token -- Step id
* @return true if successful
*/
public boolean zoneExportRemovePaths(List<NetworkZoningParam> zoningParams, TaskCompleter taskCompleter, String token) {
if (zoningParams.isEmpty()) {
_log.info("zoningParams is empty, returning");
taskCompleter.ready(_dbClient);
return true;
}
NetworkFCContext context = new NetworkFCContext();
boolean completedSuccessfully = false;
URI exportGroupId = zoningParams.get(0).getExportGroupId();
URI virtualArray = zoningParams.get(0).getVirtualArray();
_log.info(String.format("Entering zoneExportRemovePaths for ExportGroup: %s", zoningParams.get(0).getExportGroupDisplay()));
try {
if (!isZoningRequired(virtualArray)) {
taskCompleter.ready(_dbClient);
return true;
}
context.setAddingZones(false);
// Get the zoning targets to be removed.
List<NetworkFCZoneInfo> zoneInfos = _networkScheduler.getZoningRemoveTargets(zoningParams, null);
context.getZoneInfos().addAll(zoneInfos);
logZones(zoneInfos);
// If there are no zones to do, we were successful.
if (context.getZoneInfos().isEmpty()) {
taskCompleter.ready(_dbClient);
return true;
}
// Now call addRemoveZones to remove all the required zones.
BiosCommandResult result = addRemoveZones(exportGroupId, context.getZoneInfos(), true);
completedSuccessfully = result.isCommandSuccess();
if (completedSuccessfully) {
taskCompleter.ready(_dbClient);
} else {
ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportRemovePathsError(result.getMessage());
taskCompleter.error(_dbClient, svcError);
}
} catch (Exception ex) {
_log.error("Exception zoning remove initiators", ex);
ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportRemovePathsFailed(ex.getMessage(), ex);
taskCompleter.error(_dbClient, svcError);
}
return completedSuccessfully;
}
use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.
the class NetworkDeviceController method zoneExportAddPaths.
/**
* Handle zoning when adding paths to ExportMasks
* @param systemURI -- Storage system URI
* @param exportGroupURI -- Export Group URI
* @param exportMaskURIs -- List of ExportMask URIs
* @param newPaths -- Zoning map of the new paths to be added
* @param taskCompleter -- Task completer to be called
* @param token -- Step id
* @return true if successful
* @throws ControllerException
*/
public boolean zoneExportAddPaths(URI systemURI, URI exportGroupURI, Collection<URI> exportMaskURIs, Map<URI, List<URI>> newPaths, TaskCompleter taskCompleter, String token) throws ControllerException {
NetworkFCContext context = new NetworkFCContext();
boolean completedSucessfully = false;
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
_log.info(String.format("Entering zoneExportAddPaths for ExportGroup: %s (%s)", exportGroup.getLabel(), exportGroup.getId()));
try {
if (!isZoningRequired(exportGroup.getVirtualArray())) {
_log.info("The zoning is not required.");
taskCompleter.ready(_dbClient);
return true;
}
// get existing zones on the switch
Map<String, List<Zone>> zonesMap = getExistingZonesMap(exportMaskURIs, token);
// Compute zones that are required.
List<NetworkFCZoneInfo> zoneInfos = _networkScheduler.getZoningTargetsForPaths(systemURI, exportGroup, exportMaskURIs, newPaths, zonesMap, _dbClient);
context.getZoneInfos().addAll(zoneInfos);
logZones(zoneInfos);
// If there are no zones to do, we were successful.
if (context.getZoneInfos().isEmpty()) {
taskCompleter.ready(_dbClient);
;
return true;
}
// Now call addRemoveZones to add all the required zones.
BiosCommandResult result = addRemoveZones(exportGroup.getId(), context.getZoneInfos(), false);
completedSucessfully = result.isCommandSuccess();
if (completedSucessfully) {
taskCompleter.ready(_dbClient);
} else {
ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportAddPathsError(result.getMessage());
taskCompleter.error(_dbClient, svcError);
}
} catch (Exception ex) {
_log.error("Exception zoning add paths", ex);
ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportAddPathsFailed(ex.getMessage(), ex);
taskCompleter.error(_dbClient, svcError);
}
return completedSucessfully;
}
use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo 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.NetworkFCZoneInfo 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