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);
}
}
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);
}
}
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);
}
}
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));
}
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()));
}
}
Aggregations