Search in sources :

Example 1 with Add

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

the class HDSApiExportManager method constructAddLUNQuery.

/**
 * Constructs the addLun query using multiple path elements. Each path
 * element defines the path from volume to initiators.
 *
 * @param systemId
 * @param targetPortId
 * @param domainId
 * @param deviceLunList
 * @param pathList
 * @param model
 * @return
 * @throws Exception
 */
private String constructAddLUNQuery(String systemId, String targetPortId, String domainId, Map<String, String> deviceLunList, List<Path> pathList, String model) throws Exception {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Add addOp = new Add(HDSConstants.LUN_TARGET);
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.ADD, addOp);
    attributeMap.put(HDSConstants.MODEL, model);
    if (null != deviceLunList && !deviceLunList.isEmpty()) {
        for (String device : deviceLunList.keySet()) {
            String lun = deviceLunList.get(device);
            Path path = new Path(targetPortId, domainId, null, lun, device);
            pathList.add(path);
            log.info("Device :{} lun:{}", device, lun);
        }
    }
    attributeMap.put(HDSConstants.PATH_LIST, pathList);
    String addLunInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_PATH_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addLunInputXML;
}
Also used : Add(com.emc.storageos.hds.model.Add) Path(com.emc.storageos.hds.model.Path) HashMap(java.util.HashMap) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 2 with Add

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

the class HDSApiProtectionManager method createShadowImagePair.

/**
 * Creates ShadowImage Pair
 *
 * @param replicationGroupObjId
 * @param pairName
 * @param arrayType
 * @param arraySerialNumber
 * @param pvolDevNum
 * @param svolDevNum
 * @param model
 * @return {@link ReplicationInfo}
 */
public ReplicationInfo createShadowImagePair(String replicationGroupObjId, String pairName, String arrayType, String arraySerialNumber, String pvolDevNum, String svolDevNum, String model) throws Exception {
    log.info("Shadow Image pair creation started");
    InputStream responseStream = null;
    ReplicationInfo replicationInfoResponse = null;
    String syncTaskMessageId = null;
    try {
        log.info("replicationGroupObjId {} ", replicationGroupObjId);
        log.info("arrayType {} arraySerialNumber {}", arrayType, arraySerialNumber);
        log.info(" pvolDevNum {} svolDevNum {}", pvolDevNum, svolDevNum);
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        Add addOp = new Add(HDSConstants.REPLICATION);
        ReplicationGroup replicationGroup = new ReplicationGroup();
        replicationGroup.setObjectID(replicationGroupObjId);
        replicationGroup.setReplicationFunction(HDSConstants.SHADOW_IMAGE);
        ReplicationInfo replicationInfo = new ReplicationInfo();
        replicationInfo.setPairName(pairName);
        replicationInfo.setPvolArrayType(arrayType);
        replicationInfo.setPvolSerialNumber(arraySerialNumber);
        replicationInfo.setPvolDevNum(pvolDevNum);
        replicationInfo.setSvolArrayType(arrayType);
        replicationInfo.setSvolSerialNumber(arraySerialNumber);
        replicationInfo.setSvolDevNum(svolDevNum);
        replicationInfo.setReplicationFunction(HDSConstants.SHADOW_IMAGE);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.REPLICATION_GROUP, replicationGroup);
        attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
        String createShadowImagePairInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_SHADOW_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to create shadow image pair volume: {}", createShadowImagePairInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, createShadowImagePairInputXML);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_REPLICATION_CONFIG_FILE);
            EchoCommand command = result.getBean(EchoCommand.class);
            if (HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
                log.info("ShadowImage Pair has been created successfully");
                replicationInfoResponse = result.getBean(ReplicationInfo.class);
                if (null == replicationInfoResponse) {
                    throw HDSException.exceptions.notAbleToCreateShadowImagePair();
                }
            } else if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus())) {
                syncTaskMessageId = command.getMessageID();
            } else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
                Error error = result.getBean(Error.class);
                log.error("Shadow Image pair creation failed status messageID: {}", command.getMessageID());
                log.error("Shadow Image pair creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
                throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("Shadow Image pair creation failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Shadow Image pair creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), arraySerialNumber));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("Exception occurred while close Shadow Image Pair creation response stream");
            }
        }
    }
    log.info("Shadow Image pair creation completed");
    return replicationInfoResponse;
}
Also used : Add(com.emc.storageos.hds.model.Add) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Error(com.emc.storageos.hds.model.Error) IOException(java.io.IOException) ReplicationGroup(com.emc.storageos.hds.model.ReplicationGroup) URI(java.net.URI) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand)

