use of com.iwave.ext.netappc.SVMNetInfo in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method discoverPorts.
/**
* Discover the IP Interfaces/Storage Ports for NetApp Cluster mode array
*
* @param system
* Storage system information
* @return Map of new and existing storage ports
* @throws NetAppCException
*/
private Map<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem, List<StorageVirtualMachineInfo> svms, List<StorageHADomain> haDomains) throws NetAppCException {
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 (svms != null && !svms.isEmpty()) {
for (StorageVirtualMachineInfo svm : svms) {
for (SVMNetInfo intf : svm.getInterfaces()) {
if (intf.getRole().contains(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(svm.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(svm.getName());
storagePort.setStorageHADomain(findMatchingHADomain(svm.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 NetAppC 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 NetAppCException("discoverPorts failed. Storage system: " + storageSystemId, e);
}
}
Aggregations