Search in sources :

Example 51 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    List<ExportRule> allExports = args.getExistingDBExportRules();
    String subDir = args.getSubDirectory();
    boolean allDirs = args.isAllDir();
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    boolean isFile = args.getFileOperation();
    boolean ifRulePresent = false;
    String exportPath;
    String subDirExportPath = "";
    subDir = args.getSubDirectory();
    if (!args.getFileOperation()) {
        exportPath = args.getSnapshotPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getSnapshotPath() + "/" + subDir;
        }
    } else {
        exportPath = args.getFs().getPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getFs().getPath() + "/" + subDir;
        }
    }
    _logger.info("exportPath : {}", exportPath);
    args.setExportPath(exportPath);
    _logger.info("Number of existing exports found {}", allExports.size());
    try {
        VNXeApiClient apiClient = getVnxUnityClient(storage);
        if (allDirs) {
            // ALL EXPORTS
            _logger.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
            for (ExportRule rule : allExports) {
                FileShareExport fsExport = null;
                if (args.getFileObjExports() != null) {
                    Collection<FileExport> expList = args.getFileObjExports().values();
                    Iterator<FileExport> it = expList.iterator();
                    FileExport exp = null;
                    while (it.hasNext()) {
                        FileExport export = it.next();
                        if (export.getPath().equalsIgnoreCase(rule.getExportPath())) {
                            exp = export;
                        }
                    }
                    fsExport = new FileShareExport(exp);
                }
                String vnxeShareId = rule.getDeviceExportId();
                _logger.info("Delete UnityExport id {} for path {}", rule.getDeviceExportId(), rule.getExportPath());
                if (isFile) {
                    String fsId = args.getFs().getNativeId();
                    job = apiClient.removeNfsShare(vnxeShareId, fsId);
                } else {
                    job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
                }
                if (job != null) {
                    if (isFile) {
                        completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                    } else {
                        completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                    }
                    VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, rule.getExportPath(), isFile);
                    ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
                } else {
                    _logger.error("No job returned from exportFileSystem");
                    ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                    return BiosCommandResult.createErrorResult(error);
                }
            }
        } else if (subDir != null && !subDir.isEmpty()) {
            // Filter for a specific Sub Directory export
            _logger.info("Deleting all subdir exports rules at ViPR and  sub directory export at device {}", subDir);
            FileShareExport fsExport = null;
            String vnxeShareId = null;
            if (args.getFileObjExports() != null) {
                Collection<FileExport> expList = args.getFileObjExports().values();
                Iterator<FileExport> it = expList.iterator();
                FileExport exp = null;
                while (it.hasNext()) {
                    FileExport export = it.next();
                    if (export.getPath().equalsIgnoreCase(subDirExportPath)) {
                        exp = export;
                        break;
                    }
                }
                fsExport = new FileShareExport(exp);
            }
            for (ExportRule rule : allExports) {
                _logger.info("Delete UnityExport id for path {} f containing subdirectory {}", rule.getDeviceExportId() + ":" + rule.getExportPath(), subDir);
                if (rule.getExportPath().equalsIgnoreCase(subDirExportPath)) {
                    ifRulePresent = true;
                    vnxeShareId = rule.getDeviceExportId();
                }
            }
            if (!ifRulePresent) {
                if (fsExport != null) {
                    vnxeShareId = fsExport.getIsilonId();
                }
            }
            _logger.info("Delete UnityExport id {} for path {}", vnxeShareId, subDirExportPath);
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, subDirExportPath, isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // Filter for No SUBDIR - main export rules with no sub dirs
            _logger.info("Deleting all export rules  from DB and export at device not included sub dirs");
            FileShareExport fsExport = null;
            String vnxeShareId = null;
            if (args.getFileObjExports() != null) {
                Collection<FileExport> expList = args.getFileObjExports().values();
                Iterator<FileExport> it = expList.iterator();
                FileExport exp = null;
                while (it.hasNext()) {
                    FileExport export = it.next();
                    if (export.getPath().equalsIgnoreCase(exportPath)) {
                        exp = export;
                        break;
                    }
                }
                fsExport = new FileShareExport(exp);
            }
            for (ExportRule rule : allExports) {
                if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
                    ifRulePresent = true;
                    vnxeShareId = rule.getDeviceExportId();
                }
            }
            if (!ifRulePresent) {
                if (fsExport != null) {
                    vnxeShareId = fsExport.getIsilonId();
                }
            }
            _logger.info("Delete UnityExport id {} for path {}", vnxeShareId, fsExport.getPath());
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, fsExport, fsExport.getPath(), isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        }
    } catch (VNXeException e) {
        _logger.error("Unexport file system got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    if (job != null) {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Unexport filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
        return BiosCommandResult.createPendingResult();
    } else {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("No export found - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
        return BiosCommandResult.createSuccessfulResult();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) FileExport(com.emc.storageos.db.client.model.FileExport) Iterator(java.util.Iterator) ExportRule(com.emc.storageos.model.file.ExportRule) Collection(java.util.Collection) VNXeUnexportFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeUnexportFileSystemJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 52 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class HDSCloneOperations method activateSingleClone.

/**
 * @param storageSystem {@link StorageSystem} StorageSystem instance
 * @param fullCopy {@link URI} clone's URI
 * @param completer {@link TaskCompleter}
 *
 * @prereq Create full copy as inactive
 *
 * @brief Activate Clone Volume
 */
@Override
public void activateSingleClone(StorageSystem storageSystem, URI fullCopy, TaskCompleter completer) {
    log.info("START activateSingleClone for {}", fullCopy);
    try {
        Volume clone = dbClient.queryObject(Volume.class, fullCopy);
        Volume sourceVolume = dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
        hdsProtectionOperations.modifyShadowImagePair(storageSystem, sourceVolume.getNativeId(), clone.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.split);
        ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageSystem.getId(), sourceVolume.getNativeId(), clone.getNativeId(), ReplicationStatus.SPLIT, completer)));
        // Update state.
        clone.setSyncActive(true);
        clone.setReplicaState(ReplicationState.SYNCHRONIZED.name());
        dbClient.persistObject(clone);
        log.info("FINISH activateSingleClone for {}", fullCopy);
    } catch (Exception e) {
        String errorMsg = String.format(ACTIVATE_ERROR_MSG_FORMAT, fullCopy);
        log.error(errorMsg, e);
        completer.error(dbClient, DeviceControllerException.exceptions.activateVolumeFullCopyFailed(e));
    }
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 53 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class HDSCloneOperations method resyncSingleClone.

