use of com.emc.storageos.hds.model.Delete in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructRemoveISCSIQuery.
/**
* 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 constructRemoveISCSIQuery(String systemId, String hsdId, List<String> scsiNameList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Delete deleteOp = new Delete(HDSConstants.ISCSI_NAME_FOR_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<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 removeISCSINamesToHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.REMOVE_ISCSI_NAME_FROM_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return removeISCSINamesToHSDQuery;
}
use of com.emc.storageos.hds.model.Delete in project coprhd-controller by CoprHD.
the class HDSApiExportManager method deleteHostStorageDomain.
/**
* Delete the Host Storage Domain for a given storage array.
*
* @param systemObjectId
* @param hsdObjectId
* @param model
* @throws Exception
*/
public void deleteHostStorageDomain(String systemObjectId, String hsdObjectId, String model) throws Exception {
InputStream responseStream = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemObjectId);
Delete deleteOp = new Delete(HDSConstants.HOST_STORAGE_DOMAIN);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.MODEL, model);
HostStorageDomain inputHsd = new HostStorageDomain(hsdObjectId);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
String deleteHSDFromSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_HSD_FROM_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to delete HostStorageDomain: {}", deleteHSDFromSystemQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteHSDFromSystemQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
log.info("Deleted HSD {} from system {}", hsdObjectId, systemObjectId);
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete 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");
}
}
}
}
use of com.emc.storageos.hds.model.Delete in project coprhd-controller by CoprHD.
the class HDSApiProtectionManager method deleteShadowImagePair.
/**
* Deletes SI replicationInfo instance from replication group
*
* @param replicationGroupObjId
* @param replicationInfoObjId
* @return {@link ReplicationInfo}
* @throws Exception
*/
public ReplicationInfo deleteShadowImagePair(String replicationGroupObjId, String replicationInfoObjId, String model) throws Exception {
InputStream responseStream = null;
ReplicationInfo replicationInfo = null;
try {
if (replicationGroupObjId != null && replicationInfoObjId != null) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
Delete deleteOp = new Delete(HDSConstants.REPLICATION);
ReplicationGroup replicationGroup = new ReplicationGroup();
replicationGroup.setObjectID(replicationGroupObjId);
replicationInfo = new ReplicationInfo();
replicationInfo.setObjectID(replicationInfoObjId);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.REPLICATION_GROUP, replicationGroup);
attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
String deletePairQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to delete shadow image pair Query: {}", deletePairQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deletePairQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_REPLICATION_CONFIG_FILE);
verifyErrorPayload(javaResult);
log.info("Successfully Deleted pair");
replicationInfo = javaResult.getBean(ReplicationInfo.class);
log.info("replicationInfo :{}", replicationInfo);
/*
* if (null == replicationInfo) {
* throw HDSException.exceptions.notAbleToCreateShadowImagePair();
* }
*/
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete shadow image pair due to invalid response %1$s from server", response.getStatus()));
}
} else {
log.info("Replication info is not available on pair management server");
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return replicationInfo;
}
use of com.emc.storageos.hds.model.Delete in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method deleteSnapshotVolume.
public String deleteSnapshotVolume(String storageSystemObjId, String logicalUnitObjId, String model) throws Exception {
String asyncTaskMessageId = null;
InputStream responseStream = null;
try {
if (null != storageSystemObjId && null != logicalUnitObjId) {
log.info("Deleting snapshot with id {} from Storage System {}", logicalUnitObjId, storageSystemObjId);
Map<String, Object> attributeMap = new HashMap<String, Object>();
Delete deleteOp = new Delete(HDSConstants.VIRTUALVOLUME);
StorageArray storageArray = new StorageArray(storageSystemObjId);
LogicalUnit logicalUnit = new LogicalUnit();
logicalUnit.setObjectID(logicalUnitObjId);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
String createSnapshotInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_SNAPSHOT_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to delete snapshot Volume: {}", createSnapshotInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, createSnapshotInputXML);
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("Snapshot volume deletion failed status messageID: {}", command.getMessageID());
log.error("Snapshot volume failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToDeleteSnapshot(error.getCode(), error.getDescription());
}
} else {
log.error("Snapshot deletion failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Snapshot deletion failed due to invalid response %1$s from server for system %2$s", response.getStatus(), storageSystemObjId));
}
log.info("Snapshot with id {} deleted from Storage System {}", logicalUnitObjId, storageSystemObjId);
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("Exception occurred while closing snapshot deletion response stream");
}
}
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.Delete in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method deleteThickLogicalUnits.
public String deleteThickLogicalUnits(String systemObjectID, Set<String> logicalUnitIdList, String model) throws Exception {
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
// If the LogicalUnits are LUSE, we should release them.
releaseLUSEVolumesIfPresent(systemObjectID, logicalUnitIdList);
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectID);
Delete deleteOp = new Delete(HDSConstants.LOGICALUNIT);
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();
} 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