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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations