Search in sources :

Example 76 with StoragePort

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

the class ExportUtils method getZonedPorts.

/**
 * Return the ports that were zoned to an initiator according to the zoningMap.
 *
 * @param initiator - Initiator
 * @param ports - List of ports in the ExportMask
 * @param zoningMap - zoningMap in the ExportMask
 * @return
 */
private static List<StoragePort> getZonedPorts(Initiator initiator, List<StoragePort> ports, StringSetMap zoningMap) {
    List<StoragePort> zonedPorts = new ArrayList<StoragePort>();
    if (zoningMap == null || zoningMap.isEmpty()) {
        return zonedPorts;
    }
    StringSet portSet = zoningMap.get(initiator.getId().toString());
    if (portSet != null) {
        for (StoragePort port : ports) {
            if (portSet.contains(port.getId().toString())) {
                zonedPorts.add(port);
            }
        }
    }
    return zonedPorts;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 77 with StoragePort

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

the class VirtualArrayService method getVirtualArrayStoragePorts.

/**
 * Returns the storage ports for the VirtualArray with the passed id. When
 * the VirtualArray has been explicitly assigned to one or more storage
 * ports, this API will return the ids of those storage ports. VirtualArrays
 * can be explicitly assigned to storage ports when a storage port is
 * created or later by modifying the storage port after it has been created.
 * <p>
 * Whether or not a VirtualArray has been explicitly assigned to any storage ports the VirtualArray may still have implicit associations
 * with one or more storage port due to the VirtualArray's network connectivity. That is, a network resides in a VirtualArray and may
 * contain storage ports. This implies that these storage ports reside in the VirtualArray. If the VirtualArray has no explicit storage
 * port assignments, but does have implicit associations, the API will instead return those storage ports implicitly associated.
 * <p>
 * The API provides the ability to force the return of the list of storage ports implicitly associated with the VirtualArray using the
 * request parameter "network_connectivity". Passing this parameter with a value of "true" will return the ids of the storage ports
 * implicitly associated with the VirtualArray as described.
 *
 * @param id the URN of a ViPR VirtualArray.
 * @param useNetworkConnectivity true to use the network connectivity to
 *            get the list of storage ports implicitly connected to the
 *            VirtualArray.
 *
 * @brief List VirtualArray storage ports
 * @return The ids of the storage ports associated with the VirtualArray.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public StoragePortList getVirtualArrayStoragePorts(@PathParam("id") URI id, @QueryParam("network_connectivity") boolean useNetworkConnectivity) {
    // Get and validate the varray with the passed id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntity(varray, id, isIdEmbeddedInURL(id));
    // Query the database for the storage ports associated with the
    // VirtualArray. If the request is for storage ports whose
    // association with the VirtualArray is implicit through network
    // connectivity, then return only these storage ports. Otherwise,
    // the result is for storage ports explicitly assigned to the
    // VirtualArray.
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    if (useNetworkConnectivity) {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getImplicitVirtualArrayStoragePortsConstraint(id.toString()), storagePortURIs);
    } else {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(id.toString()), storagePortURIs);
    }
    // Create and return the result.
    StoragePortList storagePorts = new StoragePortList();
    for (URI uri : storagePortURIs) {
        StoragePort storagePort = _dbClient.queryObject(StoragePort.class, uri);
        if ((storagePort != null) && (RegistrationStatus.REGISTERED.toString().equals(storagePort.getRegistrationStatus())) && DiscoveryStatus.VISIBLE.toString().equals(storagePort.getDiscoveryStatus())) {
            storagePorts.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
        }
    }
    return storagePorts;
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePort(com.emc.storageos.db.client.model.StoragePort) StoragePortList(com.emc.storageos.model.ports.StoragePortList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 78 with StoragePort

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

the class FrontEndPortStatsProcessor method setPortRelatedInfo.

/**
 * Return the port nativeGuid based on the Stat objects wwn.
 *
 * @param storagePortStatInstance
 * @param systemId
 * @param dbClient
 * @return
 */
private void setPortRelatedInfo(CIMInstance storagePortStatInstance, URI systemId, DbClient dbClient, Stat fePortStat) {
    String instanceId = getCIMPropertyValue(storagePortStatInstance, INSTANCE_ID);
    Iterable<String> splitter = Splitter.on(HDSConstants.DOT_OPERATOR).limit(3).split(instanceId);
    String portWWN = Iterables.getLast(splitter);
    URIQueryResultList storagePortURIList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(SanUtils.normalizeWWN(portWWN).toUpperCase()), storagePortURIList);
    Iterator<URI> itr = storagePortURIList.iterator();
    while (itr.hasNext()) {
        StoragePort port = dbClient.queryObject(StoragePort.class, itr.next());
        if (port.getStorageDevice().equals(systemId)) {
            fePortStat.setNativeGuid(port.getNativeGuid());
            fePortStat.setResourceId(port.getId());
            portMetricsProcessor.processFEPortMetrics(fePortStat.getKbytesTransferred(), fePortStat.getTotalIOs(), port, fePortStat.getTimeInMillis());
            break;
        }
    }
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 79 with StoragePort

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

the class HDSExportOperations method checkIfMixedTargetPortTypeSelected.

/**
 * @param portURIList
 * @return
 */
private boolean checkIfMixedTargetPortTypeSelected(List<StoragePort> ports) {
    boolean isFC = false;
    boolean isIP = false;
    for (StoragePort port : ports) {
        if (port.getPortType().equalsIgnoreCase(Transport.FC.name())) {
            isFC = true;
        } else if (port.getPortType().equalsIgnoreCase(Transport.IP.name())) {
            isIP = true;
        }
        if (isFC && isIP) {
            return true;
        }
    }
    return false;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort)

Example 80 with StoragePort

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

the class HDSExportOperations method addInitiators.

@Override
public void addInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIs, List<Initiator> initiators, List<URI> targetURIList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} addInitiator START...", storage.getSerialNumber());
    HDSApiClient hdsApiClient = null;
    String systemObjectID = null;
    List<HostStorageDomain> hsdsToCreate = null;
    List<HostStorageDomain> hsdsWithInitiators = null;
    try {
        log.info("addInitiator: Export mask id: {}", exportMaskURI);
        if (volumeURIs != null) {
            log.info("addInitiator: volumes : {}", Joiner.on(',').join(volumeURIs));
        }
        log.info("addInitiator: initiators : {}", Joiner.on(',').join(initiators));
        log.info("addInitiator: targets : {}", Joiner.on(",").join(targetURIList));
        hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
        systemObjectID = HDSUtils.getSystemObjectID(storage);
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        List<StoragePort> ports = dbClient.queryObject(StoragePort.class, targetURIList, true);
        if (checkIfMixedTargetPortTypeSelected(ports)) {
            log.error("Unsupported Host as it has both FC & iSCSI Initiators");
            throw HDSException.exceptions.unsupportedConfigurationFoundInHost();
        }
        // @TODO register new initiators by adding them to host on HiCommand DM.
        // Currently, HiCommand is not supporting this. Need to see how we can handle.
        String hostName = getHostNameForInitiators(initiators);
        String hostMode = null, hostModeOption = null;
        Pair<String, String> hostModeInfo = getHostModeInfo(storage, initiators);
        if (hostModeInfo != null) {
            hostMode = hostModeInfo.first;
            hostModeOption = hostModeInfo.second;
        }
        if (targetURIList != null && !targetURIList.isEmpty()) {
            Set<URI> newTargetPorts = new HashSet<>(targetURIList);
            Set<URI> existingTargetPortsInMask = new HashSet<>();
            if (exportMask.getStoragePorts() != null) {
                existingTargetPortsInMask = new HashSet<>(targetURIList);
                Collection<URI> targetPorts = Collections2.transform(exportMask.getStoragePorts(), CommonTransformerFunctions.FCTN_STRING_TO_URI);
                existingTargetPortsInMask.retainAll(targetPorts);
            }
            newTargetPorts.removeAll(existingTargetPortsInMask);
            log.info("list of new storage target ports {}", newTargetPorts);
            log.info("list of existing storage target ports available in export masks {}", existingTargetPortsInMask);
            // Case 1 is handled here for the new initiators & new target ports.
            if (!newTargetPorts.isEmpty()) {
                // If the HLU's are already configured on this target port, then an exception is thrown.
                // User should make sure that all volumes should have same HLU across all target HSD's.
                VolumeURIHLU[] volumeURIHLUs = getVolumeURIHLUFromExportMask(exportMask);
                if (0 < volumeURIHLUs.length) {
                    List<URI> portList = new ArrayList<>(newTargetPorts);
                    hsdsToCreate = processTargetPortsToFormHSDs(hdsApiClient, storage, portList, hostName, exportMask, hostModeInfo, systemObjectID);
                    // Step 1: Create all HSD's using batch operation.
                    List<HostStorageDomain> hsdResponseList = hdsApiClient.getHDSBatchApiExportManager().addHostStorageDomains(systemObjectID, hsdsToCreate, storage.getModel());
                    if (null == hsdResponseList || hsdResponseList.isEmpty()) {
                        log.error("Batch HSD creation failed to add new initiators. Aborting operation...");
                        throw HDSException.exceptions.notAbleToAddHSD(storage.getSerialNumber());
                    }
                    // Step 2: Add initiators to all HSD's.
                    Iterator<StoragePort> storagePortIterator = dbClient.queryIterativeObjects(StoragePort.class, newTargetPorts);
                    List<StoragePort> stPortList = new ArrayList<>();
                    while (storagePortIterator.hasNext()) {
                        StoragePort stPort = storagePortIterator.next();
                        if (stPort != null && !stPort.getInactive()) {
                            stPortList.add(stPort);
                        }
                    }
                    hsdsWithInitiators = executeBatchHSDAddInitiatorsCommand(hdsApiClient, systemObjectID, hsdResponseList, stPortList, initiators, storage.getModel());
                    // Step 3: Add volumes to all HSD's.
                    List<Path> allHSDPaths = executeBatchHSDAddVolumesCommand(hdsApiClient, systemObjectID, hsdsWithInitiators, volumeURIHLUs, storage.getModel());
                    if (null != allHSDPaths && !allHSDPaths.isEmpty()) {
                        updateExportMaskDetailInDB(hsdsWithInitiators, allHSDPaths, exportMask, storage, volumeURIHLUs);
                    }
                } else {
                    log.info("There are no volumes on this exportmask: {} to add to new initiator", exportMaskURI);
                }
            }
            // existing HSD to access the volumes already exported in the exportmask.
            if (!existingTargetPortsInMask.isEmpty()) {
                // Step 1: Collect all HSDs from export mask
                StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
                if (null != deviceDataMap && !deviceDataMap.isEmpty()) {
                    List<HostStorageDomain> hsdResponseList = new ArrayList<>();
                    Set<String> hsdObjectIdSet = deviceDataMap.keySet();
                    for (String hsdObjectId : hsdObjectIdSet) {
                        HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectId);
                        if (null == hsd) {
                            throw HDSException.exceptions.notAbleToFindHostStorageDomain(hsdObjectId);
                        }
                        hsdResponseList.add(hsd);
                    }
                    // Step 2: Add initiators to all HSD's.
                    Iterator<StoragePort> storagePortIterator = dbClient.queryIterativeObjects(StoragePort.class, existingTargetPortsInMask, true);
                    List<StoragePort> stPortList = new ArrayList<>();
                    while (storagePortIterator.hasNext()) {
                        StoragePort stPort = storagePortIterator.next();
                        if (stPort != null) {
                            stPortList.add(stPort);
                        }
                    }
                    hsdsWithInitiators = executeBatchHSDAddInitiatorsCommand(hdsApiClient, systemObjectID, hsdResponseList, stPortList, initiators, storage.getModel());
                } else {
                    log.info("There are no hsd information in exportMask to add initiators");
                }
            }
        }
        taskCompleter.ready(dbClient);
    } catch (Exception ex) {
        try {
            log.info("Exception occurred while adding new initiators: {}", ex.getMessage());
            if (null != hsdsWithInitiators && !hsdsWithInitiators.isEmpty()) {
                hdsApiClient.getHDSBatchApiExportManager().deleteBatchHostStorageDomains(systemObjectID, hsdsWithInitiators, storage.getModel());
            } else {
                if (null != hsdsToCreate && !hsdsToCreate.isEmpty()) {
                    List<HostStorageDomain> allHSDs = hdsApiClient.getHDSApiExportManager().getHostStorageDomains(systemObjectID);
                    List<HostStorageDomain> partialHSDListToRemove = getPartialHSDListToDelete(allHSDs, hsdsToCreate);
                    hdsApiClient.getHDSBatchApiExportManager().deleteBatchHostStorageDomains(systemObjectID, partialHSDListToRemove, storage.getModel());
                }
            }
            log.error(String.format("addInitiator failed - maskURI: %s", exportMaskURI.toString()), ex);
        } catch (Exception ex1) {
            log.error("Exception occurred while deleting unsuccessful HSDs on system: {}", systemObjectID, ex1.getMessage());
        } finally {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedOpMsg(ResourceOperationTypeEnum.ADD_EXPORT_INITIATOR.getName(), ex.getMessage());
            taskCompleter.error(dbClient, serviceError);
        }
    }
    log.info("{} addInitiator END...", storage.getSerialNumber());
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet) Path(com.emc.storageos.hds.model.Path) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

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