Search in sources :

Example 11 with Path

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

the class HDSExportOperations method addVolumes.

@Override
public void addVolumes(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} addVolumes START...", storage.getSerialNumber());
    HDSApiClient hdsApiClient = null;
    String systemObjectID = null;
    try {
        log.info("addVolumes: Export mask id: {}", exportMaskURI);
        log.info("addVolumes: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
        if (initiatorList != null) {
            log.info("addVolumes: initiators impacted: {}", Joiner.on(',').join(initiatorList));
        }
        hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
        systemObjectID = HDSUtils.getSystemObjectID(storage);
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
        Set<String> hsdList = deviceDataMap.keySet();
        if (null == hsdList || hsdList.isEmpty()) {
            throw HDSException.exceptions.notAbleToFindHostStorageDomain(systemObjectID);
        }
        if (null != exportMask && !exportMask.getInactive() && !hsdList.isEmpty()) {
            List<Path> pathList = new ArrayList<Path>();
            for (String hsdObjectID : hsdList) {
                // Query the provider to see whether the HSD exists or not.
                HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectID);
                if (null != hsd) {
                    Map<String, String> volumeLunMap = getVolumeLunMap(systemObjectID, hsd.getObjectID(), volumeURIHLUs, exportMgr);
                    for (Map.Entry<String, String> entry : volumeLunMap.entrySet()) {
                        if (!checkIfVolumeAlreadyExistsOnHSD(entry.getKey(), hsd)) {
                            Path path = new Path(hsd.getPortID(), hsd.getDomainID(), null, entry.getValue(), entry.getKey());
                            pathList.add(path);
                        }
                    }
                }
            }
            if (!pathList.isEmpty()) {
                List<Path> pathResponseList = hdsApiClient.getHDSBatchApiExportManager().addLUNPathsToHSDs(systemObjectID, pathList, storage.getModel());
                if (null != pathResponseList && !pathResponseList.isEmpty()) {
                    // update volume-lun relationship to exportmask.
                    updateVolumeHLUInfo(volumeURIHLUs, pathResponseList, exportMask);
                    dbClient.updateObject(exportMask);
                } else {
                    log.error(String.format("addVolumes failed - maskURI: %s", exportMaskURI.toString()), new Exception("Not able to parse the response of addLUN from server"));
                    ServiceError serviceError = DeviceControllerException.errors.jobFailedOpMsg(ResourceOperationTypeEnum.ADD_EXPORT_VOLUME.getName(), "Not able to parse the response of addLUN from server");
                    taskCompleter.error(dbClient, serviceError);
                    return;
                }
            } else {
                log.info("All the volumes are already part of the HSDs.");
            }
            taskCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error(String.format("addVolumes failed - maskURI: %s", exportMaskURI.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} addVolumes END...", storage.getSerialNumber());
}
Also used : Path(com.emc.storageos.hds.model.Path) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap)

Example 12 with Path

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

the class HDSApiExportManager method constructDeleteLunPathsQuery.

/**
 * 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 lunPathObjectIdList
 * @return
 */
private String constructDeleteLunPathsQuery(String systemId, List<String> lunPathObjectIdList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<Path> pathList = new ArrayList<Path>();
    StorageArray array = new StorageArray(systemId);
    Delete deleteOp = new Delete(HDSConstants.LUN_TARGET);
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.MODEL, model);
    attributeMap.put(HDSConstants.DELETE, deleteOp);
    if (null != lunPathObjectIdList && !lunPathObjectIdList.isEmpty()) {
        for (String pathObjectId : lunPathObjectIdList) {
            Path path = new Path(pathObjectId);
            pathList.add(path);
        }
    }
    attributeMap.put(HDSConstants.PATH_LIST, pathList);
    String deleteLunInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_PATH_FROM_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return deleteLunInputXML;
}
Also used : Path(com.emc.storageos.hds.model.Path) Delete(com.emc.storageos.hds.model.Delete) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 13 with Path

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

the class HDSBatchApiExportManager method addLUNPathsToHSDs.

/**
 * This method makes a HTTP POST call to add multiple LUN Paths using a
 * batch query.
 *
 * @param systemId
 *            - Represents the storage system objectID.
 * @param pathList
 *            - List of Path objects.
 * @param model - model of the system
 * @return - List of Path objects after successful creation.
 * @throws Exception
 *             - Incase of processing Error.
 */
public List<Path> addLUNPathsToHSDs(String systemId, List<Path> pathList, String model) throws Exception {
    InputStream responseStream = null;
    List<Path> pathResponseList = null;
    try {
        String addLUNQuery = constructAddLUNQuery(systemId, 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);
            pathResponseList = (List<Path>) javaResult.getBean(HDSConstants.PATHLIST_RESPONSE_BEANID);
            if (null == pathResponseList || pathResponseList.isEmpty()) {
                throw HDSException.exceptions.notAbleToAddVolumeToHSD(null, 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 pathResponseList;
}
Also used : Path(com.emc.storageos.hds.model.Path) ClientResponse(com.sun.jersey.api.client.ClientResponse) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 14 with Path

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

the class HDSProtectionOperations method getDummyHSDPathId.

/**
 * Get Dummy Lun Path's path objectID
 *
 * @param storageSystem
 * @param volume
 * @return
 * @throws Exception
 */
private String getDummyHSDPathId(StorageSystem storageSystem, BlockObject blockObj) throws Exception {
    String dummyLunPathId = null;
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    List<HostStorageDomain> hsdList = apiExportManager.getHostStorageDomains(systemObjectId);
    if (hsdList != null) {
        for (HostStorageDomain hsd : hsdList) {
            if (hsd != null && HDSConstants.DUMMY_HSD.equalsIgnoreCase(hsd.getNickname())) {
                if (hsd.getPathList() != null) {
                    for (Path path : hsd.getPathList()) {
                        if (path.getDevNum().equalsIgnoreCase(blockObj.getNativeId())) {
                            dummyLunPathId = path.getObjectID();
                            log.info("Found secondary volume's dummy lun path id :{}", dummyLunPathId);
                            return dummyLunPathId;
                        }
                    }
                }
            }
        }
    }
    log.info("Dummy lun path has been removed already for this secondary volume");
    return dummyLunPathId;
}
Also used : Path(com.emc.storageos.hds.model.Path) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager)

Example 15 with Path

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

the class HDSUtils method getVolumesFromHSD.

/**
 * Return a map[deviceId] => lun from the give HostStorageDomain.
 *
 * @param hsd
 * @return
 */
public static Map<String, Integer> getVolumesFromHSD(HostStorageDomain hsd, StorageSystem storage) {
    Map<String, Integer> volumesFromHSD = new HashMap<String, Integer>();
    List<Path> pathList = hsd.getPathList();
    if (null != pathList) {
        for (Path path : pathList) {
            String volumeWWN = generateHitachiVolumeWWN(storage, path.getDevNum());
            volumesFromHSD.put(volumeWWN, Integer.valueOf(path.getLun()));
        }
    }
    return volumesFromHSD;
}
Also used : Path(com.emc.storageos.hds.model.Path) HashMap(java.util.HashMap)

Aggregations

Path (com.emc.storageos.hds.model.Path)15 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)6 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)5 URI (java.net.URI)5 ExportMask (com.emc.storageos.db.client.model.ExportMask)4 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 HDSException (com.emc.storageos.hds.HDSException)4 HDSApiExportManager (com.emc.storageos.hds.api.HDSApiExportManager)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 StorageArray (com.emc.storageos.hds.model.StorageArray)2 VolumeURIHLU (com.emc.storageos.volumecontroller.impl.VolumeURIHLU)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2