Search in sources :

Example 96 with QueueJob

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

the class ExternalBlockStorageDevice method doRestoreFromClone.

@Override
public void doRestoreFromClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    DriverTask task = null;
    Volume clone = dbClient.queryObject(Volume.class, cloneVolume);
    _log.info("Restore from volume clone on storage system {}, clone: {} .", storageSystem.getNativeId(), clone.toString());
    try {
        BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
        VolumeClone driverClone = new VolumeClone();
        driverClone.setStorageSystemId(storageSystem.getNativeId());
        driverClone.setNativeId(clone.getNativeId());
        driverClone.setParentId(sourceVolume.getNativeId());
        driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
        // Call driver
        task = driver.restoreFromClone(Collections.unmodifiableList(Collections.singletonList(driverClone)));
        if (!isTaskInTerminalState(task.getStatus())) {
            // If the task is not in a terminal state and will be completed asynchronously
            // create a job to monitor the progress of the request and update the clone
            // volume replica state and call the completer as appropriate based on the result
            // of the request.
            RestoreFromCloneExternalDeviceJob job = new RestoreFromCloneExternalDeviceJob(storageSystem.getId(), cloneVolume, task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("doRestoreFromClone -- Restored volume from clone: %s .", task.getMessage());
            _log.info(msg);
            ExternalDeviceUtils.updateRestoredClone(clone, driverClone, dbClient, true);
            taskCompleter.ready(dbClient);
        } else {
            String msg = String.format("Failed to restore volume from clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
            _log.error(msg);
            // todo: add error
            ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromClone", msg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        String msg = String.format("Failed to restore volume from clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
        _log.error(msg, e);
        ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromClone", msg);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RestoreFromCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.RestoreFromCloneExternalDeviceJob) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageBlockObject(com.emc.storageos.storagedriver.model.StorageBlockObject) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException)

Example 97 with QueueJob

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

the class HDSStorageDevice method doCreateVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doCreateVolumes(com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.StoragePool, java.lang.String, java.util.List,
     * com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper, com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doCreateVolumes(StorageSystem storageSystem, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    boolean isThinVolume = false;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
        if ((label == null) && (volumes.size() == 1)) {
            String tenantName = "";
            try {
                TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
                tenantName = tenant.getLabel();
            } catch (DatabaseException e) {
                log.error("Error lookup TenantOrb object", e);
            }
            label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
        }
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
        isThinVolume = volume.getThinlyProvisioned();
    }
    log.info(logMsgBuilder.toString());
    try {
        multiVolumeCheckForHitachiModel(volumes, storageSystem);
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        String poolObjectID = HDSUtils.getPoolObjectID(storagePool);
        String asyncTaskMessageId = null;
        // isThinVolume = false, creates LogicalUnits
        if (isThinVolume) {
            asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, storagePool.getNativeId(), capacity, volumes.size(), label, QUICK_FORMAT_TYPE, storageSystem.getModel());
        } else if (!isThinVolume) {
            asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, capacity, volumes.size(), label, null, storageSystem.getModel(), null);
        }
        if (asyncTaskMessageId != null) {
            HDSJob createHDSJob = (volumes.size() > 1) ? new HDSCreateMultiVolumeJob(asyncTaskMessageId, volumes.get(0).getStorageController(), storagePool.getId(), volumes.size(), taskCompleter) : new HDSCreateVolumeJob(asyncTaskMessageId, volumes.get(0).getStorageController(), storagePool.getId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(createHDSJob));
        } else {
            throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
        }
    } catch (final InternalException e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(dbClient, e);
    } catch (final Exception e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            dbClient.persistObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    log.info(logMsgBuilder.toString());
}
Also used : 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) HDSCreateVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateVolumeJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) HDSCreateMultiVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateMultiVolumeJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 98 with QueueJob

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

the class HDSStorageDevice method doExpandVolume.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doExpandVolume(com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.StoragePool, com.emc.storageos.db.client.model.Volume, java.lang.Long,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doExpandVolume(StorageSystem storageSystem, StoragePool storagePool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getLabel(), size));
    try {
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        String asyncTaskMessageId = null;
        if (volume.getThinlyProvisioned()) {
            asyncTaskMessageId = hdsApiClient.modifyThinVolume(systemObjectID, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storageSystem), size, storageSystem.getModel());
        }
        if (null != asyncTaskMessageId) {
            HDSJob expandVolumeJob = new HDSVolumeExpandJob(asyncTaskMessageId, storageSystem.getId(), storagePool.getId(), taskCompleter, "ExpandVolume");
            ControllerServiceImpl.enqueueJob(new QueueJob(expandVolumeJob));
        } else {
            throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the expand volume call");
        }
    } catch (final InternalException e) {
        log.error("Problem in doExpandVolume: ", e);
        taskCompleter.error(dbClient, e);
    } catch (final Exception e) {
        log.error("Problem in doExpandVolume: ", e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doExpandVolume", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    log.info(String.format("Expand Volume End - Array: %s, Pool: %s, Volume: %s", storageSystem.getSerialNumber(), storagePool.getNativeGuid(), volume.getLabel()));
}
Also used : 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) HDSVolumeExpandJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSVolumeExpandJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 99 with QueueJob

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

