Search in sources :

Example 26 with UnManagedExportMask

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

the class ExternalDeviceUnManagedVolumeDiscoverer method createUnManagedExportMask.

/**
 * This method builds unManaged export mask from the provided hostExportInfo.
 *
 * @param hostExportInfo       source for unmanaged export mask data
 * @param unManagedVolumesUris set of unManaged volumes database ids for unManaged mask
 * @param managedVolumesUris   set of managed volumes database ids for unManaged mask
 * @param dbClient             reference to db client [IN]
 * @return unManaged export mask
 */
private UnManagedExportMask createUnManagedExportMask(com.emc.storageos.db.client.model.StorageSystem storageSystem, HostExportInfo hostExportInfo, Set<String> unManagedVolumesUris, Set<String> managedVolumesUris, DbClient dbClient) {
    UnManagedExportMask exportMask = new UnManagedExportMask();
    exportMask.setId(URIUtil.createId(UnManagedExportMask.class));
    StringSet knownInitiatorUris = new StringSet();
    StringSet knownInitiatorNetworkIds = new StringSet();
    StringSet unknownInitiatorNetworkIds = new StringSet();
    StringSet knownStoragePortUris = new StringSet();
    StringSet unmanagedStoragePortNetworkIds = new StringSet();
    StringSet unknownVolumesUris = new StringSet();
    StringSet knownVolumesUris = new StringSet();
    List<com.emc.storageos.db.client.model.Initiator> knownFCInitiators = new ArrayList<>();
    List<com.emc.storageos.db.client.model.StoragePort> knownFCPorts = new ArrayList<>();
    // FQDN of a host
    String hostName = hostExportInfo.getHostName();
    // List of host initiators
    List<Initiator> initiators = hostExportInfo.getInitiators();
    // List of storage ports
    List<StoragePort> targets = hostExportInfo.getTargets();
    exportMask.setMaskName(getUnManagedMaskName(hostName, storageSystem.getNativeGuid()));
    exportMask.setStorageSystemUri(storageSystem.getId());
    // get URIs for the initiators
    for (Initiator driverInitiator : initiators) {
        com.emc.storageos.db.client.model.Initiator knownInitiator = NetworkUtil.getInitiator(driverInitiator.getPort(), dbClient);
        if (knownInitiator != null) {
            URI initiatorUri = knownInitiator.getId();
            knownInitiatorUris.add(initiatorUri.toString());
            knownInitiatorNetworkIds.add(driverInitiator.getPort());
            if (HostInterface.Protocol.FC.toString().equals(knownInitiator.getProtocol())) {
                knownFCInitiators.add(knownInitiator);
            }
        } else {
            // unknown initiator
            unknownInitiatorNetworkIds.add(driverInitiator.getPort());
        }
    }
    exportMask.setKnownInitiatorNetworkIds(knownInitiatorNetworkIds);
    exportMask.setKnownInitiatorUris(knownInitiatorUris);
    exportMask.setUnmanagedInitiatorNetworkIds(unknownInitiatorNetworkIds);
    // get URIs for storage ports
    for (StoragePort driverPort : targets) {
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, driverPort.getNativeId(), NativeGUIDGenerator.PORT);
        URIQueryResultList storagePortURIs = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), storagePortURIs);
        if (storagePortURIs.iterator().hasNext()) {
            URI portUri = storagePortURIs.iterator().next();
            knownStoragePortUris.add(portUri.toString());
            com.emc.storageos.db.client.model.StoragePort port = dbClient.queryObject(com.emc.storageos.db.client.model.StoragePort.class, portUri);
            if (com.emc.storageos.db.client.model.StoragePort.TransportType.FC.toString().equals(port.getTransportType())) {
                knownFCPorts.add(port);
            }
        } else {
            // unknown storage port
            unmanagedStoragePortNetworkIds.add(driverPort.getPortNetworkId());
        }
    }
    exportMask.setKnownStoragePortUris(knownStoragePortUris);
    exportMask.setUnmanagedStoragePortNetworkIds(unmanagedStoragePortNetworkIds);
    // set unManaged volume uris
    if (unManagedVolumesUris != null && !unManagedVolumesUris.isEmpty()) {
        unknownVolumesUris.addAll(unManagedVolumesUris);
        exportMask.setUnmanagedVolumeUris(unknownVolumesUris);
    }
    // set managed volume uris
    if (managedVolumesUris != null && !managedVolumesUris.isEmpty()) {
        knownVolumesUris.addAll(managedVolumesUris);
        exportMask.setKnownVolumeUris(knownVolumesUris);
    }
    // populate zone map for FC initiators and FC storage ports from the mask.
    // we zone only known FC initiators to known FC ports defined in the mask.
    updateZoningMap(exportMask, knownFCInitiators, knownFCPorts);
    return exportMask;
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 27 with UnManagedExportMask

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

