use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSExportOperations method getPartialHSDListToDelete.
/**
* Returns a list of HostStorageDomain objects created partially from a
* batch operation.
*
* @param allHSDs
* @param hsdsToCreate
* @return
*/
private List<HostStorageDomain> getPartialHSDListToDelete(List<HostStorageDomain> allHSDs, List<HostStorageDomain> hsdsToCreate) {
Collection<String> hsdNickNamesList = Collections2.transform(hsdsToCreate, HDSUtils.fctnHSDToNickName());
List<HostStorageDomain> partialHSDsCreated = new ArrayList<HostStorageDomain>();
if (null != allHSDs && !allHSDs.isEmpty()) {
for (HostStorageDomain hsd : allHSDs) {
if (hsdNickNamesList.contains(hsd.getNickname())) {
partialHSDsCreated.add(hsd);
}
}
}
return partialHSDsCreated;
}
use of com.emc.storageos.hds.model.HostStorageDomain 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.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSExportOperations method updateExportMaskDetailInDB.
/**
* Updates ExportMask details like volumes, HSD's & target port details in DB.
*
* @param hsdsWithInitiators
* : HSD's create successfully.
* @param allHSDPaths
* : Volume LunPaths added successfully.
* @param exportMask
* : ExportMask db object.
* @param storage
* : StorageSystem db object.
* @param volumeURIHLUs
* : volume-lun details.
*/
private void updateExportMaskDetailInDB(List<HostStorageDomain> hsdsWithInitiators, List<Path> allHSDPaths, ExportMask exportMask, StorageSystem storage, VolumeURIHLU[] volumeURIHLUs) {
StringSetMap deviceDataMap = new StringSetMap();
for (HostStorageDomain hsd : hsdsWithInitiators) {
StringSet targetPortSet = new StringSet();
List<String> hsdPorts = Arrays.asList(hsd.getPortID());
List<String> targetPortURIs = getStoragePortURIs(hsdPorts, storage);
targetPortSet.addAll(targetPortURIs);
deviceDataMap.put(hsd.getObjectID(), targetPortSet);
}
exportMask.addDeviceDataMap(deviceDataMap);
updateVolumeHLUInfo(volumeURIHLUs, allHSDPaths, exportMask);
dbClient.updateObject(exportMask);
log.info("ExportMask: {} details updated successfully.", exportMask.getId());
}
use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSApiExportManager method getHostStorageDomain.
/**
* Return the existing HSD's configured on the storage array.
*
* @param systemId
* @param type
* @return
* @throws Exception
*/
public HostStorageDomain getHostStorageDomain(String systemId, String hsdId) throws Exception {
InputStream responseStream = null;
HostStorageDomain hsd = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
Get getOp = new Get(HDSConstants.STORAGEARRAY);
attributeMap.put(HDSConstants.GET, getOp);
HostStorageDomain inputHsd = new HostStorageDomain(hsdId);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
String getHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_HSD_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to get HostStorageDomain: {}", getHSDQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, getHSDQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsd = javaResult.getBean(HostStorageDomain.class);
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query HostStorageDomain due to invalid response %1$s from server", response.getStatus()));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return hsd;
}
use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSApiExportManager method deleteHostStorageDomain.
/**
* Delete the Host Storage Domain for a given storage array.
*
* @param systemObjectId
* @param hsdObjectId
* @param model
* @throws Exception
*/
public void deleteHostStorageDomain(String systemObjectId, String hsdObjectId, String model) throws Exception {
InputStream responseStream = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemObjectId);
Delete deleteOp = new Delete(HDSConstants.HOST_STORAGE_DOMAIN);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.MODEL, model);
HostStorageDomain inputHsd = new HostStorageDomain(hsdObjectId);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
String deleteHSDFromSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_HSD_FROM_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to delete HostStorageDomain: {}", deleteHSDFromSystemQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteHSDFromSystemQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
log.info("Deleted HSD {} from system {}", hsdObjectId, systemObjectId);
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete HostStorageDomain due to invalid response %1$s from server", response.getStatus()));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
}
Aggregations