Example 3 with Add

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

the class HDSApiProtectionManager method createThinImagePair.

/**
 * Creates ThinImage pair for HDS Snapshot
 *
 * @param snapshotGroupObjId
 * @param hostObjId
 * @param sourNativeId
 * @param snapNativeId
 * @param thinImagePoolId
 * @return
 * @throws Exception
 */
public boolean createThinImagePair(String snapshotGroupObjId, String hostObjId, String sourNativeId, String snapNativeId, String thinImagePoolId, String model) throws Exception {
    log.info("Thin Image pair creation started");
    boolean status = false;
    InputStream responseStream = null;
    String syncTaskMessageId = null;
    try {
        log.info("snapshotGroupObjId {} ", snapshotGroupObjId);
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        Add addOp = new Add(HDSConstants.REPLICATION);
        addOp.setOption(HDSConstants.INBAND2);
        HDSHost host = new HDSHost();
        host.setObjectID(hostObjId);
        SnapshotGroup snapshotGroup = new SnapshotGroup();
        snapshotGroup.setObjectID(snapshotGroupObjId);
        snapshotGroup.setReplicationFunction(HDSConstants.THIN_IMAGE);
        ReplicationInfo replicationInfo = new ReplicationInfo();
        replicationInfo.setPvolDevNum(sourNativeId);
        replicationInfo.setSvolDevNum(snapNativeId);
        replicationInfo.setPvolPoolID(thinImagePoolId);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.HOST, host);
        attributeMap.put(HDSConstants.SNAPSHOTGROUP, snapshotGroup);
        attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
        String createThinImagePairInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_THIN_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to create thin image pair : {}", createThinImagePairInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, createThinImagePairInputXML);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_THINIMAGE_CONFIG_FILE);
            EchoCommand command = result.getBean(EchoCommand.class);
            if (HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
                log.info("ThinImage Pair has been created successfully");
                status = true;
                SnapshotGroup snapshotGrpResponse = result.getBean(SnapshotGroup.class);
                if (null == snapshotGrpResponse) {
                    throw HDSException.exceptions.notAbleToCreateThinImagePair();
                }
            } else if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus())) {
                syncTaskMessageId = command.getMessageID();
            } else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
                Error error = result.getBean(Error.class);
                log.error("Thin Image pair creation failed status messageID: {}", command.getMessageID());
                log.error("Thin Image pair creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
                throw HDSException.exceptions.notAbleToCreateThinImagePairError(error.getCode(), error.getDescription());
            }
        } else {
            log.error("Thin Image pair creation failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Image pair creation failed due to invalid response %1$s from server", response.getStatus()));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("Exception occurred while close Thin Image Pair creation response stream");
            }
        }
    }
    log.info("Thin Image pair creation completed");
    return status;
}
Also used : Add(com.emc.storageos.hds.model.Add) ClientResponse(com.sun.jersey.api.client.ClientResponse) HDSHost(com.emc.storageos.hds.model.HDSHost) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Error(com.emc.storageos.hds.model.Error) IOException(java.io.IOException) URI(java.net.URI) SnapshotGroup(com.emc.storageos.hds.model.SnapshotGroup) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand)

Example 4 with Add

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

the class HDSApiVolumeManager method createThinVolumes.

/**
 * Creates the Thin volume with the passed information.
 *
 * @param systemId : represents SystemObjectID.
 * @param arrayGroupId : represents StoragePoolObjectID.
 * @param luCapacityInBytes: Logical Unit Capacity in bytes.
 * @param noOfLus : No. of LU's to created
 * @param volumeName : Logical Unit name.
 * @param formatType : formatType.
 * @param model : model.
 * @return : asyncMessageId
 * @throws Exception
 */
