use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockMirrorDeleteJob in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method deleteSingleVolumeMirror.
/**
* Deletes mirror instance from StorageSystem
*/
@Override
public void deleteSingleVolumeMirror(StorageSystem storageSystem, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Mirror Start - Array:%s", storageSystem.getSerialNumber()));
Set<String> thickLogicalUnitIdList = new HashSet<String>();
Set<String> thinLogicalUnitIdList = new HashSet<String>();
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
logMsgBuilder.append(String.format("%nMirror:%s", mirrorObj.getLabel()));
String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(mirrorObj.getNativeId(), storageSystem);
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, logicalUnitObjectId);
if (logicalUnit == null) {
// related volume state (if any) has been deleted. skip
// processing, if already deleted from array.
log.info(String.format("Mirror %s already deleted: ", mirrorObj.getNativeId()));
// HDSMirrorOperations.removeReferenceFromSourceVolume(dbClient, mirrorObj);
dbClient.markForDeletion(mirrorObj);
} else {
if (mirrorObj.getThinlyProvisioned()) {
thinLogicalUnitIdList.add(logicalUnitObjectId);
} else {
thickLogicalUnitIdList.add(logicalUnitObjectId);
}
log.info(logMsgBuilder.toString());
if (!thickLogicalUnitIdList.isEmpty()) {
String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectID, thickLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThickLUsJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThickLUsJobId, mirrorObj.getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
}
}
if (!thinLogicalUnitIdList.isEmpty()) {
String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectID, thinLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThinHDSJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThinHDSJobId, mirrorObj.getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
}
}
}
log.info("Delete Mirror End - Array: {} Mirror: {}", storageSystem.getSerialNumber(), mirror);
} catch (Exception e) {
log.error("Problem in deleteSingleVolumeMirror: ", e);
ServiceError error = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeMirror", e.getMessage());
taskCompleter.error(dbClient, error);
}
}
Aggregations