the class ExternalDeviceUnManagedVolumeDiscoverer method getUnManagedExportMask.

/**
 * Get unManaged export mask for specified mask name and specified array.
 * Based on the enforced constraint for unmanaged export masks,
 * there will be only zero or one such mask.
 *
 * @param maskName  mask name
 * @param dbClient  reference to db client [IN]
 * @param systemURI storage system
 * @return unmanaged export mask or null, if there is no mask this name and storage array
 */
private UnManagedExportMask getUnManagedExportMask(String maskName, DbClient dbClient, URI systemURI) {
    UnManagedExportMask uem = null;
    URIQueryResultList masks = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedExportMaskNameConstraint(maskName), masks);
    Iterator<URI> maskIterator = masks.iterator();
    while (maskIterator.hasNext()) {
        UnManagedExportMask potentialUem = dbClient.queryObject(UnManagedExportMask.class, maskIterator.next());
        // Check whether the unManaged export mask belongs to the specified storage system.
        if (URIUtil.identical(potentialUem.getStorageSystemUri(), systemURI)) {
            uem = potentialUem;
            break;
        }
    }
    return uem;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 28 with UnManagedExportMask

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

the class ExportMaskUtils method checkZoneUseInUnManagedExportMasks.

/**
 * Check if a particular zone (as represented by a ZoneInfo) is in use by an UnManagedExportMask
 * (excluding the UnManagedExportMask corresponding to the named exportMask.
 * @param exportMaskName -- ExportMask name filed
 * @param info -- ZoneInfo representing the Zone
 * @param dbClient == databasehandle
 * @return -- true IFF the same zone was found in other UnManagedExportMasks
 */
private static boolean checkZoneUseInUnManagedExportMasks(String exportMaskName, ZoneInfo info, DbClient dbClient) {
    String initiatorWwn = info.getInitiatorWwn();
    boolean inUse = false;
    List<UnManagedExportMask> unmanagedMasks = CustomQueryUtility.queryActiveResourcesByAltId(dbClient, UnManagedExportMask.class, "knownInitiatorNetworkIds", initiatorWwn);
    for (UnManagedExportMask umask : unmanagedMasks) {
        if (umask.getKnownInitiatorNetworkIds().contains(initiatorWwn) && !umask.getUnmanagedVolumeUris().isEmpty()) {
            for (ZoneInfo umZoneInfo : umask.getZoningMap().values()) {
                if (exportMaskName.equals(umask.getMaskName())) {
                    continue;
                }
                if (info.getInitiatorWwn().equals(umZoneInfo.getInitiatorWwn()) && info.getPortWwn().equals(umZoneInfo.getPortWwn())) {
                    _log.info(String.format("UnManagedExportMask %s zone %s is using the same initiator %s and port %s", umask.getNativeId(), umZoneInfo.getZoneName(), umZoneInfo.getInitiatorWwn(), umZoneInfo.getPortWwn()));
                    inUse = true;
                    break;
                }
            }
        }
    }
    return inUse;
}
Also used : ZoneInfo(com.emc.storageos.db.client.model.ZoneInfo) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 29 with UnManagedExportMask

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

