use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method processScanResponse.
/**
* Process the XMLAPI response and persist storageSystem.
*
* @param result
*/
private void processScanResponse(List<StorageArray> arrayList, AccessProfile accessProfile) {
_logger.info("{} systems found", arrayList.size());
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
for (StorageArray array : arrayList) {
String systemType = StorageSystem.Type.hds.name();
String model = array.getDisplayArrayType();
String objectID = array.getObjectID();
String serialNumber = objectID.split(COMMA_SEPERATOR)[2];
String arrayFamily = array.getArrayFamily();
// @TODO Add a model based check for HDS arrays if required.
StorageSystemViewObject systemVO = null;
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(systemType, objectID);
if (storageSystemsCache.containsKey(nativeGuid)) {
systemVO = storageSystemsCache.get(nativeGuid);
} else {
systemVO = new StorageSystemViewObject();
}
systemVO.setDeviceType(systemType);
systemVO.addprovider(accessProfile.getSystemId().toString());
systemVO.setProperty(StorageSystemViewObject.MODEL, model);
systemVO.setProperty(StorageSystemViewObject.SERIAL_NUMBER, serialNumber);
systemVO.setProperty(StorageSystemViewObject.STORAGE_NAME, nativeGuid);
storageSystemsCache.put(nativeGuid, systemVO);
}
_logger.info("Found {} systems during scanning for ip {}", storageSystemsCache.size(), accessProfile.getIpAddress());
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
if ((null != accessProfile.getnamespace()) && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()))) {
discoverUnManagedVolumes(accessProfile);
} else {
_logger.info("Discovery started for system {}", accessProfile.getSystemId());
StorageSystem storageSystem = null;
String detailedStatusMessage = "Unknown Status";
try {
storageSystem = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
// HDS+ARRAY.AMS200.73012495
Iterable<String> splitter = Splitter.on(HDSConstants.PLUS_OPERATOR).limit(2).split(storageSystem.getNativeGuid());
String objectID = Iterables.getLast(splitter);
StorageArray storageArray = hdsApiClient.getStorageSystemDetails(objectID);
if (null != storageArray) {
parseDiscoveryResponse(storageArray, accessProfile);
storageArray = hdsApiClient.getStorageSystemTieringPolicies(objectID);
parseDiscoveryTieringPolicyResponse(storageArray, accessProfile);
fetchStoragePoolTiers(storageSystem, objectID, accessProfile, hdsApiClient);
} else {
_logger.error("Discovery failed for system {} as not able to retrieve information from HiCommand DM");
throw new HDSCollectionException("Discovery failed for system as not able to retrieve information from HiCommand Device Manager.");
}
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for HDS: %s", accessProfile.getSystemId());
} catch (Exception e) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
}
detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystem.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw new HDSCollectionException(detailedStatusMessage);
} finally {
try {
if (storageSystem != null) {
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
}
} catch (Exception e) {
_logger.error(e.getMessage(), e);
}
}
_logger.info("Discovery Ended for system {}", accessProfile.getSystemId());
}
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("Scanning started for provider: {}", accessProfile.getSystemId());
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
boolean exceptionOccured = false;
try {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
String apiVersion = hdsApiClient.getProviderAPIVersion();
_logger.info("Provider {} API Version:{}", provider.getLabel(), apiVersion);
provider.setVersionString(apiVersion);
String minimumSupportedVersion = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, CONTROLLER_HICOMMAND_PROVIDER_VERSION);
if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, apiVersion) < 0) {
provider.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
throw new HDSCollectionException(String.format(" ** The HiCommand Device Manager API version is not supported. Minimum supported version should be: %s", minimumSupportedVersion));
}
provider.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
List<StorageArray> storageArrayList = hdsApiClient.getStorageSystemsInfo();
if (null != storageArrayList && !storageArrayList.isEmpty()) {
_logger.debug("Received proper response from HiCommand server");
processScanResponse(storageArrayList, accessProfile);
} else {
_logger.info("No Systems found during scanning of provider: {}", provider.getId());
}
} catch (Exception ex) {
exceptionOccured = true;
_logger.error("Exception occurred while scanning provider {}", accessProfile.getSystemId(), ex);
throw HDSException.exceptions.scanFailed(ex);
} finally {
if (exceptionOccured) {
provider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
} else {
provider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
}
_dbClient.persistObject(provider);
}
_logger.info("Scanning ended for provider: {}", accessProfile.getSystemId());
}
use of com.emc.storageos.hds.model.StorageArray in project coprhd-controller by CoprHD.
the class HDSApiExportManager method getHostStorageDomain.
/**
* Return the existing HSD's configured on the storage array.
*
* @param systemId
* @param type
* @return
* @throws Exception
*/
public HostStorageDomain getHostStorageDomain(String systemId, String hsdId) throws Exception {
InputStream responseStream = null;
HostStorageDomain hsd = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
Get getOp = new Get(HDSConstants.STORAGEARRAY);
attributeMap.put(HDSConstants.GET, getOp);
HostStorageDomain inputHsd = new HostStorageDomain(hsdId);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
String getHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_HSD_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to get HostStorageDomain: {}", getHSDQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, getHSDQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsd = javaResult.getBean(HostStorageDomain.class);
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query 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");
}
}
}
return hsd;
}
use of com.emc.storageos.hds.model.StorageArray 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");
}
}
}
}
Aggregations