use of com.emc.storageos.isilon.restapi.IsilonSmartConnectInfoV2 in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverPorts.
private HashMap<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem) throws IsilonCollectionException {
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 {
_log.info("discoverPorts for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
List<IsilonStoragePort> isilonStoragePorts = new ArrayList<IsilonStoragePort>();
try {
_log.info("Trying to get latest smart connect version");
IsilonSmartConnectInfoV2 connInfo = isilonApi.getSmartConnectInfoV2();
if (connInfo == null || (connInfo != null && connInfo.getSmartZones() == null)) {
throw new Exception("Failed new Interface, try old Interface");
}
if (connInfo != null) {
isilonStoragePorts = connInfo.getPorts();
}
} catch (Exception e) {
_log.info("Latest version failed so Trying to get old smart connect version");
IsilonSmartConnectInfo connInfo = isilonApi.getSmartConnectInfo();
if (connInfo != null) {
isilonStoragePorts = connInfo.getPorts();
}
}
if (isilonStoragePorts == null || isilonStoragePorts.isEmpty()) {
// No ports defined throw an exception and fail the discovery
IsilonCollectionException ice = new IsilonCollectionException("discoverPorts failed. No Smartzones defined");
throw ice;
}
for (IsilonStoragePort isilonPort : isilonStoragePorts) {
StoragePort storagePort = null;
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, isilonPort.getIpAddress(), NativeGUIDGenerator.PORT);
// Check if storage port was already discovered
@SuppressWarnings("deprecation") List<URI> portURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid));
for (URI portUri : portURIs) {
StoragePort port = _dbClient.queryObject(StoragePort.class, portUri);
if (port.getStorageDevice().equals(storageSystemId) && !port.getInactive()) {
storagePort = port;
break;
}
}
if (storagePort == null) {
// Create Isilon storage port for Isilon cluster IP address (smart connect ip)
storagePort = new StoragePort();
storagePort.setId(URIUtil.createId(StoragePort.class));
storagePort.setTransportType("IP");
storagePort.setNativeGuid(portNativeGuid);
storagePort.setLabel(portNativeGuid);
storagePort.setStorageDevice(storageSystemId);
storagePort.setPortNetworkId(isilonPort.getIpAddress().toLowerCase());
storagePort.setPortName(isilonPort.getPortName());
storagePort.setLabel(isilonPort.getPortName());
storagePort.setPortSpeed(isilonPort.getPortSpeed());
storagePort.setPortGroup(isilonPort.getPortName());
storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_log.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());
}
_log.info("discoverPorts for storage system {} - complete", storageSystemId);
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
} catch (Exception e) {
_log.error("discoverPorts failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverPorts failed. Storage system: " + storageSystemId);
throw ice;
}
}
Aggregations