Search in sources :

Example 36 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 37 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)

Example 38 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 39 with StringSet

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

the class TransportZoneReconciler method handleUpdatedTransportZone.

private void handleUpdatedTransportZone(NetworkSystem networkSystem, Network oldTransportZone, Network newTransportZone, Results results) throws IOException {
    List<String> removedEndPoints = new ArrayList<String>();
    List<String> addedEndPoints = new ArrayList<String>(newTransportZone.retrieveEndpoints());
    StringSet newEndPoints = newTransportZone.retrieveEndpoints();
    for (String endpoint : oldTransportZone.retrieveEndpoints()) {
        if (newEndPoints.contains(endpoint)) {
            // The endpoint still present, account for that
            addedEndPoints.remove(endpoint);
        } else if (oldTransportZone.endpointIsDiscovered(endpoint)) {
            removedEndPoints.add(endpoint);
        }
    }
    if (!addedEndPoints.isEmpty()) {
        oldTransportZone.addEndpoints(addedEndPoints, true);
        // update the results object
        results.getAddedEndPoints().put(oldTransportZone, addedEndPoints);
        _log.info("Endpoints {} were added to fabric {} on network {}", new Object[] { addedEndPoints.toArray(), oldTransportZone.getNativeId(), oldTransportZone.getId().toString() });
    }
    if (!removedEndPoints.isEmpty()) {
        oldTransportZone.removeEndpoints(removedEndPoints);
        // update the results object
        results.getRemovedEndPoints().put(oldTransportZone, removedEndPoints);
        _log.info("Endpoints {} were removed from fabric {} on network {}", new Object[] { removedEndPoints.toArray(), oldTransportZone.getNativeId(), oldTransportZone.getId().toString() });
    }
    if (!oldTransportZone.getNetworkSystems().contains(networkSystem.getId().toString())) {
        oldTransportZone.addNetworkSystems(Collections.singletonList(networkSystem.getId().toString()));
        if (RegistrationStatus.REGISTERED.name().equalsIgnoreCase(networkSystem.getRegistrationStatus())) {
            oldTransportZone.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
        }
    }
    if (!oldTransportZone.getNativeId().equals(newTransportZone.getNativeId())) {
        oldTransportZone.setNativeId(newTransportZone.getNativeId());
    }
    // update the results object
    results.getModified().add(oldTransportZone);
}
Also used : ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 40 with StringSet

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

the class StoragePortService method updatevNasVirtualArrays.

/**
 * Updates the virtual arrays to which the port of virtual nas is assigned.
 *
 * @param storagePort A reference to the storage port.
 * @param newNetwork Network service assicated with varray
 * @param varrayAssignmentChanges The virtual array changes.
 * @param removePort - is port remove or add
 * @return true if there was a virtual array assignment change, false otherwise.
 */
