use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class NetworkScheduler method generateFullZoningMap.
/**
* Generates a zoning map that maps all initiators to all ports on the same Network.
*
* @param varrayURI - the ExportGroup varray
* @param mask - the Export Mask
* @param initiators - List of Initiators to be zoned
*/
public static void generateFullZoningMap(DbClient dbClient, URI varrayURI, ExportMask mask, Collection<Initiator> initiators) {
boolean changed = false;
Set<StoragePort> storagePorts = ExportMaskUtils.getPortsForExportMask(dbClient, mask, Transport.FC);
for (Initiator initiator : initiators) {
if (mask.getZoningMap() == null || mask.getZoningMap().get(initiator.getId().toString()) == null) {
_log.info(String.format("No zoning map entry for initiator %s (%s), will zone to all ports", initiator.getInitiatorPort(), initiator.getId()));
List<URI> targetPorts = findInitiatorTargetsInVarray(dbClient, varrayURI, initiator, storagePorts);
if (!targetPorts.isEmpty()) {
changed = true;
mask.addZoningMapEntry(initiator.getId().toString(), StringSetUtil.uriListToStringSet(targetPorts));
}
}
}
if (changed) {
// Update the mask to save the zoningMap entries.
dbClient.updateObject(mask);
}
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ConnectivityUtil method getStoragePortsOfTypeAndVArray.
/**
* Retrieve all the storage ports of a given StorageSystem and type in a Map by Network URI.
*
* @param storage -- StorageSystem URI
* @param type -- frontend or backend (note normal array ports are frontend).
* @param varrayURI -- URI of varray that must be in port's tagged varrays
* @return Map<URI, List<StoragePort>> -- A map of the Network URI the Storage Ports in that Network
*/
public static Map<URI, List<StoragePort>> getStoragePortsOfTypeAndVArray(DbClient dbClient, URI storage, StoragePort.PortType type, URI varrayURI) {
String varray = varrayURI.toString();
Map<URI, List<StoragePort>> netURIToStoragePortsMap = getStoragePortsOfType(dbClient, storage, type);
// Filter out any ports that do not include the varray in their tagged list
Set<URI> networks = new HashSet<URI>(netURIToStoragePortsMap.keySet());
for (URI network : networks) {
List<StoragePort> ports = netURIToStoragePortsMap.get(network);
List<StoragePort> filteredPorts = new ArrayList<StoragePort>();
for (StoragePort port : ports) {
if (port.getTaggedVirtualArrays() != null && port.getTaggedVirtualArrays().contains(varray)) {
filteredPorts.add(port);
}
}
// remove a network entry if no remaining ports in that network
if (!filteredPorts.isEmpty()) {
netURIToStoragePortsMap.put(network, filteredPorts);
} else {
netURIToStoragePortsMap.remove(network);
}
}
return netURIToStoragePortsMap;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ConnectivityUtil method getStoragePortsForSystem.
/**
* Retrieve all the storage ports of a given StorageSystem and type.
*
* @param storage -- StorageSystem URI
* @return List<StoragePort> -- A list of the the Storage Ports in that Network
*/
public static List<StoragePort> getStoragePortsForSystem(DbClient dbClient, URI storage) {
List<StoragePort> ports = new ArrayList<StoragePort>();
URIQueryResultList storagePortURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(storage), storagePortURIs);
Iterator<URI> storagePortsIter = storagePortURIs.iterator();
while (storagePortsIter.hasNext()) {
URI portURI = storagePortsIter.next();
StoragePort port = dbClient.queryObject(StoragePort.class, portURI);
if (port == null || port.getInactive() == true) {
continue;
}
if (!DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name().equals(port.getCompatibilityStatus())) {
continue;
}
if (false == port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name())) {
continue;
}
if (!DiscoveryStatus.VISIBLE.name().equals(port.getDiscoveryStatus())) {
continue;
}
ports.add(port);
}
return ports;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ConnectivityUtil method findAllVirtualArraysForRPSiteArray.
/**
* Find all the associated VSA URIs for the passed in RPSiteArray
*
* @param dbClient
* @param siteArray
* @param ids virtual array ids collected
* @return void
*/
private static void findAllVirtualArraysForRPSiteArray(DbClient dbClient, RPSiteArray siteArray, Collection<URI> ids) {
if (siteArray != null) {
// Find all the Storage Pools associated to this RPSiteArray
URIQueryResultList storagePoolURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(siteArray.getStorageSystem()), storagePoolURIs);
Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
while (storagePoolIter.hasNext()) {
URI storagePoolURI = storagePoolIter.next();
StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
// For each Storage Pool get all the connected VSAs
if (storagePool != null && !storagePool.getInactive() && storagePool.getConnectedVirtualArrays() != null) {
for (String vArrayId : storagePool.getConnectedVirtualArrays()) {
ids.add(URI.create(vArrayId));
}
}
}
// If the rpsite array storage system is vplex check virtual array
// connectivity to rpsite using front end storage ports
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, siteArray.getStorageSystem());
if (storageSystem != null && isAVPlex(storageSystem)) {
Map<URI, List<StoragePort>> storagePortMap = ConnectivityUtil.getStoragePortsOfType(dbClient, storageSystem.getId(), PortType.frontend);
for (Map.Entry<URI, List<StoragePort>> storagePortEntry : storagePortMap.entrySet()) {
for (StoragePort storagePort : storagePortEntry.getValue()) {
// For each Storage Port get all the connected VSAs
if (storagePort.getConnectedVirtualArrays() != null && !storagePort.getConnectedVirtualArrays().isEmpty() && !ids.containsAll(URIUtil.toURIList(storagePort.getConnectedVirtualArrays()))) {
_log.info(String.format("Vplex System [%s] has connectvity to RP Site [%s]", storageSystem.getLabel(), siteArray.getRpSiteName()));
ids.addAll(URIUtil.toURIList(storagePort.getConnectedVirtualArrays()));
}
if (storagePort.getAssignedVirtualArrays() != null && !storagePort.getAssignedVirtualArrays().isEmpty() && !ids.containsAll(URIUtil.toURIList(storagePort.getAssignedVirtualArrays()))) {
_log.info(String.format("Vplex System [%s] has connectvity to RP Site [%s]", storageSystem.getLabel(), siteArray.getRpSiteName()));
ids.addAll(URIUtil.toURIList(storagePort.getAssignedVirtualArrays()));
}
}
}
}
}
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ConnectivityUtil method getVplexClusterForVarray.
/**
* This method returns the VPLEX cluster information for the virtual array. The assumption here is that the passed
* varrayURI will not have ports from both VPLEX clusters. This is true when its called for the varray
* which has VPLEX volume created on it. Until VPLEX volume create is attempted on the varray we cannot use this
* method as user can just assign the network and varray could get ports from both the VPLEX clusters
*
* @param varrayURI The URI of the virtaul array
* @param vplexStorageSystemURI The URI of the VPLEX storage system
* @param dbClient dbclient
* @return "1" or "2". Returns "unknown-cluster" if error.
*
* TODO: Move this method to VPlexUtil
*/
public static String getVplexClusterForVarray(URI varrayURI, URI vplexStorageSystemURI, DbClient dbClient) {
String vplexCluster = CLUSTER_UNKNOWN;
URIQueryResultList storagePortURIs = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(varrayURI.toString()), storagePortURIs);
for (URI uri : storagePortURIs) {
StoragePort storagePort = dbClient.queryObject(StoragePort.class, uri);
if ((storagePort != null) && DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name().equals(storagePort.getCompatibilityStatus()) && (RegistrationStatus.REGISTERED.toString().equals(storagePort.getRegistrationStatus())) && DiscoveryStatus.VISIBLE.toString().equals(storagePort.getDiscoveryStatus())) {
if (storagePort.getStorageDevice().equals(vplexStorageSystemURI)) {
// Assumption is this varray cannot have mix of CLuster 1
// and Cluster 2 ports from VPLEX so getting
// cluster information from one of the VPLEX port should
// work.
vplexCluster = getVplexClusterOfPort(storagePort);
break;
}
}
}
return vplexCluster;
}
Aggregations