Search in sources :

Example 6 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiDiscoveryManager method getStorageSystemTieringPolicyDetails.

/**
 * Returns all storage system information.
 *
 * @return
 * @throws Exception
 */
public StorageArray getStorageSystemTieringPolicyDetails(String systemObjectID) throws Exception {
    InputStream responseStream = null;
    StorageArray storageArray = 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 getSystemDetailsInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_SYSTEM_TIERING_DETAILS_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    log.info("Get system Tiering details query payload :{}", getSystemDetailsInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getSystemDetailsInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        storageArray = result.getBean(StorageArray.class);
    } else {
        log.error("Get system details failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query system details due to invalid response %1$s from server", response.getStatus()));
    }
    return storageArray;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 7 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiDiscoveryManager method getStorageSystemsInfo.

/**
 * Returns all storage system information.
 *
 * @return
 * @throws Exception
 */
public List<StorageArray> getStorageSystemsInfo() throws Exception {
    InputStream responseStream = null;
    List<StorageArray> arrayList = null;
    try {
        URI endpointURI = hdsApiClient.getBaseURI();
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(HDSConstants.STAR);
        Get getOp = new Get(HDSConstants.STORAGEARRAY);
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.GET, getOp);
        String getSystemsInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_SYSTEMS_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Get all systems query payload :{}", getSystemsInputXML);
        ClientResponse response = hdsApiClient.post(endpointURI, getSystemsInputXML);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(result);
            arrayList = (List<StorageArray>) result.getBean(HDSConstants.SYSTEMLIST_BEAN_ID);
        } else {
            log.error("Get all systems query failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query all systems 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 arrayList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) 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 8 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiExportManager method registerHost.

/**
 * Register the given host with HiCommand Device Manager.
 *
 * @param hostName
 * @param ipAddress
 * @param portWWN
 * @return
 * @throws Exception
 */
public HDSHost registerHost(HDSHost hdshost, List<String> portWWNList, String initiatorType) throws Exception {
    String addHostQueryWithParams = null;
    InputStream responseStream = null;
    HDSHost registeredhost = null;
    try {
        if (initiatorType.equalsIgnoreCase(HDSConstants.FC)) {
            addHostQueryWithParams = constructAddFCInitiatorHostQuery(hdshost, portWWNList);
        } else if (initiatorType.equalsIgnoreCase(HDSConstants.ISCSI)) {
            addHostQueryWithParams = constructAddiSCSIInitiatorHostQuery(hdshost, portWWNList);
        }
        log.info("Query to Add host: {}", addHostQueryWithParams);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addHostQueryWithParams);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HOST_INFO_SMOOKS_CONFIG_FILE);
            EchoCommand command = javaResult.getBean(EchoCommand.class);
            if (null == command || null == command.getStatus() || HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
                Error error = javaResult.getBean(Error.class);
                if (error.getCode() == HDSConstants.HOST_ALREADY_EXISTS) {
                    log.info("The host {} already exists on DeviceManager", hdshost.getName());
                    return registeredhost;
                } else if (error.getCode() == HDSConstants.HOST_PORT_WWN_ALREADY_EXISTS) {
                    log.info("The WWN is already in use by another host");
                    return registeredhost;
                } else {
                    log.error("Error response received for messageID", command.getMessageID());
                    log.error("command failed with error code: {} with message {}", error.getCode(), error.getDescription());
                    throw HDSException.exceptions.notAbleToAddHostToDeviceManager(hdshost.getName());
                }
            }
            registeredhost = javaResult.getBean(HDSHost.class);
            if (null == registeredhost) {
                throw HDSException.exceptions.notAbleToAddHostToDeviceManager(String.format("Not able to add host:%1$s to Device manager", hdshost.getName()));
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Add Host to Device Manager 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 registeredhost;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HDSHost(com.emc.storageos.hds.model.HDSHost) InputStream(java.io.InputStream) Error(com.emc.storageos.hds.model.Error) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand)

Example 9 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiExportManager method addLUN.

/**
 * API call to addLun to the storage array.
 * Once the client makes the call, the luns should be visible to the host.
 *
 * @param systemId
 * @param targetPortId
 * @param domainId
 * @param deviceLunList
 * @param model
 * @throws Exception
 */
public List<Path> addLUN(String systemId, String targetPortId, String domainId, Map<String, String> deviceLunList, String model) throws Exception {
    InputStream responseStream = null;
    List<Path> pathList = new ArrayList<Path>();
    try {
        String addLUNQuery = constructAddLUNQuery(systemId, targetPortId, domainId, deviceLunList, pathList, model);
        log.info("Query to addLUN Query: {}", addLUNQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addLUNQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            pathList = (List<Path>) javaResult.getBean(HDSConstants.PATHLIST_RESPONSE_BEANID);
            if (pathList.isEmpty()) {
                throw HDSException.exceptions.notAbleToAddVolumeToHSD(domainId, systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add Volume to 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 pathList;
}
Also used : Path(com.emc.storageos.hds.model.Path) ClientResponse(com.sun.jersey.api.client.ClientResponse) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 10 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiExportManager method deleteISCSIsFromHostStorageDomain.

/**
 * Remove ISCSIName from the HostStorageDomain means disable LUN security by to the given iSCSIName.
 *
 * @param systemId
 * @param hsdId
 * @param scsiNameList
 * @param model
 * @return
 * @throws Exception
 */
public void deleteISCSIsFromHostStorageDomain(String systemId, String hsdId, List<String> scsiNameList, String model) throws Exception {
    InputStream responseStream = null;
    try {
        String addISCSINamesToHSDQuery = constructRemoveISCSIQuery(systemId, hsdId, scsiNameList, model);
        log.info("Query to remove SCSI Initiators from HostStorageDomain: {}", addISCSINamesToHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addISCSINamesToHSDQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            log.info("Remove iscsi initiators: {} from HSD: {}", scsiNameList, hsdId);
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Remove iSCSI initiator From HostStorageDomain 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");
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Aggregations

JavaResult (org.milyn.payload.JavaResult)57 InputStream (java.io.InputStream)53 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 URI (java.net.URI)50 IOException (java.io.IOException)42 HashMap (java.util.HashMap)38 StorageArray (com.emc.storageos.hds.model.StorageArray)26 Error (com.emc.storageos.hds.model.Error)17 Get (com.emc.storageos.hds.model.Get)16 EchoCommand (com.emc.storageos.hds.model.EchoCommand)15 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)13 Add (com.emc.storageos.hds.model.Add)11 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)11 HDSHost (com.emc.storageos.hds.model.HDSHost)8 Delete (com.emc.storageos.hds.model.Delete)7 HDSException (com.emc.storageos.hds.HDSException)6 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)6 Modify (com.emc.storageos.hds.model.Modify)5 Pool (com.emc.storageos.hds.model.Pool)5 ArrayList (java.util.ArrayList)5