use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.
the class FileSystemIngestionUtil method getTotalUnManagedFileSystemCapacity.
public static long getTotalUnManagedFileSystemCapacity(DbClient dbClient, List<URI> unManagedFileSystemUris) {
BigInteger totalUnManagedFileSystemCapacity = new BigInteger("0");
try {
Iterator<UnManagedFileSystem> unManagedFileSystems = dbClient.queryIterativeObjects(UnManagedFileSystem.class, unManagedFileSystemUris);
while (unManagedFileSystems.hasNext()) {
UnManagedFileSystem unManagedFileSystem = unManagedFileSystems.next();
StringSetMap unManagedFileSystemInfo = unManagedFileSystem.getFileSystemInformation();
if (null == unManagedFileSystemInfo) {
continue;
}
String unManagedFileSystemCapacity = PropertySetterUtil.extractValueFromStringSet(SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), unManagedFileSystemInfo);
if (null != unManagedFileSystemCapacity && !unManagedFileSystemCapacity.isEmpty()) {
totalUnManagedFileSystemCapacity = totalUnManagedFileSystemCapacity.add(new BigInteger(unManagedFileSystemCapacity));
}
}
} catch (Exception e) {
throw APIException.internalServerErrors.capacityComputationFailed();
}
return totalUnManagedFileSystemCapacity.longValue();
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.
the class StorageSystemService method getUnManagedFileSystems.
/**
* List all unmanaged file systems which are available for a storage system.Unmanaged file systems refers to file systems which are
* available within underlying storage systems , but
* still not managed in ViPR.
* As these file systems are not managed in ViPR, there will not be any ViPR specific
* details associated such as, virtual array, virtual pool, or project.
*
* @param id the URN of a ViPR storage system
*
* @prereq none
* @brief List of all unmanaged file systems available for a storage system
* @return UnManagedFileSystemList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/unmanaged/filesystems")
public UnManagedFileSystemList getUnManagedFileSystems(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
UnManagedFileSystemList unManagedFileSystemList = new UnManagedFileSystemList();
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceUnManagedFileSystemConstraint(id), result);
Iterator<UnManagedFileSystem> unmanagedFileSystemItr = _dbClient.queryIterativeObjects(UnManagedFileSystem.class, result, true);
while (unmanagedFileSystemItr.hasNext()) {
UnManagedFileSystem umfs = unmanagedFileSystemItr.next();
unManagedFileSystemList.getUnManagedFileSystem().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_FILESYSTEMS, umfs.getId()));
}
return unManagedFileSystemList;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method createUnManagedFileSystem.
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, String unManagedFileSystemNativeGuid, DDMTreeInfoDetail mtree, StorageSystem system, StoragePool pool, StringSet vPools) {
if (null == unManagedFileSystem) {
unManagedFileSystem = new UnManagedFileSystem();
unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
unManagedFileSystem.setStorageSystemUri(system.getId());
unManagedFileSystem.setFsUnManagedExportMap(new UnManagedFSExportMap());
unManagedFileSystem.setHasExports(false);
unManagedFileSystem.setHasShares(false);
} else {
// existing File System
UnManagedFSExportMap exportMap = unManagedFileSystem.getFsUnManagedExportMap();
if (exportMap != null) {
exportMap.clear();
}
}
Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
StringMap unManagedFileSystemCharacteristics = new StringMap();
// TODO: DD does not provide snapshot API yet
// This will be determined at snapshot discovery, once implemented
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), FALSE);
// DD supports only thinly provisioned FS
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), TRUE);
// Don't yet know if the FS is exported, to be determined at export discovery
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), FALSE);
unManagedFileSystem.setHasExports(false);
if (null != pool) {
StringSet pools = new StringSet();
pools.add(pool.getId().toString());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
unManagedFileSystem.setStoragePoolUri(pool.getId());
}
_log.debug("Matched Pools : {}", Joiner.on("\t").join(vPools));
if (null == vPools || vPools.isEmpty()) {
unManagedFileSystem.getSupportedVpoolUris().clear();
} else {
unManagedFileSystem.getSupportedVpoolUris().replace(vPools);
_log.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
}
List<StoragePort> ports = getPortFromDB(system);
if (ports != null) {
StringSet storagePorts = new StringSet();
for (StoragePort storagePort : ports) {
String portId = storagePort.getId().toString();
storagePorts.add(portId);
}
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
}
if (null != system) {
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
}
StringSet provisionedCapacity = new StringSet();
if (mtree.quotaConfig != null) {
provisionedCapacity.add(Long.toString(mtree.quotaConfig.getHardLimit()));
} else {
provisionedCapacity.add(Long.toString(mtree.logicalCapacity.getTotal()));
}
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
StringSet allocatedCapacity = new StringSet();
if (mtree.logicalCapacity != null) {
allocatedCapacity.add(Long.toString(mtree.logicalCapacity.getUsed()));
} else {
allocatedCapacity.add(Long.toString(0));
}
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
// Save off FileSystem Name, Path, Mount and label information
String name = mtree.name;
StringSet fsName = new StringSet();
fsName.add(name);
StringSet fsMountPath = new StringSet();
fsMountPath.add(mtree.name);
StringSet nativeId = new StringSet();
nativeId.add(mtree.id);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NAME.toString(), fsName);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NATIVE_ID.toString(), nativeId);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PATH.toString(), fsName);
unManagedFileSystemInformation.put(UnManagedFileSystem.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 DataDomainCommunicationInterface method discoverUnManagedNewExports.
private void discoverUnManagedNewExports(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
String detailedStatusMessage = "Discovery of Data Domain Unmanaged Exports started";
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
// Used to cache UMFS once retrieved from DB
Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
// Used to Save the rules to DB
List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<UnManagedFileExportRule>();
try {
// Get exports on the array and loop through each export.
DDExportList exportList = ddClient.getExports(storageSystem.getNativeGuid());
// Verification Utility
UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(_dbClient);
for (DDExportInfo exp : exportList.getExports()) {
DDExportInfoDetail export = ddClient.getExport(storageSystem.getNativeGuid(), exp.getId());
if (export.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), export.getMtreeID());
// Get UMFS from cache if possible, otherwise try to retrieve from DB
UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
if (unManagedFS == null) {
unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
}
// Used for rules validation
List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
if (unManagedFS != null) {
// Add UMFS to cache
existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
// Build ViPR export rules from the export retrieved from the array
List<UnManagedFileExportRule> exportRules = applyAllSecurityRules(export, unManagedFS.getId());
_log.info("Number of exports discovered for file system {} is {}", unManagedFS.getId(), exportRules.size());
for (UnManagedFileExportRule dbExportRule : exportRules) {
_log.info("Un Managed File Export Rule : {}", dbExportRule);
String fsExportRulenativeId = dbExportRule.getFsExportIndex();
_log.info("Native Id using to build Native Guid {}", fsExportRulenativeId);
String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, fsExportRulenativeId);
_log.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
dbExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
dbExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
// Build all export rules list.
unManagedExportRules.add(dbExportRule);
}
// apply as per API SVC Validations.
if (!unManagedExportRules.isEmpty()) {
boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
if (isAllRulesValid) {
_log.info("Validating rules success for export {}", export.getPath());
for (UnManagedFileExportRule exportRule : unManagedExportRules) {
UnManagedFileExportRule existingRule = checkUnManagedFsExportRuleExistsInDB(_dbClient, exportRule.getNativeGuid());
if (existingRule == null) {
newUnManagedExportRules.add(exportRule);
} else {
// Remove the existing rule.
existingRule.setInactive(true);
_dbClient.persistObject(existingRule);
newUnManagedExportRules.add(exportRule);
}
}
unManagedFS.setHasExports(true);
unManagedFS.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_dbClient.persistObject(unManagedFS);
_log.info("File System {} has Exports and their size is {}", unManagedFS.getId(), newUnManagedExportRules.size());
} else {
_log.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", export.getPath());
// Don't consider the file system with invalid exports!!!
unManagedFS.setInactive(true);
}
}
// Adding this additional logic to avoid OOM
if (newUnManagedExportRules.size() == MAX_UMFS_RECORD_SIZE) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
_dbClient.persistObject(newUnManagedExportRules);
newUnManagedExportRules.clear();
}
} else {
_log.info("FileSystem " + fsUnManagedFsNativeGuid + " is not present in ViPR DB. Hence ignoring " + export + " export");
}
}
if (!newUnManagedExportRules.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(newUnManagedExportRules);
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.persistObject(existingUnManagedFileSystems.values());
_log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeded
detailedStatusMessage = String.format("Discovery completed successfully for Data Domain: %s", storageSystem.getId().toString());
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
} catch (DataDomainApiException dde) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId());
} catch (Exception e) {
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId(), e);
} finally {
if (storageSystem != null) {
try {
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_log.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 VNXUnityUnManagedObjectDiscoverer method discoverAllCifsShares.
public void discoverAllCifsShares(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
log.info("discoverAllCifsShares for storage system {} - start", storageSystem.getId());
unManagedCifsAclInsert = new ArrayList<UnManagedCifsShareACL>();
unManagedCifsAclUpdate = new ArrayList<UnManagedCifsShareACL>();
List<VNXeCifsShare> cifsExports = apiClient.getAllCifsShares();
for (VNXeCifsShare exp : cifsExports) {
log.info("Discovered fS share {}", exp.toString());
VNXeFileSystem fs = null;
if (exp.getFilesystem() != null) {
fs = apiClient.getFileSystemByFSId(exp.getFilesystem().getId());
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
try {
if (checkStorageFileSystemExistsInDB(fsNativeGuid, dbClient)) {
log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGuid);
continue;
}
// Create UnManaged FS
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getId());
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(dbClient, fsUnManagedFsNativeGuid);
StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
String mountPath = extractValueFromStringSet(SupportedFileSystemInformation.MOUNT_PATH.toString(), unManagedFs.getFileSystemInformation());
String exportPath = exp.getPath();
if (!exportPath.equalsIgnoreCase("/")) {
mountPath = mountPath + exportPath;
}
// String mountPoint = storagePort.getPortNetworkId() + ":" + mountPath;
String mountPoint = "\\\\" + storagePort.getPortNetworkId() + "\\" + exp.getName();
String cifsShareId = exp.getId();
associateCifsExportWithUMFS(unManagedFs, mountPoint, exp, storagePort);
List<UnManagedCifsShareACL> cifsACLs = applyCifsSecurityRules(unManagedFs, mountPoint, exp, storagePort);
log.info("Number of export rules discovered for file system {} is {}", unManagedFs.getId() + ":" + unManagedFs.getLabel(), cifsACLs.size());
for (UnManagedCifsShareACL cifsAcl : cifsACLs) {
log.info("Unmanaged File share acls : {}", cifsAcl);
String fsShareNativeId = cifsAcl.getFileSystemShareACLIndex();
log.info("UMFS Share ACL index {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
cifsAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
// Check whether the CIFS share ACL was present in ViPR DB.
UnManagedCifsShareACL existingACL = checkUnManagedFsCifsACLExistsInDB(dbClient, cifsAcl.getNativeGuid());
if (existingACL == null) {
unManagedCifsAclInsert.add(cifsAcl);
} else {
unManagedCifsAclInsert.add(cifsAcl);
existingACL.setInactive(true);
unManagedCifsAclUpdate.add(existingACL);
}
}
// Persist the UMFS as it changed the SMB Share Map.
unManagedFs.setHasShares(true);
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), Boolean.TRUE.toString());
dbClient.updateObject(unManagedFs);
} catch (IOException e) {
log.error("IOException occured in discoverAllCifsShares()", e);
}
}
}
if (!unManagedCifsAclInsert.isEmpty()) {
// Add UnManagedFileSystem
partitionManager.insertInBatches(unManagedCifsAclInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_CIFS_SHARE_ACL);
unManagedCifsAclInsert.clear();
}
if (!unManagedCifsAclUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateInBatches(unManagedCifsAclUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_CIFS_SHARE_ACL);
unManagedCifsAclUpdate.clear();
}
}
Aggregations