use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method createConsistencyGroup.
private BlockConsistencyGroup createConsistencyGroup() {
BlockConsistencyGroup cg = new BlockConsistencyGroup();
cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
cg.setType(BlockConsistencyGroup.Types.LOCAL.name());
cg.setLabel("ViPRTest");
cg.setProject(new NamedURI(_project.getId(), _project.getLabel()));
cg.setTenant(_project.getTenantOrg());
cg.setInactive(false);
_dbClient.createObject(cg);
return cg;
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class WorkflowTest method createVolumeResource.
/**
* creates a volume resource
*
* @return
*/
private Volume createVolumeResource() {
TenantOrg tenant = new TenantOrg();
tenant.setId(URIUtil.createId(TenantOrg.class));
dbClient.createObject(tenant);
Project project = new Project();
project.setId(URIUtil.createId(Project.class));
project.setLabel("project1");
project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
dbClient.createObject(project);
Volume vol = new Volume();
vol.setId(URIUtil.createId(Volume.class));
vol.setLabel("volumeObject");
vol.setProject(new NamedURI(project.getId(), vol.getLabel()));
vol.setTenant(new NamedURI(tenant.getId(), vol.getLabel()));
dbClient.createObject(vol);
return vol;
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class SRDFOperations method updateSourceAndTargetPairings.
/**
* Checks with the SMI-S provider to ensure that ViPR's source and target volumes are paired up
* correctly and fixes any inconsistencies.
*
* @param sourceURIs The source volumes
* @param targetURIs The target volumes
*/
public void updateSourceAndTargetPairings(List<URI> sourceURIs, List<URI> targetURIs) {
final String KEY = "%s:%s";
List<Volume> sources = dbClient.queryObject(Volume.class, sourceURIs);
List<Volume> targets = dbClient.queryObject(Volume.class, targetURIs);
// Convenience maps
Map<String, Volume> volumesMap = new HashMap<>();
for (Volume v : Iterables.concat(sources, targets)) {
String key = format(KEY, v.getStorageController(), v.getNativeId());
volumesMap.put(key, v);
}
final Map<String, String> tgtURI2tgtDevId = new HashMap<>();
for (Volume target : targets) {
tgtURI2tgtDevId.put(target.getId().toString(), target.getNativeId());
}
Volume firstSource = sources.get(0);
StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
Volume firstTarget = targets.get(0);
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
Collection<CIMObjectPath> syncPairs = null;
try {
// Note that we may have existing sync pairs in the consistency group.
syncPairs = getConsistencyGroupSyncPairs(sourceSystem, firstSource, targetSystem, firstTarget);
} catch (WBEMException e) {
log.error("Failed to update SRDF pairings", e);
return;
}
for (CIMObjectPath syncPair : syncPairs) {
log.info("Checking {}", syncPair);
// Get the deviceID for the system (source) element from SMI-S provider
String srcEl = syncPair.getKeyValue(CP_SYSTEM_ELEMENT).toString();
CIMObjectPath srcElPath = new CIMObjectPath(srcEl);
String trustedSrcDevId = srcElPath.getKeyValue(CP_DEVICE_ID).toString();
// Get the deviceID for the synced (target) element from SMI-S provider
String tgtEl = syncPair.getKeyValue(CP_SYNCED_ELEMENT).toString();
CIMObjectPath tgtElPath = new CIMObjectPath(tgtEl);
String trustedTgtDevId = tgtElPath.getKeyValue(CP_DEVICE_ID).toString();
// Get ViPR's side which requires validating...
String srcKey = format(KEY, sourceSystem.getId(), trustedSrcDevId);
Volume srcVolume = volumesMap.get(srcKey);
if (srcVolume == null) {
// Skip existing source volumes that were part of the consistency group.
log.info("Skipping as {} is an existing consistency group member", srcKey);
continue;
}
StringSet srdfTargets = srcVolume.getSrdfTargets();
Collection<String> uncheckedTgtDevIds = transform(srdfTargets, new Function<String, String>() {
@Override
public String apply(String targetURI) {
return tgtURI2tgtDevId.get(targetURI);
}
});
if (!uncheckedTgtDevIds.contains(trustedTgtDevId)) {
log.info("Found pairing inconsistency!");
String msg = format("Source %s is paired with Target %s", trustedSrcDevId, trustedTgtDevId);
log.info(msg);
// The target found in the sync pair will need updating in ViPR (has wrong SRDF parent)
Volume invalidTgt = volumesMap.get(format(KEY, targetSystem.getId(), trustedTgtDevId));
// This SRDF parent will need its SRDF target list updating (remove the target)
Volume invalidSrc = dbClient.queryObject(Volume.class, invalidTgt.getSrdfParent().getURI());
// The source found in the sync pair will need its SRDF target list updating (add the real target)
Volume trustedSrc = volumesMap.get(format(KEY, sourceSystem.getId(), trustedSrcDevId));
invalidTgt.setSrdfParent(new NamedURI(trustedSrc.getId(), trustedSrc.getLabel()));
trustedSrc.getSrdfTargets().add(invalidTgt.getId().toString());
invalidSrc.getSrdfTargets().remove(invalidTgt.getId().toString());
// Update the volume labels (and labels on associated Vplex volume if any)
updateVolumeLabels(trustedSrc, invalidTgt);
// Rename the volume on the vmax array itself and update the deviceLabel
helper.renameVolume(dbClient, targetSystem, invalidTgt, invalidTgt.getLabel());
dbClient.updateAndReindexObject(asList(invalidTgt, trustedSrc, invalidSrc));
}
}
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class SRDFOperations method changeSRDFVolumeBehaviors.
private void changeSRDFVolumeBehaviors(Volume sourceVolume, Volume targetVolume, DbClient dbClient, String status) {
List<Volume> volumes = new ArrayList<>();
if (sourceVolume.hasConsistencyGroup()) {
List<URI> srcVolumeUris = dbClient.queryByConstraint(getVolumesByConsistencyGroup(sourceVolume.getConsistencyGroup()));
List<Volume> cgSrcVolumes = dbClient.queryObject(Volume.class, srcVolumeUris);
volumes.addAll(cgSrcVolumes);
} else {
volumes.add(sourceVolume);
/**
* Swap operation will happen for all volumes under ra group for Async without CG.
* Adding the missing source volumes to change the personalities of the missing volumes
*/
if (Mode.ASYNCHRONOUS.name().equalsIgnoreCase(targetVolume.getSrdfCopyMode())) {
volumes.addAll(utils.getRemainingSourceVolumesForAsyncRAGroup(sourceVolume, targetVolume));
}
}
log.debug("volumes size:{}", volumes.size());
for (Volume sourceVol : volumes) {
StringSet srdfTargets = new StringSet();
String copyMode = null;
if (sourceVol.getSrdfTargets() == null) {
// This may happen if a target volume is not deleted properly
continue;
}
srdfTargets.addAll(sourceVol.getSrdfTargets());
// CG cannot have different RA Groups and copyMode
URI raGroupUri = null;
for (String targetUri : srdfTargets) {
Volume targetVol = dbClient.queryObject(Volume.class, URI.create(targetUri));
raGroupUri = targetVol.getSrdfGroup();
copyMode = targetVol.getSrdfCopyMode();
targetVol.setPersonality(SOURCE.toString());
targetVol.setAccessState(Volume.VolumeAccessState.READWRITE.name());
srdfTargets.add(sourceVol.getId().toString());
srdfTargets.remove(targetVol.getId().toString());
if (null == targetVol.getSrdfTargets()) {
targetVol.setSrdfTargets(new StringSet());
}
targetVol.getSrdfTargets().addAll(srdfTargets);
targetVol.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
targetVol.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
targetVol.setSrdfGroup(NullColumnValueGetter.getNullURI());
targetVol.setLinkStatus(status);
// Set source fields
sourceVol.setLinkStatus(status);
sourceVol.setSrdfParent(new NamedURI(targetVol.getId(), targetVol.getLabel()));
dbClient.persistObject(targetVol);
}
sourceVol.setPersonality(TARGET.toString());
sourceVol.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
sourceVol.setSrdfCopyMode(copyMode);
sourceVol.setSrdfGroup(raGroupUri);
sourceVol.getSrdfTargets().clear();
dbClient.persistObject(sourceVol);
}
}
use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.
the class SRDFOperations method refreshStorageSystem.
public void refreshStorageSystem(final URI storageSystemURI, List<URI> volumeURIs) {
StorageSystem system = null;
try {
system = utils.getStorageSystem(storageSystemURI);
// 60 sec
long waitTime = 60000;
if (null != volumeURIs && !volumeURIs.isEmpty()) {
List<Volume> volumes = dbClient.queryObject(Volume.class, volumeURIs);
if (null == volumes || volumes.isEmpty()) {
return;
}
Collection<String> nativeGuids = transform(volumes, fctnBlockObjectToNativeGuid());
NamedURI sourceVolumeURI = volumes.get(0).getSrdfParent();
if (NullColumnValueGetter.isNullURI(sourceVolumeURI.getURI())) {
return;
}
Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeURI);
BlockConsistencyGroup cgObj = dbClient.queryObject(BlockConsistencyGroup.class, sourceVolume.getConsistencyGroup());
String cgName = cgObj.getAlternateLabel();
if (null == cgName) {
cgName = cgObj.getLabel();
}
while (waitTime > 0) {
log.debug("Entering loop to check volume exists on replication group.");
CIMObjectPath groupPath = helper.checkDeviceGroupExists(cgName, system, system);
if (null == groupPath) {
log.info("No group found with name {}", cgName);
break;
}
Set<String> commonElements = new HashSet<String>();
Set<String> deviceNativeGuids = getVolumesPartOfRG(groupPath, system, system);
log.info("Found volumes {} in RG {}", deviceNativeGuids, cgName);
if (null == deviceNativeGuids) {
log.info("No volumes found in the RG");
break;
}
Sets.intersection(new HashSet<String>(nativeGuids), deviceNativeGuids).copyInto(commonElements);
if (!commonElements.isEmpty()) {
log.info("Volumes {} still exists in RG {}.", Arrays.toString(commonElements.toArray()), cgName);
Thread.sleep(SLEEP_TIME);
waitTime = waitTime - SLEEP_TIME;
} else {
log.debug("Volumes not exist in RG {}", cgName);
break;
}
}
}
callEMCRefresh(helper, system, true);
} catch (Exception ex) {
log.error("SMI-S error while refreshing target system {}", storageSystemURI, ex);
}
}
Aggregations