use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method updateExportGroup.
public void updateExportGroup(URI exportGroup, Map<URI, Integer> newVolumesMap, Set<URI> addedClusters, Set<URI> removedClusters, Set<URI> adedHosts, Set<URI> removedHosts, Set<URI> addedInitiators, Set<URI> removedInitiators, String stepId) throws Exception {
Map<URI, Integer> addedBlockObjects = new HashMap<URI, Integer>();
Map<URI, Integer> removedBlockObjects = new HashMap<URI, Integer>();
try {
ExportGroup exportGroupObject = _dbClient.queryObject(ExportGroup.class, exportGroup);
ExportUtils.getAddedAndRemovedBlockObjects(newVolumesMap, exportGroupObject, addedBlockObjects, removedBlockObjects);
BlockExportController blockController = getController(BlockExportController.class, BlockExportController.EXPORT);
Operation op = _dbClient.createTaskOpStatus(ExportGroup.class, exportGroup, stepId, ResourceOperationTypeEnum.UPDATE_EXPORT_GROUP);
exportGroupObject.getOpStatus().put(stepId, op);
_dbClient.updateObject(exportGroupObject);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_026);
blockController.exportGroupUpdate(exportGroup, addedBlockObjects, removedBlockObjects, addedClusters, removedClusters, adedHosts, removedHosts, addedInitiators, removedInitiators, stepId);
// No code should be added following the call to the block controller to preserve rollback integrity
} catch (Exception ex) {
_log.error("Exception occured while updating export group {}", exportGroup, ex);
// Clean up any pending tasks
ExportTaskCompleter taskCompleter = new ExportUpdateCompleter(exportGroup, addedBlockObjects, removedBlockObjects, addedInitiators, removedInitiators, adedHosts, removedHosts, addedClusters, removedClusters, stepId);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
taskCompleter.error(_dbClient, serviceError);
// Fail the step
WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(ex));
}
}
use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.
the class ExportService method processDetachRequest.
// INTERNAL FUNCTIONS
private boolean processDetachRequest(Volume vol, VolumeActionRequest.DetachVolume detach, String openstackTenantId, String protocol) throws InterruptedException {
_log.info("Detach request");
// Step 1: Find export group of volume
ExportGroup exportGroup = findExportGroup(vol);
if (exportGroup == null)
throw APIException.badRequests.parameterIsNotValid("volume_id");
Set<URI> addedClusters = new HashSet<>();
Set<URI> removedClusters = new HashSet<>();
Set<URI> addedHosts = new HashSet<>();
Set<URI> removedHosts = new HashSet<>();
Set<URI> addedInitiators = new HashSet<>();
Set<URI> removedInitiators = new HashSet<>();
// Step 2: Validate initiators are part of export group
List<URI> currentURIs = new ArrayList<URI>();
List<Initiator> detachInitiators = getListOfInitiators(detach.connector, openstackTenantId, protocol, vol);
currentURIs = StringSetUtil.stringSetToUriList(exportGroup.getInitiators());
for (Initiator initiator : detachInitiators) {
URI uri = initiator.getId();
if (!currentURIs.contains(uri)) {
throw APIException.badRequests.parameterIsNotValid("volume_id");
}
removedInitiators.add(uri);
}
_log.info("updateExportGroup request is submitted.");
// get block controller
BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
// Now update export group
String task = UUID.randomUUID().toString();
initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.DELETE_EXPORT_VOLUME);
Map<URI, Integer> noUpdatesVolumeMap = new HashMap<URI, Integer>();
exportController.exportGroupUpdate(exportGroup.getId(), noUpdatesVolumeMap, noUpdatesVolumeMap, addedClusters, removedClusters, addedHosts, removedHosts, addedInitiators, removedInitiators, task);
return waitForTaskCompletion(exportGroup.getId(), task);
// TODO: If now the list is empty, change volume status to 'not exported'
// and delete the exportGroup
}
use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.
the class ExportService method processAttachRequest.
private boolean processAttachRequest(Volume vol, VolumeActionRequest.AttachVolume attach, String openstack_tenant_id, String protocol) throws InterruptedException {
_log.info("Attach request");
Map<URI, Integer> volumeMap = new HashMap<URI, Integer>();
List<URI> initiatorURIs = new ArrayList<URI>();
String task = UUID.randomUUID().toString();
// Step 1: get list of host initiators to be added
_log.debug("THE ATTACH.CONNECTOR IS {}", attach.connector.toString());
List<Initiator> newInitiators = getListOfInitiators(attach.connector, openstack_tenant_id, protocol, vol);
ExportGroup exportGroup = findExportGroup(vol);
Set<URI> addedClusters = new HashSet<>();
Set<URI> removedClusters = new HashSet<>();
Set<URI> addedHosts = new HashSet<>();
Set<URI> removedHosts = new HashSet<>();
Set<URI> addedInitiators = new HashSet<>();
Set<URI> removedInitiators = new HashSet<>();
if (exportGroup != null) {
// export group exists, we need to add the initiators to it.
volumeMap = StringMapUtil.stringMapToVolumeMap(exportGroup.getVolumes());
initiatorURIs = StringSetUtil.stringSetToUriList(exportGroup.getInitiators());
for (Initiator initiator : newInitiators) {
URI uri = initiator.getId();
if (!initiatorURIs.contains(uri)) {
addedInitiators.add(uri);
}
}
_log.info("updateExportGroup request is submitted.");
// get block controller
initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.UPDATE_EXPORT_GROUP);
BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
// Now update export group
Map<URI, Integer> noUpdatesVolumeMap = new HashMap<URI, Integer>();
exportController.exportGroupUpdate(exportGroup.getId(), noUpdatesVolumeMap, noUpdatesVolumeMap, addedClusters, removedClusters, addedHosts, removedHosts, addedInitiators, removedInitiators, task);
} else {
// Create a new export group with the given list of initiators
String name = "eg-" + vol.getLabel();
exportGroup = createNewGroup(newInitiators, openstack_tenant_id, name);
exportGroup.setVirtualArray(vol.getVirtualArray());
// put volume map
volumeMap.put(vol.getId(), ExportGroup.LUN_UNASSIGNED);
exportGroup.addVolume(vol.getId(), ExportGroup.LUN_UNASSIGNED);
// put list of initiators
for (Initiator initiator : newInitiators) {
initiatorURIs.add(initiator.getId());
}
exportGroup.setInitiators(StringSetUtil.uriListToStringSet(initiatorURIs));
_dbClient.createObject(exportGroup);
_log.info("createExportGroup request is submitted.");
initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.CREATE_EXPORT_GROUP);
// get block controller
BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
// Now create export group
exportController.exportGroupCreate(exportGroup.getId(), volumeMap, initiatorURIs, task);
}
boolean bTaskComplete = waitForTaskCompletion(exportGroup.getId(), task);
return bTaskComplete;
}
use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method deleteExportGroup.
public void deleteExportGroup(URI exportGroup, String stepId) {
try {
BlockExportController blockController = getController(BlockExportController.class, BlockExportController.EXPORT);
_dbClient.createTaskOpStatus(ExportGroup.class, exportGroup, stepId, ResourceOperationTypeEnum.DELETE_EXPORT_GROUP);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_027);
blockController.exportGroupDelete(exportGroup, stepId);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_028);
} catch (Exception ex) {
_log.error("Exception occured while deleting export group {}", exportGroup, ex);
// Clean up any pending tasks
ExportTaskCompleter taskCompleter = new ExportDeleteCompleter(exportGroup, false, stepId);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
taskCompleter.error(_dbClient, serviceError);
// Fail the step
WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(ex));
}
}
use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.
the class CreateExportGroupSchedulingThread method run.
@Override
public void run() {
_log.info("Starting scheduling for export group create thread...");
// Call out placementManager to get the recommendation for placement.
try {
// validate clients (initiators, hosts clusters) input and package them
// This call may take a long time.
List<URI> affectedInitiators = this.exportGroupService.validateClientsAndPopulate(exportGroup, project, virtualArray, storageMap.keySet(), clusters, hosts, initiators, volumeMap.keySet(), pathParam);
_log.info("Initiators {} will be used.", affectedInitiators);
// If ExportPathParameter block is present, and volumes are present, capture those arguments.
if (pathParam != null && !volumeMap.keySet().isEmpty()) {
ExportPathParams exportPathParam = exportGroupService.validateAndCreateExportPathParam(pathParam, exportGroup, volumeMap.keySet());
exportGroupService.addBlockObjectsToPathParamMap(volumeMap.keySet(), exportPathParam.getId(), exportGroup);
exportGroupService._dbClient.createObject(exportPathParam);
}
this.exportGroupService._dbClient.updateObject(exportGroup);
// If initiators list is empty or storage map is empty, there's no work to do (yet).
if (storageMap.isEmpty() || affectedInitiators.isEmpty()) {
this.exportGroupService._dbClient.ready(ExportGroup.class, taskRes.getResource().getId(), taskRes.getOpId());
return;
}
// push it to storage devices
BlockExportController exportController = this.exportGroupService.getExportController();
_log.info("createExportGroup request is submitted.");
exportController.exportGroupCreate(exportGroup.getId(), volumeMap, affectedInitiators, task);
} catch (Exception ex) {
if (ex instanceof ServiceCoded) {
this.exportGroupService._dbClient.error(ExportGroup.class, taskRes.getResource().getId(), taskRes.getOpId(), (ServiceCoded) ex);
} else {
this.exportGroupService._dbClient.error(ExportGroup.class, taskRes.getResource().getId(), taskRes.getOpId(), InternalServerErrorException.internalServerErrors.unexpectedErrorExportGroupPlacement(ex));
}
_log.error(ex.getMessage(), ex);
taskRes.setMessage(ex.getMessage());
// Mark the export group to be deleted
this.exportGroupService._dbClient.markForDeletion(exportGroup);
}
_log.info("Ending export group create scheduling thread...");
}
Aggregations