Search in sources :

Example 36 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 37 with VNXeApiClient

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

the class VNXeCreateVolumesJob method updateStatus.

/**
 * Called to update the job status when the volumes create 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()));
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        // If terminal state update storage pool capacity
        if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
            List<URI> volUris = getTaskCompleter().getIds();
            List<String> volsInPool = new ArrayList<String>();
            for (URI voluri : volUris) {
                volsInPool.add(voluri.toString());
            }
            VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, storagePool, volsInPool);
        }
        Calendar now = Calendar.getInstance();
        int volumeCount = 0;
        if (_status == JobStatus.SUCCESS) {
            if (!isConsistencyGroup) {
                for (String jobId : getJobIds()) {
                    VNXeCommandJob vnxeJob = vnxeApiClient.getJob(jobId);
                    ParametersOut output = vnxeJob.getParametersOut();
                    String nativeId = null;
                    URI volumeId = getTaskCompleter().getId(volumeCount);
                    if (output != null) {
                        VNXeBase storageResource = output.getStorageResource();
                        if (storageResource != null) {
                            nativeId = storageResource.getId();
                        }
                    }
                    processVolume(vnxeApiClient, nativeId, volumeId, dbClient, logMsgBuilder, now);
                    volumeCount++;
                }
            } else {
                List<URI> volIds = getTaskCompleter().getIds();
                processVolumesinConsistencyGroup(vnxeApiClient, volIds, dbClient, logMsgBuilder, now);
            }
        } else if (_status == JobStatus.FAILED) {
            List<URI> volIds = getTaskCompleter().getIds();
            for (URI volId : volIds) {
                Volume volume = dbClient.queryObject(Volume.class, volId);
                volume.setInactive(true);
                dbClient.updateObject(volume);
                if (logMsgBuilder.length() != 0) {
                    logMsgBuilder.append("\n");
                }
                logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, volId));
            }
        }
        _logger.info(logMsgBuilder.toString());
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeCreateVolumesJob", e);
        setErrorStatus("Encountered an internal error during volume create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) ParametersOut(com.emc.storageos.vnxe.models.ParametersOut) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List)

Example 38 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)

Example 39 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 40 with VNXeApiClient

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

the class VNXeExpandFileSystemJob method updateStatus.

/**
 * Called to update the job status when the file system create 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()));
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        URI fsId = getTaskCompleter().getId();
        FileShare fsObj = dbClient.queryObject(FileShare.class, fsId);
        // If terminal state update storage pool capacity
        if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
            VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, fsObj.getPool(), null);
        }
        if (_status == JobStatus.SUCCESS && fsObj != null) {
            updateFS(fsObj, dbClient, logMsgBuilder, vnxeApiClient);
        } else if (_status == JobStatus.FAILED && fsObj != null) {
            logMsgBuilder.append("\n");
            logMsgBuilder.append(String.format("Task %s failed to expand file system: %s", opId, fsId.toString()));
        } else {
            logMsgBuilder.append(String.format("The file system: %s is not found anymore", fsId));
        }
        _logger.info(logMsgBuilder.toString());
        FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, _isSuccess, logMsgBuilder.toString(), "", fsObj, String.valueOf(fsObj.getCapacity()));
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemJob", e);
        setErrorStatus("Encountered an internal error during file system create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : 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)36 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)13