Search in sources :

Example 61 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeDeleteVolumesJob method updateStatus.

/**
 * Called to update the job status when the volumes delete job completes.
 *
 * @param jobContext The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
        // Get list of volumes; get set of storage pool ids to which they belong.
        List<Volume> volumes = dbClient.queryObject(Volume.class, getTaskCompleter().getIds());
        Set<URI> poolURIs = new HashSet<URI>();
        for (Volume volume : volumes) {
            poolURIs.add(volume.getPool());
        }
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        // If terminal state update storage pool capacity
        if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
            for (URI poolURI : poolURIs) {
                VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, poolURI, null);
            }
        }
        if (_status == JobStatus.SUCCESS) {
            for (Volume volume : volumes) {
                volume.setInactive(true);
                volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                dbClient.updateObject(volume);
                if (logMsgBuilder.length() != 0) {
                    logMsgBuilder.append("\n");
                }
                logMsgBuilder.append(String.format("Successfully deleted volume %s", volume.getId()));
            }
        } else if (_status == JobStatus.FAILED) {
            for (URI id : getTaskCompleter().getIds()) {
                if (logMsgBuilder.length() != 0) {
                    logMsgBuilder.append("\n");
                }
                logMsgBuilder.append(String.format("Failed to delete volume: %s", id));
            }
        }
        _logger.info(logMsgBuilder.toString());
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeDeleteVolumesJob", e);
        setErrorStatus("Encountered an internal error during volume delete job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) URI(java.net.URI) HashSet(java.util.HashSet)

Example 62 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeSnapshotOperation method deleteGroupSnapshots.

@Override
public void deleteGroupSnapshots(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, Arrays.asList(snapshot));
        BlockSnapshot snapshotObj = snapshots.get(0);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
        if (lunGroupSnap != null) {
            VNXeCommandJob job = apiClient.deleteLunGroupSnap(lunGroupSnap.getId());
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockDeleteSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
            } else {
                // Should not take this path, but treat as an error if we do
                // happen to get a null job due to some error in the client.
                _log.error("Unexpected null job from VNXe client call to delete group snapshot.");
                ServiceCoded sc = DeviceControllerExceptions.vnxe.nullJobForDeleteGroupSnapshot(snapshotObj.forDisplay(), snapshotObj.getReplicationGroupInstance());
                taskCompleter.error(_dbClient, sc);
            }
        } else {
            // Treat as in the single volume snapshot case and presume
            // the group snapshot has already been deleted.
            List<BlockSnapshot> grpSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
            for (BlockSnapshot grpSnapshot : grpSnapshots) {
                grpSnapshot.setInactive(true);
                grpSnapshot.setIsSyncActive(false);
            }
            _dbClient.updateObject(grpSnapshots);
            taskCompleter.ready(_dbClient);
        }
    } catch (VNXeException e) {
        _log.error("Delete group snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Delete group snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeletGroupSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeLunGroupSnap(com.emc.storageos.vnxe.models.VNXeLunGroupSnap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeBlockDeleteSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockDeleteSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 63 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeSnapshotOperation method createSingleVolumeSnapshot.

@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeCommandJob job = apiClient.createLunSnap(volume.getNativeId(), snapLabelToUse);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
        }
    } catch (VNXeException e) {
        _log.error("Create volume snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Create volume snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VNXeBlockSnapshotCreateJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockSnapshotCreateJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 64 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeCreateShareJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        String event = "";
        FileShare fsObj = null;
        Snapshot snapObj = null;
        URI fsId = getTaskCompleter().getId();
        fsObj = dbClient.queryObject(FileShare.class, fsId);
        if (_status == JobStatus.SUCCESS) {
            if (isFile) {
                updateFileSystem(vnxeApiClient, dbClient, fsObj);
                event = String.format("Create file system smbShare successfully for URI: %s", getTaskCompleter().getId());
            } else {
                snapObj = updateSnapshot(vnxeApiClient, dbClient);
                event = String.format("Create snapshot smbShare successfully for URI: %s", getTaskCompleter().getId());
            }
        } else if (_status == JobStatus.FAILED) {
            event = String.format("Task %s failed to create file system smbShare: %s", opId, smbShare.getName());
            logMsgBuilder.append("\n");
            logMsgBuilder.append(event);
        }
        _logger.info(logMsgBuilder.toString());
        if (isFile) {
            FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SHARE, _isSuccess, event, smbShare.getName(), fsObj, smbShare);
        } else {
            fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent());
            FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE, _isSuccess, event, smbShare.getName(), snapObj, fsObj, smbShare);
        }
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemSnapshotJob", e);
        setErrorStatus("Encountered an internal error during file system snapshot create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI)

Example 65 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeDeleteShareJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        URI fsId = getTaskCompleter().getId();
        FileShare fsObj = null;
        Snapshot snapObj = null;
        String event = null;
        if (_status == JobStatus.SUCCESS) {
            if (isFile) {
                fsObj = dbClient.queryObject(FileShare.class, fsId);
                updateFileSystem(vnxeApiClient, dbClient, fsObj);
            } else {
                snapObj = updateSnapshot(vnxeApiClient, dbClient);
                fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent());
            }
            event = String.format("Deleted file system smbShare successfully for URI: %s", getTaskCompleter().getId());
        } else if (_status == JobStatus.FAILED) {
            event = String.format("Task %s failed to delete file system sbmShare: %s", opId, smbShare.getName());
            logMsgBuilder.append("\n");
            logMsgBuilder.append(event);
        }
        _logger.info(logMsgBuilder.toString());
        if (isFile) {
            FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE, _isSuccess, event, smbShare.getName(), fsObj, smbShare);
        } else {
            FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, _isSuccess, event, smbShare.getName(), snapObj, fsObj, smbShare);
        }
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemSnapshotJob", e);
        setErrorStatus("Encountered an internal error during file system snapshot create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Aggregations

VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)123 VNXeException (com.emc.storageos.vnxe.VNXeException)79 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)66 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)55 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)48 ControllerException (com.emc.storageos.volumecontroller.ControllerException)44 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)40 URI (java.net.URI)37 ArrayList (java.util.ArrayList)34 FileShare (com.emc.storageos.db.client.model.FileShare)33 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 Snapshot (com.emc.storageos.db.client.model.Snapshot)27 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)24 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)23 DbClient (com.emc.storageos.db.client.DbClient)21 Volume (com.emc.storageos.db.client.model.Volume)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileExport (com.emc.storageos.db.client.model.FileExport)14 HashMap (java.util.HashMap)14