use of com.emc.storageos.hds.model.Add in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method addLabelToObject.
/**
* Adds the label to an Object in DeviceManager.
* Currently this is supported for labeling LDEV.
* So, targetID must be a LDEV ID of a LU.
*
* @param targetID
* @param label
* @return
* @throws Exception
*/
public ObjectLabel addLabelToObject(String targetID, String label) throws Exception {
InputStream responseStream = null;
ObjectLabel objectLabel = null;
Map<String, Object> attributeMap = new HashMap<String, Object>();
Add addOp = new Add(HDSConstants.OBJECTLABEL);
addOp.setOverwrite(Boolean.TRUE);
attributeMap.put(HDSConstants.ADD, addOp);
ObjectLabel objectLabelReq = new ObjectLabel(targetID, label);
attributeMap.put(HDSConstants.OBJECTLABEL, objectLabelReq);
String addLabelToObject = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_LABEL_TO_OBJECT_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
log.info("Add Label to Object payload :{}", addLabelToObject);
ClientResponse response = hdsApiClient.post(endpointURI, addLabelToObject);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
objectLabel = result.getBean(ObjectLabel.class);
} else {
log.error("Add label to Object failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to Add Label to object due to invalid response %1$s from server", response.getStatus()));
}
return objectLabel;
}
use of com.emc.storageos.hds.model.Add 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;
}
use of com.emc.storageos.hds.model.Add in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method createSnapshotVolume.
public String createSnapshotVolume(String systemObjectId, Long luCapacityInBytes, String model) throws Exception {
Long luCapacityInKB = luCapacityInBytes / 1024;
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
log.info("Creating snapshot with {}KB size on Storage System {}", luCapacityInKB, systemObjectId);
Map<String, Object> attributeMap = new HashMap<String, Object>();
Add addOp = new Add(HDSConstants.VIRTUALVOLUME);
StorageArray storageArray = new StorageArray(systemObjectId);
ArrayGroup arrayGroup = new ArrayGroup();
arrayGroup.setType("2");
LogicalUnit logicalUnit = new LogicalUnit();
logicalUnit.setCapacityInKB(String.valueOf(luCapacityInKB));
logicalUnit.setEmulation(HDSConstants.EMULATION_OPENV);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
String createSnapshotInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_SNAPSHOT_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to create 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("Thin snapshot creation failed status messageID: {}", command.getMessageID());
log.error("Thin snapshot creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateSnapshot(error.getCode(), error.getDescription());
}
} else {
log.error("Thin snapshot creation failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin snapshot creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
}
log.info("Snapshot creation initiated on Storage System {}", systemObjectId);
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("Exception occurred while closing snapshot creation response stream");
}
}
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.Add in project coprhd-controller by CoprHD.
the class HDSBatchApiExportManager method constructAddLUNQuery.
/**
* Constructs a batch query for the given Path objects to add LUN's to
* storage system.
*
* @param systemId
* - represents storagesystem objectID.
* @param pathList
* - List of Path objects.
* @return - XML String to add LUN's to storage system.
*/
private String constructAddLUNQuery(String systemId, List<Path> pathList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.LUN_TARGET);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.PATH_LIST, pathList);
return InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_PATH_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
}
Aggregations