use of com.emc.storageos.hds.model.Delete in project coprhd-controller by CoprHD.
the class HDSBatchApiExportManager method deleteBatchHostStorageDomains.
/**
* This method makes a HTTP POST call to delete all HostStorageDomain's
* using a batch query.
*
* @param systemId
* - Represents storage system ObjectID.
* @param hsdList
* - List of HostStorageDomain objects to delete.
* @param model - Model of the system
*
* @throws Exception
*/
public void deleteBatchHostStorageDomains(String systemId, List<HostStorageDomain> hsdList, String model) throws Exception {
InputStream responseStream = null;
try {
List<HostStorageDomain> unDeletedHSDs = new ArrayList<>();
unDeletedHSDs.addAll(hsdList);
boolean operationSucceeds = false;
int retryCount = 0;
StringBuilder errorDescriptionBuilder = new StringBuilder();
while (!operationSucceeds && retryCount < MAX_RETRIES) {
retryCount++;
String deleteHSDsQuery = constructDeleteHSDsQuery(systemId, unDeletedHSDs, model);
log.info("Batch Query to delete HSD's: {}", deleteHSDsQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteHSDsQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
try {
verifyErrorPayload(javaResult);
// If no exception then operation succeeds
operationSucceeds = true;
} catch (HDSException hdsException) {
Error error = javaResult.getBean(Error.class);
if (error != null && (error.getDescription().contains("2010") || error.getDescription().contains("5132") || error.getDescription().contains("7473"))) {
log.error("Error response recieved from HiCommandManger: {}", error.getDescription());
log.info("Exception from HICommand Manager recieved during delete operation, retrying operation {} time", retryCount);
errorDescriptionBuilder.append("error ").append(retryCount).append(" : ").append(error.getDescription()).append("-#####-");
// Wait for a minute before retry
Thread.sleep(60000);
unDeletedHSDs.clear();
unDeletedHSDs.addAll(hsdList.stream().filter(hsd -> getHostStorageDomain(systemId, hsd.getObjectID()) != null).collect(Collectors.toList()));
if (unDeletedHSDs.isEmpty()) {
// Operation succeeded
operationSucceeds = true;
log.info("Deleted {} LUN paths from system:{}", hsdList.size(), systemId);
} else {
// Retry the operation again if retry count not exceeded
continue;
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete HostStorageDomains due to invalid response from server. Error Code - %s Error Message - %s", error.getCode(), error.getDescription()));
}
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete HostStorageDomains due to invalid response %1$s from server", response.getStatus()));
}
}
if (!operationSucceeds) {
// Delete operation failed ever after repeated retries
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete HostStorageDomains due to repeated errors from HiCommand server, errors description are as %s", errorDescriptionBuilder.toString()));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
log.info("Batch Query to delete HSD's completed.");
}
use of com.emc.storageos.hds.model.Delete 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.Delete 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.Delete in project coprhd-controller by CoprHD.
the class HDSApiProtectionManager method deleteThinImagePair.
/**
* Deletes ReplicationInfo instance from SnapshotGroup
*
* @param snapshotGroupObjId
* @param replicationInfoObjId
* @throws Exception
*/
public void deleteThinImagePair(String hostObjId, String snapshotGroupObjId, String replicationInfoObjId, String model) throws Exception {
InputStream responseStream = null;
ReplicationInfo replicationInfo = null;
try {
if (hostObjId != null && snapshotGroupObjId != null && replicationInfoObjId != null) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
Delete deleteOp = new Delete(HDSConstants.REPLICATION, HDSConstants.INBAND2);
HDSHost host = new HDSHost();
host.setObjectID(hostObjId);
SnapshotGroup snapshotGroup = new SnapshotGroup();
snapshotGroup.setObjectID(snapshotGroupObjId);
replicationInfo = new ReplicationInfo();
replicationInfo.setObjectID(replicationInfoObjId);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.HOST, host);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.SNAPSHOTGROUP, snapshotGroup);
attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
String deleteThinImagePairInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_THIN_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to delete thin image pair : {}", deleteThinImagePairInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteThinImagePairInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_THINIMAGE_CONFIG_FILE);
verifyErrorPayload(result);
log.info("Thin Image pair deleted successfully.");
} else {
log.error("Thin Image pair deletion failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Image pair deletion failed 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");
}
}
}
}
use of com.emc.storageos.hds.model.Delete 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;
}
Aggregations