Search in sources :

Example 1 with WorldWideName

use of com.emc.storageos.hds.model.WorldWideName in project coprhd-controller by CoprHD.

the class HDSExportOperations method executeBatchHSDAddInitiatorsCommand.

/**
 * This routine will take care of following items.
 * 1. Prepares a batch of HostStorageDomain objects with initiators to add.
 * 2. Executes the batch operation.
 *
 * @param hdsApiClient
 * @param systemObjectID
 * @param createHsdsResponseList
 * @param storagePorts
 * @param initiators
 * @return
 * @throws Exception
 */
private List<HostStorageDomain> executeBatchHSDAddInitiatorsCommand(HDSApiClient hdsApiClient, String systemObjectID, List<HostStorageDomain> createHsdsResponseList, List<StoragePort> storagePorts, List<Initiator> initiators, String model) throws Exception {
    List<HostStorageDomain> fcHsdsToAddInitiators = new ArrayList<HostStorageDomain>();
    List<HostStorageDomain> iSCSIHsdsToAddInitiators = new ArrayList<HostStorageDomain>();
    List<HostStorageDomain> hsdsWithAddIniResponseList = new ArrayList<HostStorageDomain>();
    // Considers the IVR Networks as well.
    Map<URI, Set<String>> networkInitiatorsMap = NetworkUtil.getNetworkToInitiators(dbClient, initiators);
    Map<HostStorageDomain, URI> networkToHsdObjectIdMap = getHostGroupNetworkIdMap(storagePorts, createHsdsResponseList, dbClient);
    log.info("networkInitiatorsMap: {}", networkInitiatorsMap);
    log.info("networkToHsdObjectIdMap :{}", networkToHsdObjectIdMap);
    // Step 2: Add initiators to all HSD's using batch operation
    for (Entry<HostStorageDomain, URI> hsdNetworkEntry : networkToHsdObjectIdMap.entrySet()) {
        HostStorageDomain hsd = hsdNetworkEntry.getKey();
        log.info("Processing hsd: {}", hsd.getObjectID());
        HostStorageDomain hsdToAddInitiators = new HostStorageDomain(hsdNetworkEntry.getKey());
        Set<String> initiatorsOnSameNetwork = networkInitiatorsMap.get(hsdNetworkEntry.getValue());
        // Get the initiators part of the storagePort's Network
        List<String> formattedInitiators = getFormattedInitiators(initiatorsOnSameNetwork);
        if (hsd.getDomainType().equalsIgnoreCase(HDSConstants.HOST_GROUP_DOMAIN_TYPE)) {
            List<WorldWideName> wwnList = new ArrayList<WorldWideName>(Collections2.transform(formattedInitiators, HDSUtils.fctnPortWWNToWorldWideName()));
            hsdToAddInitiators.setWwnList(wwnList);
            fcHsdsToAddInitiators.add(hsdToAddInitiators);
        }
        if (hsd.getDomainType().equalsIgnoreCase(HDSConstants.ISCSI_TARGET_DOMAIN_TYPE)) {
            List<ISCSIName> iscsiNameList = new ArrayList<ISCSIName>(Collections2.transform(formattedInitiators, HDSUtils.fctnPortNameToISCSIName()));
            hsdToAddInitiators.setIscsiList(iscsiNameList);
            iSCSIHsdsToAddInitiators.add(hsdToAddInitiators);
        }
    }
    if (!fcHsdsToAddInitiators.isEmpty()) {
        hsdsWithAddIniResponseList.addAll(hdsApiClient.getHDSBatchApiExportManager().addWWNsToHostStorageDomain(systemObjectID, fcHsdsToAddInitiators, model));
    }
    if (!iSCSIHsdsToAddInitiators.isEmpty()) {
        hsdsWithAddIniResponseList.addAll(hdsApiClient.getHDSBatchApiExportManager().addISCSINamesToHostStorageDomain(systemObjectID, iSCSIHsdsToAddInitiators, model));
    }
    if (null == hsdsWithAddIniResponseList || hsdsWithAddIniResponseList.isEmpty()) {
        log.error("Batch add initiators to HSD creation failed. Aborting operation...");
        throw HDSException.exceptions.notAbleToAddInitiatorsToHostStorageDomain(systemObjectID);
    }
    return hsdsWithAddIniResponseList;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) ISCSIName(com.emc.storageos.hds.model.ISCSIName) URI(java.net.URI) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Example 2 with WorldWideName

use of com.emc.storageos.hds.model.WorldWideName in project coprhd-controller by CoprHD.

the class HDSUtils method getInitiatorsFromHSD.

/**
 * Return the initiators from HSD passed in.
 *
 * @param hsd
 * @return
 */
