use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class SRDFDeviceController method createCGSRDFVolumes.
protected void createCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, List<VolumeDescriptor> targetDescriptors, Map<URI, Volume> uriVolumeMap) {
RemoteDirectorGroup group = getRAGroup(targetDescriptors, uriVolumeMap);
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, group.getRemoteStorageSystemUri());
// finding actual volumes from Provider
Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
if (group.getVolumes() == null) {
group.setVolumes(new StringSet());
}
/*
* Check the following 2 conditions.
* 1. If there are no volumes in RDFGroup on Array & volumes in RDFGroup in ViPR DB.
* 2. If there are volumes in RDFGroup on Array & no volumes in RDFGroup in ViPR DB.
*/
if ((group.getVolumes().isEmpty() && !volumes.isEmpty()) || (!group.getVolumes().isEmpty() && volumes.isEmpty())) {
// throw Exception rediscover source and target arrays.
log.warn("RDF Group {} out of sync with Array", group.getNativeGuid());
List<URI> sourceURIs = VolumeDescriptor.getVolumeURIs(sourceDescriptors);
List<URI> targetURIs = VolumeDescriptor.getVolumeURIs(targetDescriptors);
URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
for (URI sourceUri : sourceURIs) {
Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUri);
if (null != sourceVolume) {
log.info("Clearing source volume {}-->{}", sourceVolume.getNativeGuid(), sourceVolume.getId());
if (null == vpoolChangeUri) {
// clear everything if not vpool change
sourceVolume.setPersonality(NullColumnValueGetter.getNullStr());
sourceVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
sourceVolume.setInactive(true);
sourceVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
if (null != sourceVolume.getSrdfTargets()) {
sourceVolume.getSrdfTargets().clear();
}
dbClient.updateObject(sourceVolume);
}
}
for (URI targetUri : targetURIs) {
Volume targetVolume = dbClient.queryObject(Volume.class, targetUri);
if (null != targetVolume) {
log.info("Clearing target volume {}-->{}", targetVolume.getNativeGuid(), targetVolume.getId());
targetVolume.setPersonality(NullColumnValueGetter.getNullStr());
targetVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
targetVolume.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
targetVolume.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
targetVolume.setSrdfGroup(NullColumnValueGetter.getNullURI());
targetVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
targetVolume.setInactive(true);
dbClient.updateObject(targetVolume);
}
}
throw DeviceControllerException.exceptions.srdfAsyncStepCreationfailed(group.getNativeGuid());
}
group.getVolumes().replace(volumes);
dbClient.updateObject(group);
if (volumes.isEmpty() && SupportedCopyModes.ALL.toString().equalsIgnoreCase(group.getSupportedCopyMode())) {
log.info("RA Group {} was empty", group.getId());
waitFor = createSrdfCgPairStepsOnEmptyGroup(sourceDescriptors, targetDescriptors, group, waitFor, workflow);
} else {
log.info("RA Group {} not empty", group.getId());
waitFor = createSrdfCGPairStepsOnPopulatedGroup(sourceDescriptors, group, uriVolumeMap, waitFor, workflow);
}
// Generate workflow step to refresh target system after CG creation.
if (null != system) {
waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, system, null, waitFor, workflow);
}
if (null != targetSystem) {
waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, targetSystem, null, waitFor, workflow);
}
// Refresh target volume properties
Mode SRDFMode = getSRDFMode(sourceDescriptors, uriVolumeMap);
if (Mode.ACTIVE.equals(SRDFMode)) {
refreshVolumeProperties(targetDescriptors, targetSystem, waitFor, workflow);
}
}
use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class StorageSystemService method getAllRAGroups.
/**
* Get All RA Groups
*
* @param id
* @brief List RDF groups names in a storage system
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/rdf-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public RDFGroupList getAllRAGroups(@PathParam("id") URI id) {
// Make sure storage system is registered.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
RDFGroupList rdfGroupList = new RDFGroupList();
URIQueryResultList rdfGroupURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceRemoteGroupsConstraint(id), rdfGroupURIs);
Iterator<URI> rdfGroupIter = rdfGroupURIs.iterator();
while (rdfGroupIter.hasNext()) {
URI rdfGroupURI = rdfGroupIter.next();
RemoteDirectorGroup rdfGroup = _dbClient.queryObject(RemoteDirectorGroup.class, rdfGroupURI);
if (rdfGroup != null && !rdfGroup.getInactive()) {
rdfGroupList.getRdfGroups().add(toNamedRelatedResource(rdfGroup, rdfGroup.getNativeGuid()));
}
}
return rdfGroupList;
}
use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class PlacementTestUtils method createSRDFStorageSystems.
/**
* Create SRDF paired vmax arrays.
* @param dbClient
* @param label1
* @param network1
* @param portWWNs1
* @param varray1
* @param label2
* @param network2
* @param portWWNs2
* @param varray2
* @return StorageSystem[1] and StorageSystem[2]; StorageSystem[0] not used.
*/
public static StorageSystem[] createSRDFStorageSystems(DbClient dbClient, String label1, Network network1, String[] portWWNs1, VirtualArray varray1, String label2, Network network2, String[] portWWNs2, VirtualArray varray2) {
StorageSystem[] storageSystems = new StorageSystem[3];
// Create 2 storage systems
StorageSystem storageSystem1 = PlacementTestUtils.createStorageSystem(dbClient, "vmax", label1);
storageSystems[1] = storageSystem1;
StorageSystem storageSystem2 = PlacementTestUtils.createStorageSystem(dbClient, "vmax", label2);
storageSystems[2] = storageSystem2;
// Mark them SRDF capable
StringSet supportedAsynchronousActions = new StringSet();
supportedAsynchronousActions.add(StorageSystem.AsyncActions.CreateElementReplica.name());
supportedAsynchronousActions.add(StorageSystem.AsyncActions.CreateGroupReplica.name());
storageSystem1.setSupportedAsynchronousActions(supportedAsynchronousActions);
storageSystem2.setSupportedAsynchronousActions(supportedAsynchronousActions);
StringSet supportedReplicationTypes = new StringSet();
supportedReplicationTypes.add(StorageSystem.SupportedReplicationTypes.SRDF.name());
storageSystem1.setSupportedReplicationTypes(supportedReplicationTypes);
storageSystem2.setSupportedReplicationTypes(supportedReplicationTypes);
// Set connected to.
StringSet connectedTo = new StringSet();
connectedTo.add(storageSystem2.getId().toString());
storageSystem1.setRemotelyConnectedTo(connectedTo);
connectedTo = new StringSet();
connectedTo.add(storageSystem1.getId().toString());
storageSystem2.setRemotelyConnectedTo(connectedTo);
dbClient.updateObject(storageSystem1, storageSystem2);
// Create RemoteDirectorGroups
RemoteDirectorGroup rdg1 = new RemoteDirectorGroup();
rdg1.setActive(true);
rdg1.setConnectivityStatus(RemoteDirectorGroup.ConnectivityStatus.UP.name());
rdg1.setLabel("RDG1");
rdg1.setId(URI.create("RDG1" + label1));
rdg1.setNativeGuid("$label1+$label2+6");
rdg1.setRemoteGroupId("6");
rdg1.setRemoteStorageSystemUri(storageSystem2.getId());
rdg1.setSourceGroupId("6");
rdg1.setSourceStorageSystemUri(storageSystem1.getId());
rdg1.setSupportedCopyMode(RemoteDirectorGroup.SupportedCopyModes.ASYNCHRONOUS.name());
dbClient.createObject(rdg1);
RemoteDirectorGroup rdg2 = new RemoteDirectorGroup();
rdg2.setActive(true);
rdg2.setConnectivityStatus(RemoteDirectorGroup.ConnectivityStatus.UP.name());
rdg2.setLabel("RDG2");
rdg2.setId(URI.create("RDG2" + label1));
rdg2.setNativeGuid("$label2+$label1+6");
rdg2.setRemoteGroupId("6");
rdg2.setRemoteStorageSystemUri(storageSystem1.getId());
rdg2.setSourceGroupId("6");
rdg2.setSourceStorageSystemUri(storageSystem2.getId());
rdg2.setSupportedCopyMode(RemoteDirectorGroup.SupportedCopyModes.ASYNCHRONOUS.name());
dbClient.createObject(rdg2);
// Create two front-end storage ports system1.
List<StoragePort> system1Ports = new ArrayList<StoragePort>();
for (int i = 0; i < portWWNs1.length; i++) {
system1Ports.add(PlacementTestUtils.createStoragePort(dbClient, storageSystem1, network1, portWWNs1[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1vmax" + i, "C0+FC0" + i));
}
// Create two front-end storage ports system2
List<StoragePort> system2Ports = new ArrayList<StoragePort>();
for (int i = 0; i < portWWNs2.length; i++) {
system2Ports.add(PlacementTestUtils.createStoragePort(dbClient, storageSystem2, network2, portWWNs2[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2vmax" + i, "D0+FC0" + i));
}
return storageSystems;
}
use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class SRDFChangeCopyModeTaskCompleter method complete.
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
try {
setDbClient(dbClient);
switch(status) {
case ready:
RemoteDirectorGroup rdfGrp = null;
for (Volume target : tgtVolumes) {
target.setSrdfCopyMode(newCopyMode);
dbClient.persistObject(target);
log.info(String.format("SRDF Device source %s and target %s copy mode got changed into %s", target.getSrdfParent().toString(), target.getId().toString(), newCopyMode));
if (rdfGrp == null) {
rdfGrp = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
}
}
if (rdfGrp != null) {
rdfGrp.setSupportedCopyMode(newCopyMode);
dbClient.persistObject(rdfGrp);
log.info("RDF Group {} copy mode got changed into : {}", rdfGrp.getId(), newCopyMode);
}
break;
default:
log.info("Unable to handle SRDF Link Change Copy Mode Operational status: {}", status);
}
} catch (Exception e) {
log.error("Failed change copy mode. SRDFMirror {}, for task " + getOpId(), getId(), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class ConnectivityCollectionRelationshipsProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
@SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
boolean volumeAdded = false;
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
CIMObjectPath raGroupPath = getObjectPathfromCIMArgument(args);
String ragGroupId = NativeGUIDGenerator.generateRAGroupNativeGuid(raGroupPath);
_log.debug("RA Group Id : {}", ragGroupId);
RemoteDirectorGroup rg = getRAGroupUriFromDB(dbClient, ragGroupId);
if (null == rg) {
_log.info("RA Group Not found : {}", ragGroupId);
return;
}
URI raGroupUri = rg.getId();
@SuppressWarnings("unchecked") Map<String, URI> rAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
Set<String> volumeNativeGuids = new StringSet();
while (it.hasNext()) {
CIMObjectPath connCollectionRelationPaths = it.next();
String cimClass = connCollectionRelationPaths.getObjectName();
if (PROTOCOL_END_POINT.equals(cimClass)) {
String endPointId = connCollectionRelationPaths.getKey(Constants.NAME).getValue().toString();
_log.info("End Point Added {}", connCollectionRelationPaths);
addPath(keyMap, Constants.ENDPOINTS_RAGROUP, connCollectionRelationPaths);
rAGroupMap.put(endPointId, raGroupUri);
} else if (VOLUME.equals(cimClass)) {
String volumeNativeGuid = getVolumeNativeGuid(connCollectionRelationPaths);
if (!volumeAdded && !rAGroupMap.containsKey(volumeNativeGuid)) {
volumeAdded = true;
_log.info("Volume Added {}", connCollectionRelationPaths);
addPath(keyMap, Constants.VOLUME_RAGROUP, connCollectionRelationPaths);
rAGroupMap.put(volumeNativeGuid, raGroupUri);
} else {
_log.info("Volume {} is part of multiple RA Groups", volumeNativeGuid);
}
volumeNativeGuids.add(volumeNativeGuid);
}
}
RemoteDirectorGroup remoteGroup = dbClient.queryObject(RemoteDirectorGroup.class, raGroupUri);
// async
if (!volumeAdded) {
remoteGroup.setSupportedCopyMode(SupportedCopyModes.ALL.toString());
}
if (null == remoteGroup.getVolumes() || remoteGroup.getVolumes().isEmpty()) {
remoteGroup.setVolumes(new StringSet(volumeNativeGuids));
} else {
_log.debug("Existing Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
_log.debug("New Volumes {}", Joiner.on("\t").join(volumeNativeGuids));
remoteGroup.getVolumes().replace(volumeNativeGuids);
_log.debug("Updated Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
}
dbClient.persistObject(remoteGroup);
} catch (Exception e) {
_log.error("Exception occurred while processing remote connectivity information.", e);
}
}
Aggregations