use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method runUpdateVirtualNasAssociationsProcess.
/**
* This method is responsible for
* Assign the virtual arrays of storage port to virtual nas
*
* @param ports
* @param remPorts
* @param dbClient
* @param coordinator
* @throws IOException
*/
public static void runUpdateVirtualNasAssociationsProcess(Collection<StoragePort> ports, Collection<StoragePort> remPorts, DbClient dbClient) {
try {
List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
if (ports != null && !ports.isEmpty()) {
// for better reading, added a method to group Ports by Network
Map<String, List<NetworkLite>> vNasNetworkMap = getVNasNetworksMap(ports, dbClient);
if (!vNasNetworkMap.isEmpty()) {
for (Map.Entry<String, List<NetworkLite>> vNasEntry : vNasNetworkMap.entrySet()) {
String nativeId = vNasEntry.getKey();
VirtualNAS vNas = findvNasByNativeId(nativeId, dbClient);
if (vNas != null) {
for (NetworkLite network : vNasEntry.getValue()) {
Set<String> varraySet = new HashSet<String>(network.getAssignedVirtualArrays());
if (vNas.getAssignedVirtualArrays() == null) {
vNas.setAssignedVirtualArrays(new StringSet());
}
vNas.getAssignedVirtualArrays().addAll(varraySet);
_log.info("found virtual NAS: {} and varrays: {}", vNas.getNasName(), varraySet.toString());
}
modifiedServers.add(vNas);
}
}
}
}
if (!modifiedServers.isEmpty()) {
dbClient.persistObject(modifiedServers);
}
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
use of com.emc.storageos.util.NetworkLite 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.util.NetworkLite 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;
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method maskHasStoragePortsInExportVarray.
/**
* Check that export mask has at least one valid port from virtual array
*
* @param virtualArray
* @param mask
* @return
*/
protected boolean maskHasStoragePortsInExportVarray(VirtualArray virtualArray, ExportMask mask) {
boolean isMatched = 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()));
continue;
}
// Port must belong to the VArray
if (!port.taggedToVirtualArray(virtualArray.getId())) {
_log.info(String.format("maskHasStoragePortsInExportVarray - Port %s (%s) is not tagged to VArray %s (%s)", port.getPortName(), uri.toString(), virtualArray.getLabel(), virtualArray.getId()));
// reverted the fix, as the probability of Consistent lun violation will be more.
continue;
}
// at least one port is in virtualArray
isMatched = true;
break;
}
return isMatched;
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method getEndpointNetworks.
/**
* This is function is used at the time an 'add zone' request is received when we need
* to decide if the zone request requires creating an LSAN zone or a regular zone. For
* each member find the network the member is in. Note, zones can be created for WWNs
* that are not logged into the switch, or for aliases. In this case, we assume only
* regular zones will be created.
*
* @param zone the zone to be added.
* @return A map of zoneMember-to-network
*/
private Map<ZoneMember, NetworkLite> getEndpointNetworks(Zone zone, String fabricId, String fabricWwn) {
NetworkLite network = NetworkUtil.getNetworkLiteByFabricId(fabricId, fabricWwn, _dbClient);
Map<ZoneMember, NetworkLite> epNetworks = new HashMap<ZoneMember, NetworkLite>();
NetworkLite loopNetwork = null;
for (ZoneMember member : zone.getMembers()) {
// For alias-type members, more investigation is needed.
if (!StringUtils.isEmpty(member.getAddress())) {
loopNetwork = NetworkUtil.getEndpointNetworkLite(member.getAddress(), _dbClient);
}
// it belongs to the request network.
if (loopNetwork == null && network != null) {
loopNetwork = network;
}
if (loopNetwork != null) {
epNetworks.put(member, loopNetwork);
}
}
return epNetworks;
}
Aggregations