public String createThinVolumes(String systemId, String arrayGroupId, Long luCapacityInBytes, int noOfLus, String volumeName, String formatType, String model) throws Exception {
    Long luCapacityInKB = luCapacityInBytes / 1024;
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemId);
        Pool arrayGroup = new Pool(null);
        Add addOp = new Add(HDSConstants.VIRTUALVOLUME, noOfLus, null);
        LogicalUnit logicalUnit = new LogicalUnit(arrayGroupId, String.valueOf(luCapacityInKB), volumeName, HDSConstants.EMULATION_OPENV, null);
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
        attributeMap.put(HDSConstants.MODEL, model);
        String createVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_THIN_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to create thin Volume: {}", createVolumeInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, createVolumeInputXML);
        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 creation failed status messageID: {}", command.getMessageID());
                log.error("Thin Volume creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
                throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("Thin Volume creation failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Volume creation 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 close thin volume creation response stream");
            }
        }
    }
    return asyncTaskMessageId;
}
Also used : Add(com.emc.storageos.hds.model.Add) 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) IOException(java.io.IOException) URI(java.net.URI) Pool(com.emc.storageos.hds.model.Pool) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 5 with Add

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

the class HDSApiProtectionManager method refreshPairManagementServer.

public void refreshPairManagementServer(String pairMgmtServerHostObjId) throws Exception {
    InputStream responseStream = null;
    try {
        if (pairMgmtServerHostObjId != null) {
            log.info("Refreshing Pair Mgmt Server started");
            Map<String, Object> attributeMap = new HashMap<String, Object>();
            Add addOp = new Add(HDSConstants.HOST_REFRESH);
            HDSHost host = new HDSHost();
            host.setObjectID(pairMgmtServerHostObjId);
            attributeMap.put(HDSConstants.ADD, addOp);
            attributeMap.put(HDSConstants.HOST, host);
            String refreshHostQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.REFRESH_HOST_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
            log.info("Query to refresh pair mgmt server: {}", refreshHostQuery);
            URI endpointURI = hdsApiClient.getBaseURI();
            ClientResponse response = hdsApiClient.post(endpointURI, refreshHostQuery);
            if (HttpStatus.SC_OK == response.getStatus()) {
                responseStream = response.getEntityInputStream();
                JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_THINIMAGE_CONFIG_FILE);
                verifyErrorPayload(javaResult);
                log.info("Successfully refreshed pair mgmt server");
            } else {
                throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to refresh pair mgmt server due to invalid response %1$s from server", response.getStatus()));
            }
        } else {
            log.info("Pair Mgmt Server Object id is null");
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("IOException occurred while closing the response stream");
            }
        }
    }
}
Also used : Add(com.emc.storageos.hds.model.Add) ClientResponse(com.sun.jersey.api.client.ClientResponse) HDSHost(com.emc.storageos.hds.model.HDSHost) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Aggregations

Add (com.emc.storageos.hds.model.Add)19 HashMap (java.util.HashMap)19 StorageArray (com.emc.storageos.hds.model.StorageArray)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 InputStream (java.io.InputStream)10 URI (java.net.URI)10 JavaResult (org.milyn.payload.JavaResult)10 IOException (java.io.IOException)9 EchoCommand (com.emc.storageos.hds.model.EchoCommand)5 Error (com.emc.storageos.hds.model.Error)5 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)4 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)4 ArrayList (java.util.ArrayList)4 HDSHost (com.emc.storageos.hds.model.HDSHost)2 ISCSIName (com.emc.storageos.hds.model.ISCSIName)2 Pool (com.emc.storageos.hds.model.Pool)2 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)2 WorldWideName (com.emc.storageos.hds.model.WorldWideName)2 ArrayGroup (com.emc.storageos.hds.model.ArrayGroup)1 LDEV (com.emc.storageos.hds.model.LDEV)1