Search in sources :

Example 1 with ISCSIName

use of com.emc.storageos.hds.model.ISCSIName 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 ISCSIName

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

the class HDSExportOperations method getISCSIInitiatorsExistOnHSD.

/**
 * Return the list of ISCSINames to be removed from the HSD.
 *
 * @param hsd
 * @param allInitiatorsToRemove
 * @return
 */
private List<String> getISCSIInitiatorsExistOnHSD(HostStorageDomain hsd, List<Initiator> allInitiatorsToRemove) {
    List<ISCSIName> hsdISCSIList = hsd.getIscsiList();
    List<String> iSCSIInitiatorsToRemove = new ArrayList<String>();
    Collection<String> portNames = Collections2.transform(allInitiatorsToRemove, CommonTransformerFunctions.fctnInitiatorToPortName());
    if (null != hsdISCSIList && !hsdISCSIList.isEmpty()) {
        for (ISCSIName iSCSIName : hsdISCSIList) {
            if (portNames.contains(iSCSIName.getiSCSIName())) {
                iSCSIInitiatorsToRemove.add(iSCSIName.getiSCSIName());
            }
        }
    }
    return iSCSIInitiatorsToRemove;
}
Also used : ISCSIName(com.emc.storageos.hds.model.ISCSIName) ArrayList(java.util.ArrayList)

Example 3 with ISCSIName

use of com.emc.storageos.hds.model.ISCSIName 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 4 with ISCSIName

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

the class HDSApiExportManager method constructRemoveISCSIQuery.

/**
 * Construct the iSCSINames Query by adding multiple WWNs.
 * This query should be used to add the iSCSI initiators to the iSCSI HSD.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @return
 */
private String constructRemoveISCSIQuery(String systemId, String hsdId, List<String> scsiNameList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Delete deleteOp = new Delete(HDSConstants.ISCSI_NAME_FOR_HSD_TARGET);
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.DELETE, deleteOp);
    attributeMap.put(HDSConstants.MODEL, model);
    HostStorageDomain hsd = new HostStorageDomain(hsdId);
    attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
    List<ISCSIName> iSCSIObjList = new ArrayList<ISCSIName>();
    if (null != scsiNameList && !scsiNameList.isEmpty()) {
        for (String iScsiName : scsiNameList) {
            ISCSIName iSCSIName = new ISCSIName(iScsiName, null);
            iSCSIObjList.add(iSCSIName);
        }
    }
    attributeMap.put(HDSConstants.ISCSINAME_LIST, iSCSIObjList);
    String removeISCSINamesToHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.REMOVE_ISCSI_NAME_FROM_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return removeISCSINamesToHSDQuery;
}
Also used : Delete(com.emc.storageos.hds.model.Delete) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ISCSIName(com.emc.storageos.hds.model.ISCSIName) ArrayList(java.util.ArrayList) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 5 with ISCSIName

use of com.emc.storageos.hds.model.ISCSIName 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)

Aggregations

ISCSIName (com.emc.storageos.hds.model.ISCSIName)7 ArrayList (java.util.ArrayList)7 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)3 WorldWideName (com.emc.storageos.hds.model.WorldWideName)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