Search in sources :

Example 6 with NetworkLite

use of com.emc.storageos.util.NetworkLite 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 7 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class StoragePortAssociationHelper method getVNasNetworksMap.

/**
 * Gets the networks of the virtual nas and organized in a map.
 * This code assumes that an end point exists in one and only one network.
 *
 * @param sports the ports
 * @param dbClient an instance of {@link DbClient}
 * @return a map of networks and the virtual nas that are associated to them.
 */
private static Map<String, List<NetworkLite>> getVNasNetworksMap(Collection<StoragePort> sports, DbClient dbClient) {
    Map<String, List<NetworkLite>> vNasNetwork = new HashMap<>();
    NetworkLite network;
    List<VirtualNAS> vNasList = null;
    List<NetworkLite> list = null;
    for (StoragePort sport : sports) {
        if (TransportType.IP.name().equalsIgnoreCase(sport.getTransportType())) {
            StorageSystem system = dbClient.queryObject(StorageSystem.class, sport.getStorageDevice());
            if (DiscoveredDataObject.Type.vnxfile.name().equals(system.getSystemType()) || DiscoveredDataObject.Type.isilon.name().equals(system.getSystemType()) || DiscoveredDataObject.Type.unity.name().equals(system.getSystemType())) {
                network = NetworkUtil.getEndpointNetworkLite(sport.getPortNetworkId(), dbClient);
                vNasList = getStoragePortVirtualNAS(sport, dbClient);
                if (network != null && network.getInactive() == false && network.getTransportType().equals(sport.getTransportType()) && vNasList != null && !vNasList.isEmpty()) {
                    for (VirtualNAS vNas : vNasList) {
                        list = vNasNetwork.get(vNas.getNativeGuid());
                        if (list == null) {
                            list = new ArrayList<NetworkLite>();
                            vNasNetwork.put(vNas.getNativeGuid(), list);
                        }
                        list.add(network);
                    }
                }
            }
        }
    }
    return vNasNetwork;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 8 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method maskHasStoragePortsInExportVarray.

/**
 * Routine validates if the ExportMask has StoragePorts that point to the same
 * VArray as the ExportGroup's and that the Network associated with the StoragePorts
 * matches those of the initiator.
 *
 * @param exportGroup
 *            [in] - ExportGroup object
 * @param mask
 *            [in] - ExportMask object
 * @param initiator
 *            [in] - Initiator object to validate
 * @param storagePortToNetwork
 *            [out] - will populate the map with StoragePort.name to Network.Name
 * @return true --> iff the ExportMask has viable StoragePorts that are associated to the ExportGroup's
 *         VArray and it matches the export path parameters of the ExportGroup
 */
private boolean maskHasStoragePortsInExportVarray(ExportGroup exportGroup, ExportMask mask, Initiator initiator, Map<String, String> storagePortToNetwork) {
    boolean isMatched = false;
    SetMultimap<URI, URI> initiatorToMatchedSP = TreeMultimap.create();
    if (mask.getStoragePorts() != null) {
        VirtualArray virtualArray = _dbClient.queryObject(VirtualArray.class, exportGroup.getVirtualArray());
        // Look up the Initiator's network
        NetworkLite initiatorNetwork = BlockStorageScheduler.lookupNetworkLite(_dbClient, StorageProtocol.block2Transport(initiator.getProtocol()), initiator.getInitiatorPort());
        if (initiatorNetwork == null) {
            _log.info(String.format("maskHasStoragePortsInExportVarray - Initiator %s is not in any network, returning false", initiator.getInitiatorPort()));
            return false;
        }
        for (String uriString : mask.getStoragePorts()) {
            URI uri = URI.create(uriString);
            StoragePort port = _dbClient.queryObject(StoragePort.class, uri);
            // Basic validation of the StoragePort
            if (port == null || port.getInactive()) {
                _log.info(String.format("maskHasStoragePortsInExportVarray - Could not find port or it is inactive %s", uri.toString()));
                continue;
            }
            // StoragePort needs to be in the REGISTERED and VISIBLE status
            if (!port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name()) || port.getDiscoveryStatus().equals(DiscoveryStatus.NOTVISIBLE.name())) {
                _log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not registered or not visible", port.getPortName(), uri.toString()));
                continue;
            }
            // Look up the StoragePort's network
            NetworkLite storagePortNetwork = BlockStorageScheduler.lookupNetworkLite(_dbClient, StorageProtocol.Transport.valueOf(port.getTransportType()), port.getPortNetworkId());
            if (storagePortNetwork == null) {
                _log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not associated with any network", port.getPortName(), uri.toString()));
                storagePortToNetwork.put(port.getPortName(), UNASSOCIATED);
                continue;
            }
            // Keep track of the StoragePort's network name
            storagePortToNetwork.put(port.getPortName(), storagePortNetwork.getLabel());
            // Port must belong to the VArray of the ExportGroup
            if (!port.taggedToVirtualArray(exportGroup.getVirtualArray())) {
                _log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not tagged to VArray %s (%s)", port.getPortName(), uri.toString(), virtualArray.getLabel(), exportGroup.getVirtualArray().toString()));
                // reverted the fix, as the probability of Consistent lun violation will be more.
                continue;
            }
            // Check if the StoragePort and Initiator point to the same Network
            if (storagePortNetwork.connectedToNetwork(initiatorNetwork.getId())) {
                _log.info(String.format("maskHasStoragePortsInExportVarray - StoragePort matches: VArray=%s (%s), StoragePort=%s, Network=%s, Initiator=%s", virtualArray.getLabel(), exportGroup.getVirtualArray().toString(), port.getPortName(), storagePortNetwork.getLabel(), initiator.getInitiatorPort()));
            }
            // Got here, so we can update the list of initiators to list of StoragePorts
            // that show a relationship through the Network and the VArray
            initiatorToMatchedSP.put(initiator.getId(), port.getId());
        }
    }
    // Validate that the ExportMask is a positive match based on the StoragePorts
    // that it references and the ExportGroups path parameters.
    Set<URI> matchedSPs = initiatorToMatchedSP.get(initiator.getId());
    isMatched = (matchedSPs != null && !matchedSPs.isEmpty());
    _log.info(String.format("maskHasStoragePortsInExportVarray - Returning %s", isMatched));
    return isMatched;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI)

