use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class XtremioBlockSnapshotDeviceLabelMigrationTest method createXIOSnapshots.
private void createXIOSnapshots() throws Exception {
log.info("Preparing BlockSnapshot for XtremioBlockSnapshotDeviceLabelMigrationTest");
StorageSystem xioStorageSystem = new StorageSystem();
xioStorageSystem.setId(URIUtil.createId(StorageSystem.class));
xioStorageSystem.setSystemType(DiscoveredDataObject.Type.xtremio.name());
_dbClient.createObject(xioStorageSystem);
Volume parentVolume = new Volume();
URI volumeUri = URIUtil.createId(Volume.class);
parentVolume.setId(volumeUri);
parentVolume.setLabel("parentVolume");
_dbClient.createObject(parentVolume);
NamedURI parentVolNamedUri = new NamedURI(parentVolume.getId(), parentVolume.getLabel());
BlockSnapshot snapshot = createSnapshot(SNAPSHOT_LABEL, xioStorageSystem.getId(), parentVolNamedUri);
_dbClient.createObject(snapshot);
BlockSnapshot snapshotWithDeviceLabel = createSnapshot("snap-with-device-label", xioStorageSystem.getId(), parentVolNamedUri);
snapshotWithDeviceLabel.setDeviceLabel("snapshot-device-label");
_dbClient.createObject(snapshotWithDeviceLabel);
BlockSnapshot inactiveSnapshot = createSnapshot("inactive-snapshot", xioStorageSystem.getId(), parentVolNamedUri);
_dbClient.createObject(inactiveSnapshot);
inactiveSnapshot.setInactive(true);
_dbClient.updateObject(inactiveSnapshot);
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class SmisBlockDeleteSnapshotJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
BlockSnapshotDeleteCompleter completer = (BlockSnapshotDeleteCompleter) getTaskCompleter();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, completer.getId());
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
// 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);
NamedURI volumeURI = snapshot.getParent();
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
URI poolURI = volume.getPool();
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Deleting snapshot job was successful.");
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to delete snapshot: {}", getTaskCompleter().getId());
}
} catch (Exception e) {
setFatalErrorStatus(e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteSnapshotJob", e);
Operation updateOp = new Operation();
updateOp.setStatus("Encountered an internal error during block delete snapshot job status processing: " + e.getMessage());
dbClient.updateTaskOpStatus(BlockSnapshot.class, getTaskCompleter().getId(), getTaskCompleter().getOpId(), updateOp);
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionUnlinkTargetJob method getBlockConsistencyGroupForPromotedSnapshot.
/**
* Given a CG snapshot that is to be promoted, create a new BlockConsistencyGroup based on its
* ReplicationGroup. A group cache parameter is accepted and serves to cache BlockConsistencyGroup
* instances that have already been created.
*
* @param snapshot BlockSnapshot being promoted.
* @param groupCache Cache mapping of ReplicationGroup name to BlockConsistencyGroup instances.
* @param dbClient Database client.
* @return BlockConsistencyGroup URI or null.
*/
private URI getBlockConsistencyGroupForPromotedSnapshot(BlockSnapshot snapshot, Map<String, BlockConsistencyGroup> groupCache, DbClient dbClient) {
if (!snapshot.hasConsistencyGroup()) {
return null;
}
// Create new BlockConsistencyGroup instances to track the existing target groups.
String groupInstance = snapshot.getReplicationGroupInstance();
BlockConsistencyGroup cg = null;
if (groupCache.containsKey(groupInstance)) {
cg = groupCache.get(groupInstance);
} else {
cg = new BlockConsistencyGroup();
cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
Project project = dbClient.queryObject(Project.class, snapshot.getProject().getURI());
cg.setProject(new NamedURI(project.getId(), project.getLabel()));
cg.setTenant(new NamedURI(project.getTenantOrg().getURI(), project.getTenantOrg().getName()));
String repGrpName = groupInstance.substring(groupInstance.indexOf("+") + 1, groupInstance.length());
cg.setLabel(repGrpName);
StringSetMap map = new StringSetMap();
map.put(snapshot.getStorageController().toString(), new StringSet(Arrays.asList(repGrpName)));
cg.setSystemConsistencyGroups(map);
StringSet types = new StringSet();
types.add(BlockConsistencyGroup.Types.LOCAL.name());
cg.setTypes(types);
cg.setRequestedTypes(types);
cg.setStorageController(snapshot.getStorageController());
s_logger.info("Creating new BlockConsistencyGroup for ReplicationGroup {} with ID: {}", groupInstance, cg.getId());
dbClient.createObject(cg);
groupCache.put(groupInstance, cg);
}
return cg.getId();
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class SmisDeleteVolumeJob method updateStatus.
/**
* Called to update the job status when the volume delete job completes.
*
* @param jobContext The job context.
*/
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
// Get list of volumes; get set of storage pool ids to which they belong.
List<Volume> volumes = new ArrayList<Volume>();
Set<URI> poolURIs = new HashSet<URI>();
for (URI id : getTaskCompleter().getIds()) {
Volume volume = dbClient.queryObject(Volume.class, id);
if (volume != null && !volume.getInactive()) {
volumes.add(volume);
poolURIs.add(volume.getPool());
}
}
// If terminal job state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
// Update capacity of storage pools.
for (URI poolURI : poolURIs) {
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
}
StringBuilder logMsgBuilder = new StringBuilder();
if (jobStatus == JobStatus.SUCCESS) {
for (Volume volume : volumes) {
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Successfully deleted volume %s", volume.getId()));
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
for (URI id : getTaskCompleter().getIds()) {
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Failed to delete volume: %s", id));
}
// This fix, converts a RDF device to non-rdf device in ViPr, so that this volume is exposed to UI for deletion again.
for (Volume volume : volumes) {
if (volume.checkForSRDF()) {
volume.setPersonality(NullColumnValueGetter.getNullStr());
volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
volume.setLinkStatus(NullColumnValueGetter.getNullStr());
if (!NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent())) {
volume.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
volume.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
volume.setSrdfGroup(NullColumnValueGetter.getNullURI());
} else if (null != volume.getSrdfTargets()) {
volume.getSrdfTargets().clear();
}
}
}
dbClient.updateObject(volumes);
}
if (logMsgBuilder.length() > 0) {
_log.info(logMsgBuilder.toString());
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during delete volume job status processing: " + e.getMessage());
_log.error("Caught exception while handling updateStatus for delete volume job.", e);
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class VNXeBlockRestoreSnapshotJob method getSnapshotFromVol.
private BlockSnapshot getSnapshotFromVol(final Volume volume, final String label) {
BlockSnapshot createdSnap = new BlockSnapshot();
createdSnap.setId(URIUtil.createId(BlockSnapshot.class));
createdSnap.setConsistencyGroup(volume.getConsistencyGroup());
createdSnap.setSourceNativeId(volume.getNativeId());
createdSnap.setParent(new NamedURI(volume.getId(), label));
createdSnap.setLabel(label);
createdSnap.setStorageController(volume.getStorageController());
createdSnap.setSystemType(volume.getSystemType());
createdSnap.setVirtualArray(volume.getVirtualArray());
createdSnap.setProtocol(new StringSet());
createdSnap.getProtocol().addAll(volume.getProtocol());
createdSnap.setProject(new NamedURI(volume.getProject().getURI(), label));
createdSnap.setSnapsetLabel(ResourceOnlyNameGenerator.removeSpecialCharsForName(label, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH));
return createdSnap;
}
Aggregations