Search in sources :

Example 6 with HostStorageDomain

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

the class HDSExportOperations method getPartialHSDListToDelete.

/**
 * Returns a list of HostStorageDomain objects created partially from a
 * batch operation.
 *
 * @param allHSDs
 * @param hsdsToCreate
 * @return
 */
private List<HostStorageDomain> getPartialHSDListToDelete(List<HostStorageDomain> allHSDs, List<HostStorageDomain> hsdsToCreate) {
    Collection<String> hsdNickNamesList = Collections2.transform(hsdsToCreate, HDSUtils.fctnHSDToNickName());
    List<HostStorageDomain> partialHSDsCreated = new ArrayList<HostStorageDomain>();
    if (null != allHSDs && !allHSDs.isEmpty()) {
        for (HostStorageDomain hsd : allHSDs) {
            if (hsdNickNamesList.contains(hsd.getNickname())) {
                partialHSDsCreated.add(hsd);
            }
        }
    }
    return partialHSDsCreated;
}
Also used : HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ArrayList(java.util.ArrayList)

Example 7 with HostStorageDomain

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

the class HDSExportOperations method executeBatchHSDAddInitiatorsCommand.

/**
 * This routine will take care of following items.
 * 1. Prepares a batch of HostStorageDomain objects with initiators to add.
 * 2. Executes the batch operation.
 *
 * @param hdsApiClient
 * @param systemObjectID
 * @param createHsdsResponseList
 * @param storagePorts
 * @param initiators
 * @return
 * @throws Exception
 */
private List<HostStorageDomain> executeBatchHSDAddInitiatorsCommand(HDSApiClient hdsApiClient, String systemObjectID, List<HostStorageDomain> createHsdsResponseList, List<StoragePort> storagePorts, List<Initiator> initiators, String model) throws Exception {
    List<HostStorageDomain> fcHsdsToAddInitiators = new ArrayList<HostStorageDomain>();
    List<HostStorageDomain> iSCSIHsdsToAddInitiators = new ArrayList<HostStorageDomain>();
    List<HostStorageDomain> hsdsWithAddIniResponseList = new ArrayList<HostStorageDomain>();
    // Considers the IVR Networks as well.
    Map<URI, Set<String>> networkInitiatorsMap = NetworkUtil.getNetworkToInitiators(dbClient, initiators);
    Map<HostStorageDomain, URI> networkToHsdObjectIdMap = getHostGroupNetworkIdMap(storagePorts, createHsdsResponseList, dbClient);
    log.info("networkInitiatorsMap: {}", networkInitiatorsMap);
    log.info("networkToHsdObjectIdMap :{}", networkToHsdObjectIdMap);
    // Step 2: Add initiators to all HSD's using batch operation
    for (Entry<HostStorageDomain, URI> hsdNetworkEntry : networkToHsdObjectIdMap.entrySet()) {
        HostStorageDomain hsd = hsdNetworkEntry.getKey();
        log.info("Processing hsd: {}", hsd.getObjectID());
        HostStorageDomain hsdToAddInitiators = new HostStorageDomain(hsdNetworkEntry.getKey());
        Set<String> initiatorsOnSameNetwork = networkInitiatorsMap.get(hsdNetworkEntry.getValue());
        // Get the initiators part of the storagePort's Network
        List<String> formattedInitiators = getFormattedInitiators(initiatorsOnSameNetwork);
        if (hsd.getDomainType().equalsIgnoreCase(HDSConstants.HOST_GROUP_DOMAIN_TYPE)) {
            List<WorldWideName> wwnList = new ArrayList<WorldWideName>(Collections2.transform(formattedInitiators, HDSUtils.fctnPortWWNToWorldWideName()));
            hsdToAddInitiators.setWwnList(wwnList);
            fcHsdsToAddInitiators.add(hsdToAddInitiators);
        }
        if (hsd.getDomainType().equalsIgnoreCase(HDSConstants.ISCSI_TARGET_DOMAIN_TYPE)) {
            List<ISCSIName> iscsiNameList = new ArrayList<ISCSIName>(Collections2.transform(formattedInitiators, HDSUtils.fctnPortNameToISCSIName()));
            hsdToAddInitiators.setIscsiList(iscsiNameList);
            iSCSIHsdsToAddInitiators.add(hsdToAddInitiators);
        }
    }
    if (!fcHsdsToAddInitiators.isEmpty()) {
        hsdsWithAddIniResponseList.addAll(hdsApiClient.getHDSBatchApiExportManager().addWWNsToHostStorageDomain(systemObjectID, fcHsdsToAddInitiators, model));
    }
    if (!iSCSIHsdsToAddInitiators.isEmpty()) {
        hsdsWithAddIniResponseList.addAll(hdsApiClient.getHDSBatchApiExportManager().addISCSINamesToHostStorageDomain(systemObjectID, iSCSIHsdsToAddInitiators, model));
    }
    if (null == hsdsWithAddIniResponseList || hsdsWithAddIniResponseList.isEmpty()) {
        log.error("Batch add initiators to HSD creation failed. Aborting operation...");
        throw HDSException.exceptions.notAbleToAddInitiatorsToHostStorageDomain(systemObjectID);
    }
    return hsdsWithAddIniResponseList;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) ISCSIName(com.emc.storageos.hds.model.ISCSIName) URI(java.net.URI) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Example 8 with HostStorageDomain

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