public static List<String> getInitiatorsFromHSD(HostStorageDomain hsd) {
    List<String> initiatorsList = new ArrayList<String>();
    if (null != hsd.getWwnList()) {
        for (WorldWideName wwn : hsd.getWwnList()) {
            String wwnName = wwn.getWwn();
            String normalizedPortWWN = wwnName.replace(HDSConstants.DOT_OPERATOR, "");
            initiatorsList.add(normalizedPortWWN);
        }
    }
    if (null != hsd.getIscsiList()) {
        for (ISCSIName iscsi : hsd.getIscsiList()) {
            initiatorsList.add(iscsi.getiSCSIName());
        }
    }
    return initiatorsList;
}
Also used : ArrayList(java.util.ArrayList) ISCSIName(com.emc.storageos.hds.model.ISCSIName) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Example 3 with WorldWideName

use of com.emc.storageos.hds.model.WorldWideName in project coprhd-controller by CoprHD.

the class HDSExportOperations method getFCInitiatorsExistOnHSD.

/**
 * Return the list of WWN's to be removed from the HSD.
 *
 * @param hsd
 * @param allInitiatorsToRemove
 * @return
 */
private List<String> getFCInitiatorsExistOnHSD(HostStorageDomain hsd, List<Initiator> allInitiatorsToRemove) {
    List<WorldWideName> hsdWWNList = hsd.getWwnList();
    List<String> fcInitiatorsToRemove = new ArrayList<String>();
    Collection<String> portNames = Collections2.transform(allInitiatorsToRemove, CommonTransformerFunctions.fctnInitiatorToPortName());
    if (null != hsdWWNList && !hsdWWNList.isEmpty()) {
        for (WorldWideName wwn : hsdWWNList) {
            if (portNames.contains(wwn.getWwn().replace(HDSConstants.DOT_OPERATOR, HDSConstants.EMPTY_STR).toUpperCase())) {
                fcInitiatorsToRemove.add(wwn.getWwn());
            }
        }
    }
    return fcInitiatorsToRemove;
}
Also used : ArrayList(java.util.ArrayList) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Example 4 with WorldWideName

use of com.emc.storageos.hds.model.WorldWideName in project coprhd-controller by CoprHD.

the class HDSExportOperations method getInitiatorsExistsOnHSD.

/**
 * Return the list of initiators that were exists on the HostStorageDomain.
 *
 * @param wwnList
 * @param scsiList
 * @return
 */
private List<String> getInitiatorsExistsOnHSD(List<WorldWideName> wwnList, List<ISCSIName> scsiList) {
    List<String> initiatorsExistsOnHSD = new ArrayList<String>();
    if (null != wwnList && !wwnList.isEmpty()) {
        for (WorldWideName wwn : wwnList) {
            String wwnWithOutDot = wwn.getWwn().replace(HDSConstants.DOT_OPERATOR, "");
            initiatorsExistsOnHSD.add(wwnWithOutDot);
        }
    }
    if (null != scsiList && !scsiList.isEmpty()) {
        for (ISCSIName scsiName : scsiList) {
            initiatorsExistsOnHSD.add(scsiName.getiSCSIName());
        }
    }
    return initiatorsExistsOnHSD;
}
Also used : ArrayList(java.util.ArrayList) ISCSIName(com.emc.storageos.hds.model.ISCSIName) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Example 5 with WorldWideName

use of com.emc.storageos.hds.model.WorldWideName in project coprhd-controller by CoprHD.

the class HDSApiExportManager method constructAddFCInitiatorHostQuery.

/**
 * Constructs the addHostQuery.
 *
 * @param hostName
 * @param ipAddress
 * @param portWWNList
 * @return
 */
private String constructAddFCInitiatorHostQuery(HDSHost hdshost, List<String> portWWNList) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<WorldWideName> wwnList = new ArrayList<WorldWideName>();
    Add addOp = new Add(HDSConstants.HOST);
    attributeMap.put(HDSConstants.HOST, hdshost);
    attributeMap.put(HDSConstants.ADD, addOp);
    if (null != portWWNList && !portWWNList.isEmpty()) {
        for (String portWWN : portWWNList) {
            WorldWideName wwn = new WorldWideName(portWWN);
            wwnList.add(wwn);
        }
        hdshost.setWwnList(wwnList);
    }
    attributeMap.put(HDSConstants.WWN_LIST, wwnList);
    String addHostWithWorldWideNamesQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_HOST_WITH_WWN_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addHostWithWorldWideNamesQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Aggregations

WorldWideName (com.emc.storageos.hds.model.WorldWideName)7 ArrayList (java.util.ArrayList)7 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)3 ISCSIName (com.emc.storageos.hds.model.ISCSIName)3 HashMap (java.util.HashMap)3 Add (com.emc.storageos.hds.model.Add)2 StorageArray (com.emc.storageos.hds.model.StorageArray)2 StringSet (com.emc.storageos.db.client.model.StringSet)1 Delete (com.emc.storageos.hds.model.Delete)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1