Search in sources :

Example 1 with Initiator

use of com.emc.storageos.storagedriver.model.Initiator in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method prepareInitiators.

private void prepareInitiators(Collection<com.emc.storageos.db.client.model.Initiator> initiatorList, boolean isClusterExport, List<Initiator> driverInitiators) {
    for (com.emc.storageos.db.client.model.Initiator initiator : initiatorList) {
        Initiator driverInitiator = createDriverInitiator(initiator);
        if (isClusterExport) {
            driverInitiator.setInitiatorType(Initiator.Type.Cluster);
        } else {
            driverInitiator.setInitiatorType(Initiator.Type.Host);
        }
        driverInitiators.add(driverInitiator);
    }
}
Also used : Initiator(com.emc.storageos.storagedriver.model.Initiator)

Example 2 with Initiator

use of com.emc.storageos.storagedriver.model.Initiator in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method removeVolumes.

@Override
public void removeVolumes(StorageSystem storage, URI exportMaskUri, List<URI> volumeUris, List<com.emc.storageos.db.client.model.Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} removeVolumes START...", storage.getSerialNumber());
    try {
        log.info("removeVolumes: Export mask id: {}", exportMaskUri);
        log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumeUris));
        if (initiatorList != null) {
            log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
        }
        BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
        ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
        StringSet maskInitiators = exportMask.getInitiators();
        List<String> maskInitiatorList = new ArrayList<>();
        for (String initiatorUri : maskInitiators) {
            maskInitiatorList.add(initiatorUri);
        }
        log.info("Export mask existing initiators: {} ", Joiner.on(",").join(maskInitiatorList));
        // Prepare volumes. We send to driver only new volumes for the export mask.
        List<StorageVolume> driverVolumes = new ArrayList<>();
        prepareVolumes(storage, volumeUris, driverVolumes);
        // Prepare initiators
        Set<com.emc.storageos.db.client.model.Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(dbClient, exportMask, null);
        List<Initiator> driverInitiators = new ArrayList<>();
        // Get export group uri from task completer
        URI exportGroupUri = taskCompleter.getId();
        ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
        prepareInitiators(initiators, exportGroup.forCluster(), driverInitiators);
        // Ready to call driver
        DriverTask task = driver.unexportVolumesFromInitiators(driverInitiators, driverVolumes);
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("Removed volumes from export: %s.", task.getMessage());
            log.info(msg);
            taskCompleter.ready(dbClient);
        } else {
            String errorMsg = String.format("Failed to remove volumes from export mask: %s .", task.getMessage());
            log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.deleteVolumesFromExportMaskFailed("removeVolumes", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception ex) {
        log.error("Problem in removeVolumes: ", ex);
        String errorMsg = String.format("Failed to remove volumes from export mask: %s .", ex.getMessage());
        log.error(errorMsg);
        ServiceError serviceError = ExternalDeviceException.errors.deleteVolumesFromExportMaskFailed("removeVolumes", errorMsg);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} removeVolumes END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 3 with Initiator

use of com.emc.storageos.storagedriver.model.Initiator in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method createDriverInitiator.

private Initiator createDriverInitiator(com.emc.storageos.db.client.model.Initiator initiator) {
    Initiator driverInitiator = new Initiator();
    driverInitiator.setPort(initiator.getInitiatorPort());
    driverInitiator.setHostName(initiator.getHostName());
    driverInitiator.setClusterName(initiator.getClusterName());
    driverInitiator.setNode(initiator.getInitiatorNode());
    driverInitiator.setProtocol(Initiator.Protocol.valueOf(initiator.getProtocol()));
    driverInitiator.setDisplayName(initiator.getLabel());
    // set host OS type
    driverInitiator.setHostOsType(Initiator.HostOsType.Other);
    Host host = dbClient.queryObject(Host.class, initiator.getHost());
    String hostType = host.getType();
    for (Initiator.HostOsType driverInitiatorHostType : Initiator.HostOsType.values()) {
        if (hostType.equals(driverInitiatorHostType.toString())) {
            driverInitiator.setHostOsType(driverInitiatorHostType);
        }
    }
    log.info("Initiator host OS type {}", driverInitiator.getHostOsType());
    return driverInitiator;
}
Also used : Initiator(com.emc.storageos.storagedriver.model.Initiator) Host(com.emc.storageos.db.client.model.Host)

Example 4 with Initiator

use of com.emc.storageos.storagedriver.model.Initiator in project coprhd-controller by CoprHD.

the class ExternalDeviceUnManagedVolumeDiscoverer method verifyHostExports.

/**
 * Verifies that all members of the specified list have the same set of initiators ans the same set
 * of storage ports.
 *
 * @param hostExportInfoList list of HostExportInfo data
 * @return If validation is success return VolumeToHostExportInfo with common set of initiators, common set of
 * ports, and all volumes from all elements of input list.
 * If validation failed, return null.
 */
private HostExportInfo verifyHostExports(List<HostExportInfo> hostExportInfoList) {
    HostExportInfo exportInfo = hostExportInfoList.get(0);
    // FQDN of a host
    String hostName = exportInfo.getHostName();
    // storage volumes native Ids
    Set<String> volumeNativeIds = new HashSet<>();
    // initiators port Ids
    Set<String> masterInitiatorNetworkIds = new HashSet<>();
    // target native Ids
    Set<String> masterTargetNativeIds = new HashSet<>();
    // get benchmark set of initiators and targets from first host export info instances
    // List of host initiators
    List<Initiator> initiators = exportInfo.getInitiators();
    // List of storage ports
    List<StoragePort> targets = exportInfo.getTargets();
    for (Initiator initiator : initiators) {
        masterInitiatorNetworkIds.add(initiator.getPort());
    }
    for (StoragePort port : targets) {
        masterTargetNativeIds.add(port.getNativeId());
    }
    for (HostExportInfo hostExportInfo : hostExportInfoList) {
        boolean isValid = verifyHostExports(masterInitiatorNetworkIds, masterTargetNativeIds, hostExportInfo);
        if (!isValid) {
            return null;
        }
        // Aggregate all volumes in one set.
        volumeNativeIds.addAll(hostExportInfo.getStorageObjectNativeIds());
    }
    // Create result export info
    HostExportInfo hostExportInfo = new HostExportInfo(hostName, new ArrayList<>(volumeNativeIds), initiators, targets);
    return hostExportInfo;
}
Also used : Initiator(com.emc.storageos.storagedriver.model.Initiator) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) HashSet(java.util.HashSet)

