use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.
the class HDSApiDiscoveryManager method getStoragePoolsTierInfo.
/**
* Returns all storage system information.
*
* @return
* @throws Exception
*/
public List<Pool> getStoragePoolsTierInfo(String systemObjectID) throws Exception {
InputStream responseStream = null;
List<Pool> poolList = null;
URI endpointURI = hdsApiClient.getBaseURI();
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray inputStorageArray = new StorageArray(systemObjectID);
Get getOp = new Get(HDSConstants.STORAGEARRAY);
attributeMap.put(HDSConstants.STORAGEARRAY, inputStorageArray);
attributeMap.put(HDSConstants.GET, getOp);
String getPoolTieringInfoInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_STORAGE_POOL_TIERING_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Get StoragePools Tiering info query payload :{}", getPoolTieringInfoInputXML);
ClientResponse response = hdsApiClient.post(endpointURI, getPoolTieringInfoInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
poolList = (List<Pool>) result.getBean("thinPoolList");
} else {
log.error("Get pools tiering info failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query pools tiering info due to invalid response %1$s from server", response.getStatus()));
}
return poolList;
}
use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method createThinVolumes.
/**
* Creates the Thin volume with the passed information.
*
* @param systemId : represents SystemObjectID.
* @param arrayGroupId : represents StoragePoolObjectID.
* @param luCapacityInBytes: Logical Unit Capacity in bytes.
* @param noOfLus : No. of LU's to created
* @param volumeName : Logical Unit name.
* @param formatType : formatType.
* @param model : model.
* @return : asyncMessageId
* @throws Exception
*/
public String createThinVolumes(String systemId, String arrayGroupId, Long luCapacityInBytes, int noOfLus, String volumeName, String formatType, String model) throws Exception {
Long luCapacityInKB = luCapacityInBytes / 1024;
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemId);
Pool arrayGroup = new Pool(null);
Add addOp = new Add(HDSConstants.VIRTUALVOLUME, noOfLus, null);
LogicalUnit logicalUnit = new LogicalUnit(arrayGroupId, String.valueOf(luCapacityInKB), volumeName, HDSConstants.EMULATION_OPENV, null);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
attributeMap.put(HDSConstants.MODEL, model);
String createVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_THIN_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to create thin Volume: {}", createVolumeInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, createVolumeInputXML);
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 Volume creation failed status messageID: {}", command.getMessageID());
log.error("Thin Volume creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("Thin Volume creation failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Volume creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemId));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("Exception occurred while close thin volume creation response stream");
}
}
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method getStoragePoolInfo.
/**
* Return the storagepool information.
*
* @param systemObjectId
* @param poolObjectId
* @return
* @throws Exception
*/
public Pool getStoragePoolInfo(String systemObjectId, String poolObjectId) throws Exception {
InputStream responseStream = null;
Pool storagePool = null;
String poolMethodType = null;
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectId);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
Get getOp = new Get(HDSConstants.STORAGEARRAY);
attributeMap.put(HDSConstants.GET, getOp);
Pool pool = new Pool(poolObjectId);
if (poolObjectId.contains(HDSConstants.ARRAYGROUP)) {
attributeMap.put(HDSConstants.ARRAY_GROUP, pool);
poolMethodType = HDSConstants.GET_ARRAYGROUP_INFO_OP;
} else if (poolObjectId.contains(HDSConstants.JOURNALPOOL)) {
attributeMap.put(HDSConstants.JOURNAL_POOL, pool);
poolMethodType = HDSConstants.GET_JOURNAL_POOL_INFO_OP;
}
String getStoragePoolInputXML = InputXMLGenerationClient.getInputXMLString(poolMethodType, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
log.info("Storagepool info query payload :{}", getStoragePoolInputXML);
ClientResponse response = hdsApiClient.post(endpointURI, getStoragePoolInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
storagePool = result.getBean(Pool.class);
} else {
log.error("Get StoragePool info failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query StoragePool info due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
}
return storagePool;
}
use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method createThickVolumes.
/**
* Creates the Thick volume with the passed information.
*
* @TODO we should add support for multi volume creation by constructing the xml with new attributes. rest will work fine.
* @param systemId : represents SystemObjectID.
* @param arrayGroupId : represents StoragePoolObjectID.
* @param luCapacityInBytes: Logical Unit Capacity in bytes.
* @param noOfLus : No. of LU's to created
* @param volumeName : Logical Unit name.
* @return : asyncMessageId
* @throws Exception
*/
public String createThickVolumes(String systemId, String arrayGroupId, Long luCapacityInBytes, int noOfLus, String volumeName, String formatType, String model, Integer devNum) throws Exception {
Long luCapacityInKB = luCapacityInBytes / 1024;
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemId);
Pool arrayGroup = new Pool(arrayGroupId);
Add addOp = new Add(HDSConstants.LOGICALUNIT, noOfLus, formatType);
addOp.setBulk(Boolean.TRUE);
LogicalUnit logicalUnit = new LogicalUnit(null, String.valueOf(luCapacityInKB), volumeName, null, devNum);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
String createVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_THICK_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to create thick volume: {}", createVolumeInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, createVolumeInputXML);
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("Volume creation failed status messageID: {}", command.getMessageID());
log.error("Volume creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("LogicalUnit creation 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(), systemId));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("Exception occurred while close volume creation response stream");
}
}
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.Pool in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method processStorageThinPoolResponse.
/**
* Process the thin pool response received from server.
*
* @param system
* @param thinPoolListFromResponse
* @param accessProfile
* @param supportedProtocols
* @param poolsToMatchWithVpool
* @throws IOException
*/
private List<StoragePool> processStorageThinPoolResponse(StorageSystem system, List<Pool> thinPoolListFromResponse, AccessProfile accessProfile, Set<String> supportedProtocols, List<StoragePool> poolsToMatchWithVpool) throws IOException {
_logger.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> updatePools = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
if (null != thinPoolListFromResponse && !thinPoolListFromResponse.isEmpty()) {
_logger.debug("thinPoolListFromResponse size:{}", thinPoolListFromResponse.size());
for (Pool poolFromResponse : thinPoolListFromResponse) {
if (poolFromResponse.getPoolFunction() == 5) {
boolean isNew = false;
// indicates whether to add to modified pools list or not
boolean isModified = false;
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(system, poolFromResponse.getObjectID(), NativeGUIDGenerator.POOL);
_logger.debug("nativeGuid :{}", nativeGuid);
StoragePool pool = checkPoolExistsInDB(nativeGuid);
if (null == pool) {
isNew = true;
pool = new StoragePool();
pool.setNativeGuid(nativeGuid);
pool.setStorageDevice(system.getId());
pool.setId(URIUtil.createId(StoragePool.class));
pool.setNativeId(poolFromResponse.getPoolID());
pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
// @TODO hard coded for now. Need to see how to get it from API or documentation.
pool.setMaximumThinVolumeSize(104857600L);
pool.setPoolServiceType(PoolServiceType.block.toString());
pool.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
StringSet raidLevels = new StringSet();
raidLevels.add(poolFromResponse.getRaidType());
//
pool.addSupportedRaidLevels(raidLevels);
pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
_logger.info("pool objectId {}", poolFromResponse.getObjectID());
pool.setThinVolumePreAllocationSupported(Boolean.FALSE);
}
// Set TieringEnabled flag based on tierControl of the pool.
if (poolFromResponse.getTierControl() == 1) {
pool.setAutoTieringEnabled(Boolean.TRUE);
} else {
pool.setAutoTieringEnabled(Boolean.FALSE);
}
StringSet protocols = new StringSet(supportedProtocols);
if (!isNew && ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getProtocols(), protocols)) {
isModified = true;
}
pool.setProtocols(protocols);
StringSet copyTypes = new StringSet();
copyTypes.add(StoragePool.CopyTypes.UNSYNC_ASSOC.name());
copyTypes.add(StoragePool.CopyTypes.UNSYNC_UNASSOC.name());
copyTypes.add(StoragePool.CopyTypes.SYNC.name());
copyTypes.add(StoragePool.CopyTypes.ASYNC.name());
pool.setSupportedCopyTypes(copyTypes);
String label = null;
if (StringUtils.isBlank(poolFromResponse.getName()) || poolFromResponse.getName().length() <= 2) {
label = "DP " + poolFromResponse.getDisplayName();
} else {
label = poolFromResponse.getName();
}
pool.setPoolName(label);
pool.setFreeCapacity(poolFromResponse.getFreeCapacity());
pool.setTotalCapacity(poolFromResponse.getUsedCapacity());
pool.setSubscribedCapacity(poolFromResponse.getSubscribedCapacityInKB());
if (null != poolFromResponse.getDiskType()) {
Set<String> driveTypes = new HashSet<String>();
driveTypes.add(getPoolSupportedDriveType(poolFromResponse.getDiskType()));
pool.addDriveTypes(driveTypes);
}
// TODO workaround to display the display name based on the pool name
pool.setLabel(label);
if (!isNew && !isModified && (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name()))) {
isModified = true;
}
pool.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
if (isNew) {
newPools.add(pool);
// add new pools to modified pools list to consider them for implicit pool matching.
poolsToMatchWithVpool.add(pool);
} else {
updatePools.add(pool);
// add to modified pools list if pool's property which is required for vPool matcher, has changed.
if (isModified) {
poolsToMatchWithVpool.add(pool);
}
}
}
}
StoragePoolAssociationHelper.setStoragePoolVarrays(system.getId(), newPools, _dbClient);
_logger.info("New pools size: {}", newPools.size());
_logger.info("updatePools size: {}", updatePools.size());
_dbClient.createObject(newPools);
_dbClient.persistObject(updatePools);
allPools.addAll(newPools);
allPools.addAll(updatePools);
}
_logger.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
return allPools;
}
Aggregations