Search in sources :

Example 26 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class ConnectivityUtil method findAllVirtualArraysForRPSiteArray.

/**
 * Find all the associated VSA URIs for the passed in RPSiteArray
 *
 * @param dbClient
 * @param siteArray
 * @param ids virtual array ids collected
 * @return void
 */
private static void findAllVirtualArraysForRPSiteArray(DbClient dbClient, RPSiteArray siteArray, Collection<URI> ids) {
    if (siteArray != null) {
        // Find all the Storage Pools associated to this RPSiteArray
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(siteArray.getStorageSystem()), storagePoolURIs);
        Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
        while (storagePoolIter.hasNext()) {
            URI storagePoolURI = storagePoolIter.next();
            StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
            // For each Storage Pool get all the connected VSAs
            if (storagePool != null && !storagePool.getInactive() && storagePool.getConnectedVirtualArrays() != null) {
                for (String vArrayId : storagePool.getConnectedVirtualArrays()) {
                    ids.add(URI.create(vArrayId));
                }
            }
        }
        // If the rpsite array storage system is vplex check virtual array
        // connectivity to rpsite using front end storage ports
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, siteArray.getStorageSystem());
        if (storageSystem != null && isAVPlex(storageSystem)) {
            Map<URI, List<StoragePort>> storagePortMap = ConnectivityUtil.getStoragePortsOfType(dbClient, storageSystem.getId(), PortType.frontend);
            for (Map.Entry<URI, List<StoragePort>> storagePortEntry : storagePortMap.entrySet()) {
                for (StoragePort storagePort : storagePortEntry.getValue()) {
                    // For each Storage Port get all the connected VSAs
                    if (storagePort.getConnectedVirtualArrays() != null && !storagePort.getConnectedVirtualArrays().isEmpty() && !ids.containsAll(URIUtil.toURIList(storagePort.getConnectedVirtualArrays()))) {
                        _log.info(String.format("Vplex System [%s] has connectvity to RP Site [%s]", storageSystem.getLabel(), siteArray.getRpSiteName()));
                        ids.addAll(URIUtil.toURIList(storagePort.getConnectedVirtualArrays()));
                    }
                    if (storagePort.getAssignedVirtualArrays() != null && !storagePort.getAssignedVirtualArrays().isEmpty() && !ids.containsAll(URIUtil.toURIList(storagePort.getAssignedVirtualArrays()))) {
                        _log.info(String.format("Vplex System [%s] has connectvity to RP Site [%s]", storageSystem.getLabel(), siteArray.getRpSiteName()));
                        ids.addAll(URIUtil.toURIList(storagePort.getAssignedVirtualArrays()));
                    }
                }
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) HashMap(java.util.HashMap) Map(java.util.Map) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 27 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class ExportUtils method getStoragePortSystemType.

private static String getStoragePortSystemType(DbClient dbClient, StoragePort port, Map<URI, String> systemURIToType) {
    URI systemURI = port.getStorageDevice();
    String systemType = systemURIToType.get(systemURI);
    if (systemType == null) {
        StorageSystem system = dbClient.queryObject(StorageSystem.class, systemURI);
        systemType = system.getSystemType();
        systemURIToType.put(systemURI, systemType);
    }
    return systemType;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 28 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class VPlexUtil method isBackendFullCopyInReplicationGroup.

/**
 * Check if the full copy is a vplex full copy and its backend full copy is in a replication group
 *
 * @param fullcopy
 * @param dbClient
 * @return true or false
 */
public static boolean isBackendFullCopyInReplicationGroup(Volume fullcopy, DbClient dbClient) {
    boolean result = false;
    URI systemURI = fullcopy.getStorageController();
    StorageSystem system = dbClient.queryObject(StorageSystem.class, systemURI);
    String type = system.getSystemType();
    if (type.equals(DiscoveredDataObject.Type.vplex.name())) {
        Volume backendFullcopy = getVPLEXBackendVolume(fullcopy, true, dbClient);
        if (backendFullcopy != null) {
            String replicationGroup = backendFullcopy.getReplicationGroupInstance();
            if (NullColumnValueGetter.isNotNullValue(replicationGroup)) {
                result = true;
            }
        }
    }
    return result;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 29 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class VPlexUtil method isVplexBackendVolume.

/**
 * Check if the volume is a backend volume of a vplex volume
 *
 * @param volume the volume
 * @param dbClient
 * @return true or false
 */
public static boolean isVplexBackendVolume(Volume volume, DbClient dbClient) {
    final List<Volume> vplexVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Volume.class, getVolumesByAssociatedId(volume.getId().toString()));
    for (Volume vplexVolume : vplexVolumes) {
        URI storageURI = vplexVolume.getStorageController();
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, storageURI);
        if (DiscoveredDataObject.Type.vplex.name().equals(storage.getSystemType())) {
            return true;
        }
    }
    return false;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 30 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class FileDeviceController method deleteNFSAcls.

@Override
public void deleteNFSAcls(URI storage, URI fsURI, String subDir, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    FileObject fsObj = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    FileShare fs = null;
    Snapshot snapshotObj = null;
    boolean isFile = false;
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        args.setSubDirectory(subDir);
        _log.info("FileDeviceController::deleteNFSAcls Recieved Nfs ACL DELETE Operation ");
        // File
        if (URIUtil.isType(fsURI, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fsURI);
            fsObj = fs;
            args.addFSFileObject(fs);
            args.setFileSystemPath(fs.getPath());
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        } else {
            // Snapshot
            snapshotObj = _dbClient.queryObject(Snapshot.class, fsURI);
            fsObj = snapshotObj;
            fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
            args.addFileShare(fs);
            args.setFileSystemPath(fs.getPath());
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        List<NfsACE> aceDeleteList = new ArrayList<NfsACE>();
        List<NFSShareACL> dbNfsAclTemp = queryAllNfsACLInDB(fs, subDir, args);
        makeNfsAceFromDB(aceDeleteList, dbNfsAclTemp);
        args.setNfsAclsToDelete(aceDeleteList);
        // Do the Operation on device.
        BiosCommandResult result = getDevice(storageObj.getSystemType()).deleteNfsACLs(storageObj, args);
        if (result.isCommandSuccess()) {
            // Update Database
            if (!dbNfsAclTemp.isEmpty()) {
                for (NFSShareACL nfsShareACL : dbNfsAclTemp) {
                    nfsShareACL.setInactive(true);
                }
                _dbClient.updateObject(dbNfsAclTemp);
            }
        }
        if (result.getCommandPending()) {
            return;
        }
        // Audit & Update the task status
        OperationTypeEnum auditType = null;
        auditType = (isFile) ? OperationTypeEnum.DELETE_FILE_SYSTEM_NFS_ACL : OperationTypeEnum.DELETE_FILE_SNAPSHOT_NFS_ACL;
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        // Monitoring - Event Processing
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        if (isFile) {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), snapshotObj, fs, storageObj);
        }
        _dbClient.updateObject(fsObj);
    } catch (Exception e) {
        String[] params = { storage.toString(), fsURI.toString() };
        _log.error("Unable to Delete  ACL on  file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
        _log.error("{}, {} ", e.getMessage(), e);
        updateTaskStatus(opId, fsObj, e);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) NfsACE(com.emc.storageos.model.file.NfsACE) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) ArrayList(java.util.ArrayList) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) 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) Snapshot(com.emc.storageos.db.client.model.Snapshot) FileObject(com.emc.storageos.db.client.model.FileObject) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1088 URI (java.net.URI)581 ArrayList (java.util.ArrayList)424 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)319 Volume (com.emc.storageos.db.client.model.Volume)299 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)272 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)258 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)246 NamedURI (com.emc.storageos.db.client.model.NamedURI)243 WorkflowException (com.emc.storageos.workflow.WorkflowException)233 ControllerException (com.emc.storageos.volumecontroller.ControllerException)231 HashMap (java.util.HashMap)172 StoragePool (com.emc.storageos.db.client.model.StoragePool)159 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)158 StringSet (com.emc.storageos.db.client.model.StringSet)156 URISyntaxException (java.net.URISyntaxException)145 List (java.util.List)139 IOException (java.io.IOException)136 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)127 Workflow (com.emc.storageos.workflow.Workflow)126