Search in sources :

Example 66 with StringSet

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);
        }
    }
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 67 with StringSet

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);
    }
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) ArrayList(java.util.ArrayList) IOException(java.io.IOException) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 68 with StringSet

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);
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 69 with StringSet

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);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) StringSet(com.emc.storageos.db.client.model.StringSet) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) SchedulePolicy(com.emc.storageos.db.client.model.SchedulePolicy) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 70 with StringSet

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);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)760 URI (java.net.URI)371 ArrayList (java.util.ArrayList)278 Volume (com.emc.storageos.db.client.model.Volume)189 NamedURI (com.emc.storageos.db.client.model.NamedURI)176 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)137 HashMap (java.util.HashMap)132 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)124 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)116 List (java.util.List)108 HashSet (java.util.HashSet)106 StoragePort (com.emc.storageos.db.client.model.StoragePort)90 StoragePool (com.emc.storageos.db.client.model.StoragePool)75 StringMap (com.emc.storageos.db.client.model.StringMap)74 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)71 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)70 Initiator (com.emc.storageos.db.client.model.Initiator)60 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)50 Map (java.util.Map)48