Search in sources :

Example 1 with StorageArray

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());
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 2 with StorageArray

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());
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HDSException(com.emc.storageos.hds.HDSException) WBEMException(javax.wbem.WBEMException) IOException(java.io.IOException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 3 with StorageArray

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());
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HDSException(com.emc.storageos.hds.HDSException) WBEMException(javax.wbem.WBEMException) IOException(java.io.IOException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 4 with StorageArray

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;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 5 with StorageArray

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");
            }
        }
    }
}
Also used : Delete(com.emc.storageos.hds.model.Delete) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Aggregations

StorageArray (com.emc.storageos.hds.model.StorageArray)41 HashMap (java.util.HashMap)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)25 InputStream (java.io.InputStream)25 URI (java.net.URI)25 JavaResult (org.milyn.payload.JavaResult)25 IOException (java.io.IOException)19 Add (com.emc.storageos.hds.model.Add)13 Get (com.emc.storageos.hds.model.Get)12 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)12 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)10 Delete (com.emc.storageos.hds.model.Delete)9 EchoCommand (com.emc.storageos.hds.model.EchoCommand)9 Error (com.emc.storageos.hds.model.Error)9 ArrayList (java.util.ArrayList)7 Pool (com.emc.storageos.hds.model.Pool)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 HDSException (com.emc.storageos.hds.HDSException)3 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)3 Modify (com.emc.storageos.hds.model.Modify)3