use of com.iwave.ext.netapp.VFNetInfo in project coprhd-controller by CoprHD.
the class NetAppFileCommunicationInterface method discoverPorts.
private Map<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem, List<VFilerInfo> vFilers, List<StorageHADomain> haDomains) throws NetAppFileCollectionException {
URI storageSystemId = storageSystem.getId();
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
// Discover storage ports
try {
_logger.info("discoverPorts for storage system {} - start", storageSystemId);
StoragePort storagePort = null;
if (vFilers != null && !vFilers.isEmpty()) {
for (VFilerInfo filer : vFilers) {
for (VFNetInfo intf : filer.getInterfaces()) {
if (intf.getNetInterface().equals(MANAGEMENT_INTERFACE)) {
continue;
}
URIQueryResultList results = new URIQueryResultList();
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
storagePort = null;
if (results.iterator().hasNext()) {
StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
if (tmpPort.getStorageDevice().equals(storageSystem.getId()) && tmpPort.getPortGroup().equals(filer.getName())) {
storagePort = tmpPort;
_logger.debug("found duplicate intf {}", intf.getIpAddress());
}
}
if (storagePort == null) {
storagePort = new StoragePort();
storagePort.setId(URIUtil.createId(StoragePort.class));
storagePort.setTransportType("IP");
storagePort.setNativeGuid(portNativeGuid);
storagePort.setLabel(portNativeGuid);
storagePort.setStorageDevice(storageSystemId);
storagePort.setPortName(intf.getIpAddress());
storagePort.setPortNetworkId(intf.getIpAddress());
storagePort.setPortGroup(filer.getName());
storagePort.setStorageHADomain(findMatchingHADomain(filer.getName(), haDomains));
storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_logger.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
newStoragePorts.add(storagePort);
} else {
existingStoragePorts.add(storagePort);
}
storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
}
} else {
// Check if storage port was already discovered
URIQueryResultList results = new URIQueryResultList();
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, storageSystem.getIpAddress(), NativeGUIDGenerator.PORT);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
if (results.iterator().hasNext()) {
StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
if (tmpPort.getStorageDevice().equals(storageSystem.getId()) && tmpPort.getPortGroup().equals(storageSystem.getSerialNumber())) {
storagePort = tmpPort;
_logger.debug("found duplicate dm intf {}", storageSystem.getSerialNumber());
}
}
if (storagePort == null) {
// Create NetApp storage port for IP address
storagePort = new StoragePort();
storagePort.setId(URIUtil.createId(StoragePort.class));
storagePort.setTransportType("IP");
storagePort.setNativeGuid(portNativeGuid);
storagePort.setLabel(portNativeGuid);
storagePort.setStorageDevice(storageSystemId);
storagePort.setPortName(storageSystem.getIpAddress());
storagePort.setPortNetworkId(storageSystem.getIpAddress());
storagePort.setPortGroup(storageSystem.getSerialNumber());
storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_logger.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
newStoragePorts.add(storagePort);
} else {
existingStoragePorts.add(storagePort);
}
storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_logger.info("discoverPorts for storage system {} - complete", storageSystemId);
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
} catch (Exception e) {
_logger.error("discoverPorts failed. Storage system: " + storageSystemId, e);
throw new NetAppFileCollectionException("discoverPorts failed. Storage system: " + storageSystemId, e);
}
}
Aggregations