use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructISCSIQuery.
/**
* 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 constructISCSIQuery(String systemId, String hsdId, List<String> scsiNameList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.ISCSI_NAME_FOR_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<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 addISCSINamesToHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_ISCSI_NAME_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return addISCSINamesToHSDQuery;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method constructAddLUSEQuery.
private String constructAddLUSEQuery(String systemId, String metaHead, List<String> ldevIds) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
List<LDEV> ldevsList = new LinkedList<LDEV>();
StorageArray storageArray = new StorageArray(systemId);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
Add addOp = new Add(HDSConstants.LUSE_TARGET, true);
attributeMap.put(HDSConstants.ADD, addOp);
if (null != ldevIds && !ldevIds.isEmpty()) {
LDEV metaHeadLDEV = new LDEV(metaHead);
ldevsList.add(metaHeadLDEV);
for (String ldevId : ldevIds) {
LDEV metaMemberLDEV = new LDEV(ldevId);
ldevsList.add(metaMemberLDEV);
}
}
attributeMap.put("LDEV_List", ldevsList);
String addLUSEVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_LUSE_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return addLUSEVolumeInputXML;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method deleteThinLogicalUnits.
public String deleteThinLogicalUnits(String systemObjectID, Set<String> logicalUnitIdList, String model) throws Exception {
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectID);
Delete deleteOp = new Delete(HDSConstants.VIRTUALVOLUME, true);
List<LogicalUnit> luList = new ArrayList<LogicalUnit>();
for (String logicalUnitId : logicalUnitIdList) {
LogicalUnit logicalUnit = new LogicalUnit(logicalUnitId, null);
luList.add(logicalUnit);
}
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.LOGICALUNIT_LIST, luList);
String deleteVolumesInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("volume delete payload :{}", deleteVolumesInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteVolumesInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
EchoCommand command = result.getBean(EchoCommand.class);
log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
asyncTaskMessageId = command.getMessageID();
log.info("Async task id : {}", asyncTaskMessageId);
} else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = result.getBean(Error.class);
log.info("command failed error code: {}", error.getCode());
log.info("Command failed: messageID: {} {}", command.getMessageID(), error.getDescription());
throw HDSException.exceptions.notAbleToDeleteVolume(error.getCode(), error.getDescription());
}
} else {
log.error("LogicalUnit deletion failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("LogicalUnit creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method modifyThinVolumeTieringPolicy.
public String modifyThinVolumeTieringPolicy(String systemObjectID, String luObjectID, String ldevObjectID, String tieringPolicyName, String model) {
InputStream responseStream = null;
String asyncTaskMessageId = null;
Map<String, Object> attributeMap = new HashMap<String, Object>();
Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME);
StorageArray array = new StorageArray(systemObjectID);
LogicalUnit logicalUnit = new LogicalUnit();
logicalUnit.setObjectID(luObjectID);
LDEV ldev = new LDEV(ldevObjectID);
ldev.setTierLevel(Integer.parseInt(tieringPolicyName));
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
attributeMap.put(HDSConstants.LDEV, ldev);
String modifyThinVolumeTieringPolicyPayload = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
log.info("Modify Volume TieringPolicy payload:{}", modifyThinVolumeTieringPolicyPayload);
ClientResponse response = hdsApiClient.post(endpointURI, modifyThinVolumeTieringPolicyPayload);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
EchoCommand command = result.getBean(EchoCommand.class);
log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
asyncTaskMessageId = command.getMessageID();
} else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = result.getBean(Error.class);
log.error("Modify Volume TieringPolicy failed status messageID: {}", command.getMessageID());
log.error("Modify Volume TieringPolicy failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("Modify Volume TieringPolicy failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Modify Volume TieringPolicy failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method releaseLUSE.
/**
* This client method is responsible to release all the volumes in LUSE volume.
*
* @param systemObjectId
* @param logicalUnitId
* @return
* @throws Exception
*/
public LogicalUnit releaseLUSE(String systemObjectId, String logicalUnitId) throws Exception {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectId);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
Add addOp = new Add(HDSConstants.LUSE_TARGET);
attributeMap.put(HDSConstants.GET, addOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnitId);
String releaseLUSEVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.RELEASE_LUSE_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
InputStream responseStream = null;
LogicalUnit logicalUnit = null;
try {
log.info("release LUSE Query payload :{}", releaseLUSEVolumeInputXML);
ClientResponse response = hdsApiClient.post(endpointURI, releaseLUSEVolumeInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
logicalUnit = (LogicalUnit) result.getBean(HDSConstants.LOGICALUNIT_BEAN_NAME);
} else {
log.error("deleteLUSE failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete LUSE due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return logicalUnit;
}
Aggregations