use of com.iwave.ext.netappc.StorageVirtualMachineInfo in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method discoverUmanagedFileSystems.
private void discoverUmanagedFileSystems(AccessProfile profile) {
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
String detailedStatusMessage = "Discovery of NetApp Cluster Mode Unmanaged FileSystem started";
List<UnManagedFileSystem> unManagedFileSystems = new ArrayList<UnManagedFileSystem>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
int newFileSystemsCount = 0;
int existingFileSystemsCount = 0;
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
Collection<String> attrs = new ArrayList<String>();
for (String property : ntpPropertiesList) {
attrs.add(SupportedNtpFileSystemInformation.getFileSystemInformation(property));
}
try {
StoragePort storagePort = getStoragePortPool(storageSystem);
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
HashMap<String, StoragePool> pools = new HashMap();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
pools.put(storagePool.getNativeGuid(), storagePool);
}
// Retrieve all the file system and SVM info.
List<Map<String, String>> fileSystemInfo = netAppCApi.listVolumeInfo(null, attrs);
List<StorageVirtualMachineInfo> svms = netAppCApi.listSVM();
for (Map<String, String> fileSystemChar : fileSystemInfo) {
String poolName = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.STORAGE_POOL.toString()));
String filesystem = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.NAME.toString()));
boolean isSVMRootVolume = Boolean.valueOf(fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.IS_SVM_ROOT.toString())));
boolean isNodeRootVolume = Boolean.valueOf(fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.IS_NODE_ROOT.toString())));
String path = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.PATH.toString()));
String state = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.STATE.toString()));
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, poolName, NativeGUIDGenerator.POOL);
StoragePool pool = pools.get(poolNativeGuid);
String nativeId;
if ("".equals(filesystem)) {
continue;
}
if (filesystem.startsWith(VOL_ROOT)) {
nativeId = filesystem;
} else {
nativeId = VOL_ROOT + filesystem;
}
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), nativeId);
// Ignore export for root volume and don't pull it into ViPR db.
if (isNodeRootVolume || isSVMRootVolume) {
_logger.info("Ignore and not discover root" + filesystem + "on NTP array");
continue;
}
// Ignore volume that is offline and don't pull it into ViPR db.
if (state.equalsIgnoreCase(VOLUME_STATE_OFFLINE)) {
_logger.info("Ignoring volume " + filesystem + " as it is offline");
continue;
}
// to create an UnManaged Filesystems.
if (checkStorageFileSystemExistsInDB(fsNativeGuid)) {
continue;
}
_logger.debug("retrieve info for file system: " + filesystem);
String svm = getOwningSVM(filesystem, fileSystemInfo);
String address = getSVMAddress(svm, svms);
if (svm != null && !svm.isEmpty()) {
// Need to use storage port for SVM.
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, address, NativeGUIDGenerator.PORT);
storagePort = getSVMStoragePort(storageSystem, portNativeGuid, svm);
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), nativeId);
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
boolean alreadyExist = unManagedFs == null ? false : true;
unManagedFs = createUnManagedFileSystem(unManagedFs, profile, fsUnManagedFsNativeGuid, nativeId, storageSystem, pool, filesystem, storagePort, fileSystemChar);
if (alreadyExist) {
existingUnManagedFileSystems.add(unManagedFs);
existingFileSystemsCount++;
} else {
unManagedFileSystems.add(unManagedFs);
newFileSystemsCount++;
}
allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
/**
* Persist 200 objects and clear them to avoid memory issue
*/
validateListSizeLimitAndPersist(unManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to
// mark them inactive.
markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
_logger.info("New unmanaged NetappC file systems count: {}", newFileSystemsCount);
_logger.info("Update unmanaged NetappC file systems count: {}", existingFileSystemsCount);
if (!unManagedFileSystems.isEmpty()) {
// Add UnManagedFileSystem
_partitionManager.insertInBatches(unManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILESYSTEM);
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_partitionManager.updateAndReIndexInBatches(existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILESYSTEM);
}
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for NetAppC: %s", storageSystemId.toString());
} catch (NetAppCException ve) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
}
_logger.error("discoverStorage failed. Storage system: " + storageSystemId);
throw ve;
} catch (Exception e) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
}
_logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
throw NetAppCException.exceptions.discoveryFailed(storageSystemId.toString(), e);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.iwave.ext.netappc.StorageVirtualMachineInfo in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method discoverAll.
public void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemId = null;
StorageSystem storageSystem = null;
String detailedStatusMessage = "Unknown Status";
try {
_logger.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
storageSystemId = accessProfile.getSystemId();
storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
// Retrieve NetAppC Filer information.
discoverFilerInfo(storageSystem);
String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(storageSystem.getSystemType()));
String firmwareVersion = storageSystem.getFirmwareVersion();
// Example version String for NetappC looks like 8.2
_logger.info("Verifying version details : Minimum Supported Version {} - Discovered NetApp Cluster Mode Version {}", minimumSupportedVersion, firmwareVersion);
if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, firmwareVersion) < 0) {
storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
storageSystem.setReachableStatus(false);
DiscoveryUtils.setSystemResourcesIncompatible(_dbClient, _coordinator, storageSystem.getId());
throw new NetAppCException(String.format(" ** This version of NetApp Cluster Mode is not supported ** Should be a minimum of %s", minimumSupportedVersion));
}
storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
storageSystem.setReachableStatus(true);
_dbClient.persistObject(storageSystem);
if (!storageSystem.getReachableStatus()) {
throw new NetAppCException("Failed to connect to " + storageSystem.getIpAddress());
}
_completer.statusPending(_dbClient, "Identified physical storage");
List<StorageVirtualMachineInfo> svms = new ArrayList<StorageVirtualMachineInfo>();
Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, svms);
_logger.info("No of newly discovered groups {}", groups.get(NEW).size());
_logger.info("No of existing discovered groups {}", groups.get(EXISTING).size());
if (!groups.get(NEW).isEmpty()) {
_dbClient.createObject(groups.get(NEW));
}
if (!groups.get(EXISTING).isEmpty()) {
_dbClient.persistObject(groups.get(EXISTING));
}
List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
Map<String, List<StoragePool>> pools = discoverStoragePools(storageSystem, poolsToMatchWithVpool);
_logger.info("No of newly discovered pools {}", pools.get(NEW).size());
_logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
if (!pools.get(NEW).isEmpty()) {
allPools.addAll(pools.get(NEW));
_dbClient.createObject(pools.get(NEW));
}
if (!pools.get(EXISTING).isEmpty()) {
allPools.addAll(pools.get(EXISTING));
_dbClient.persistObject(pools.get(EXISTING));
}
List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystemId);
if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
poolsToMatchWithVpool.addAll(notVisiblePools);
}
_completer.statusPending(_dbClient, "Completed pool discovery");
// discover ports
List<StoragePort> allPorts = new ArrayList<StoragePort>();
Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, svms, groups.get(NEW));
_logger.info("No of newly discovered port {}", ports.get(NEW).size());
_logger.info("No of existing discovered port {}", ports.get(EXISTING).size());
if (!ports.get(NEW).isEmpty()) {
allPorts.addAll(ports.get(NEW));
_dbClient.createObject(ports.get(NEW));
}
if (!ports.get(EXISTING).isEmpty()) {
allPorts.addAll(ports.get(EXISTING));
_dbClient.persistObject(ports.get(EXISTING));
}
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
_completer.statusPending(_dbClient, "Completed port discovery");
List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
allExistingPorts.addAll(notVisiblePorts);
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(ports.get(NEW), allExistingPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemId.toString());
} catch (Exception e) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
}
detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw new NetAppCException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
Aggregations