private boolean updatevNasVirtualArrays(StoragePort storagePort, Network newNetwork, VirtualArrayAssignmentChanges varrayAssignmentChanges, boolean removePort) {
    _log.info("StoragePort:updatevNasVirtualArrays {} ", storagePort.getLabel());
    // Validate that the virtual arrays to be assigned to the vnas
    // reference existing virtual arrays in the database and add them to
    // the vnas.
    Set<String> varraysAddedTovNas = new HashSet<String>();
    Set<String> varraysRemovedFromvNas = new HashSet<String>();
    boolean varraysForvNasUpdated = false;
    VirtualNAS vNas = getVirtualNasForStoragePort(storagePort);
    if (vNas == null) {
        _log.info("No Virtual NAS found for port {} ", storagePort.getLabel());
        return false;
    }
    VirtualArrayAssignments addAssignments = null;
    VirtualArrayAssignments removeAssignments = null;
    StringSet currentAssignmentsForvNas = null;
    if (varrayAssignmentChanges != null) {
        addAssignments = varrayAssignmentChanges.getAdd();
        removeAssignments = varrayAssignmentChanges.getRemove();
        currentAssignmentsForvNas = vNas.getAssignedVirtualArrays();
    }
    // Update the vNas virtual arrays from network!!!
    if (newNetwork != null) {
        StringSet vArrays = newNetwork.getAssignedVirtualArrays();
        if (vArrays != null && !vArrays.isEmpty()) {
            if (!removePort) {
                vNas.addAssignedVirtualArrays(vArrays);
                varraysForvNasUpdated = true;
            } else {
                // Removing storage port from netwok!!!
                _log.info("Step to Removing storage port from netwok");
                StringSet vNasVarrys = new StringSet();
                StringSet vNasVarryOther = new StringSet();
                for (String sp : vNas.getStoragePorts()) {
                    StoragePort vNasSp = _dbClient.queryObject(StoragePort.class, URI.create(sp));
                    if (!sp.equalsIgnoreCase(storagePort.getId().toString())) {
                        if (vNasSp.getConnectedVirtualArrays() != null && !vNasSp.getConnectedVirtualArrays().isEmpty()) {
                            vNasVarrys.addAll(vNasSp.getConnectedVirtualArrays());
                        }
                    }
                }
                if (!vNasVarrys.isEmpty()) {
                    _log.info("varrays of vNas other ports {} and varrays of a network {}", vNasVarrys.toString(), vArrays.toString());
                }
                /*
                        If the varray of the port to be deleted is common with another port then we should not update vnas.
                        because the other ports of vnas may exist with same network of deleting port
                    */
                if ((vNasVarrys.isEmpty()) || (!vNasVarrys.isEmpty() && !vNasVarrys.containsAll(vArrays))) {
                    _log.info("Remove the varray from vNAS {} ", vNasVarrys.toString());
                    vNas.getAssignedVirtualArrays().removeAll(vArrays);
                    // remaining vNASvarray of other ports
                    vNas.getAssignedVirtualArrays().addAll(vNasVarrys);
                    varraysForvNasUpdated = true;
                }
            }
        }
    }
    if (varrayAssignmentChanges != null) {
        if (addAssignments != null) {
            Set<String> addVArrays = addAssignments.getVarrays();
            if ((addVArrays != null) && (!addVArrays.isEmpty())) {
                // Iterate over the virtual arrays and assign them
                // to the virtual NAS.
                Iterator<String> addVArraysIterForvNas = addVArrays.iterator();
                while (addVArraysIterForvNas.hasNext()) {
                    String addVArrayId = addVArraysIterForvNas.next();
                    if ((currentAssignmentsForvNas != null) && (currentAssignmentsForvNas.contains(addVArrayId))) {
                        // Just ignore those already assigned
                        _log.info("Virtual Nas already assigned to virtual array {}", addVArrayId);
                        continue;
                    }
                    varraysAddedTovNas.add(addVArrayId);
                    _log.info("virtual nas will be assigned to virtual array {}", addVArrayId);
                }
                if (!varraysAddedTovNas.isEmpty()) {
                    vNas.addAssignedVirtualArrays(varraysAddedTovNas);
                    _log.info("virtual nas assigned with virtual arrays size {}", varraysAddedTovNas.size());
                    varraysForvNasUpdated = true;
                }
            }
        }
        if (removeAssignments != null) {
            Set<String> removeVArrays = removeAssignments.getVarrays();
            if ((removeVArrays != null) && (!removeVArrays.isEmpty())) {
                // Iterate over the virtual arrays and assign them
                // to the virtual NAS.
                _log.info("Virtual Nas that has virtual array to remove {}", removeVArrays.toString());
                Iterator<String> removeVArraysIterForvNas = removeVArrays.iterator();
                while (removeVArraysIterForvNas.hasNext()) {
                    String removeVArrayId = removeVArraysIterForvNas.next();
                    if ((currentAssignmentsForvNas != null) && (!currentAssignmentsForvNas.contains(removeVArrayId))) {
                        // Just ignore those already assigned
                        _log.info("Virtual Nas not assigned to virtual array {}", removeVArrayId);
                        continue;
                    }
                    varraysRemovedFromvNas.add(removeVArrayId);
                    _log.info("virtual nas will be unassigned to virtual array {}", removeVArrayId);
                }
                if (!varraysRemovedFromvNas.isEmpty()) {
                    vNas.removeAssignedVirtualArrays(varraysRemovedFromvNas);
                    _log.info("virtual nas un-assigned with virtual arrays size {}", varraysRemovedFromvNas.size());
                    varraysForvNasUpdated = true;
                }
            }
        }
    } else {
        _log.info("Ignored assignment of varray to virtual nas as the storage port not belongs to vnx file");
    }
    if (varraysForvNasUpdated) {
        _dbClient.persistObject(vNas);
    }
    return varraysForvNasUpdated;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) VirtualArrayAssignments(com.emc.storageos.model.pools.VirtualArrayAssignments) HashSet(java.util.HashSet)

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