Search in sources :

Example 26 with StringSet

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

Example 27 with StringSet

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

Example 28 with StringSet

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

Example 29 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 30 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)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)753 URI (java.net.URI)366 ArrayList (java.util.ArrayList)274 Volume (com.emc.storageos.db.client.model.Volume)189 NamedURI (com.emc.storageos.db.client.model.NamedURI)173 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)135 HashMap (java.util.HashMap)129 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)119 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)111 HashSet (java.util.HashSet)105 List (java.util.List)105 StoragePort (com.emc.storageos.db.client.model.StoragePort)86 StoragePool (com.emc.storageos.db.client.model.StoragePool)75 StringMap (com.emc.storageos.db.client.model.StringMap)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)71 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)70 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)55 Initiator (com.emc.storageos.db.client.model.Initiator)54 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 Map (java.util.Map)47