use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.
the class NetAppFileCommunicationInterface 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 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>();
NetAppApi netAppApi = new NetAppApi.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 vFiler info.
List<Map<String, String>> fileSystemInfo = netAppApi.listVolumeInfo(null, attrs);
List<VFilerInfo> vFilers = netAppApi.listVFilers(null);
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()));
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, poolName, NativeGUIDGenerator.POOL);
StoragePool pool = pools.get(poolNativeGuid);
String nativeId;
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 (nativeId.contains(ROOT_VOL)) {
_logger.info("Ignore and not discover root filesystem on NTP array");
continue;
}
// to create an UnManaged Filesystems.
if (checkStorageFileSystemExistsInDB(fsNativeGuid)) {
continue;
}
_logger.debug("retrieve info for file system: " + filesystem);
String vFiler = getOwningVfiler(filesystem, fileSystemInfo);
if (vFiler != null && !vFiler.equalsIgnoreCase(DEFAULT_FILER)) {
_logger.info("Ignoring {} because it is owned by {}", filesystem, vFiler);
continue;
}
String address = getVfilerAddress(vFiler, vFilers);
if (vFiler != null && !vFiler.isEmpty()) {
// Need to use storage port for vFiler.
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, address, NativeGUIDGenerator.PORT);
storagePort = getVfilerStoragePort(storageSystem, portNativeGuid, vFiler);
}
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 Netapp file systems count: {}", newFileSystemsCount);
_logger.info("Update unmanaged Netapp 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 NetApp: %s", storageSystemId.toString());
} catch (NetAppException 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 NetAppException.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.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.
the class NetAppFileCommunicationInterface method createUnManagedFileSystem.
/**
* create StorageFileSystem Info Object
*
* @param unManagedFileSystem
* @param unManagedFileSystemNativeGuid
* @param storageSystemUri
* @param storagePool
* @param fileSystem
* @param storagePort
* @param fileSystemChars
* @return UnManagedFileSystem
* @throws IOException
* @throws NetAppException
*/
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, AccessProfile profile, String unManagedFileSystemNativeGuid, String unManangedFileSystemNativeId, StorageSystem system, StoragePool pool, String fileSystem, StoragePort storagePort, Map<String, String> fileSystemChars) throws IOException, NetAppException {
if (null == unManagedFileSystem) {
unManagedFileSystem = new UnManagedFileSystem();
unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
unManagedFileSystem.setStorageSystemUri(system.getId());
unManagedFileSystem.setHasExports(false);
unManagedFileSystem.setHasShares(false);
}
Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
StringMap unManagedFileSystemCharacteristics = new StringMap();
// TODO: We are not able to extract this information from filesystem
// properties from netapp api from iwave.
// may need to go over all the snapshots/exports to determine if we have
// any associated filesystems.
unManagedFileSystemCharacteristics.put(SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), FALSE);
unManagedFileSystemCharacteristics.put(SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), FALSE);
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), TRUE);
// On netapp Systems this currently true.
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), FALSE);
if (null != storagePort) {
StringSet storagePorts = new StringSet();
storagePorts.add(storagePort.getId().toString());
unManagedFileSystemInformation.put(SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
}
if (null != pool) {
StringSet pools = new StringSet();
pools.add(pool.getId().toString());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
unManagedFileSystem.setStoragePoolUri(pool.getId());
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
_logger.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
if (null == matchedVPools || matchedVPools.isEmpty()) {
// clear all existing supported vpool list.
unManagedFileSystem.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedFileSystem.getSupportedVpoolUris().replace(matchedVPools);
_logger.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
}
}
if (null != system) {
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
unManagedFileSystemInformation.put(SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
}
// Get FileSystem used Space.
if (null != fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.ALLOCATED_CAPACITY.toString()))) {
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.ALLOCATED_CAPACITY.toString())));
unManagedFileSystemInformation.put(SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
}
// Get FileSystem used Space.
if (null != fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.PROVISIONED_CAPACITY.toString()))) {
StringSet provisionedCapacity = new StringSet();
String totalCapacity = fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.PROVISIONED_CAPACITY.toString()));
String snapShotReserveBlocks = fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.SNAPSHOT_BLOCKS_RESERVED.toString()));
// Snapshot reserved Blocks - 1 block is 1024 bytes, convert it to bytes
String fsProvisionedCapacity = Long.toString(Long.parseLong(totalCapacity) + (Long.parseLong(snapShotReserveBlocks) * BYTESCONVERTER));
provisionedCapacity.add(fsProvisionedCapacity);
unManagedFileSystemInformation.put(SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
}
// Save off FileSystem Name, Path, Mount and label information
if (null != fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.NAME.toString()))) {
StringSet fsName = new StringSet();
String fileSystemName = fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.NAME.toString()));
fsName.add(fileSystemName);
unManagedFileSystem.setLabel(fileSystemName);
StringSet fsPath = new StringSet();
fsPath.add(unManangedFileSystemNativeId);
StringSet fsMountPath = new StringSet();
fsMountPath.add(VOL_ROOT + fileSystem);
unManagedFileSystemInformation.put(SupportedFileSystemInformation.NAME.toString(), fsName);
unManagedFileSystemInformation.put(SupportedFileSystemInformation.NATIVE_ID.toString(), fsPath);
unManagedFileSystemInformation.put(SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
unManagedFileSystemInformation.put(SupportedFileSystemInformation.PATH.toString(), fsPath);
unManagedFileSystemInformation.put(SupportedFileSystemInformation.MOUNT_PATH.toString(), fsMountPath);
}
// Add fileSystemInformation and Characteristics.
unManagedFileSystem.addFileSystemInformation(unManagedFileSystemInformation);
unManagedFileSystem.setFileSystemCharacterstics(unManagedFileSystemCharacteristics);
return unManagedFileSystem;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.
the class FileSystemIngestionUtil method isIngestionRequestValidForUnManagedFileSystems.
/**
* Validation Steps
* 1. validate PreExistingFileSystem uri.
* 2. Check PreExistingFileSystem is under Bourne Management already.
* 3. Check whether given CoS is present in the PreExistingFileSystems Supported CoS List
*
* @param UnManagedFileSystems
* @param cos
* @throws Exception
*/
public static void isIngestionRequestValidForUnManagedFileSystems(List<URI> UnManagedFileSystems, VirtualPool cos, DbClient dbClient) throws DatabaseException {
for (URI unManagedFileSystemUri : UnManagedFileSystems) {
ArgValidator.checkUri(unManagedFileSystemUri);
UnManagedFileSystem unManagedFileSystem = dbClient.queryObject(UnManagedFileSystem.class, unManagedFileSystemUri);
ArgValidator.checkEntityNotNull(unManagedFileSystem, unManagedFileSystemUri, false);
if (null == unManagedFileSystem.getFileSystemCharacterstics() || null == unManagedFileSystem.getFileSystemInformation()) {
continue;
}
StringSetMap unManagedFileSystemInformation = unManagedFileSystem.getFileSystemInformation();
String fileSystemNativeGuid = unManagedFileSystem.getNativeGuid().replace(UNMANAGEDFILESYSTEM, FILESYSTEM);
if (VirtualPoolUtil.checkIfFileSystemExistsInDB(fileSystemNativeGuid, dbClient)) {
throw APIException.internalServerErrors.objectAlreadyManaged("FileSystem", fileSystemNativeGuid);
}
checkStoragePoolValidForUnManagedFileSystemUri(unManagedFileSystemInformation, dbClient, unManagedFileSystemUri);
checkVirtualPoolValidForGivenUnManagedFileSystemUris(unManagedFileSystem.getSupportedVpoolUris(), unManagedFileSystemUri, cos.getId());
// TODO: Today, We bring in all the volumes that are exported.We need to add support to bring in all the related FS exports
// checkUnManagedFileSystemAlreadyExported(unManagedFileSystem);
}
}
Aggregations