use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSExportOperations method addVolumes.
@Override
public void addVolumes(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} addVolumes START...", storage.getSerialNumber());
HDSApiClient hdsApiClient = null;
String systemObjectID = null;
try {
log.info("addVolumes: Export mask id: {}", exportMaskURI);
log.info("addVolumes: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
if (initiatorList != null) {
log.info("addVolumes: initiators impacted: {}", Joiner.on(',').join(initiatorList));
}
hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
systemObjectID = HDSUtils.getSystemObjectID(storage);
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
Set<String> hsdList = deviceDataMap.keySet();
if (null == hsdList || hsdList.isEmpty()) {
throw HDSException.exceptions.notAbleToFindHostStorageDomain(systemObjectID);
}
if (null != exportMask && !exportMask.getInactive() && !hsdList.isEmpty()) {
List<Path> pathList = new ArrayList<Path>();
for (String hsdObjectID : hsdList) {
// Query the provider to see whether the HSD exists or not.
HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectID);
if (null != hsd) {
Map<String, String> volumeLunMap = getVolumeLunMap(systemObjectID, hsd.getObjectID(), volumeURIHLUs, exportMgr);
for (Map.Entry<String, String> entry : volumeLunMap.entrySet()) {
if (!checkIfVolumeAlreadyExistsOnHSD(entry.getKey(), hsd)) {
Path path = new Path(hsd.getPortID(), hsd.getDomainID(), null, entry.getValue(), entry.getKey());
pathList.add(path);
}
}
}
}
if (!pathList.isEmpty()) {
List<Path> pathResponseList = hdsApiClient.getHDSBatchApiExportManager().addLUNPathsToHSDs(systemObjectID, pathList, storage.getModel());
if (null != pathResponseList && !pathResponseList.isEmpty()) {
// update volume-lun relationship to exportmask.
updateVolumeHLUInfo(volumeURIHLUs, pathResponseList, exportMask);
dbClient.updateObject(exportMask);
} else {
log.error(String.format("addVolumes failed - maskURI: %s", exportMaskURI.toString()), new Exception("Not able to parse the response of addLUN from server"));
ServiceError serviceError = DeviceControllerException.errors.jobFailedOpMsg(ResourceOperationTypeEnum.ADD_EXPORT_VOLUME.getName(), "Not able to parse the response of addLUN from server");
taskCompleter.error(dbClient, serviceError);
return;
}
} else {
log.info("All the volumes are already part of the HSDs.");
}
taskCompleter.ready(dbClient);
}
} catch (Exception e) {
log.error(String.format("addVolumes failed - maskURI: %s", exportMaskURI.toString()), e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(dbClient, serviceError);
}
log.info("{} addVolumes END...", storage.getSerialNumber());
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructDeleteLunPathsQuery.
/**
* Construct the WWN Query by adding multiple WWNs.
* This query should be used to add FC initiators to the FC HSD.
*
* @param systemId
* @param hsdId
* @param lunPathObjectIdList
* @return
*/
private String constructDeleteLunPathsQuery(String systemId, List<String> lunPathObjectIdList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
List<Path> pathList = new ArrayList<Path>();
StorageArray array = new StorageArray(systemId);
Delete deleteOp = new Delete(HDSConstants.LUN_TARGET);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.DELETE, deleteOp);
if (null != lunPathObjectIdList && !lunPathObjectIdList.isEmpty()) {
for (String pathObjectId : lunPathObjectIdList) {
Path path = new Path(pathObjectId);
pathList.add(path);
}
}
attributeMap.put(HDSConstants.PATH_LIST, pathList);
String deleteLunInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_PATH_FROM_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return deleteLunInputXML;
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSBatchApiExportManager method addLUNPathsToHSDs.
/**
* This method makes a HTTP POST call to add multiple LUN Paths using a
* batch query.
*
* @param systemId
* - Represents the storage system objectID.
* @param pathList
* - List of Path objects.
* @param model - model of the system
* @return - List of Path objects after successful creation.
* @throws Exception
* - Incase of processing Error.
*/
public List<Path> addLUNPathsToHSDs(String systemId, List<Path> pathList, String model) throws Exception {
InputStream responseStream = null;
List<Path> pathResponseList = null;
try {
String addLUNQuery = constructAddLUNQuery(systemId, pathList, model);
log.info("Query to addLUN Query: {}", addLUNQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addLUNQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
pathResponseList = (List<Path>) javaResult.getBean(HDSConstants.PATHLIST_RESPONSE_BEANID);
if (null == pathResponseList || pathResponseList.isEmpty()) {
throw HDSException.exceptions.notAbleToAddVolumeToHSD(null, systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add Volume to 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 pathResponseList;
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method getDummyHSDPathId.
/**
* Get Dummy Lun Path's path objectID
*
* @param storageSystem
* @param volume
* @return
* @throws Exception
*/
private String getDummyHSDPathId(StorageSystem storageSystem, BlockObject blockObj) throws Exception {
String dummyLunPathId = null;
HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
List<HostStorageDomain> hsdList = apiExportManager.getHostStorageDomains(systemObjectId);
if (hsdList != null) {
for (HostStorageDomain hsd : hsdList) {
if (hsd != null && HDSConstants.DUMMY_HSD.equalsIgnoreCase(hsd.getNickname())) {
if (hsd.getPathList() != null) {
for (Path path : hsd.getPathList()) {
if (path.getDevNum().equalsIgnoreCase(blockObj.getNativeId())) {
dummyLunPathId = path.getObjectID();
log.info("Found secondary volume's dummy lun path id :{}", dummyLunPathId);
return dummyLunPathId;
}
}
}
}
}
}
log.info("Dummy lun path has been removed already for this secondary volume");
return dummyLunPathId;
}
use of com.emc.storageos.hds.model.Path in project coprhd-controller by CoprHD.
the class HDSUtils method getVolumesFromHSD.
/**
* Return a map[deviceId] => lun from the give HostStorageDomain.
*
* @param hsd
* @return
*/
public static Map<String, Integer> getVolumesFromHSD(HostStorageDomain hsd, StorageSystem storage) {
Map<String, Integer> volumesFromHSD = new HashMap<String, Integer>();
List<Path> pathList = hsd.getPathList();
if (null != pathList) {
for (Path path : pathList) {
String volumeWWN = generateHitachiVolumeWWN(storage, path.getDevNum());
volumesFromHSD.put(volumeWWN, Integer.valueOf(path.getLun()));
}
}
return volumesFromHSD;
}
Aggregations