use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.
the class ExportUtils method createInitiatorTargetRefRep.
/**
* Creates and returns an instance of REST response object.
*
* @param exportGroup the export group the initiator is in
* @param blockObject the block object
* @param hlu the lun id used for the block object by the initiator
* @param initiator the initiator
* @param port the target port
* @param fcZoneReference the record of the SAN zone created on the switch when a zone is created.
* Returns null when zoning is not required or when the zone creation failed.
* @return the export REST response object.
*/
private static ITLRestRep createInitiatorTargetRefRep(ExportGroup exportGroup, BlockObject blockObject, String hlu, Initiator initiator, StoragePort port, FCZoneReference fcZoneReference) {
ITLRestRep rep = new ITLRestRep();
rep.setHlu(Integer.parseInt(hlu));
// Set block object
ITLRestRep.ITLBlockObjectRestRep blockObjectRestRep = new ITLRestRep.ITLBlockObjectRestRep();
blockObjectRestRep.setId(blockObject.getId());
blockObjectRestRep.setLink(new RestLinkRep("self", RestLinkFactory.newLink(blockObject)));
blockObjectRestRep.setWwn(getBlockObjectFormattedWWN(blockObject));
rep.setBlockObject(blockObjectRestRep);
// Set initiator
ITLRestRep.ITLInitiatorRestRep initiatorRestRep = new ITLRestRep.ITLInitiatorRestRep();
initiatorRestRep.setId(initiator.getId());
initiatorRestRep.setLink(new RestLinkRep("self", RestLinkFactory.newLink(initiator)));
initiatorRestRep.setPort(initiator.getInitiatorPort());
rep.setInitiator(initiatorRestRep);
// Set storage port
ITLRestRep.ITLStoragePortRestRep storagePortRestRep = new ITLRestRep.ITLStoragePortRestRep();
if (port != null) {
storagePortRestRep.setId(port.getId());
storagePortRestRep.setLink(new RestLinkRep("self", RestLinkFactory.newLink(port)));
storagePortRestRep.setPort(port.getPortNetworkId());
if (port.getIpAddress() != null) {
storagePortRestRep.setIpAddress(port.getIpAddress());
storagePortRestRep.setTcpPort(String.valueOf(port.getTcpPortNumber()));
}
}
rep.setStoragePort(storagePortRestRep);
// Export
rep.setExport(toNamedRelatedResource(exportGroup, exportGroup.getLabel()));
if (fcZoneReference != null) {
rep.setSanZoneName(fcZoneReference.getZoneName());
}
return rep;
}
use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.
the class ExportUtils method getItlsForMaskInitiator.
/**
* For a volume/snapshot-initiator pair find the target ports for the initiator in the list of
* ports and find the zone name if zoning was performed. Return a list of ITLs for
* each volume-initiator-target found.
*
* @param dbClient db client
* @param exportMask the export mask the initiator is in
* @param initiator the initiator
* @param hlu the lun Id used by the initiator for the volume
* @param blockObject the volume or snapshot
* @param initiatorPorts ports to which the initiator is zoned in the export mask
* @param zoneRefs a map of port-to-zone-reference
* @param exportGroup the export groups in this export mask
* @return all ITLs for a volume/snapshot-initiator pair.
*/
private static List<ITLRestRep> getItlsForMaskInitiator(DbClient dbClient, List<ExportGroup> exportGroups, ExportMask exportMask, Initiator initiator, String hlu, BlockObject blockObject, List<StoragePort> initiatorPorts, Map<StoragePort, List<FCZoneReference>> zoneRefs) {
List<ITLRestRep> list = new ArrayList<ITLRestRep>();
Map<StoragePort, FCZoneReference> initiatorZoneRefs = null;
// Find the block object that would appear in the Export Mask
BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
if (bo != null) {
_log.debug("Finding target ports for initiator {} and block object {}", initiator.getInitiatorPort(), bo.getNativeGuid());
initiatorZoneRefs = getZoneReferences(bo.getId(), initiator, initiatorPorts, zoneRefs);
_log.debug("{} target ports and {} SAN zones were found for initiator {} and block object {}", new Object[] { initiatorPorts.size(), initiatorZoneRefs.size(), initiator.getInitiatorPort(), bo.getNativeGuid() });
// TODO - Should we add special handling of iscsi initiators?
for (ExportGroup exportGroup : exportGroups) {
if (exportGroup.getVolumes() != null && exportGroup.getVolumes().containsKey(blockObject.getId().toString()) && exportGroup.getInitiators() != null && exportGroup.getInitiators().contains(initiator.getId().toString())) {
// We want to check if there are any ports in this export group for this initiator
List<StoragePort> portsInExportGroupVarray = filterPortsInVarray(exportGroup, exportMask.getStorageDevice(), initiatorPorts);
if (!portsInExportGroupVarray.isEmpty()) {
for (StoragePort port : portsInExportGroupVarray) {
list.add(createInitiatorTargetRefRep(exportGroup, blockObject, hlu, initiator, port, initiatorZoneRefs.get(port)));
}
} else {
list.add(createInitiatorTargetRefRep(exportGroup, blockObject, hlu, initiator, null, null));
}
}
}
}
return list;
}
use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.
the class ResourceUtils method getExportMap.
private static Map<ITLRestRep, ExportGroupRestRep> getExportMap(Collection<ITLRestRep> itls) {
Map<URI, ExportGroupRestRep> blockExports = getBlockExports(itls);
Map<ITLRestRep, ExportGroupRestRep> exports = Maps.newLinkedHashMap();
for (ITLRestRep itl : itls) {
URI exportId = id(itl.getExport());
if (exportId != null) {
exports.put(itl, blockExports.get(exportId));
}
}
return exports;
}
use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.
the class VMWareProvider method getVolumeHLUs.
private Map<URI, Integer> getVolumeHLUs(AssetOptionsContext context, List<URI> volumeIds) {
BulkIdParam bulkParam = new BulkIdParam();
Map<URI, Integer> volumeHLUs = Maps.newHashMap();
bulkParam.getIds().addAll(volumeIds);
List<ITLRestRep> bulkResponse = api(context).blockVolumes().getExports(bulkParam).getExportList();
for (ITLRestRep export : bulkResponse) {
volumeHLUs.put(export.getBlockObject().getId(), export.getHlu());
}
return volumeHLUs;
}
use of com.emc.storageos.model.block.export.ITLRestRep in project coprhd-controller by CoprHD.
the class BlockStorageUtils method removeBlockResourcesFromExports.
public static void removeBlockResourcesFromExports(Collection<URI> blockResourceIds) {
Map<URI, Set<URI>> resourcesInExport = Maps.newHashMap();
for (URI blockResourceId : blockResourceIds) {
List<ITLRestRep> exports = getExportsForBlockObject(blockResourceId);
for (ITLRestRep export : exports) {
URI exportId = export.getExport().getId();
if (resourcesInExport.containsKey(exportId)) {
resourcesInExport.get(exportId).add(blockResourceId);
} else {
resourcesInExport.put(exportId, Sets.newHashSet(blockResourceId));
}
}
}
removeBlockResourcesFromExports(resourcesInExport);
}
Aggregations