Search in sources :

Example 16 with EchoCommand

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

the class HDSApiExportManager method verifyErrorPayload.

/**
 * Utility method to check if there are any errors or not.
 *
 * @param javaResult
 * @throws Exception
 */
private void verifyErrorPayload(JavaResult javaResult) throws Exception {
    EchoCommand command = javaResult.getBean(EchoCommand.class);
    if (null == command || null == command.getStatus() || HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
        Error error = javaResult.getBean(Error.class);
        log.info("Error response received from Hitachi server for messageID", command.getMessageID());
        log.info("Hitachi command failed with error code:{} with message:{} for request:{}", new Object[] { error.getCode().toString(), error.getDescription(), error.getSource() });
        throw HDSException.exceptions.errorResponseReceived(error.getCode(), error.getDescription());
    }
}
Also used : Error(com.emc.storageos.hds.model.Error) EchoCommand(com.emc.storageos.hds.model.EchoCommand)

Example 17 with EchoCommand

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

the class HDSApiProtectionManager method verifyErrorPayload.

/**
 * Utility method to check if there are any errors or not.
 *
 * @param javaResult
 * @throws Exception
 */
private void verifyErrorPayload(JavaResult javaResult) throws Exception {
    EchoCommand command = javaResult.getBean(EchoCommand.class);
    if (null == command || null == command.getStatus() || HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
        Error error = javaResult.getBean(Error.class);
        log.info("Error response received from Hitachi server for messageID", command.getMessageID());
        log.info("Hitachi command failed with error code:{} with message:{} for request:{}", new Object[] { error.getCode().toString(), error.getDescription(), error.getSource() });
        throw HDSException.exceptions.errorResponseReceived(error.getCode(), error.getDescription());
    }
}
Also used : Error(com.emc.storageos.hds.model.Error) EchoCommand(com.emc.storageos.hds.model.EchoCommand)

Example 18 with EchoCommand

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

the class HDSApiVolumeManager method deleteThinLogicalUnits.

public String deleteThinLogicalUnits(String systemObjectID, Set<String> logicalUnitIdList, String model) throws Exception {
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemObjectID);
        Delete deleteOp = new Delete(HDSConstants.VIRTUALVOLUME, true);
        List<LogicalUnit> luList = new ArrayList<LogicalUnit>();
        for (String logicalUnitId : logicalUnitIdList) {
            LogicalUnit logicalUnit = new LogicalUnit(logicalUnitId, null);
            luList.add(logicalUnit);
        }
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.DELETE, deleteOp);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.LOGICALUNIT_LIST, luList);
        String deleteVolumesInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("volume delete payload :{}", deleteVolumesInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, deleteVolumesInputXML);
        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();
                log.info("Async task id : {}", asyncTaskMessageId);
            } else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
                Error error = result.getBean(Error.class);
                log.info("command failed error code: {}", error.getCode());
                log.info("Command failed: messageID: {} {}", command.getMessageID(), error.getDescription());
                throw HDSException.exceptions.notAbleToDeleteVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("LogicalUnit deletion 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(), systemObjectID));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return asyncTaskMessageId;
}
Also used : Delete(com.emc.storageos.hds.model.Delete) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) 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) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 19 with EchoCommand

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

the class HDSApiVolumeManager method modifyThinVolumeTieringPolicy.

public String modifyThinVolumeTieringPolicy(String systemObjectID, String luObjectID, String ldevObjectID, String tieringPolicyName, String model) {
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME);
    StorageArray array = new StorageArray(systemObjectID);
    LogicalUnit logicalUnit = new LogicalUnit();
    logicalUnit.setObjectID(luObjectID);
    LDEV ldev = new LDEV(ldevObjectID);
    ldev.setTierLevel(Integer.parseInt(tieringPolicyName));
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.MODIFY, modifyOp);
    attributeMap.put(HDSConstants.MODEL, model);
    attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
    attributeMap.put(HDSConstants.LDEV, ldev);
    String modifyThinVolumeTieringPolicyPayload = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    URI endpointURI = hdsApiClient.getBaseURI();
    log.info("Modify Volume TieringPolicy payload:{}", modifyThinVolumeTieringPolicyPayload);
    ClientResponse response = hdsApiClient.post(endpointURI, modifyThinVolumeTieringPolicyPayload);
    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("Modify Volume TieringPolicy failed status messageID: {}", command.getMessageID());
            log.error("Modify Volume TieringPolicy failed with error code: {} with message: {}", error.getCode(), error.getDescription());
            throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
        }
    } else {
        log.error("Modify Volume TieringPolicy failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Modify Volume TieringPolicy failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
    }
    return asyncTaskMessageId;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) Error(com.emc.storageos.hds.model.Error) Modify(com.emc.storageos.hds.model.Modify) LDEV(com.emc.storageos.hds.model.LDEV) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 20 with EchoCommand

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

the class HDSApiVolumeManager method modifyVirtualVolume.

/**
 * Modify the Virtual Volumes with the passed information.
 *
 * @param systemId : represents SystemObjectID.
 * @param newLUCapacityInBytes: new VirtualVolume Capacity in bytes.
 * @return : asyncMessageId
 * @throws Exception
 */
public String modifyVirtualVolume(String systemId, String luObjectId, Long newLUCapacityInBytes, String model) throws Exception {
    Long luCapacityInKB = newLUCapacityInBytes / 1024;
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemId);
        Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME, false);
        LogicalUnit logicalUnit = new LogicalUnit(luObjectId, String.valueOf(luCapacityInKB));
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.MODIFY, modifyOp);
        attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
        String modifyVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to modify Thin Volume: {}", modifyVolumeInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, modifyVolumeInputXML);
        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 modification failed status messageID: {}", command.getMessageID());
                log.error("Thin Volume modification failed with error code: {} with message: {}", error.getCode(), error.getDescription());
                throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("Thin Volume modification failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Volume modification 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 closing Thin volume modification response stream");
            }
        }
    }
    return asyncTaskMessageId;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) Error(com.emc.storageos.hds.model.Error) Modify(com.emc.storageos.hds.model.Modify) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Aggregations

EchoCommand (com.emc.storageos.hds.model.EchoCommand)21 Error (com.emc.storageos.hds.model.Error)21 JavaResult (org.milyn.payload.JavaResult)14 ClientResponse (com.sun.jersey.api.client.ClientResponse)13 InputStream (java.io.InputStream)13 IOException (java.io.IOException)12 URI (java.net.URI)12 HashMap (java.util.HashMap)11 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)9 StorageArray (com.emc.storageos.hds.model.StorageArray)9 Add (com.emc.storageos.hds.model.Add)5 Delete (com.emc.storageos.hds.model.Delete)3 Modify (com.emc.storageos.hds.model.Modify)3 HDSHost (com.emc.storageos.hds.model.HDSHost)2 Pool (com.emc.storageos.hds.model.Pool)2 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)2 ArrayList (java.util.ArrayList)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 HDSException (com.emc.storageos.hds.HDSException)1 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)1