the class HDSStorageDevice method doWaitForSynchronized.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.emc.storageos.volumecontroller.BlockStorageDevice#doWaitForSynchronized
     * (java.lang.Class, com.emc.storageos.db.client.model.StorageSystem,
     * java.net.URI, com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doWaitForSynchronized(Class<? extends BlockObject> clazz, StorageSystem storageObj, URI target, TaskCompleter completer) {
    log.info("START waitForSynchronized for {}", target);
    try {
        Volume targetObj = dbClient.queryObject(Volume.class, target);
        // Source could be either Volume or BlockSnapshot
        BlockObject sourceObj = BlockObject.fetch(dbClient, targetObj.getAssociatedSourceVolume());
        // We split the pair which causes the data to be synchronized.
        // When the split is complete that data is synchronized.
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageObj), storageObj.getSmisUserName(), storageObj.getSmisPassword());
        HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
        String replicationGroupObjectID = hdsApiProtectionManager.getReplicationGroupObjectId();
        ReplicationInfo replicationInfo = hdsApiProtectionManager.getReplicationInfoFromSystem(sourceObj.getNativeId(), targetObj.getNativeId()).first;
        hdsApiProtectionManager.modifyShadowImagePair(replicationGroupObjectID, replicationInfo.getObjectID(), HDSApiProtectionManager.ShadowImageOperationType.split, storageObj.getModel());
        // Update state in case we are waiting for synchronization
        // after creation of a new full copy that was not created
        // inactive.
        String state = targetObj.getReplicaState();
        if (!ReplicationState.SYNCHRONIZED.name().equals(state)) {
            targetObj.setSyncActive(true);
            targetObj.setReplicaState(ReplicationState.SYNCHRONIZED.name());
            dbClient.persistObject(targetObj);
        }
        // Queue job to wait for replication status to move to split.
        ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageObj.getId(), sourceObj.getNativeId(), targetObj.getNativeId(), ReplicationStatus.SPLIT, completer)));
    } catch (Exception e) {
        log.error("Exception occurred while waiting for synchronization", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(dbClient, serviceError);
    }
    log.info("completed doWaitForSynchronized");
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 100 with QueueJob

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

the class HDSStorageDevice method doCleanupMetaMembers.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doCleanupMetaMembers(com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.Volume,
     * com.emc.storageos.volumecontroller.impl.block.taskcompleter.CleanupMetaVolumeMembersCompleter)
     */
@Override
public void doCleanupMetaMembers(StorageSystem storageSystem, Volume volume, CleanupMetaVolumeMembersCompleter cleanupCompleter) throws DeviceControllerException {
    // Remove meta member volumes from storage device
    try {
        log.info(String.format("doCleanupMetaMembers  Start - Array: %s, Volume: %s", storageSystem.getSerialNumber(), volume.getLabel()));
        // Load meta volume members from WF data
        String sourceStepId = cleanupCompleter.getSourceStepId();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getUsername(), storageSystem.getSmisPassword());
        List<String> metaMembers = (ArrayList<String>) WorkflowService.getInstance().loadStepData(sourceStepId);
        if (metaMembers != null && !metaMembers.isEmpty()) {
            log.info(String.format("doCleanupMetaMembers: Members stored for meta volume: %n %s", metaMembers));
            // Check if volumes still exist in array and if it is not composite member (already
            // added to the meta volume)
            Set<String> volumeIds = new HashSet<String>();
            for (String logicalUnitObjectId : metaMembers) {
                LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(HDSUtils.getSystemObjectID(storageSystem), logicalUnitObjectId);
                if (logicalUnit != null) {
                    log.debug("doCleanupMetaMembers: Volume: " + logicalUnitObjectId + ", Usage of volume: " + logicalUnit.getComposite());
                    if (logicalUnit.getComposite() != HDSConstants.COMPOSITE_ELEMENT_MEMBER) {
                        volumeIds.add(logicalUnitObjectId);
                    }
                }
            }
            if (volumeIds.isEmpty()) {
                log.info("doCleanupMetaMembers: No meta members to cleanup in array.");
                cleanupCompleter.ready(dbClient);
            } else {
                log.info(String.format("doCleanupMetaMembers: Members to cleanup in array: %n   %s", volumeIds));
                // Prepare parameters and call method to delete meta members from array
                HDSCleanupMetaVolumeMembersJob hdsJobCompleter = null;
                // When "cleanup" is separate workflow step, call async (for example rollback
                // step in volume expand)
                // Otherwise, call synchronously (for example when cleanup is part of meta
                // volume create rollback)
                String asyncMessageId = hdsApiClient.deleteThickLogicalUnits(HDSUtils.getSystemObjectID(storageSystem), volumeIds, storageSystem.getModel());
                if (asyncMessageId == null) {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
                }
                if (cleanupCompleter.isWFStep()) {
                    if (asyncMessageId != null) {
                        ControllerServiceImpl.enqueueJob(new QueueJob(new HDSCleanupMetaVolumeMembersJob(asyncMessageId, storageSystem.getId(), volume.getId(), cleanupCompleter)));
                    }
                } else {
                    // invoke synchronously
                    hdsJobCompleter = new HDSCleanupMetaVolumeMembersJob(asyncMessageId, storageSystem.getId(), volume.getId(), cleanupCompleter);
                    ((HDSMetaVolumeOperations) metaVolumeOperations).invokeMethodSynchronously(hdsApiFactory, asyncMessageId, hdsJobCompleter);
                }
            }
        } else {
            log.info("doCleanupMetaMembers: No meta members stored for meta volume. Nothing to cleanup in array.");
            cleanupCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error("Problem in doCleanupMetaMembers: ", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doCleanupMetaMembers", e.getMessage());
        cleanupCompleter.error(dbClient, error);
    }
    log.info(String.format("doCleanupMetaMembers End - Array: %s,  Volume: %s", storageSystem.getSerialNumber(), volume.getLabel()));
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSCleanupMetaVolumeMembersJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCleanupMetaVolumeMembersJob) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) HashSet(java.util.HashSet)

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