use of com.emc.storageos.datadomain.restapi.model.DDNetworkDetails in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverPort.
private void discoverPort(DataDomainClient ddClient, StorageSystem storageSystem) {
boolean newPort = false;
_log.info("discoverPorts for storage system {} - start", storageSystem.getId());
try {
DDNetworkList networks = ddClient.getNetworks(storageSystem.getNativeGuid());
if (networks.network.isEmpty()) {
return;
}
List<StoragePort> ports = new ArrayList<StoragePort>();
for (DDNetworkInfo network : networks.network) {
DDNetworkDetails detailedNetworkInfo = ddClient.getNetwork(storageSystem.getNativeGuid(), network.getId());
if ((!detailedNetworkInfo.getEnabled()) || (detailedNetworkInfo.getIp() == null)) {
continue;
}
StoragePort storagePort = null;
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, detailedNetworkInfo.getIp(), NativeGUIDGenerator.PORT);
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
while (results.iterator().hasNext()) {
StoragePort port = _dbClient.queryObject(StoragePort.class, results.iterator().next());
if (!port.getInactive() && port.getStorageDevice().equals(storageSystem.getId())) {
storagePort = port;
break;
}
}
if (storagePort == null) {
// Create DataDomain 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(storageSystem.getId());
storagePort.setPortName(detailedNetworkInfo.getName());
storagePort.setPortGroup(detailedNetworkInfo.getName());
storagePort.setPortNetworkId(detailedNetworkInfo.getIp());
storagePort.setIpAddress(detailedNetworkInfo.getIp());
storagePort.setPortSpeed((long) detailedNetworkInfo.getLinkSpeed());
storagePort.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
newPort = true;
_log.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
}
storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
storagePort.setOperationalStatus(StoragePort.OperationalStatus.OK.toString());
storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
_log.info("discoverPorts for storage system {} - complete", storageSystem.getId());
StoragePortAssociationHelper.updatePortAssociations(Arrays.asList(storagePort), _dbClient);
if (newPort) {
_dbClient.createObject(storagePort);
} else {
_dbClient.persistObject(storagePort);
}
ports.add(storagePort);
}
DiscoveryUtils.checkStoragePortsNotVisible(ports, _dbClient, storageSystem.getId());
} catch (InternalException e) {
throw e;
} catch (Exception e) {
_log.error("discoverPorts failed. Storage system: " + storageSystem.getId(), e);
throw DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
}
}
Aggregations