Search in sources :

Example 16 with StoragePort

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

the class ExportUtils method getPortsInInitiatorNetwork.

/**
 * Returns the storage ports allocated to each initiator based
 * on the connectivity between them.
 *
 * @param mask
 * @param initiator
 * @param dbClient
 * @return
 */
public static List<URI> getPortsInInitiatorNetwork(ExportMask mask, Initiator initiator, DbClient dbClient) {
    List<URI> list = new ArrayList<URI>();
    List<StoragePort> ports = getStoragePorts(mask, dbClient);
    NetworkLite networkLite = NetworkUtil.getEndpointNetworkLite(initiator.getInitiatorPort(), dbClient);
    if (networkLite != null) {
        for (StoragePort port : ports) {
            if (port.getNetwork() != null && port.getNetwork().equals(networkLite.getId())) {
                list.add(port.getId());
            }
        }
        if (list.isEmpty() && networkLite.getRoutedNetworks() != null) {
            for (StoragePort port : ports) {
                if (port.getNetwork() != null && networkLite.getRoutedNetworks().contains(port.getNetwork().toString())) {
                    list.add(port.getId());
                }
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 17 with StoragePort

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

the class ExportUtils method storagePortNamesToURIs.

/**
 * Take in a list of storage port names (hex digits separated by colons),
 * then returns a list of URIs representing the StoragePort URIs they represent.
 *
 * This method ignores the storage ports from cinder storage systems.
 *
 * @param storagePorts [in] - Storage port name, hex digits separated by colons
 * @return List of StoragePort URIs
 */
public static List<String> storagePortNamesToURIs(DbClient dbClient, List<String> storagePorts) {
    List<String> storagePortURIStrings = new ArrayList<String>();
    Map<URI, String> systemURIToType = new HashMap<URI, String>();
    for (String port : storagePorts) {
        URIQueryResultList portUriList = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(port), portUriList);
        Iterator<URI> storagePortIter = portUriList.iterator();
        while (storagePortIter.hasNext()) {
            URI portURI = storagePortIter.next();
            StoragePort sPort = dbClient.queryObject(StoragePort.class, portURI);
            if (sPort != null && !sPort.getInactive()) {
                String systemType = getStoragePortSystemType(dbClient, sPort, systemURIToType);
                // ignore cinder managed storage system's port
                if (!DiscoveredDataObject.Type.openstack.name().equals(systemType)) {
                    storagePortURIStrings.add(portURI.toString());
                }
            }
        }
    }
    return storagePortURIStrings;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 18 with StoragePort

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

the class NetworkUtil method findStoragePortsInDB.

/**
 * This method returns storage ports if they exist in database.
 * Returns empty list if a storage port could not be found.
 *
 * @param pwwn storage port pwwn
 * @return storagePort object or null
 */
public static List<StoragePort> findStoragePortsInDB(String pwwn, DbClient dbClient) {
    List<StoragePort> ports = new ArrayList<StoragePort>();
    _log.info("Looking for storage port {} in database", pwwn);
    URIQueryResultList portUriList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(pwwn), portUriList);
    Iterator<URI> itr = portUriList.iterator();
    while (itr.hasNext()) {
        StoragePort port = dbClient.queryObject(StoragePort.class, itr.next());
        if (port != null && !port.getInactive()) {
            _log.info("Found storage port {}", pwwn);
            ports.add(port);
        }
    }
    return ports;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 19 with StoragePort

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

the class VPlexUtil method getBackendPortInitiators.

/**
 * Returns a set of all VPLEX backend ports as their related
 * Initiator URIs for a given VPLEX storage system.
 *
 * @param vplexUri - URI of the VPLEX system to find initiators for
 * @param dbClient - database client instance
 * @return a Set of Initiator URIs
 */
public static Set<URI> getBackendPortInitiators(URI vplexUri, DbClient dbClient) {
    _log.info("finding backend port initiators for VPLEX: " + vplexUri);
    Set<URI> initiators = new HashSet<>();
    List<StoragePort> ports = ConnectivityUtil.getStoragePortsForSystem(dbClient, vplexUri);
    for (StoragePort port : ports) {
        if (StoragePort.PortType.backend.name().equals(port.getPortType())) {
            Initiator init = ExportUtils.getInitiator(port.getPortNetworkId(), dbClient);
            if (init != null) {
                _log.info("found initiator {} for wwpn {}", init.getId(), port.getPortNetworkId());
                initiators.add(init.getId());
            }
        }
    }
    return initiators;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) HashSet(java.util.HashSet)

Example 20 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort 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)

Aggregations

StoragePort (com.emc.storageos.db.client.model.StoragePort)477 URI (java.net.URI)285 ArrayList (java.util.ArrayList)261 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)143 HashMap (java.util.HashMap)134 List (java.util.List)130 NetworkLite (com.emc.storageos.util.NetworkLite)110 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 StringSet (com.emc.storageos.db.client.model.StringSet)92 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)84 HashSet (java.util.HashSet)81 Initiator (com.emc.storageos.db.client.model.Initiator)78 Map (java.util.Map)64 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)62 StoragePool (com.emc.storageos.db.client.model.StoragePool)51 IOException (java.io.IOException)48 StringMap (com.emc.storageos.db.client.model.StringMap)45 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)34