Search in sources :

Example 11 with Add

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

the class HDSApiExportManager method constructAddiSCSIInitiatorHostQuery.

/**
 * Constructs the addHostQuery.
 *
 * @param hostName
 * @param ipAddress
 * @param portWWNList
 * @return
 */
private String constructAddiSCSIInitiatorHostQuery(HDSHost hdshost, List<String> portWWNList) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<ISCSIName> wwnList = new ArrayList<ISCSIName>();
    Add addOp = new Add(HDSConstants.HOST);
    attributeMap.put(HDSConstants.HOST, hdshost);
    attributeMap.put(HDSConstants.ADD, addOp);
    if (null != portWWNList && !portWWNList.isEmpty()) {
        for (String portWWN : portWWNList) {
            ISCSIName wwn = new ISCSIName(portWWN, null);
            wwnList.add(wwn);
        }
    }
    attributeMap.put(HDSConstants.ISCSINAME_LIST, wwnList);
    String addHostWithISCSINamesQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_HOST_WITH_ISCSINAMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addHostWithISCSINamesQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) ISCSIName(com.emc.storageos.hds.model.ISCSIName) ArrayList(java.util.ArrayList)

Example 12 with Add

use of com.emc.storageos.hds.model.Add 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 13 with Add

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

the class HDSApiExportManager method addHostStorageDomain.

/**
 * Add new HostStorageDomain.
 *
 * @param systemId
 * @param targetPortID
 * @param hsdNickName
 * @param hostMode.
 * @param hostModeOption
 * @param model
 * @return
 * @throws Exception
 */
public HostStorageDomain addHostStorageDomain(String systemId, String targetPortID, String domainType, String hsdName, String hsdNickName, String hostMode, String hostModeOption, String model) throws Exception {
    InputStream responseStream = null;
    HostStorageDomain hsd = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray array = new StorageArray(systemId);
        Add addOp = new Add(HDSConstants.HOST_STORAGE_DOMAIN);
        attributeMap.put(HDSConstants.STORAGEARRAY, array);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.MODEL, model);
        HostStorageDomain inputHsd = new HostStorageDomain(targetPortID, hsdName, domainType, hsdNickName);
        inputHsd.setHostMode(hostMode);
        inputHsd.setHostModeOption(hostModeOption);
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
        String addHSDToSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_HSD_TO_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to create HostStorageDomain: {}", addHSDToSystemQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addHSDToSystemQuery);
        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);
            if (null == hsd) {
                throw HDSException.exceptions.notAbleToAddHSD(systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add 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 : Add(com.emc.storageos.hds.model.Add) ClientResponse(com.sun.jersey.api.client.ClientResponse) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 14 with Add

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

the class HDSApiExportManager method constructISCSIQuery.

/**
 * Construct the iSCSINames Query by adding multiple WWNs.
 * This query should be used to add the iSCSI initiators to the iSCSI HSD.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @return
 */
private String constructISCSIQuery(String systemId, String hsdId, List<String> scsiNameList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Add addOp = new Add(HDSConstants.ISCSI_NAME_FOR_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<ISCSIName> iSCSIObjList = new ArrayList<ISCSIName>();
    if (null != scsiNameList && !scsiNameList.isEmpty()) {
        for (String iScsiName : scsiNameList) {
            ISCSIName iSCSIName = new ISCSIName(iScsiName, null);
            iSCSIObjList.add(iSCSIName);
        }
    }
    attributeMap.put(HDSConstants.ISCSINAME_LIST, iSCSIObjList);
    String addISCSINamesToHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_ISCSI_NAME_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addISCSINamesToHSDQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ISCSIName(com.emc.storageos.hds.model.ISCSIName) ArrayList(java.util.ArrayList) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 15 with Add

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

the class HDSApiVolumeManager method constructAddLUSEQuery.

private String constructAddLUSEQuery(String systemId, String metaHead, List<String> ldevIds) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<LDEV> ldevsList = new LinkedList<LDEV>();
    StorageArray storageArray = new StorageArray(systemId);
    attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
    Add addOp = new Add(HDSConstants.LUSE_TARGET, true);
    attributeMap.put(HDSConstants.ADD, addOp);
    if (null != ldevIds && !ldevIds.isEmpty()) {
        LDEV metaHeadLDEV = new LDEV(metaHead);
        ldevsList.add(metaHeadLDEV);
        for (String ldevId : ldevIds) {
            LDEV metaMemberLDEV = new LDEV(ldevId);
            ldevsList.add(metaMemberLDEV);
        }
    }
    attributeMap.put("LDEV_List", ldevsList);
    String addLUSEVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_LUSE_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addLUSEVolumeInputXML;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) LDEV(com.emc.storageos.hds.model.LDEV) LinkedList(java.util.LinkedList) StorageArray(com.emc.storageos.hds.model.StorageArray)

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