@Override
public void resyncSingleClone(StorageSystem storageSystem, URI cloneURI, TaskCompleter taskCompleter) {
    try {
        Volume cloneVolume = dbClient.queryObject(Volume.class, cloneURI);
        Volume sourceVolume = dbClient.queryObject(Volume.class, cloneVolume.getAssociatedSourceVolume());
        hdsProtectionOperations.modifyShadowImagePair(storageSystem, sourceVolume.getNativeId(), cloneVolume.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.resync);
        ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageSystem.getId(), sourceVolume.getNativeId(), cloneVolume.getNativeId(), ReplicationStatus.PAIR, taskCompleter)));
        log.info("FINISH resyncSingleClone for {}", cloneURI);
    } catch (Exception e) {
        String errorMsg = String.format(RESTORE_ERROR_MSG_FORMAT, cloneURI);
        log.error(errorMsg, e);
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.activateVolumeFullCopyFailed(e));
    }
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 54 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class HDSExportOperations method updateStorageGroupPolicyAndLimits.

@Override
public void updateStorageGroupPolicyAndLimits(StorageSystem storage, ExportMask exportMask, List<URI> volumeURIs, VirtualPool newVirtualPool, boolean rollback, TaskCompleter taskCompleter) throws Exception {
    String message = rollback ? ("updateAutoTieringPolicy" + "(rollback)") : ("updateAutoTieringPolicy");
    log.info("{} {} START...", storage.getSerialNumber(), message);
    log.info("{} : volumeURIs: {}", message, volumeURIs);
    try {
        String newPolicyName = ControllerUtils.getFastPolicyNameFromVirtualPool(dbClient, storage, newVirtualPool);
        log.info("{} : AutoTieringPolicy: {}", message, newPolicyName);
        List<Volume> volumes = dbClient.queryObject(Volume.class, volumeURIs);
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storage);
        for (Volume volume : volumes) {
            String luObjectId = HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storage);
            LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, luObjectId);
            if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
                Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
                if (ldevItr.hasNext()) {
                    LDEV ldev = ldevItr.next();
                    hdsApiClient.getLogicalUnitInfo(systemObjectID, luObjectId);
                    String tieringPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
                    String policId = HitachiTieringPolicy.getPolicy(tieringPolicyName.replaceAll(HDSConstants.SLASH_OPERATOR, HDSConstants.UNDERSCORE_OPERATOR)).getKey();
                    String asyncMessageId = hdsApiClient.modifyThinVolumeTieringPolicy(systemObjectID, luObjectId, ldev.getObjectID(), policId, storage.getModel());
                    if (null != asyncMessageId) {
                        HDSJob modifyHDSJob = new HDSModifyVolumeJob(asyncMessageId, volume.getStorageController(), taskCompleter, HDSModifyVolumeJob.VOLUME_VPOOL_CHANGE_JOB);
                        ControllerServiceImpl.enqueueJob(new QueueJob(modifyHDSJob));
                    } else {
                        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the modify volume call");
                    }
                }
            }
        }
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while updating Auto-tiering policy for Volumes %s", volumeURIs);
        log.error(errMsg, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} {} updateAutoTieringPolicy END...", storage.getSerialNumber(), message);
}
Also used : HDSModifyVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 55 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VmaxMirrorOperations method createGroupMirrors.

