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