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 StoragePortAssociationHelper method runUpdateVirtualNasAssociationsProcess.
/**
* This method is responsible for
* Assign the virtual arrays of storage port to virtual nas
*
* @param ports
* @param remPorts
* @param dbClient
* @param coordinator
* @throws IOException
*/
public static void runUpdateVirtualNasAssociationsProcess(Collection<StoragePort> ports, Collection<StoragePort> remPorts, DbClient dbClient) {
try {
List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
if (ports != null && !ports.isEmpty()) {
// for better reading, added a method to group Ports by Network
Map<String, List<NetworkLite>> vNasNetworkMap = getVNasNetworksMap(ports, dbClient);
if (!vNasNetworkMap.isEmpty()) {
for (Map.Entry<String, List<NetworkLite>> vNasEntry : vNasNetworkMap.entrySet()) {
String nativeId = vNasEntry.getKey();
VirtualNAS vNas = findvNasByNativeId(nativeId, dbClient);
if (vNas != null) {
for (NetworkLite network : vNasEntry.getValue()) {
Set<String> varraySet = new HashSet<String>(network.getAssignedVirtualArrays());
if (vNas.getAssignedVirtualArrays() == null) {
vNas.setAssignedVirtualArrays(new StringSet());
}
vNas.getAssignedVirtualArrays().addAll(varraySet);
_log.info("found virtual NAS: {} and varrays: {}", vNas.getNasName(), varraySet.toString());
}
modifiedServers.add(vNas);
}
}
}
}
if (!modifiedServers.isEmpty()) {
dbClient.persistObject(modifiedServers);
}
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class StoragePoolAssociationHelper method updateSystemVarrays.
/**
* When the ports-varray associations change, for vplex system, update the system-varray association.
* For other storage systems, update the pools-varrays associations.
*
* @param systemUri the system where the varray association has changed
* @param dbClient an instance of dbClient
*/
private static void updateSystemVarrays(URI systemUri, DbClient dbClient) {
StorageSystem system = dbClient.queryObject(StorageSystem.class, systemUri);
if (!system.getInactive()) {
_log.info("Updating the virtual arrays for storage system {}", system.getNativeGuid());
if (ConnectivityUtil.isAVPlex(system)) {
StringSet varrays = getSystemConnectedVarrays(systemUri, PortType.frontend.name(), dbClient);
_log.info("vplex system {} varrays will be set to {}", system.getNativeGuid(), varrays);
if (system.getVirtualArrays() == null) {
system.setVirtualArrays(varrays);
} else {
system.getVirtualArrays().replace(varrays);
}
dbClient.updateAndReindexObject(system);
_log.info("Updated vplex system {} varrays to {}", system.getNativeGuid(), varrays);
} else {
StringSet varrays = getSystemConnectedVarrays(systemUri, null, dbClient);
_log.info("The pools of storage system {} varrays will be set to {}", system.getNativeGuid(), varrays);
List<StoragePool> pools = getSystemPools(systemUri, dbClient);
for (StoragePool pool : pools) {
pool.replaceConnectedVirtualArray(varrays);
_log.info("Updated storage pool {} varrays to {}", pool.getNativeGuid(), varrays);
}
dbClient.updateAndReindexObject(pools);
}
}
}
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);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class StoragePoolAssociationHelper method setStoragePoolVarrays.
/**
* When a pool is newly discovered, set its varray associations.
*
* @param systemUri the pool's system
* @param storagePools the pool to be updated
* @param dbClient an instance of db client
*/
public static void setStoragePoolVarrays(URI systemUri, List<StoragePool> storagePools, DbClient dbClient) {
StringSet varrayURIs = getSystemConnectedVarrays(systemUri, null, dbClient);
for (StoragePool storagePool : storagePools) {
if (storagePool.getStorageDevice().equals(systemUri)) {
storagePool.replaceConnectedVirtualArray(varrayURIs);
} else {
_log.error("Pool {} does not belong to storage system {} and will not be updated", storagePool.getNativeGuid(), systemUri);
}
}
dbClient.updateAndReindexObject(storagePools);
// now ensure any RP systems are getting their varray connections updated
ConnectivityUtil.updateRpSystemsConnectivity(java.util.Collections.singletonList(systemUri), dbClient);
}
Aggregations