use of com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate in project coprhd-controller by CoprHD.
the class DellSCDiscovery method getVolumeMirrors.
/**
* Gets all mirrors of a volume.
*
* @param storageVolume The volume.
* @return The mirrors.
*/
public List<VolumeMirror> getVolumeMirrors(StorageVolume storageVolume) {
LOG.info("Getting mirrors for volume {}", storageVolume.getNativeId());
List<VolumeMirror> result = new ArrayList<>();
try {
StorageCenterAPI api = connectionManager.getConnection(storageVolume.getStorageSystemId());
ScVolume scVolume = api.getVolume(storageVolume.getNativeId());
if (scVolume != null && scVolume.cmmSource) {
ScCopyMirrorMigrate[] cmms = api.getVolumeCopyMirrorMigrate(scVolume.instanceId);
for (ScCopyMirrorMigrate cmm : cmms) {
if ("Mirror".equals(cmm.type)) {
ScVolume targetVol = api.getVolume(cmm.destinationVolume.instanceId);
VolumeMirror mirror = new VolumeMirror();
mirror.setAccessStatus(AccessStatus.READ_WRITE);
mirror.setDeviceLabel(targetVol.name);
mirror.setDisplayName(targetVol.name);
mirror.setNativeId(targetVol.instanceId);
mirror.setParentId(cmm.sourceVolume.instanceId);
mirror.setStorageSystemId(storageVolume.getStorageSystemId());
SynchronizationState syncState = SynchronizationState.SYNCHRONIZED;
if (cmm.percentComplete != 100) {
syncState = SynchronizationState.COPYINPROGRESS;
}
mirror.setSyncState(syncState);
mirror.setWwn(targetVol.deviceId);
result.add(mirror);
}
}
}
} catch (DellSCDriverException e) {
String msg = String.format("Error getting mirrors for volume %s", storageVolume.getNativeId(), e);
LOG.warn(msg);
}
return result;
}
use of com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate in project coprhd-controller by CoprHD.
the class DellSCMirroring method deleteVolumeMirror.
/**
* Delete volume mirror and the destination volume.
*
* @param mirror The mirror to delete.
* @return The delete task.
*/
public DriverTask deleteVolumeMirror(VolumeMirror mirror) {
LOG.info("Deleting volume mirror {}", mirror);
DellSCDriverTask task = new DellSCDriverTask("deleteVolumeMirror");
try {
StorageCenterAPI api = connectionManager.getConnection(mirror.getStorageSystemId());
ScCopyMirrorMigrate cmm = api.getMirror(mirror.getNativeId());
api.deleteMirror(cmm.instanceId);
api.deleteVolume(cmm.destinationVolume.instanceId);
task.setStatus(TaskStatus.READY);
} catch (StorageCenterAPIException | DellSCDriverException dex) {
String error = String.format("Error deleting volume mirror %s: %s", mirror.getNativeId(), dex);
LOG.error(error);
task.setFailed(error);
}
return task;
}
use of com.emc.storageos.driver.dellsc.scapi.objects.ScCopyMirrorMigrate in project coprhd-controller by CoprHD.
the class DellSCMirroring method createVolumeMirror.
/**
* Create volume mirrors.
*
* @param mirrors The volume mirrors to create.
* @return The creation task.
*/
public DriverTask createVolumeMirror(List<VolumeMirror> mirrors) {
LOG.info("Creating volume mirror");
DriverTask task = new DellSCDriverTask("createVolumeMirror");
StringBuilder errBuffer = new StringBuilder();
int mirrorsCreated = 0;
for (VolumeMirror mirror : mirrors) {
LOG.debug("Creating mirror of volume {}", mirror.getParentId());
String ssn = mirror.getStorageSystemId();
try {
StorageCenterAPI api = connectionManager.getConnection(ssn);
ScVolume srcVol = api.getVolume(mirror.getParentId());
ScVolume destVol = api.createVolume(ssn, mirror.getDisplayName(), srcVol.storageType.instanceId, SizeUtil.byteToMeg(SizeUtil.sizeStrToBytes(srcVol.configuredSize)), null);
ScCopyMirrorMigrate scCmm = api.createMirror(ssn, srcVol.instanceId, destVol.instanceId);
mirror.setNativeId(scCmm.instanceId);
mirror.setSyncState(SynchronizationState.COPYINPROGRESS);
mirrorsCreated++;
LOG.info("Created volume mirror '{}'", scCmm.instanceId);
} catch (StorageCenterAPIException | DellSCDriverException dex) {
String error = String.format("Error creating volume mirror %s: %s", mirror.getDisplayName(), dex);
LOG.error(error);
errBuffer.append(String.format("%s%n", error));
}
}
task.setMessage(errBuffer.toString());
if (mirrorsCreated == mirrors.size()) {
task.setStatus(TaskStatus.READY);
} else if (mirrorsCreated == 0) {
task.setStatus(TaskStatus.FAILED);
} else {
task.setStatus(TaskStatus.PARTIALLY_FAILED);
}
return task;
}
Aggregations