Search in sources :

Example 61 with BlockConsistencyGroup

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

the class BlockConsistencyGroupAddVolumeCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    log.info("Updating add volume replicationGroupInstance");
    try {
        super.complete(dbClient, status, coded);
        if (status == Status.ready) {
            BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, getId());
            if (groupName == null) {
                groupName = (cg.getAlternateLabel() != null) ? cg.getAlternateLabel() : cg.getLabel();
            }
            VolumeGroup volumeGroup = ControllerUtils.getApplicationForCG(dbClient, cg, groupName);
            for (URI voluri : addVolumeList) {
                Volume volume = dbClient.queryObject(Volume.class, voluri);
                if (volume != null && !volume.getInactive()) {
                    boolean isFullCopy = ControllerUtils.isVolumeFullCopy(volume, dbClient);
                    if (!isFullCopy) {
                        volume.setReplicationGroupInstance(groupName);
                        volume.setConsistencyGroup(this.getConsistencyGroupURI());
                        boolean isVplexBackendVolume = Volume.checkForVplexBackEndVolume(dbClient, volume);
                        if (volumeGroup != null && !isVplexBackendVolume) {
                            // do not set Application Id on VPLEX backend volume
                            volume.getVolumeGroupIds().add(volumeGroup.getId().toString());
                        }
                        // instance on the parent virtual volume
                        if (isVplexBackendVolume) {
                            Volume virtualVolume = Volume.fetchVplexVolume(dbClient, volume);
                            if (null != virtualVolume) {
                                if (!groupName.equals(virtualVolume.getBackingReplicationGroupInstance())) {
                                    virtualVolume.setBackingReplicationGroupInstance(groupName);
                                    dbClient.updateObject(virtualVolume);
                                }
                            }
                        }
                        dbClient.updateObject(volume);
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error("Failed updating status. BlockConsistencyGroupRemoveVolume {}, for task " + getOpId(), getId(), e);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 62 with BlockConsistencyGroup

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

the class BlockConsistencyGroupTaskCompleter method recordBourneBlockConsistencyGroupEvent.

public void recordBourneBlockConsistencyGroupEvent(DbClient dbClient, URI consistencyGroupURI, RecordableEventManager.EventType evtType, Operation.Status status, String desc) throws Exception {
    RecordableEventManager eventManager = new RecordableEventManager();
    eventManager.setDbClient(dbClient);
    BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupURI);
    RecordableBourneEvent event = ControllerUtils.convertToRecordableBourneEvent(consistencyGroup, evtType.name(), desc, "", dbClient, ControllerUtils.BLOCK_EVENT_SERVICE, RecordType.Event.name(), ControllerUtils.BLOCK_EVENT_SOURCE);
    try {
        eventManager.recordEvents(event);
        _log.info("Bourne {} event recorded", evtType.name());
    } catch (Exception ex) {
        _log.error("Failed to record event. Event description: {}. Error: ", evtType.name(), ex);
    }
}
Also used : RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) RecordableEventManager(com.emc.storageos.volumecontroller.impl.monitoring.RecordableEventManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 63 with BlockConsistencyGroup

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

the class BlockConsistencyGroupUpdateCompleter method error.

@Override
public void error(DbClient dbClient, ServiceCoded serviceCoded) throws DeviceControllerException {
    try {
        super.error(dbClient, serviceCoded);
        BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, getConsistencyGroupURI());
        dbClient.error(BlockConsistencyGroup.class, consistencyGroup.getId(), getOpId(), serviceCoded);
        recordBourneBlockConsistencyGroupEvent(dbClient, consistencyGroup.getId(), eventType(Status.error), Status.error, eventMessage(Status.error, consistencyGroup));
    } catch (Exception e) {
        _log.error("Failed updating status. BlockConsistencyGroupUpdate {}, " + "for task " + getOpId(), getId(), e);
    }
}
Also used : DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 64 with BlockConsistencyGroup

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

the class BlockSnapshotSessionCompleter method getAllSources.

/**
 * Returns all appropriate sources for a given BlockSnapshotSession. That is, VPLEX volumes if
 * they exist or native backend volumes.
 *
 * For volumes that are not in any consistency group, the returned list shall contain only one element.
 *
 * @param snapSession   BlockSnapshotSession.
 * @param dbClient      Database client.
 * @return              List of one or more BlockObject instances.
 */
protected List<BlockObject> getAllSources(BlockSnapshotSession snapSession, DbClient dbClient) {
    if (NullColumnValueGetter.isNotNullValue(snapSession.getReplicationGroupInstance())) {
        BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, snapSession.getConsistencyGroup());
        List<Volume> cgSources = BlockConsistencyGroupUtils.getAllCGVolumes(cg, dbClient);
        // return only those volumes belonging to session's RG
        return ControllerUtils.getAllVolumesForRGInCG(cgSources, snapSession.getReplicationGroupInstance(), snapSession.getStorageController(), dbClient);
    }
    return Lists.newArrayList(getSource(snapSession, dbClient));
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 65 with BlockConsistencyGroup

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

the class ExternalBlockStorageDevice method doRemoveFromConsistencyGroup.

@Override
public void doRemoveFromConsistencyGroup(StorageSystem storageSystem, URI consistencyGroupId, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
    BlockConsistencyGroup consistencyGroup = null;
    try {
        _log.info("{} doRemoveVolumesFromConsistencyGroup START ...", storageSystem.getSerialNumber());
        BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
        List<Volume> volumes = dbClient.queryObject(Volume.class, blockObjects);
        List<StorageVolume> driverVolumes = new ArrayList<>();
        consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
        for (Volume volume : volumes) {
            StorageVolume driverVolume = new StorageVolume();
            driverVolume.setStorageSystemId(storageSystem.getNativeId());
            driverVolume.setNativeId(volume.getNativeId());
            driverVolume.setRequestedCapacity(volume.getCapacity());
            driverVolume.setThinlyProvisioned(volume.getThinlyProvisioned());
            driverVolume.setConsistencyGroup(consistencyGroup.getNativeId());
            driverVolume.setDisplayName(volume.getLabel());
            // add them to StorageVolumes list
            driverVolumes.add(driverVolume);
        }
        DriverTask task = driver.removeVolumesFromConsistencyGroup(driverVolumes, null);
        _log.info("doRemoveVolumesFromConsistencyGroup -- removing volumes {} from consistency Group: {}", volumes.toString(), consistencyGroupId);
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            for (Volume volume : volumes) {
                volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
            }
            dbClient.updateObject(volumes);
            taskCompleter.ready(dbClient);
        } else {
            _log.error(String.format("Remove volumes from Consistency Group operation failed %s", task.getMessage()));
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), task.getMessage()));
        }
        _log.info("{} doRemoveVolumesFromConsistencyGroup END ...", storageSystem.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Remove volumes from Consistency Group operation failed %s", e.getMessage()));
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)253 Volume (com.emc.storageos.db.client.model.Volume)134 URI (java.net.URI)134 ArrayList (java.util.ArrayList)102 NamedURI (com.emc.storageos.db.client.model.NamedURI)88 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)71 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)71 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)49 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)46 StringSet (com.emc.storageos.db.client.model.StringSet)45 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 ControllerException (com.emc.storageos.volumecontroller.ControllerException)43 BlockObject (com.emc.storageos.db.client.model.BlockObject)37 Project (com.emc.storageos.db.client.model.Project)33 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 HashMap (java.util.HashMap)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)29 List (java.util.List)29 HashSet (java.util.HashSet)28 Produces (javax.ws.rs.Produces)28