Search in sources :

Example 21 with HostStorageDomain

use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.

the class HDSApiExportManager method constructDeleteWWNQuery.

/**
 * Construct the WWN Query by adding multiple WWNs.
 * This query should be used to add FC initiators to the FC HSD.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @return
 */
private String constructDeleteWWNQuery(String systemId, String hsdId, List<String> wwnList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Delete deleteOp = new Delete(HDSConstants.ADD_WWN_TO_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<WorldWideName> wwnObjList = new ArrayList<WorldWideName>();
    if (null != wwnList && !wwnList.isEmpty()) {
        for (String initiatorWWN : wwnList) {
            WorldWideName wwn = new WorldWideName(initiatorWWN);
            wwnObjList.add(wwn);
        }
    }
    attributeMap.put(HDSConstants.WWN_LIST, wwnObjList);
    String deleteWWNFromHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_WWN_FROM_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return deleteWWNFromHSDQuery;
}
Also used : Delete(com.emc.storageos.hds.model.Delete) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ArrayList(java.util.ArrayList) WorldWideName(com.emc.storageos.hds.model.WorldWideName) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 22 with HostStorageDomain

use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.

the class HDSApiExportManager method getHostStorageDomains.

/**
 * Return the existing HSD's configured on the storage array.
 *
 * @param systemId
 * @param type
 * @return
 * @throws Exception
 */
public List<HostStorageDomain> getHostStorageDomains(String systemId) throws Exception {
    InputStream responseStream = null;
    StorageArray storageArray = null;
    List<HostStorageDomain> hsdList = 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 hsd = new HostStorageDomain();
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
        String getAllHSDQuery = 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: {}", getAllHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, getAllHSDQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            storageArray = javaResult.getBean(StorageArray.class);
            if (null != storageArray) {
                hsdList = storageArray.getHsdList();
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query HostStorageDomain's 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 hsdList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) Get(com.emc.storageos.hds.model.Get) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 23 with HostStorageDomain

use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.

the class HDSApiExportManager method constructWWNQuery.

/**
 * Construct the WWN Query by adding multiple WWNs.
 * This query should be used to add FC initiators to the FC HSD.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @return
 */
private String constructWWNQuery(String systemId, String hsdId, List<String> wwnList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Add addOp = new Add(HDSConstants.ADD_WWN_TO_HSD_TARGET);
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.ADD, addOp);
    attributeMap.put(HDSConstants.MODEL, model);
    HostStorageDomain hsd = new HostStorageDomain(hsdId);
    attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
    List<WorldWideName> wwnObjList = new ArrayList<WorldWideName>();
    if (null != wwnList && !wwnList.isEmpty()) {
        for (String initiatorWWN : wwnList) {
            WorldWideName wwn = new WorldWideName(initiatorWWN);
            wwnObjList.add(wwn);
        }
    }
    attributeMap.put(HDSConstants.WWN_LIST, wwnObjList);
    String addWWNQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_WWN_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addWWNQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ArrayList(java.util.ArrayList) WorldWideName(com.emc.storageos.hds.model.WorldWideName) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 24 with HostStorageDomain

use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.

the class HDSBatchApiExportManager method addWWNsToHostStorageDomain.

/**
 * This method makes a HTTP POST call to HiCommand with a payload of muliple
 * HSD's and each with a set of WWNs. This method can only be used for FC
 * HSD's.
 *
 * @param systemId
 *            - represents Storage System ObjectID.
 * @param hsdList
 *            - List of HostStorageDomain objects.
 * @return - List of HostStorageDomain objects with WWN's added.
 * @throws Exception
 *             - In case of processing error.
 */
public List<HostStorageDomain> addWWNsToHostStorageDomain(String systemId, List<HostStorageDomain> hsdList, String model) throws Exception {
    InputStream responseStream = null;
    List<HostStorageDomain> hsdResponseList = null;
    try {
        String addWWNToHSDsQuery = constructWWNQuery(systemId, hsdList, model);
        log.info("batch query to add FC initiators to HostStorageDomains: {}", addWWNToHSDsQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addWWNToHSDsQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            hsdResponseList = (List<HostStorageDomain>) javaResult.getBean(HDSConstants.HSD_RESPONSE_BEAN_ID);
            if (null == hsdResponseList || hsdResponseList.isEmpty()) {
                throw HDSException.exceptions.notAbleToAddInitiatorsToHostStorageDomain(systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Batch query to add FC initiators to HSDs failed 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 hsdResponseList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 25 with HostStorageDomain

use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.

the class HDSBatchApiExportManager method addISCSINamesToHostStorageDomain.

/**
 * This method makes a HTTP POST call to HiCommand with a payload of muliple
 * HSD's and each with a set of ISCSINames. This method can only be used for
 * ISCSI HSD's.
 *
 * @param systemId
 *            - represents Storage System ObjectID.
 * @param hsdList
 *            - List of HostStorageDomain objects.
 * @return - List of HostStorageDomain objects with ISCSINames's added.
 * @throws Exception
 *             - In case of processing error.
 */
public List<HostStorageDomain> addISCSINamesToHostStorageDomain(String systemId, List<HostStorageDomain> hsdList, String model) throws Exception {
    InputStream responseStream = null;
    List<HostStorageDomain> hsdResponseList = null;
    try {
        String addISCSINamesToHSDsQuery = constructISCSINamesQuery(systemId, hsdList, model);
        log.info("batch query to add ISCSI initiators to HostStorageDomains: {}", addISCSINamesToHSDsQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addISCSINamesToHSDsQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            hsdResponseList = (List<HostStorageDomain>) javaResult.getBean(HDSConstants.HSD_RESPONSE_BEAN_ID);
            if (null == hsdResponseList || hsdResponseList.isEmpty()) {
                throw HDSException.exceptions.notAbleToAddInitiatorsToHostStorageDomain(systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Batch query to add ISCSI initiators to HSDs failed 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 hsdResponseList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Aggregations

HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)35 URI (java.net.URI)18 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 HDSApiExportManager (com.emc.storageos.hds.api.HDSApiExportManager)11 StorageArray (com.emc.storageos.hds.model.StorageArray)11 ClientResponse (com.sun.jersey.api.client.ClientResponse)11 IOException (java.io.IOException)11 InputStream (java.io.InputStream)11 JavaResult (org.milyn.payload.JavaResult)11 ExportMask (com.emc.storageos.db.client.model.ExportMask)10 HDSException (com.emc.storageos.hds.HDSException)9 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)8 Path (com.emc.storageos.hds.model.Path)7 HashSet (java.util.HashSet)7 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)5 Add (com.emc.storageos.hds.model.Add)5