Example 9 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method maskHasStoragePortsInExportVarray.

/**
 * Check that export mask has at least one valid port from virtual array
 *
 * @param virtualArray
 * @param mask
 * @return
 */
protected boolean maskHasStoragePortsInExportVarray(VirtualArray virtualArray, ExportMask mask) {
    boolean isMatched = false;
    for (String uriString : mask.getStoragePorts()) {
        URI uri = URI.create(uriString);
        StoragePort port = _dbClient.queryObject(StoragePort.class, uri);
        // Basic validation of the StoragePort
        if (port == null || port.getInactive()) {
            _log.info(String.format("maskHasStoragePortsInExportVarray - Could not find port or it is inactive %s", uri.toString()));
            continue;
        }
        // StoragePort needs to be in the REGISTERED and VISIBLE status
        if (!port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name()) || port.getDiscoveryStatus().equals(DiscoveryStatus.NOTVISIBLE.name())) {
            _log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not registered or not visible", port.getPortName(), uri.toString()));
            continue;
        }
        // Look up the StoragePort's network
        NetworkLite storagePortNetwork = BlockStorageScheduler.lookupNetworkLite(_dbClient, StorageProtocol.Transport.valueOf(port.getTransportType()), port.getPortNetworkId());
        if (storagePortNetwork == null) {
            _log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not associated with any network", port.getPortName(), uri.toString()));
            continue;
        }
        // Port must belong to the VArray
        if (!port.taggedToVirtualArray(virtualArray.getId())) {
            _log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not tagged to VArray %s (%s)", port.getPortName(), uri.toString(), virtualArray.getLabel(), virtualArray.getId()));
            // reverted the fix, as the probability of Consistent lun violation will be more.
            continue;
        }
        // at least one port is in virtualArray
        isMatched = true;
        break;
    }
    return isMatched;
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI)

Example 10 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class BrocadeNetworkSystemDevice method getEndpointNetworks.

/**
 * This is function is used at the time an 'add zone' request is received when we need
 * to decide if the zone request requires creating an LSAN zone or a regular zone. For
 * each member find the network the member is in. Note, zones can be created for WWNs
 * that are not logged into the switch, or for aliases. In this case, we assume only
 * regular zones will be created.
 *
 * @param zone the zone to be added.
 * @return A map of zoneMember-to-network
 */
private Map<ZoneMember, NetworkLite> getEndpointNetworks(Zone zone, String fabricId, String fabricWwn) {
    NetworkLite network = NetworkUtil.getNetworkLiteByFabricId(fabricId, fabricWwn, _dbClient);
    Map<ZoneMember, NetworkLite> epNetworks = new HashMap<ZoneMember, NetworkLite>();
    NetworkLite loopNetwork = null;
    for (ZoneMember member : zone.getMembers()) {
        // For alias-type members, more investigation is needed.
        if (!StringUtils.isEmpty(member.getAddress())) {
            loopNetwork = NetworkUtil.getEndpointNetworkLite(member.getAddress(), _dbClient);
        }
        // it belongs to the request network.
        if (loopNetwork == null && network != null) {
            loopNetwork = network;
        }
        if (loopNetwork != null) {
            epNetworks.put(member, loopNetwork);
        }
    }
    return epNetworks;
}
Also used : HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember)

Aggregations

NetworkLite (com.emc.storageos.util.NetworkLite)130 StoragePort (com.emc.storageos.db.client.model.StoragePort)110 URI (java.net.URI)86 ArrayList (java.util.ArrayList)85 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)82 HashMap (java.util.HashMap)48 List (java.util.List)44 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 Map (java.util.Map)22 HashSet (java.util.HashSet)20 Initiator (com.emc.storageos.db.client.model.Initiator)19 StringSet (com.emc.storageos.db.client.model.StringSet)19 TreeMap (java.util.TreeMap)10 Set (java.util.Set)9 SortedMap (java.util.SortedMap)9 StringMap (com.emc.storageos.db.client.model.StringMap)7 StoragePortsAllocator (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator)6 DummyDbClient (com.emc.storageos.util.DummyDbClient)4 PortAllocatorTestContext (com.emc.storageos.volumecontroller.placement.PortAllocatorTestContext)4