Search in sources :

Example 1 with CloneCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter in project coprhd-controller by CoprHD.

the class SmisCloneVolumeJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    _log.info("START updateStatus for clone volume");
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        CIMConnectionFactory cimConnectionFactory;
        WBEMClient client = null;
        CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
        Volume cloneVolume = dbClient.queryObject(Volume.class, completer.getId());
        // from pool's reserved capacity map.
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            cimConnectionFactory = jobContext.getCimConnectionFactory();
            client = getWBEMClient(dbClient, cimConnectionFactory);
            URI poolURI = cloneVolume.getPool();
            SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
            StoragePool pool = dbClient.queryObject(StoragePool.class, poolURI);
            StringMap reservationMap = pool.getReservedCapacityMap();
            // remove from reservation map
            reservationMap.remove(cloneVolume.getId().toString());
            dbClient.persistObject(pool);
        }
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info("Clone creation success");
            iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (iterator.hasNext()) {
                CIMObjectPath cloneVolumePath = iterator.next();
                CIMInstance syncVolume = client.getInstance(cloneVolumePath, false, false, null);
                String deviceId = cloneVolumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
                String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
                String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
                cloneVolume.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
                cloneVolume.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
                cloneVolume.setWWN(wwn.toUpperCase());
                cloneVolume.setAlternateName(alternateName);
                cloneVolume.setNativeId(deviceId);
                cloneVolume.setDeviceLabel(elementName);
                cloneVolume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, cloneVolume));
                cloneVolume.setInactive(false);
                if (cloneVolume.getSyncActive()) {
                    cloneVolume.setReplicaState(ReplicationState.CREATED.name());
                } else {
                    cloneVolume.setReplicaState(ReplicationState.INACTIVE.name());
                }
                dbClient.persistObject(cloneVolume);
            }
        /*
                 * for (URI id : completer.getIds()) {
                 * completer.ready(dbClient);
                 * }
                 */
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            String msg = String.format("Failed job to create full copy from %s to %s", cloneVolume.getAssociatedSourceVolume(), cloneVolume.getId());
            _log.error(msg);
            cloneVolume.setInactive(true);
            dbClient.persistObject(cloneVolume);
        }
    } catch (Exception e) {
        String errorMsg = String.format("Encountered an internal error during block create clone job status " + "processing: %s", e.getMessage());
        setPostProcessingErrorStatus(errorMsg);
        _log.error("Failed to update status for " + getClass().getSimpleName(), e);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
        super.updateStatus(jobContext);
        _log.info("FINISH updateStatus for clone volume");
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient)

Example 2 with CloneCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter in project coprhd-controller by CoprHD.

the class SmisCreateCGCloneJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMInstance> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
        List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        if (jobStatus == JobStatus.SUCCESS) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            CIMObjectPath replicationGroupPath = client.associatorNames(getCimJob(), null, SmisConstants.SE_REPLICATION_GROUP, null, null).next();
            String replicationGroupID = (String) replicationGroupPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
            // VMAX instanceID, e.g., 000196700567+EMC_SMI_RG1414546375042 (8.0.2 provider)
            final String replicationGroupInstance = replicationGroupID.split(Constants.PATH_DELIMITER_REGEX)[storage.getUsingSmis80() ? 1 : 0];
            syncVolumeIter = client.associatorInstances(replicationGroupPath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
            processCGClones(syncVolumeIter, client, dbClient, clones, replicationGroupInstance, isSyncActive);
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create clone");
            for (Volume clone : clones) {
                clone.setInactive(true);
            }
            dbClient.persistObject(clones);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during create CG clone job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisCreateCGCloneJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) Volume(com.emc.storageos.db.client.model.Volume) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with CloneCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter in project coprhd-controller by CoprHD.

the class SmisVnxCreateCGCloneJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMInstance> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
        List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
        if (jobStatus == JobStatus.SUCCESS) {
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            // generate a UUID for the set of clones
            String setId = UUID.randomUUID().toString();
            syncVolumeIter = client.associatorInstances(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
            processCGClones(syncVolumeIter, client, dbClient, clones, setId, isSyncActive);
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create clone");
            for (Volume clone : clones) {
                clone.setInactive(true);
            }
            dbClient.persistObject(clones);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during create CG clone job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisVnxCreateCGCloneJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance)

Example 4 with CloneCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter in project coprhd-controller by CoprHD.

the class BlockStorageDeviceTest method testCreateClone.

@Test
public void testCreateClone() {
    URI sourceVolume = getVolumes(_storageSystem).get(0).getId();
    URI cloneVolume = createVolumes().get(0).getId();
    Boolean createInactive = false;
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    CloneCreateCompleter taskCompleter = new CloneCreateCompleter(cloneVolume, token);
    _deviceController.doCreateClone(_storageSystem, sourceVolume, cloneVolume, createInactive, taskCompleter);
}
Also used : CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Test(org.junit.Test)

Example 5 with CloneCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method createListClone.

public void createListClone(URI storage, List<URI> cloneList, Boolean createInactive, String taskId) {
    try {
        WorkflowStepCompleter.stepExecuting(taskId);
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        TaskCompleter taskCompleter = new CloneCreateCompleter(cloneList, taskId);
        getDevice(storageSystem.getSystemType()).doCreateListReplica(storageSystem, cloneList, createInactive, taskCompleter);
    } catch (Exception e) {
        _log.error(e.getMessage(), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(Volume.class, cloneList, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CloneCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter)6 Volume (com.emc.storageos.db.client.model.Volume)5 DbClient (com.emc.storageos.db.client.DbClient)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)3 CIMInstance (javax.cim.CIMInstance)3 WBEMClient (javax.wbem.client.WBEMClient)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 ApplicationTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter)2 BlockMirrorTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter)2 BlockSnapshotEstablishGroupTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter)2 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)2 MultiVolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter)2 SimpleTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter)2