@Override
public void createGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createGroupMirrors operation START");
    List<BlockMirror> mirrors = null;
    try {
        if (!storage.getUsingSmis80()) {
            throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
        }
        mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        BlockMirror firstMirror = mirrors.get(0);
        Volume sourceVolume = _dbClient.queryObject(Volume.class, firstMirror.getSource());
        String sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVolume, _dbClient);
        String replicaLabel = ControllerUtils.generateLabel(sourceVolume.getLabel(), firstMirror.getLabel());
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        // Create CG mirrors
        CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, replicaLabel, null, createInactive, taskCompleter, SYNC_TYPE.MIRROR, _dbClient, _helper, _cimPath);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGMirrorJob(job, storage.getId(), taskCompleter)));
        for (BlockMirror mirror : mirrors) {
            mirror.setSyncState(SynchronizationState.SYNCHRONIZED.name());
        }
        _dbClient.persistObject(mirrors);
    } catch (Exception e) {
        _log.error("Problem making SMI-S call: ", e);
        // Roll back changes
        if (mirrors != null && !mirrors.isEmpty()) {
            for (BlockMirror mirrorObj : mirrors) {
                mirrorObj.setInactive(true);
            }
        }
        _dbClient.persistObject(mirrors);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupMirrors", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info("createGroupMirrors operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) SmisBlockCreateCGMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGMirrorJob) CIMObjectPath(javax.cim.CIMObjectPath) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)109 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)104 Volume (com.emc.storageos.db.client.model.Volume)51 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)43 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)41 CIMObjectPath (javax.cim.CIMObjectPath)41 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)40 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)40 VNXeException (com.emc.storageos.vnxe.VNXeException)36 WBEMException (javax.wbem.WBEMException)33 ControllerException (com.emc.storageos.volumecontroller.ControllerException)32 CIMArgument (javax.cim.CIMArgument)32 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)25 URI (java.net.URI)23 ArrayList (java.util.ArrayList)23 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)20 Snapshot (com.emc.storageos.db.client.model.Snapshot)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileShare (com.emc.storageos.db.client.model.FileShare)16