the class HDSExportOperations method updateExportMaskDetailInDB.

/**
 * Updates ExportMask details like volumes, HSD's & target port details in DB.
 *
 * @param hsdsWithInitiators
 *            : HSD's create successfully.
 * @param allHSDPaths
 *            : Volume LunPaths added successfully.
 * @param exportMask
 *            : ExportMask db object.
 * @param storage
 *            : StorageSystem db object.
 * @param volumeURIHLUs
 *            : volume-lun details.
 */
private void updateExportMaskDetailInDB(List<HostStorageDomain> hsdsWithInitiators, List<Path> allHSDPaths, ExportMask exportMask, StorageSystem storage, VolumeURIHLU[] volumeURIHLUs) {
    StringSetMap deviceDataMap = new StringSetMap();
    for (HostStorageDomain hsd : hsdsWithInitiators) {
        StringSet targetPortSet = new StringSet();
        List<String> hsdPorts = Arrays.asList(hsd.getPortID());
        List<String> targetPortURIs = getStoragePortURIs(hsdPorts, storage);
        targetPortSet.addAll(targetPortURIs);
        deviceDataMap.put(hsd.getObjectID(), targetPortSet);
    }
    exportMask.addDeviceDataMap(deviceDataMap);
    updateVolumeHLUInfo(volumeURIHLUs, allHSDPaths, exportMask);
    dbClient.updateObject(exportMask);
    log.info("ExportMask: {} details updated successfully.", exportMask.getId());
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 9 with HostStorageDomain

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

the class HDSApiExportManager method getHostStorageDomain.

/**
 * Return the existing HSD's configured on the storage array.
 *
 * @param systemId
 * @param type
 * @return
 * @throws Exception
 */
public HostStorageDomain getHostStorageDomain(String systemId, String hsdId) throws Exception {
    InputStream responseStream = null;
    HostStorageDomain hsd = 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 inputHsd = new HostStorageDomain(hsdId);
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
        String getHSDQuery = 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: {}", getHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, getHSDQuery);
        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);
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query 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 : ClientResponse(com.sun.jersey.api.client.ClientResponse) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) 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 10 with HostStorageDomain

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

the class HDSApiExportManager method deleteHostStorageDomain.

/**
 * Delete the Host Storage Domain for a given storage array.
 *
 * @param systemObjectId
 * @param hsdObjectId
 * @param model
 * @throws Exception
 */
public void deleteHostStorageDomain(String systemObjectId, String hsdObjectId, String model) throws Exception {
    InputStream responseStream = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray array = new StorageArray(systemObjectId);
        Delete deleteOp = new Delete(HDSConstants.HOST_STORAGE_DOMAIN);
        attributeMap.put(HDSConstants.STORAGEARRAY, array);
        attributeMap.put(HDSConstants.DELETE, deleteOp);
        attributeMap.put(HDSConstants.MODEL, model);
        HostStorageDomain inputHsd = new HostStorageDomain(hsdObjectId);
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
        String deleteHSDFromSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_HSD_FROM_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to delete HostStorageDomain: {}", deleteHSDFromSystemQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, deleteHSDFromSystemQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            log.info("Deleted HSD {} from system {}", hsdObjectId, systemObjectId);
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete 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");
            }
        }
    }
}
Also used : Delete(com.emc.storageos.hds.model.Delete) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

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