use of com.emc.storageos.storagedriver.HostExportInfo in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method getStorageObjectExportInfo.
private Map<String, HostExportInfo> getStorageObjectExportInfo(String systemId, String objectId) {
Map<String, HostExportInfo> resultMap = new HashMap<>();
Map<String, List<HostExportInfo>> volumeToHostExportInfoMap = arrayToVolumeToVolumeExportInfoMap.get(systemId);
// get storage object export data
if (volumeToHostExportInfoMap != null) {
List<HostExportInfo> volumeExportInfo = volumeToHostExportInfoMap.get(objectId);
if (volumeExportInfo != null) {
for (HostExportInfo exportInfo : volumeExportInfo) {
resultMap.put(exportInfo.getHostName(), exportInfo);
}
}
}
return resultMap;
}
use of com.emc.storageos.storagedriver.HostExportInfo in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedMasksForVolumes.
/**
* This method processes export info for volumes and returns unmanaged masks to create and existing unmanaged masks to update.
*
* @param storageSystem storage system [IN]
* @param exportInfosForExistingMasks [IN] map: key --- mask uri, value --- volume export info to add to the mask.
* @param exportInfosForNewMasks [IN] list of volume export info for which we need to create new masks.
* @param unManagedVolumeNativeIdToUriMap [IN] map of unmanaged volume native id to unmanaged volume URI
* @param unManagedExportMasksToUpdate [OUT] list of unmanaged export masks to update
* @param unManagedExportMasksToCreate [OUT] list of unmanaged export masks to create
* @param dbClient reference to db client [IN]
*/
private void processUnManagedMasksForVolumes(com.emc.storageos.db.client.model.StorageSystem storageSystem, Map<URI, HostExportInfo> exportInfosForExistingMasks, List<HostExportInfo> exportInfosForNewMasks, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, URI> managedVolumeNativeIdToUriMap, List<UnManagedExportMask> unManagedExportMasksToUpdate, List<UnManagedExportMask> unManagedExportMasksToCreate, DbClient dbClient) {
log.info("Processing unmanaged volumes: {} .", unManagedVolumeNativeIdToUriMap);
// update/create unManaged masks for unManaged volumes
log.info("Processing masks to update: {} .", exportInfosForExistingMasks);
for (Map.Entry<URI, HostExportInfo> entry : exportInfosForExistingMasks.entrySet()) {
URI maskUri = entry.getKey();
HostExportInfo exportInfo = entry.getValue();
Set<String> unManagedVolumesUris = new HashSet<>();
Set<String> managedVolumesUris = new HashSet<>();
List<String> volumesNativeIds = exportInfo.getStorageObjectNativeIds();
for (String volumeNativeId : volumesNativeIds) {
URI volumeUri = unManagedVolumeNativeIdToUriMap.get(volumeNativeId);
if (volumeUri != null) {
unManagedVolumesUris.add(volumeUri.toString());
} else {
volumeUri = managedVolumeNativeIdToUriMap.get(volumeNativeId);
if (volumeUri != null) {
managedVolumesUris.add(volumeUri.toString());
}
}
}
// process unmanaged volumes
UnManagedExportMask unManagedMask = dbClient.queryObject(UnManagedExportMask.class, maskUri);
StringSet unmangedVolumesInMask = unManagedMask.getUnmanagedVolumeUris();
// check for null, since existing mask may only have "known" volumes.
if (unmangedVolumesInMask == null) {
unmangedVolumesInMask = new StringSet();
unManagedMask.setUnmanagedVolumeUris(unmangedVolumesInMask);
}
unmangedVolumesInMask.addAll(unManagedVolumesUris);
// process managed volumes
StringSet managedVolumesInMask = unManagedMask.getKnownVolumeUris();
// check for null, since existing mask may only have unManaged volumes.
if (managedVolumesInMask == null) {
managedVolumesInMask = new StringSet();
unManagedMask.setKnownVolumeUris(managedVolumesInMask);
}
managedVolumesInMask.addAll(managedVolumesUris);
unManagedExportMasksToUpdate.add(unManagedMask);
}
log.info("Processing masks to create: {} .", exportInfosForNewMasks);
for (HostExportInfo hostExportInfo : exportInfosForNewMasks) {
Set<String> unManagedVolumesUris = new HashSet<>();
Set<String> managedVolumesUris = new HashSet<>();
List<String> volumesNativeIds = hostExportInfo.getStorageObjectNativeIds();
for (String volumeNativeId : volumesNativeIds) {
URI volumeUri = unManagedVolumeNativeIdToUriMap.get(volumeNativeId);
if (volumeUri != null) {
unManagedVolumesUris.add(volumeUri.toString());
} else {
volumeUri = managedVolumeNativeIdToUriMap.get(volumeNativeId);
if (volumeUri != null) {
managedVolumesUris.add(volumeUri.toString());
}
}
}
// we will create new unManaged mask for host/array.
UnManagedExportMask newMask = createUnManagedExportMask(storageSystem, hostExportInfo, unManagedVolumesUris, managedVolumesUris, dbClient);
unManagedExportMasksToCreate.add(newMask);
}
}
use of com.emc.storageos.storagedriver.HostExportInfo in project coprhd-controller by CoprHD.
the class HP3PARIngestHelper method getBlockObjectExportInfoForHosts.
public Map<String, HostExportInfo> getBlockObjectExportInfoForHosts(String storageSystemId, String wwn, String objectName, StorageBlockObject object, Registry registry) {
try {
_log.info("3PARDriver: getBlockObjectExportInfoForHosts Running");
Map<String, HostExportInfo> resultMap = new HashMap<String, HostExportInfo>();
// get the vlun associated with the volume at consideration.
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystemId, registry);
VirtualLunsList vlunsOfVolume = hp3parApi.getVLunsOfVolume(wwn);
// Check which of the storage ports discovered, matches the
// node:portpos:cardport
// combination of the VLUN
List<StoragePort> storPortsOfStorage = new ArrayList<>();
hp3parUtil.discoverStoragePortsById(storageSystemId, storPortsOfStorage, registry);
// for (int index = 0; index < vlunsOfVolume.getTotal(); index++) {
for (VirtualLun objVirtualLun : vlunsOfVolume.getMembers()) {
if (!objVirtualLun.isActive()) {
if (objVirtualLun.getType() == 5) {
String exportPath = storageSystemId + objectName + objVirtualLun.getHostname();
_log.info("3PARDriver:Ingestion {} for registry entry", exportPath);
// Make a registry entry for ingested volume if it is
// exported to host set
Map<String, List<String>> attributes = new HashMap<>();
List<String> expValue = new ArrayList<>();
List<String> lunValue = new ArrayList<>();
expValue.add(exportPath);
attributes.put("EXPORT_PATH", expValue);
lunValue.add(objVirtualLun.getLun().toString());
attributes.put(objectName, lunValue);
registry.setDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, exportPath, attributes);
_log.info("3PARDriver:Ingestion {} for attributes entry", attributes);
}
continue;
}
_log.debug("objVirtualLun.toString() {}", objVirtualLun.toString());
List<String> volumeIds = new ArrayList<>();
List<Initiator> initiators = new ArrayList<Initiator>();
List<StoragePort> storageports = new ArrayList<>();
// To volumeIds we need to add the native id of volume
// and for hp3par volume name would be the native id
volumeIds.add(objVirtualLun.getVolumeName());
Initiator hostInitiator = new Initiator();
// hp3par returns remote name in the format like
// 10000000C98F5C79.
// we now convert this to the format 10:00:00:00:C9:8F:5C:79
String portId = SanUtils.formatWWN(objVirtualLun.getRemoteName());
String nativeId = String.format("%s:%s:%s", objVirtualLun.getPortPos().getNode(), objVirtualLun.getPortPos().getSlot(), objVirtualLun.getPortPos().getCardPort());
for (StoragePort port : storPortsOfStorage) {
if (port.getNativeId().equals(nativeId)) {
storageports.add(port);
break;
}
}
hostInitiator.setHostName(objVirtualLun.getHostname());
hostInitiator.setPort(portId);
initiators.add(hostInitiator);
HostExportInfo exportInfo = null;
if (resultMap.containsKey(objVirtualLun.getHostname())) {
exportInfo = resultMap.get(objVirtualLun.getHostname());
for (int i1 = 0; i1 < storageports.size(); i1++) {
StoragePort ob1 = storageports.get(i1);
if (!exportInfo.getTargets().contains(ob1)) {
exportInfo.getTargets().add(ob1);
}
}
for (int i1 = 0; i1 < initiators.size(); i1++) {
Initiator ob1 = initiators.get(i1);
if (!exportInfo.getInitiators().contains(ob1)) {
exportInfo.getInitiators().add(ob1);
}
}
} else {
exportInfo = new HostExportInfo(objVirtualLun.getHostname(), volumeIds, initiators, storageports);
}
resultMap.put(objVirtualLun.getHostname(), exportInfo);
}
_log.info("Resultmap of GetVolumeExportInfo {}", resultMap);
_log.info("3PARDriver: Leaving getBlockObjectExportInfoForHosts");
return resultMap;
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to get export info of the storage objet %s in storage system native id is %s; Error: %s.\n", objectName, storageSystemId, e.getMessage());
_log.error(msg);
e.printStackTrace();
}
return null;
}
use of com.emc.storageos.storagedriver.HostExportInfo in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method generateExportDataForVolumeReplica.
private void generateExportDataForVolumeReplica(StorageVolume volume, StorageBlockObject replica) {
Map<String, List<HostExportInfo>> volumeToExportInfoMap = arrayToVolumeToVolumeExportInfoMap.get(volume.getStorageSystemId());
if (volumeToExportInfoMap != null) {
List<HostExportInfo> volumeExportInfoList = volumeToExportInfoMap.get(volume.getNativeId());
if (volumeExportInfoList != null && !volumeExportInfoList.isEmpty()) {
List<HostExportInfo> replicaExportInfoList = new ArrayList<>();
// build replica export info from info of parent volume
for (HostExportInfo hostExportInfo : volumeExportInfoList) {
List<String> snapIds = new ArrayList<>();
snapIds.add(replica.getNativeId());
List<Initiator> hostInitiators = hostExportInfo.getInitiators();
List<StoragePort> exportPorts = hostExportInfo.getTargets();
HostExportInfo exportInfo = new HostExportInfo(hostExportInfo.getHostName(), snapIds, hostInitiators, exportPorts);
replicaExportInfoList.add(exportInfo);
}
_log.info("Export Info for replica: {} --- {}", replica.getNativeId(), replicaExportInfoList);
volumeToExportInfoMap.put(replica.getNativeId(), replicaExportInfoList);
}
}
}
use of com.emc.storageos.storagedriver.HostExportInfo in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method hasExports.
/**
* Check if block object has exports on device
*
* @param driver storage driver
* @param driverBlockObject driver block object
* @return true/false
*/
private boolean hasExports(BlockStorageDriver driver, StorageBlockObject driverBlockObject) {
Map<String, HostExportInfo> blocObjectToHostExportInfo = null;
// get HostExportInfo data for this block object from the driver
if (driverBlockObject instanceof VolumeClone) {
VolumeClone driverClone = (VolumeClone) driverBlockObject;
blocObjectToHostExportInfo = driver.getCloneExportInfoForHosts(driverClone);
_log.info("Export info for clone {} is {}:", driverClone, blocObjectToHostExportInfo);
} else if (driverBlockObject instanceof VolumeSnapshot) {
VolumeSnapshot driverSnapshot = (VolumeSnapshot) driverBlockObject;
blocObjectToHostExportInfo = driver.getSnapshotExportInfoForHosts(driverSnapshot);
_log.info("Export info for snapshot {} is {}:", driverSnapshot, blocObjectToHostExportInfo);
} else if (driverBlockObject instanceof StorageVolume) {
StorageVolume driverVolume = (StorageVolume) driverBlockObject;
blocObjectToHostExportInfo = driver.getVolumeExportInfoForHosts(driverVolume);
_log.info("Export info for volume {} is {}:", driverVolume, blocObjectToHostExportInfo);
} else {
// not supported type in this method
String errorMsg = String.format("Method is not supported for %s objects.", driverBlockObject.getClass().getSimpleName());
throw new RuntimeException(errorMsg);
}
return !(blocObjectToHostExportInfo == null || blocObjectToHostExportInfo.isEmpty());
}
Aggregations