use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VPlexSrdfUtil method getSrdfOrVplexTargets.
/**
* Returns the vplex front volume ids for the srdf targets if they have a vplex volume,
* otherwise returns the original srdf target id
* @param dbClient - DbClient handle
* @param srdfVolume - An Srdf volume having targets
* @return String set of volume ids for either vplex/srdf volume or srdf volume in target list
*/
public static StringSet getSrdfOrVplexTargets(DbClient dbClient, Volume srdfVolume) {
StringSet targets = new StringSet();
for (String targetVolumeId : srdfVolume.getSrdfTargets()) {
URI srdfTargetUri = URI.create(targetVolumeId);
URI vplexTargetUri = Volume.fetchVplexVolume(dbClient, srdfTargetUri);
if (vplexTargetUri != null) {
targets.add(vplexTargetUri.toString());
} else {
targets.add(srdfTargetUri.toString());
}
}
return targets;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VPlexUtil method getVPLEXBackendVolume.
/**
* Returns the source or ha backend volume of the passed VPLEX volume.
*
* @param vplexVolume A reference to the VPLEX volume.
* @param sourceVolume A boolean thats used to return either source
* or ha backend volume.
* @param dbClient an instance of {@link DbClient}
* @param errorIfNotFound A boolean thats used to either return null or throw error
*
* @return A reference to the backend volume
* If sourceVolume is true returns source backend
* volume else returns ha backend volume.
*/
public static Volume getVPLEXBackendVolume(Volume vplexVolume, boolean sourceVolume, DbClient dbClient, boolean errorIfNotFound) {
StringSet associatedVolumeIds = vplexVolume.getAssociatedVolumes();
Volume backendVolume = null;
if (associatedVolumeIds == null) {
if (errorIfNotFound) {
throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vplexVolume.forDisplay());
} else {
return backendVolume;
}
}
// Get the backend volume either source or ha.
List<URI> volumeUriList = new ArrayList<>();
for (String associatedVolumeId : associatedVolumeIds) {
volumeUriList.add(URI.create(associatedVolumeId));
}
Iterator<Volume> volumes = dbClient.queryIterativeObjects(Volume.class, volumeUriList, true);
while (volumes.hasNext()) {
Volume associatedVolume = volumes.next();
if (associatedVolume != null) {
if (sourceVolume && associatedVolume.getVirtualArray().equals(vplexVolume.getVirtualArray())) {
backendVolume = associatedVolume;
break;
}
if (!sourceVolume && !(associatedVolume.getVirtualArray().equals(vplexVolume.getVirtualArray()))) {
backendVolume = associatedVolume;
break;
}
}
}
return backendVolume;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileDeviceController method copyPropertiesToSave.
private void copyPropertiesToSave(FileExportRule dest, ExportRule orig, FileShare fs, FileDeviceInputOutput args) {
_log.info("Origin {}", orig.toString());
String exportPath = args.getExportPath();
// This export path is the one that is figured out at the device.
// Make sure you set the path on args object while doing the operation. Check for
// <Device>FileStorageDeviceXXX.java
dest.setExportPath(exportPath);
dest.setSecFlavor(orig.getSecFlavor());
dest.setAnon(orig.getAnon());
if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
_log.info("Read Only Hosts {}", dest.getReadOnlyHosts());
}
if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
_log.info("Read Write Hosts {}", dest.getReadWriteHosts());
}
if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
dest.setRootHosts(new StringSet(orig.getRootHosts()));
_log.info("Root hosts {}", dest.getRootHosts());
}
// Set this always at the end -- Thats how the model is defined.
if (!args.getFileOperation()) {
dest.setSnapshotId(args.getSnapshotId());
} else {
dest.setFileSystemId(fs.getId());
}
// Figure out Storage Port Network id to build the mount point.
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, fs.getStoragePort());
String mountPoint = ExportUtils.getFileMountPoint(storagePort.getPortNetworkId(), exportPath);
dest.setMountPoint(mountPoint);
// dest.calculateExportRuleIndex();
if ((orig.getDeviceExportId() != null) && (!orig.getDeviceExportId().isEmpty())) {
dest.setDeviceExportId(orig.getDeviceExportId());
} else if ((args.getObjIdOnDevice() != null) && (!args.getObjIdOnDevice().isEmpty())) {
dest.setDeviceExportId(args.getObjIdOnDevice());
}
// _log.info("New File Export Rule Object {}", dest);
_log.info("Dest After {}", dest.toString());
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileDeviceController method resetReplicationFileSystemsRelation.
protected void resetReplicationFileSystemsRelation(FilePolicy filePolicy, PolicyStorageResource policyResource) {
URI storageSystem = policyResource.getStorageSystem();
String policyPath = policyResource.getResourcePath();
// Remove the source - target relationship
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name())) {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getStorageDeviceFileshareConstraint(storageSystem);
List<FileShare> fileshares = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileShare.class, containmentConstraint);
List<FileShare> modifiedFileshares = new ArrayList<>();
for (FileShare fileshare : fileshares) {
// should be decoupled!!!
if (fileshare.getNativeId().startsWith(policyPath)) {
if (fileshare.getPersonality() != null && fileshare.getPersonality().equalsIgnoreCase(PersonalityTypes.SOURCE.toString())) {
fileshare.setMirrorStatus(NullColumnValueGetter.getNullStr());
fileshare.setAccessState(NullColumnValueGetter.getNullStr());
fileshare.setPersonality(NullColumnValueGetter.getNullStr());
if (fileshare.getMirrorfsTargets() != null && !fileshare.getMirrorfsTargets().isEmpty()) {
StringSet targets = fileshare.getMirrorfsTargets();
for (String strTargetFs : targets) {
FileShare targetFs = _dbClient.queryObject(FileShare.class, URI.create(strTargetFs));
targetFs.setMirrorStatus(NullColumnValueGetter.getNullStr());
targetFs.setAccessState(NullColumnValueGetter.getNullStr());
targetFs.setParentFileShare(NullColumnValueGetter.getNullNamedURI());
targetFs.setPersonality(NullColumnValueGetter.getNullStr());
modifiedFileshares.add(targetFs);
}
targets.clear();
fileshare.setMirrorfsTargets(targets);
}
}
modifiedFileshares.add(fileshare);
}
}
if (!modifiedFileshares.isEmpty()) {
_dbClient.updateObject(modifiedFileshares);
}
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileSystemSnapshotPolicy.
@Override
public void assignFileSystemSnapshotPolicy(URI storage, URI fsURI, URI policy, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(fsURI, opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
try {
fs = _dbClient.queryObject(FileShare.class, fsURI);
SchedulePolicy fp = _dbClient.queryObject(SchedulePolicy.class, policy);
if (fs != null && fp != null) {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info("Controller Recieved File Policy {}", policy);
args.addFSFileObject(fs);
args.setFileSystemPath(fs.getPath());
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.addFilePolicy(fp);
args.setFileOperation(true);
args.setOpId(opId);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).assignFilePolicy(storageObj, args);
if (result.isCommandSuccess()) {
// Update FS database
StringSet fpolicies = fs.getFilePolicies();
fpolicies.add(fp.getId().toString());
fs.setFilePolicies(fpolicies);
// Update SchedulePolicy database
StringSet resources = fp.getAssignedResources();
resources.add(fs.getId().toString());
fp.setAssignedResources(resources);
}
if (result.getCommandPending()) {
return;
}
// Audit & Update the task status
OperationTypeEnum auditType = null;
auditType = OperationTypeEnum.ASSIGN_FILE_SYSTEM_SNAPSHOT_SCHEDULE;
fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
// Monitoring - Event Processing
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, fp);
_dbClient.updateObject(fs);
_dbClient.updateObject(fp);
} else {
throw DeviceControllerException.exceptions.invalidObjectNull();
}
} catch (Exception e) {
String[] params = { storage.toString(), fsURI.toString(), e.getMessage() };
_log.error("Unable to assign policy : storage {}, FS URI {},: Error {}", params);
updateTaskStatus(opId, fs, e);
}
}
Aggregations