Search in sources :

Example 6 with ParametersOut

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

the class VNXeBlockCreateCGSnapshotJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
        List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemUri());
        if (_status == JobStatus.SUCCESS) {
            VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
            VNXeCommandJob vnxeJob = vnxeApiClient.getJob(getJobIds().get(0));
            ParametersOut output = vnxeJob.getParametersOut();
            // get the luns belonging to the lun group
            String lunGroupSnapId = output.getId();
            VNXeLunGroupSnap groupSnap = vnxeApiClient.getLunGroupSnapshot(lunGroupSnapId);
            List<VNXeLun> groupLuns = vnxeApiClient.getLunByStorageResourceId(groupSnap.getStorageResource().getId());
            // Create mapping of volume.nativeDeviceId to BlockSnapshot object
            Map<String, BlockSnapshot> volumeToSnapMap = new HashMap<String, BlockSnapshot>();
            for (BlockSnapshot snapshot : snapshots) {
                Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
                volumeToSnapMap.put(volume.getNativeId(), snapshot);
            }
            for (VNXeLun groupLun : groupLuns) {
                BlockSnapshot snapshot = volumeToSnapMap.get(groupLun.getId());
                if (snapshot == null) {
                    _logger.info("No snapshot found for the vnxe lun - ", groupLun.getId());
                    continue;
                }
                snapshot.setNativeId(output.getId());
                snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
                snapshot.setDeviceLabel(groupLun.getName());
                snapshot.setReplicationGroupInstance(lunGroupSnapId);
                snapshot.setIsSyncActive(true);
                snapshot.setInactive(false);
                snapshot.setCreationTime(Calendar.getInstance());
                snapshot.setWWN(groupLun.getSnapWwn());
                snapshot.setAllocatedCapacity(groupLun.getSnapsSizeAllocated());
                snapshot.setProvisionedCapacity(groupLun.getSnapsSize());
                _logger.info(String.format("Going to set blocksnapshot %1$s nativeId to %2$s (%3$s). Associated lun is %4$s (%5$s)", snapshot.getId().toString(), output.getId(), snapshot.getLabel(), groupLun.getId(), groupLun.getName()));
                dbClient.persistObject(snapshot);
            }
        } else if (_status == JobStatus.FAILED) {
            _logger.info("Failed to create snapshot");
            for (BlockSnapshot snapshot : snapshots) {
                snapshot.setInactive(true);
            }
            dbClient.persistObject(snapshots);
        }
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeBlockCreateCGSnapshotJob", e);
        setErrorStatus("Encountered an internal error during group snapshot create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : VNXeLunGroupSnap(com.emc.storageos.vnxe.models.VNXeLunGroupSnap) DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ParametersOut(com.emc.storageos.vnxe.models.ParametersOut) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Volume(com.emc.storageos.db.client.model.Volume) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

DbClient (com.emc.storageos.db.client.DbClient)6 Volume (com.emc.storageos.db.client.model.Volume)6 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)6 ParametersOut (com.emc.storageos.vnxe.models.ParametersOut)6 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)6 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 HashMap (java.util.HashMap)4 Snap (com.emc.storageos.vnxe.models.Snap)3 VNXeLun (com.emc.storageos.vnxe.models.VNXeLun)3 BlockSnapshotCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)2 VNXeLunGroupSnap (com.emc.storageos.vnxe.models.VNXeLunGroupSnap)2 VNXeLunSnap (com.emc.storageos.vnxe.models.VNXeLunSnap)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)1