use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class StoragePoolAssociationHelper method getSystemPorts.
private static List<StoragePort> getSystemPorts(URI systemUri, DbClient dbClient) {
List<StoragePort> ports = new ArrayList<StoragePort>();
URIQueryResultList storagePortURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(systemUri), storagePortURIs);
Iterator<URI> storagePortURIsIter = storagePortURIs.iterator();
while (storagePortURIsIter.hasNext()) {
URI storagePortURI = storagePortURIsIter.next();
StoragePort storagePort = dbClient.queryObject(StoragePort.class, storagePortURI);
if (storagePort != null && !storagePort.getInactive()) {
ports.add(storagePort);
} else {
_log.error("Can't find storage port {} in the database " + "or the port is marked for deletion", storagePortURI);
}
}
return ports;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method runUpdatePortAssociationsProcess.
/**
* This method is responsible for
* 1. Update pools to virtual arrays & system to virtual arrays in vplex case
* 2. Run implicit Pool Matcher
* 3. Run RP Connectivity Process
*
* @param ports
* @param remPorts
* @param dbClient
* @param coordinator
* @throws IOException
*/
public static void runUpdatePortAssociationsProcess(Collection<StoragePort> ports, Collection<StoragePort> remPorts, DbClient dbClient, CoordinatorClient coordinator, List<StoragePool> pools) {
try {
if (null == pools) {
pools = new ArrayList<StoragePool>();
}
if (null == ports) {
ports = new ArrayList<StoragePort>();
}
if (null != remPorts) {
ports.addAll(remPorts);
}
// for better reading, added a method to group Ports by Network
Map<NetworkLite, List<StoragePort>> portsByNetwork = groupPortsByNetwork(ports, dbClient);
if (!portsByNetwork.isEmpty()) {
updatePortAssociations(ports, portsByNetwork, dbClient);
// if any ports are associated with network, then add pools to existing list and run matching pools
Set<URI> poolUris = getStoragePoolIds(pools);
List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(dbClient, ports, remPorts);
for (StoragePool pool : modifiedPools) {
if (!poolUris.contains(pool.getId())) {
pools.add(pool);
}
}
}
StringBuffer errorMessage = new StringBuffer();
// Match the VPools to the StoragePools
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(pools, dbClient, coordinator, errorMessage);
// get all the system that were affected and update their virtual
// arrays
HashSet<URI> systemsToProcess = StoragePoolAssociationHelper.getStorageSytemsFromPorts(ports, remPorts);
// Now that pools have changed varrays, we need to update RP systems
ConnectivityUtil.updateRpSystemsConnectivity(systemsToProcess, dbClient);
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method getVArraysWithChangedConnectivityToStorageSystem.
/**
* This method finds varrays which change connection (either are newly connected or lost old connection) to storage
* system of the passed port parameter.
*
* @param port storage port for which varrays were added/removed
* @param varraysToAddIds set of added varrays to port
* @param varraysToRemoveIds set of removed varrays from port
* @param dbClient
* @return set of varrays which changed connection to port's storage system
*/
private static Set<String> getVArraysWithChangedConnectivityToStorageSystem(StoragePort port, Set<String> varraysToAddIds, Set<String> varraysToRemoveIds, DbClient dbClient) {
// This is our storage system.
URI storageSystemURI = port.getStorageDevice();
_log.info("Port {} belongs to storage system {}", port.getId(), storageSystemURI);
// Set of varrays which changed connection to the storage system.
Set<String> varraysWithChangedConnectivity = new HashSet<>();
// For these varrays there is no connection change to the storage system.
if (varraysToAddIds != null && !varraysToAddIds.isEmpty()) {
_log.info("New varrays {} added to the port {}", varraysToAddIds, port.getId());
Set<String> varraysToAddWithChangedConnectivity = new HashSet<>(varraysToAddIds);
for (String varrayId : varraysToAddIds) {
URIQueryResultList storagePortURIs = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(varrayId), storagePortURIs);
for (URI portURI : storagePortURIs) {
// If this is the same port as was added to varray in the change request, skip and continue
if (port.getId().equals(portURI)) {
continue;
}
StoragePort varrayPort = (StoragePort) dbClient.queryObject(portURI);
if (!NullColumnValueGetter.isNullURI(varrayPort.getStorageDevice()) && storageSystemURI.equals(varrayPort.getStorageDevice())) {
// This varray port belongs to our storage system
// At least one other port from our storage system belongs to varray.
// Addition of a new port to this varray does not change connection between our storage
// system and varray.
// We can stop here processing varray ports.
varraysToAddWithChangedConnectivity.remove(varrayId);
_log.info("Varray {} already has connection to storage system {} through port {}", varrayId, storageSystemURI, portURI);
break;
}
}
}
_log.info("New varrays connected to storage system {} are {}", storageSystemURI, varraysToAddWithChangedConnectivity);
varraysWithChangedConnectivity.addAll(varraysToAddWithChangedConnectivity);
}
// the varray.
if (varraysToRemoveIds != null && !varraysToRemoveIds.isEmpty()) {
_log.info("Varrays {} are removed from the port {}", varraysToRemoveIds, port.getId());
Set<String> varraysToRemoveWithChangedConnectivity = new HashSet<>(varraysToRemoveIds);
for (String varrayId : varraysToRemoveIds) {
URIQueryResultList storagePortURIs = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(varrayId), storagePortURIs);
for (URI portURI : storagePortURIs) {
StoragePort varrayPort = (StoragePort) dbClient.queryObject(portURI);
if (!NullColumnValueGetter.isNullURI(varrayPort.getStorageDevice()) && storageSystemURI.equals(varrayPort.getStorageDevice())) {
// This varray port belongs to our storage system
_log.info("Varray {} has connection to storage system {} through port {}", varrayId, storageSystemURI, portURI);
// There is other port from our storage system which belongs to varray.
// We can stop here processing varray ports.
varraysToRemoveWithChangedConnectivity.remove(varrayId);
break;
}
}
}
_log.info("Varrays which lost connection to storage system {} are {}", storageSystemURI, varraysToRemoveWithChangedConnectivity);
varraysWithChangedConnectivity.addAll(varraysToRemoveWithChangedConnectivity);
}
_log.info("Varrays with changed connection to storage system {} are {}", storageSystemURI, varraysWithChangedConnectivity);
return varraysWithChangedConnectivity;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method getVNasNetworksMap.
/**
* Gets the networks of the virtual nas and organized in a map.
* This code assumes that an end point exists in one and only one network.
*
* @param sports the ports
* @param dbClient an instance of {@link DbClient}
* @return a map of networks and the virtual nas that are associated to them.
*/
private static Map<String, List<NetworkLite>> getVNasNetworksMap(Collection<StoragePort> sports, DbClient dbClient) {
Map<String, List<NetworkLite>> vNasNetwork = new HashMap<>();
NetworkLite network;
List<VirtualNAS> vNasList = null;
List<NetworkLite> list = null;
for (StoragePort sport : sports) {
if (TransportType.IP.name().equalsIgnoreCase(sport.getTransportType())) {
StorageSystem system = dbClient.queryObject(StorageSystem.class, sport.getStorageDevice());
if (DiscoveredDataObject.Type.vnxfile.name().equals(system.getSystemType()) || DiscoveredDataObject.Type.isilon.name().equals(system.getSystemType()) || DiscoveredDataObject.Type.unity.name().equals(system.getSystemType())) {
network = NetworkUtil.getEndpointNetworkLite(sport.getPortNetworkId(), dbClient);
vNasList = getStoragePortVirtualNAS(sport, dbClient);
if (network != null && network.getInactive() == false && network.getTransportType().equals(sport.getTransportType()) && vNasList != null && !vNasList.isEmpty()) {
for (VirtualNAS vNas : vNasList) {
list = vNasNetwork.get(vNas.getNativeGuid());
if (list == null) {
list = new ArrayList<NetworkLite>();
vNasNetwork.put(vNas.getNativeGuid(), list);
}
list.add(network);
}
}
}
}
}
return vNasNetwork;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method maskHasStoragePortsInExportVarray.
/**
* Routine validates if the ExportMask has StoragePorts that point to the same
* VArray as the ExportGroup's and that the Network associated with the StoragePorts
* matches those of the initiator.
*
* @param exportGroup
* [in] - ExportGroup object
* @param mask
* [in] - ExportMask object
* @param initiator
* [in] - Initiator object to validate
* @param storagePortToNetwork
* [out] - will populate the map with StoragePort.name to Network.Name
* @return true --> iff the ExportMask has viable StoragePorts that are associated to the ExportGroup's
* VArray and it matches the export path parameters of the ExportGroup
*/
private boolean maskHasStoragePortsInExportVarray(ExportGroup exportGroup, ExportMask mask, Initiator initiator, Map<String, String> storagePortToNetwork) {
boolean isMatched = false;
SetMultimap<URI, URI> initiatorToMatchedSP = TreeMultimap.create();
if (mask.getStoragePorts() != null) {
VirtualArray virtualArray = _dbClient.queryObject(VirtualArray.class, exportGroup.getVirtualArray());
// Look up the Initiator's network
NetworkLite initiatorNetwork = BlockStorageScheduler.lookupNetworkLite(_dbClient, StorageProtocol.block2Transport(initiator.getProtocol()), initiator.getInitiatorPort());
if (initiatorNetwork == null) {
_log.info(String.format("maskHasStoragePortsInExportVarray - Initiator %s is not in any network, returning false", initiator.getInitiatorPort()));
return false;
}
for (String uriString : mask.getStoragePorts()) {
URI uri = URI.create(uriString);
StoragePort port = _dbClient.queryObject(StoragePort.class, uri);
// Basic validation of the StoragePort
if (port == null || port.getInactive()) {
_log.info(String.format("maskHasStoragePortsInExportVarray - Could not find port or it is inactive %s", uri.toString()));
continue;
}
// StoragePort needs to be in the REGISTERED and VISIBLE status
if (!port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name()) || port.getDiscoveryStatus().equals(DiscoveryStatus.NOTVISIBLE.name())) {
_log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not registered or not visible", port.getPortName(), uri.toString()));
continue;
}
// Look up the StoragePort's network
NetworkLite storagePortNetwork = BlockStorageScheduler.lookupNetworkLite(_dbClient, StorageProtocol.Transport.valueOf(port.getTransportType()), port.getPortNetworkId());
if (storagePortNetwork == null) {
_log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not associated with any network", port.getPortName(), uri.toString()));
storagePortToNetwork.put(port.getPortName(), UNASSOCIATED);
continue;
}
// Keep track of the StoragePort's network name
storagePortToNetwork.put(port.getPortName(), storagePortNetwork.getLabel());
// Port must belong to the VArray of the ExportGroup
if (!port.taggedToVirtualArray(exportGroup.getVirtualArray())) {
_log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not tagged to VArray %s (%s)", port.getPortName(), uri.toString(), virtualArray.getLabel(), exportGroup.getVirtualArray().toString()));
// reverted the fix, as the probability of Consistent lun violation will be more.
continue;
}
// Check if the StoragePort and Initiator point to the same Network
if (storagePortNetwork.connectedToNetwork(initiatorNetwork.getId())) {
_log.info(String.format("maskHasStoragePortsInExportVarray - StoragePort matches: VArray=%s (%s), StoragePort=%s, Network=%s, Initiator=%s", virtualArray.getLabel(), exportGroup.getVirtualArray().toString(), port.getPortName(), storagePortNetwork.getLabel(), initiator.getInitiatorPort()));
}
// Got here, so we can update the list of initiators to list of StoragePorts
// that show a relationship through the Network and the VArray
initiatorToMatchedSP.put(initiator.getId(), port.getId());
}
}
// Validate that the ExportMask is a positive match based on the StoragePorts
// that it references and the ExportGroups path parameters.
Set<URI> matchedSPs = initiatorToMatchedSP.get(initiator.getId());
isMatched = (matchedSPs != null && !matchedSPs.isEmpty());
_log.info(String.format("maskHasStoragePortsInExportVarray - Returning %s", isMatched));
return isMatched;
}
Aggregations