the class VNXUnityUnManagedObjectDiscoverer method getUnManagedExportMask.

/**
 * Get existing unmanaged export mask, or create a new one.
 *
 * @param knownInitiatorNetworkId
 *            The initiator network id (pwwn)
 * @param dbClient
 * @param systemURI
 * @return
 */
private UnManagedExportMask getUnManagedExportMask(String knownInitiatorNetworkId, DbClient dbClient, URI systemURI) {
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedExportMaskKnownInitiatorConstraint(knownInitiatorNetworkId), result);
    UnManagedExportMask uem = null;
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        UnManagedExportMask potentialUem = dbClient.queryObject(UnManagedExportMask.class, it.next());
        // vplex uem.
        if (URIUtil.identical(potentialUem.getStorageSystemUri(), systemURI)) {
            uem = potentialUem;
            unManagedExportMasksToUpdate.add(uem);
            break;
        }
    }
    if (uem != null && !uem.getInactive()) {
        // clean up collections (we'll be refreshing them)
        uem.getKnownInitiatorUris().clear();
        uem.getKnownInitiatorNetworkIds().clear();
        uem.getKnownStoragePortUris().clear();
        uem.getKnownVolumeUris().clear();
        uem.getUnmanagedInitiatorNetworkIds().clear();
        uem.getUnmanagedStoragePortNetworkIds().clear();
        uem.getUnmanagedVolumeUris().clear();
    } else {
        uem = new UnManagedExportMask();
        uem.setId(URIUtil.createId(UnManagedExportMask.class));
        unManagedExportMasksToCreate.add(uem);
    }
    return uem;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 30 with UnManagedExportMask

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

the class XtremIOUnManagedVolumeDiscoverer method getUnManagedExportMask.

private UnManagedExportMask getUnManagedExportMask(String knownInitiatorNetworkId, DbClient dbClient, URI systemURI) {
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedExportMaskKnownInitiatorConstraint(knownInitiatorNetworkId), result);
    UnManagedExportMask uem = null;
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        UnManagedExportMask potentialUem = dbClient.queryObject(UnManagedExportMask.class, it.next());
        // vplex uem.
        if (URIUtil.identical(potentialUem.getStorageSystemUri(), systemURI)) {
            uem = potentialUem;
            unManagedExportMasksToUpdate.add(uem);
            break;
        }
    }
    if (uem != null && !uem.getInactive()) {
        // clean up collections (we'll be refreshing them)
        uem.getKnownInitiatorUris().clear();
        uem.getKnownInitiatorNetworkIds().clear();
        uem.getKnownStoragePortUris().clear();
        uem.getKnownVolumeUris().clear();
        uem.getUnmanagedInitiatorNetworkIds().clear();
        uem.getUnmanagedStoragePortNetworkIds().clear();
        uem.getUnmanagedVolumeUris().clear();
    } else {
        uem = new UnManagedExportMask();
        uem.setId(URIUtil.createId(UnManagedExportMask.class));
        unManagedExportMasksToCreate.add(uem);
    }
    return uem;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Aggregations

UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)46 URI (java.net.URI)33 ArrayList (java.util.ArrayList)26 HashSet (java.util.HashSet)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 StringSet (com.emc.storageos.db.client.model.StringSet)17 Initiator (com.emc.storageos.db.client.model.Initiator)15 HashMap (java.util.HashMap)14 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)13 ExportMask (com.emc.storageos.db.client.model.ExportMask)8 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 Map (java.util.Map)8 Set (java.util.Set)8 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 Volume (com.emc.storageos.db.client.model.Volume)7 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)6 CIMInstance (javax.cim.CIMInstance)5 CIMObjectPath (javax.cim.CIMObjectPath)5