use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class SmisBlockDeleteCGMirrorJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockMirrorDeleteCompleter completer = (BlockMirrorDeleteCompleter) getTaskCompleter();
List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
Set<URI> poolURIs = new HashSet<URI>();
for (BlockMirror mirror : mirrors) {
poolURIs.add(mirror.getPool());
}
for (URI poolURI : poolURIs) {
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Group mirror delete success");
dbClient.markForDeletion(mirrors);
} else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
String msg = String.format("Failed to delete group mirrors");
_log.error(msg);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block delete group mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteCGMirrorJob", e);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class SmisCreateListReplicaJob method processListReplica.
protected void processListReplica(CloseableIterator<CIMInstance> syncVolumeIter, WBEMClient client, DbClient dbClient, SmisCommandHelper helper, StorageSystem storage, List<? extends BlockObject> replicas, int syncType, boolean isSyncActive) throws Exception {
// Get mapping of target Id to source Id
Map<String, String> tgtIdToSrcIdMap = !_tgtToSrcMap.isEmpty() ? _tgtToSrcMap : getConsistencyGroupSyncPairs(dbClient, helper, storage, _srcNativeIdToReplicaUriMap.keySet(), syncType);
Calendar now = Calendar.getInstance();
while (syncVolumeIter.hasNext()) {
// Get the sync volume native device id
CIMInstance syncVolume = syncVolumeIter.next();
CIMObjectPath syncVolumePath = syncVolume.getObjectPath();
String syncDeviceID = syncVolumePath.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);
// Get the associated volume for this sync volume
String volumeDeviceID = tgtIdToSrcIdMap.get(syncDeviceID);
// Lookup the replica ID based on the source volume native device ID
URI replicaURI = _srcNativeIdToReplicaUriMap.get(volumeDeviceID);
BlockObject replica = BlockObject.fetch(dbClient, replicaURI);
// we need to perform this null check to avoid a NPE.
if (!URIUtil.isType(replicaURI, BlockSnapshot.class) || replica != null) {
replica.setNativeId(syncDeviceID);
replica.setDeviceLabel(elementName);
replica.setCreationTime(now);
replica.setWWN(wwn.toUpperCase());
replica.setAlternateName(alternateName);
if (replica instanceof BlockSnapshot) {
BlockSnapshot snapshot = (BlockSnapshot) replica;
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
snapshot.setIsSyncActive(isSyncActive);
snapshot.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
snapshot.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
updateSnapshotSessionLinkedTargets(snapshot, dbClient);
setSettingsInstance(storage, snapshot, dbClient);
} else if (replica instanceof BlockMirror) {
BlockMirror mirror = (BlockMirror) replica;
mirror.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, mirror));
mirror.setSyncType(Integer.toString(syncType));
mirror.setSyncState(SynchronizationState.SYNCHRONIZED.name());
mirror.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
mirror.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
} else if (replica instanceof Volume) {
Volume clone = (Volume) replica;
clone.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, clone));
clone.setSyncActive(isSyncActive);
if (isSyncActive) {
clone.setReplicaState(ReplicationState.SYNCHRONIZED.name());
} else {
clone.setReplicaState(ReplicationState.INACTIVE.name());
}
clone.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
clone.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
}
dbClient.persistObject(replica);
}
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockObjectConsistencyGroupMigrationTest method createBlockMirrorData.
/**
* Creates the BlockObject BlockMirror data.
*
* @param name
* @param numSnapshots
* @throws Exception
*/
private void createBlockMirrorData(String name, int numBlockMirrors) throws Exception {
// Create the volume for the snapshots
Volume volume = new Volume();
URI volumeURI = URIUtil.createId(Volume.class);
testVolumeURIs.add(volumeURI);
volume.setId(volumeURI);
volume.setLabel("blockMirrorVolume");
URI cgUri = createBlockConsistencyGroup("blockMirrorVolume-cg");
volume.setConsistencyGroup(cgUri);
_dbClient.createObject(volume);
for (int i = 1; i <= numBlockMirrors; i++) {
BlockMirror blockMirror = new BlockMirror();
URI blockMirrorURI = URIUtil.createId(BlockMirror.class);
testBlockMirrorURIs.add(blockMirrorURI);
blockMirror.setId(blockMirrorURI);
blockMirror.setLabel(name + i);
blockMirror.setConsistencyGroup(cgUri);
_dbClient.createObject(blockMirror);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockObjectMultipleConsistencyGroupsMigrationTest method prepareBlockMirrorData.
/**
* Creates the BlockObject BlockMirror data.
*
* @param name
* @param numBlockMirrors
* @throws Exception
*/
private void prepareBlockMirrorData(String name, int numBlockMirrors) throws Exception {
BlockConsistencyGroup cg = createBlockConsistencyGroup("blockMirrorConsistencyGroup", null, Types.LOCAL.name(), true);
for (int i = 1; i <= numBlockMirrors; i++) {
BlockMirror blockMirror = new BlockMirror();
URI blockMirrorURI = URIUtil.createId(BlockMirror.class);
blockMirrorURIs.add(blockMirrorURI);
blockMirror.setId(blockMirrorURI);
blockMirror.setLabel(name + i);
// Set the 'old' field value so it can be migrated
blockMirror.addConsistencyGroup(cg.getId().toString());
_dbClient.createObject(blockMirror);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockObjectSystemTypeMigrationTest method prepareData.
@Override
protected void prepareData() throws Exception {
List<Volume> volumesToCreate = new ArrayList<Volume>();
// set up a vplex system
StorageSystem vplex = new StorageSystem();
vplex.setId(URIUtil.createId(StorageSystem.class));
vplex.setLabel("TEST_VPLEX");
vplex.setSystemType(DiscoveredDataObject.Type.vplex.name());
_dbClient.createObject(vplex);
// create vplex test volumes
for (int i = 1; i <= VPLEX_VOLUME_COUNT; i++) {
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setLabel("VplexSystemTypeMigrationTester" + i);
volume.setStorageController(vplex.getId());
volumesToCreate.add(volume);
}
// set up a vnx system
StorageSystem vnx = new StorageSystem();
vnx.setId(URIUtil.createId(StorageSystem.class));
vnx.setLabel("TEST_VNX");
vnx.setSystemType(DiscoveredDataObject.Type.vnxblock.name());
_dbClient.createObject(vnx);
// create vnx test volumes
for (int i = 1; i <= VNX_VOLUME_COUNT; i++) {
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setLabel("VnxSystemTypeMigrationTester" + i);
volume.setStorageController(vnx.getId());
volumesToCreate.add(volume);
}
// set up a vmax system
StorageSystem vmax = new StorageSystem();
vmax.setId(URIUtil.createId(StorageSystem.class));
vmax.setLabel("TEST_VMAX");
vmax.setSystemType(DiscoveredDataObject.Type.vmax.name());
_dbClient.createObject(vmax);
// create vmax test volumes
for (int i = 1; i <= VMAX_VOLUME_COUNT; i++) {
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setLabel("VmaxSystemTypeMigrationTester" + i);
volume.setStorageController(vmax.getId());
volumesToCreate.add(volume);
}
// set up a vmax3 system
StorageSystem vmax3 = new StorageSystem();
vmax3.setId(URIUtil.createId(StorageSystem.class));
vmax3.setLabel("TEST_VMAX3");
// vmax3 systems are created with a "vmax" type, just to make things difficult;
// actual type is determine by the firmware version number
vmax3.setSystemType(DiscoveredDataObject.Type.vmax.name());
vmax3.setFirmwareVersion("5977.931.886");
_dbClient.createObject(vmax3);
// create vmax3 test volumes
for (int i = 1; i <= VMAX3_VOLUME_COUNT; i++) {
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setLabel("Vmax3SystemTypeMigrationTester" + i);
volume.setStorageController(vmax3.getId());
volumesToCreate.add(volume);
}
_dbClient.createObject(volumesToCreate);
List<BlockSnapshot> snapsToCreate = new ArrayList<BlockSnapshot>();
// create vmax3 test snapshots
for (int i = 1; i <= SNAPSHOT_COUNT; i++) {
BlockSnapshot snap = new BlockSnapshot();
snap.setId(URIUtil.createId(BlockSnapshot.class));
snap.setLabel("SnapshotSystemTypeMigrationTester" + i);
snap.setStorageController(vmax3.getId());
snapsToCreate.add(snap);
}
_dbClient.createObject(snapsToCreate);
List<BlockMirror> mirrorsToCreate = new ArrayList<BlockMirror>();
// create vmax3 test mirrors
for (int i = 1; i <= MIRROR_COUNT; i++) {
BlockMirror mirror = new BlockMirror();
mirror.setId(URIUtil.createId(BlockMirror.class));
mirror.setLabel("MirrorSystemTypeMigrationTester" + i);
mirror.setStorageController(vmax3.getId());
mirrorsToCreate.add(mirror);
}
_dbClient.createObject(mirrorsToCreate);
}
Aggregations