Example 5 with Initiator

use of com.emc.storageos.storagedriver.model.Initiator in project coprhd-controller by CoprHD.

the class ExternalDeviceUnManagedVolumeDiscoverer method determineUnManagedExportMasksForExportInfo.

/**
 * This method processes hostToVolumeExportInfoMap to find out which existing unmanaged masks has to be updated,
 * and which unmanaged masks have to be created new for this export info. It also identifies hosts with unsupported
 * export info data (exported host volumes are not seen through the same set of initiators and the same set of storage
 * ports --- which require more than one mask per host) and adds these hosts to invalidExportHosts set.
 *
 * @param storageSystem
 * @param hostToVolumeExportInfoMap [IN] map: key --- host FQDN, value --- list of volume export info instances
 * @param invalidExportHosts        [IN, OUT] set of invalid hosts, for which we skip export processing for a given array
 * @param dbClient                  reference to db client [IN]
 * @param masksToUpdateForVolumes   [OUT] map: key --- URI of existing unmanaged export mask, value --- export info to use
 *                                  to update the mask.
 * @param masksToCreateForVolumes   [OUT] list of export info instances for which we need to create new unmanaged masks.
 */
private void determineUnManagedExportMasksForExportInfo(com.emc.storageos.db.client.model.StorageSystem storageSystem, Map<String, List<HostExportInfo>> hostToVolumeExportInfoMap, Set<String> invalidExportHosts, DbClient dbClient, Map<URI, HostExportInfo> masksToUpdateForVolumes, List<HostExportInfo> masksToCreateForVolumes) {
    for (Map.Entry<String, List<HostExportInfo>> entry : hostToVolumeExportInfoMap.entrySet()) {
        String hostName = entry.getKey();
        log.info("Processing export info for host {} .", hostName);
        if (invalidExportHosts.contains(hostName)) {
            // skip and continue to the next host.
            log.info("Found host {} in invalid hosts list. We will not process this host export data.", hostName);
            continue;
        }
        List<HostExportInfo> volumeToHostExportInfoList = entry.getValue();
        log.info("Processing export info list {} .", volumeToHostExportInfoList);
        String maskName = getUnManagedMaskName(hostName, storageSystem.getNativeGuid());
        HostExportInfo hostExportInfo = verifyHostExports(volumeToHostExportInfoList);
        if (hostExportInfo == null) {
            // invalid, continue to the next host
            invalidExportHosts.add(hostName);
            log.info("Found export info for host {} invalid. We will not process this host export data.", hostName);
            // check existing UnManaged export mask for host/array: the mask could be discovered for volumes on previous
            // pages (all unmanaged masks from previous discovery have been deactivated at the begging).
            UnManagedExportMask unManagedMask = getUnManagedExportMask(maskName, dbClient, storageSystem.getId());
            if (unManagedMask != null) {
                log.info("Found existing unmanaged export mask for host {} and array {} --- {} . We will deactivate this mask.", hostName, storageSystem.getNativeId(), unManagedMask);
                removeInvalidMaskDataFromVolumes(unManagedMask, dbClient);
                unManagedMask.setInactive(true);
                dbClient.updateObject(unManagedMask);
            }
            continue;
        }
        log.info("The result export info for host {} and array {} : {} .", hostName, storageSystem.getNativeId(), hostExportInfo);
        // check existing UnManaged export mask for host/array: the mask could be discovered for volumes on previous
        // pages (all unmanaged masks from previous discovery have been deactivated at the begging).
        UnManagedExportMask unManagedMask = getUnManagedExportMask(maskName, dbClient, storageSystem.getId());
        boolean isValid = true;
        if (unManagedMask != null) {
            log.info("Found existing unmanaged export mask for host {} and array {} --- {} .", hostName, storageSystem.getNativeId(), unManagedMask);
            // check that existing host/array unManaged export mask has the same set of initiators and the same
            // set of ports as new discovered hostExportInfo
            StringSet storagePortsUris = unManagedMask.getKnownStoragePortUris();
            Set<String> storagePortsNativeIds = new HashSet<>();
            Set<String> initiatorsNativeIds = new HashSet<>();
            for (String portUriString : storagePortsUris) {
                URI portUri = URI.create(portUriString);
                com.emc.storageos.db.client.model.StoragePort port = dbClient.queryObject(com.emc.storageos.db.client.model.StoragePort.class, portUri);
                storagePortsNativeIds.add(port.getNativeId());
            }
            storagePortsNativeIds.addAll(unManagedMask.getUnmanagedStoragePortNetworkIds());
            initiatorsNativeIds.addAll(unManagedMask.getKnownInitiatorNetworkIds());
            initiatorsNativeIds.addAll(unManagedMask.getUnmanagedInitiatorNetworkIds());
            isValid = verifyHostExports(initiatorsNativeIds, storagePortsNativeIds, hostExportInfo);
            if (!isValid) {
                // Invalid, we deactivate existing unmanaged mask --- make sure we do not discover invalid export
                // masks. We also, remove this mask from "unmanagedExportMasks" set in its unmanaged storage volumes.
                log.info("The result export info for host {} and storage array {} does not comply with existing mask.", hostName, storageSystem.getNativeId());
                removeInvalidMaskDataFromVolumes(unManagedMask, dbClient);
                unManagedMask.setInactive(true);
                dbClient.updateObject(unManagedMask);
            }
        } else {
            // Check if export mask for host/array is already managed. If host/array mask is managed, check that hostExportInfo has the same
            // storage ports and the same host initiators as in the managed mask. If we have a match for ports/initiators between the mask and hostExportInfo, we will process this
            // host export info and create a new UnManagedExportMask for the host.
            log.info("There is no existing unmanaged export mask for host {} and array {} .", hostName, storageSystem.getNativeId());
            List<String> initiatorPorts = new ArrayList<>();
            for (Initiator initiator : hostExportInfo.getInitiators()) {
                initiatorPorts.add(initiator.getPort());
            }
            // We enforce single export mask for host/array for ingested masks, so if only one initiator port match, the mask is a match.
            Map<URI, ExportMask> uriToExportMask = ExportMaskUtils.getExportMasksWithInitiatorPorts(dbClient, initiatorPorts);
            // Look for export mask for the storage system under processing.
            for (ExportMask mask : uriToExportMask.values()) {
                if (URIUtil.identical(mask.getStorageDevice(), storageSystem.getId())) {
                    // found managed export mask for storage system and host initiator
                    // the mask is already managed.
                    log.info("Found managed export mask for host {} and array {} --- {}." + " We will process this host export data to see if we can add volumes to this mask.", hostName, storageSystem.getNativeId(), mask.getId());
                    // check that this managed mask has the same initiators and ports as in the hostExportInfo
                    StringSet storagePortsUris = mask.getStoragePorts();
                    StringSet initiatorsUris = mask.getInitiators();
                    List<com.emc.storageos.db.client.model.StoragePort> ports = dbClient.queryObjectField(com.emc.storageos.db.client.model.StoragePort.class, "nativeId", StringSetUtil.stringSetToUriList(storagePortsUris));
                    List<com.emc.storageos.db.client.model.Initiator> initiators = dbClient.queryObjectField(com.emc.storageos.db.client.model.Initiator.class, "iniport", StringSetUtil.stringSetToUriList(initiatorsUris));
                    Set<String> maskStoragePortsNativeIds = new HashSet<>();
                    Set<String> maskInitiatorPorts = new HashSet<>();
                    for (com.emc.storageos.db.client.model.StoragePort storagePort : ports) {
                        maskStoragePortsNativeIds.add(storagePort.getNativeId());
                    }
                    for (com.emc.storageos.db.client.model.Initiator initiator : initiators) {
                        maskInitiatorPorts.add(initiator.getInitiatorPort());
                    }
                    log.info("Managed ExportMask {} has the following storage ports {}", mask.getId(), maskStoragePortsNativeIds);
                    log.info("Managed ExportMask {} has the following initiator ports {}", mask.getId(), maskInitiatorPorts);
                    // check that hostExportInfo has the same ports and initiators as in the export mask
                    isValid = verifyHostExports(maskInitiatorPorts, maskStoragePortsNativeIds, hostExportInfo);
                    if (isValid) {
                        // we will create unmanaged mask for this hostExportInfo
                        // we rely on ingestion to add new volumes to the managed mask.
                        log.info("Managed export mask {} has the same initiators and ports as in hostExportInfo. We will create unmanaged mask for new volumes.", mask.getId());
                        break;
                    } else {
                        log.info("Managed export mask {} has different initiators or ports as those in hostExportInfo.", mask.getId());
                    }
                }
            }
        }
        if (!isValid) {
            // invalid, continue to the next host
            // add host to invalid hosts list, so we do not process any export volume
            // info for this host in the future (for volumes found on next pages).
            log.info("Found export info for host {} invalid. Export info: {}." + " We will not process this host export data.", hostName, hostExportInfo);
            invalidExportHosts.add(hostName);
            continue;
        }
        if (unManagedMask != null) {
            // we will update this mask with additional volumes.
            URI maskId = unManagedMask.getId();
            masksToUpdateForVolumes.put(maskId, hostExportInfo);
        } else {
            // we will create new unManaged mask for host/array.
            masksToCreateForVolumes.add(hostExportInfo);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) URI(java.net.URI) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap)

Aggregations

Initiator (com.emc.storageos.storagedriver.model.Initiator)23 ArrayList (java.util.ArrayList)15 StoragePort (com.emc.storageos.storagedriver.model.StoragePort)12 URI (java.net.URI)9 HashMap (java.util.HashMap)9 ExportMask (com.emc.storageos.db.client.model.ExportMask)7 HostExportInfo (com.emc.storageos.storagedriver.HostExportInfo)7 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)7 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)6 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)6 DriverTask (com.emc.storageos.storagedriver.DriverTask)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 List (java.util.List)6 StringSet (com.emc.storageos.db.client.model.StringSet)5 HashSet (java.util.HashSet)5 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)4 CommonStorageCapabilities (com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities)4 MutableBoolean (org.apache.commons.lang.mutable.MutableBoolean)4 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)3