use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructDeleteWWNQuery.
/**
* 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 wwnList
* @return
*/
private String constructDeleteWWNQuery(String systemId, String hsdId, List<String> wwnList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Delete deleteOp = new Delete(HDSConstants.ADD_WWN_TO_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<WorldWideName> wwnObjList = new ArrayList<WorldWideName>();
if (null != wwnList && !wwnList.isEmpty()) {
for (String initiatorWWN : wwnList) {
WorldWideName wwn = new WorldWideName(initiatorWWN);
wwnObjList.add(wwn);
}
}
attributeMap.put(HDSConstants.WWN_LIST, wwnObjList);
String deleteWWNFromHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_WWN_FROM_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return deleteWWNFromHSDQuery;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructWWNQuery.
/**
* 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 wwnList
* @return
*/
private String constructWWNQuery(String systemId, String hsdId, List<String> wwnList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.ADD_WWN_TO_HSD_TARGET);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
HostStorageDomain hsd = new HostStorageDomain(hsdId);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
List<WorldWideName> wwnObjList = new ArrayList<WorldWideName>();
if (null != wwnList && !wwnList.isEmpty()) {
for (String initiatorWWN : wwnList) {
WorldWideName wwn = new WorldWideName(initiatorWWN);
wwnObjList.add(wwn);
}
}
attributeMap.put(HDSConstants.WWN_LIST, wwnObjList);
String addWWNQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_WWN_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return addWWNQuery;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiExportManager method getHostStorageDomains.
/**
* Return the existing HSD's configured on the storage array.
*
* @param systemId
* @param type
* @return
* @throws Exception
*/
public List<HostStorageDomain> getHostStorageDomains(String systemId) throws Exception {
InputStream responseStream = null;
StorageArray storageArray = null;
List<HostStorageDomain> hsdList = 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 hsd = new HostStorageDomain();
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
String getAllHSDQuery = 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: {}", getAllHSDQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, getAllHSDQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
storageArray = javaResult.getBean(StorageArray.class);
if (null != storageArray) {
hsdList = storageArray.getHsdList();
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query HostStorageDomain's 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 hsdList;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiExportManager method addHostStorageDomain.
/**
* Add new HostStorageDomain.
*
* @param systemId
* @param targetPortID
* @param hsdNickName
* @param hostMode.
* @param hostModeOption
* @param model
* @return
* @throws Exception
*/
public HostStorageDomain addHostStorageDomain(String systemId, String targetPortID, String domainType, String hsdName, String hsdNickName, String hostMode, String hostModeOption, String model) throws Exception {
InputStream responseStream = null;
HostStorageDomain hsd = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.HOST_STORAGE_DOMAIN);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
HostStorageDomain inputHsd = new HostStorageDomain(targetPortID, hsdName, domainType, hsdNickName);
inputHsd.setHostMode(hostMode);
inputHsd.setHostModeOption(hostModeOption);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
String addHSDToSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_HSD_TO_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to create HostStorageDomain: {}", addHSDToSystemQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addHSDToSystemQuery);
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);
if (null == hsd) {
throw HDSException.exceptions.notAbleToAddHSD(systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add 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.StorageArray 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;
}
Aggregations