Search in sources :

Example 31 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class HDSMirrorOperations method deleteSingleVolumeMirror.

/**
 * Deletes mirror instance from StorageSystem
 */
@Override
public void deleteSingleVolumeMirror(StorageSystem storageSystem, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Mirror Start - Array:%s", storageSystem.getSerialNumber()));
        Set<String> thickLogicalUnitIdList = new HashSet<String>();
        Set<String> thinLogicalUnitIdList = new HashSet<String>();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
        logMsgBuilder.append(String.format("%nMirror:%s", mirrorObj.getLabel()));
        String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(mirrorObj.getNativeId(), storageSystem);
        LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, logicalUnitObjectId);
        if (logicalUnit == null) {
            // related volume state (if any) has been deleted. skip
            // processing, if already deleted from array.
            log.info(String.format("Mirror %s already deleted: ", mirrorObj.getNativeId()));
            // HDSMirrorOperations.removeReferenceFromSourceVolume(dbClient, mirrorObj);
            dbClient.markForDeletion(mirrorObj);
        } else {
            if (mirrorObj.getThinlyProvisioned()) {
                thinLogicalUnitIdList.add(logicalUnitObjectId);
            } else {
                thickLogicalUnitIdList.add(logicalUnitObjectId);
            }
            log.info(logMsgBuilder.toString());
            if (!thickLogicalUnitIdList.isEmpty()) {
                String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectID, thickLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThickLUsJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThickLUsJobId, mirrorObj.getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
                }
            }
            if (!thinLogicalUnitIdList.isEmpty()) {
                String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectID, thinLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThinHDSJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThinHDSJobId, mirrorObj.getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
                }
            }
        }
        log.info("Delete Mirror End - Array: {} Mirror: {}", storageSystem.getSerialNumber(), mirror);
    } catch (Exception e) {
        log.error("Problem in deleteSingleVolumeMirror: ", e);
        ServiceError error = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeMirror", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : HDSBlockMirrorDeleteJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockMirrorDeleteJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) HashSet(java.util.HashSet)

Example 32 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ReplicaDeviceController method addMirrorToReplicationGroupStep.

private String addMirrorToReplicationGroupStep(final Workflow workflow, String waitFor, StorageSystem storageSystem, List<Volume> volumes, String repGroupName, URI cgURI) {
    log.info("START create mirror step");
    URI storage = storageSystem.getId();
    List<URI> mirrorList = new ArrayList<URI>();
    for (Volume volume : volumes) {
        String mirrorLabel = volume.getLabel() + "-" + repGroupName;
        BlockMirror mirror = createMirror(volume, volume.getVirtualPool(), volume.getPool(), mirrorLabel, repGroupName);
        URI mirrorId = mirror.getId();
        mirrorList.add(mirrorId);
    }
    waitFor = _blockDeviceController.createListMirrorStep(workflow, waitFor, storageSystem, mirrorList);
    waitFor = workflow.createStep(BlockDeviceController.UPDATE_CONSISTENCY_GROUP_STEP_GROUP, String.format("Updating consistency group  %s", cgURI), waitFor, storage, _blockDeviceController.getDeviceType(storage), this.getClass(), addToReplicationGroupMethod(storage, cgURI, repGroupName, mirrorList), removeFromReplicationGroupMethod(storage, cgURI, repGroupName, mirrorList), null);
    log.info(String.format("Step created for adding mirror [%s] to group on device [%s]", Joiner.on("\t").join(mirrorList), storage));
    return waitFor;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 33 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ReplicaDeviceController method getMirrorsToBeRemoved.

private List<URI> getMirrorsToBeRemoved(Set<URI> volumes, String repGroupName) {
    List<URI> replicas = new ArrayList<URI>();
    URIQueryResultList queryResults = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getMirrorReplicationGroupInstanceConstraint(repGroupName), queryResults);
    Iterator<URI> resultsIter = queryResults.iterator();
    while (resultsIter.hasNext()) {
        BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, resultsIter.next());
        if (volumes.contains(mirror.getSource().getURI())) {
            replicas.add(mirror.getId());
        }
    }
    return replicas;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 34 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class ReplicaDeviceController method createMirror.

/**
 * Adds a BlockMirror structure for a Volume. It also calls addMirrorToVolume to
 * link the mirror into the volume's mirror set.
 *
 * @param volume Volume
 * @param vPoolURI
 * @param recommendedPoolURI Pool that should be used to create the mirror
 * @param volumeLabel
 * @param repGroupName
 * @return BlockMirror (persisted)
 */
private BlockMirror createMirror(Volume volume, URI vPoolURI, URI recommendedPoolURI, String volumeLabel, String repGroupName) {
    BlockMirror createdMirror = new BlockMirror();
    createdMirror.setSource(new NamedURI(volume.getId(), volume.getLabel()));
    createdMirror.setId(URIUtil.createId(BlockMirror.class));
    URI cgUri = volume.getConsistencyGroup();
    if (!NullColumnValueGetter.isNullURI(cgUri)) {
        createdMirror.setConsistencyGroup(cgUri);
    }
    createdMirror.setLabel(volumeLabel);
    createdMirror.setStorageController(volume.getStorageController());
    createdMirror.setSystemType(volume.getSystemType());
    createdMirror.setVirtualArray(volume.getVirtualArray());
    createdMirror.setProtocol(new StringSet());
    createdMirror.getProtocol().addAll(volume.getProtocol());
    createdMirror.setCapacity(volume.getCapacity());
    createdMirror.setProject(new NamedURI(volume.getProject().getURI(), createdMirror.getLabel()));
    createdMirror.setTenant(new NamedURI(volume.getTenant().getURI(), createdMirror.getLabel()));
    createdMirror.setPool(recommendedPoolURI);
    createdMirror.setVirtualPool(vPoolURI);
    createdMirror.setSyncState(SynchronizationState.UNKNOWN.toString());
    createdMirror.setSyncType(BlockMirror.MIRROR_SYNC_TYPE);
    createdMirror.setThinlyProvisioned(volume.getThinlyProvisioned());
    createdMirror.setReplicationGroupInstance(repGroupName);
    _dbClient.createObject(createdMirror);
    addMirrorToVolume(volume, createdMirror);
    return createdMirror;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 35 with BlockMirror

use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.

the class StorageVolumeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    _keyMap = keyMap;
    _updateVolumes = new ArrayList<Volume>();
    _updateSnapShots = new ArrayList<BlockSnapshot>();
    _updateMirrors = new ArrayList<BlockMirror>();
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
        // create empty place holder list for meta volume paths (cannot define this in xml)
        _metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (_metaVolumePaths == null) {
            keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
        }
        _volumeToSpaceConsumedMap = (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);
        CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
        _isVMAX3 = storagePoolPath.getObjectName().equals(StoragePool.PoolClassNames.Symm_SRPStoragePool.name());
        processResultbyChunk(resultObj, keyMap);
        _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
        _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
        _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
    } catch (Exception e) {
        _logger.error("Processing Volumes and Snapshots failed", e);
    } finally {
        _updateVolumes = null;
        _updateSnapShots = null;
        _updateMirrors = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Volume(com.emc.storageos.db.client.model.Volume) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)115 Volume (com.emc.storageos.db.client.model.Volume)77 URI (java.net.URI)49 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)43 ArrayList (java.util.ArrayList)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)29 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)28 CIMObjectPath (javax.cim.CIMObjectPath)26 CIMInstance (javax.cim.CIMInstance)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 CIMArgument (javax.cim.CIMArgument)14 WBEMException (javax.wbem.WBEMException)14 BlockObject (com.emc.storageos.db.client.model.BlockObject)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9