use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructAddLUNQuery.
/**
* Constructs the addLun query using multiple path elements. Each path
* element defines the path from volume to initiators.
*
* @param systemId
* @param targetPortId
* @param domainId
* @param deviceLunList
* @param pathList
* @param model
* @return
* @throws Exception
*/
private String constructAddLUNQuery(String systemId, String targetPortId, String domainId, Map<String, String> deviceLunList, List<Path> pathList, String model) throws Exception {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.LUN_TARGET);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
if (null != deviceLunList && !deviceLunList.isEmpty()) {
for (String device : deviceLunList.keySet()) {
String lun = deviceLunList.get(device);
Path path = new Path(targetPortId, domainId, null, lun, device);
pathList.add(path);
log.info("Device :{} lun:{}", device, lun);
}
}
attributeMap.put(HDSConstants.PATH_LIST, pathList);
String addLunInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_PATH_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return addLunInputXML;
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSExportOperations method executeBatchHSDAddVolumesCommand.
/**
* This routine will take care of following items.
* 1. Prepares a batch of Path objects with volumes & HSD's to add.
* 2. Executes the batch operation.
*
* @param hdsApiClient
* @param systemId
* @param hsdsWithInitiators
* @param volumeURIHLUs
* @param model
* @return
* @throws Exception
*/
private List<Path> executeBatchHSDAddVolumesCommand(HDSApiClient hdsApiClient, String systemId, List<HostStorageDomain> hsdsWithInitiators, VolumeURIHLU[] volumeURIHLUs, String model) throws Exception {
if (null == hsdsWithInitiators || hsdsWithInitiators.isEmpty()) {
log.error("Batch HSD creation failed. Aborting operation...");
throw HDSException.exceptions.notAbleToAddHSD(systemId);
}
List<Path> pathList = new ArrayList<Path>();
for (HostStorageDomain hsd : hsdsWithInitiators) {
Map<String, String> volumeLunMap = getVolumeLunMap(systemId, hsd.getObjectID(), volumeURIHLUs, hdsApiClient.getHDSApiExportManager());
for (Map.Entry<String, String> entry : volumeLunMap.entrySet()) {
Path path = new Path(hsd.getPortID(), hsd.getDomainID(), null, entry.getValue(), entry.getKey());
pathList.add(path);
}
}
return hdsApiClient.getHDSBatchApiExportManager().addLUNPathsToHSDs(systemId, pathList, model);
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSExportOperations method getExportedVolumes.
/**
* Return the [volume-lun] map that exists on the HSD.
*
* @param pathList
* @return
*/
private Map<String, Integer> getExportedVolumes(List<Path> pathList, StorageSystem storage) {
Map<String, Integer> volumeLunMap = new HashMap<String, Integer>();
if (null != pathList && !pathList.isEmpty()) {
for (Path path : pathList) {
String volumeWWN = HDSUtils.generateHitachiVolumeWWN(storage, path.getDevNum());
volumeLunMap.put(volumeWWN, Integer.valueOf(path.getLun()));
}
}
return volumeLunMap;
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSExportOperations method createExportMask.
/**
* Creates a ExportMask with the given initiators & volumes.
*
* Below are the steps to follow to create an Export Mask on Hitachi array.
* Step 1: Register host with initiators.
* Step 2: Based on the targetport type, create a Host Storage Domain.
* Step 3: Add WWN/ISCSI names to the Host Storage Domain.
* Step 4: Add Luns to the HostStorageDomain created in step 2.
*/
@Override
public void createExportMask(StorageSystem storage, URI exportMaskId, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} createExportMask START...", storage.getSerialNumber());
HDSApiClient hdsApiClient = null;
String systemObjectID = null;
ExportMask exportMask = null;
List<HostStorageDomain> hsdsWithInitiators = null;
List<HostStorageDomain> hsdsToCreate = null;
try {
log.info("createExportMask: Export mask id :{}", exportMaskId);
log.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
log.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
log.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
systemObjectID = HDSUtils.getSystemObjectID(storage);
exportMask = dbClient.queryObject(ExportMask.class, exportMaskId);
// Check whether host is already registered or not. If host is not
// registered, add the host.
registerHostsWithInitiators(initiatorList, hdsApiClient);
List<StoragePort> storagePorts = dbClient.queryObject(StoragePort.class, targetURIList, true);
if (checkIfMixedTargetPortTypeSelected(storagePorts)) {
log.error("Unsupported Host as it has both FC & iSCSI Initiators");
throw HDSException.exceptions.unsupportedConfigurationFoundInHost();
}
if (null != targetURIList && !targetURIList.isEmpty()) {
String hostName = getHostNameForInitiators(initiatorList);
String hostMode = null, hostModeOption = null;
Pair<String, String> hostModeInfo = getHostModeInfo(storage, initiatorList);
if (hostModeInfo != null) {
hostMode = hostModeInfo.first;
hostModeOption = hostModeInfo.second;
}
hsdsToCreate = processTargetPortsToFormHSDs(hdsApiClient, storage, targetURIList, 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. Aborting operation...");
throw HDSException.exceptions.notAbleToAddHSD(storage.getSerialNumber());
}
// Step 2: Add initiators to all HSD's.
hsdsWithInitiators = executeBatchHSDAddInitiatorsCommand(hdsApiClient, systemObjectID, hsdResponseList, storagePorts, initiatorList, 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);
}
}
taskCompleter.ready(dbClient);
} catch (Exception ex) {
// initiators/volumes.
try {
log.info("Exception occurred while processing exportmask due to: {}", 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("createExportMask failed - maskName: %s", exportMaskId.toString()), ex);
} catch (Exception ex1) {
log.error("Exception occurred while deleting unsuccessful HSDs on system: {}", systemObjectID, ex1.getMessage());
} finally {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
taskCompleter.error(dbClient, serviceError);
}
}
log.info("{} createExportMask END...", storage.getSerialNumber());
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSExportOperations method getPathObjectIdsFromHsd.
/**
* Get the LUN Path objectId list from HSD.
* Since we are getting volume URI, we should query to get its nativeId.
*
* @param hsd
* @param volumes
* @return
*/
private List<Path> getPathObjectIdsFromHsd(HostStorageDomain hsd, List<URI> volumes) {
List<Path> pathObjectIdList = new ArrayList<Path>();
if (null != hsd.getPathList()) {
for (URI volumeURI : volumes) {
BlockObject volume = BlockObject.fetch(dbClient, volumeURI);
for (Path path : hsd.getPathList()) {
log.info("verifying existence of volume {} on HSD to remove", volume.getNativeId());
if (volume.getNativeId().equals(path.getDevNum())) {
log.debug("Found volume {} on HSD {}", volume.getNativeId(), hsd.getObjectID());
pathObjectIdList.add(path);
}
}
}
}
return pathObjectIdList;
}
Aggregations