use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverMtrees.
private void discoverMtrees(DataDomainClient ddClient, StorageSystem storageSystem) {
URIQueryResultList mtreeList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceFileshareConstraint(storageSystem.getId()), mtreeList);
Iterator<URI> mtreeItr = mtreeList.iterator();
while (mtreeItr.hasNext()) {
FileShare mtree = _dbClient.queryObject(FileShare.class, mtreeItr.next());
if (!mtree.getInactive()) {
try {
DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storageSystem.getNativeGuid(), mtree.getNativeId());
if (mtreeInfo.quotaConfig != null) {
// it should be always true.
// We do not inject resources without quota
mtree.setCapacity(mtreeInfo.quotaConfig.getHardLimit());
}
mtree.setUsedCapacity(mtreeInfo.logicalCapacity.getUsed());
} catch (DataDomainResourceNotFoundException ex) {
mtree.setCapacity(0L);
} catch (DataDomainApiException dex) {
mtree.setCapacity(0L);
}
}
}
}
use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedFileSystems.
private void discoverUnManagedFileSystems(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
String detailedStatusMessage = "Discovery of DataDomain Unmanaged FileSystem started";
List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
StoragePool pool = getPoolFromDB(storageSystem);
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
DDMTreeInfoDetail mtree = null;
try {
DDMTreeList mtreeList = ddClient.getMTreeList(storageSystem.getNativeGuid());
for (DDMTreeInfo mtreeInfo : mtreeList.mtree) {
mtree = ddClient.getMTree(storageSystem.getNativeGuid(), mtreeInfo.getId());
if (mtree == null || mtree.delStatus == DataDomainApiConstants.FILE_DELETED) {
continue;
}
// Filtering mtrees that are not supporting either of NFS & CIFS
if ((mtree.protocolName == null) || (mtree.protocolName.isEmpty())) {
_log.info("Mtree: {} doesn't contain any protocol defined so ignoring it", mtree.name);
continue;
} else {
if ((mtree.protocolName.contains(DataDomainApiConstants.NFS_PROTOCOL)) || (mtree.protocolName.contains(DataDomainApiConstants.CIFS_PROTOCOL))) {
_log.info("Mtree: {} contains supported protocol:{} so discovering it", mtree.name, mtree.protocolName.toArray());
} else {
_log.info("Mtree: {} contains unsupported protocol:{} so ignoring it", mtree.name, mtree.protocolName.toArray());
continue;
}
}
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
// If the filesystem already exists in db..just continue.
// No Need to create an UnManaged Filesystems.
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemNativeGUIdConstraint(fsNativeGuid), result);
if (result.iterator().hasNext()) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
UnManagedFileSystem unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
boolean alreadyExist = unManagedFS == null ? false : true;
unManagedFS = createUnManagedFileSystem(unManagedFS, fsUnManagedFsNativeGuid, mtree, storageSystem, pool, matchedVPools);
if (alreadyExist) {
existingUnManagedFileSystems.add(unManagedFS);
} else {
newUnManagedFileSystems.add(unManagedFS);
}
allDiscoveredUnManagedFileSystems.add(unManagedFS.getId());
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
if (newUnManagedFileSystems != null && !newUnManagedFileSystems.isEmpty()) {
// Add UnManagedFileSystem
_dbClient.createObject(newUnManagedFileSystems);
_log.info("{} {} Records inserted to DB", newUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
if (existingUnManagedFileSystems != null && !existingUnManagedFileSystems.isEmpty()) {
_dbClient.updateAndReindexObject(existingUnManagedFileSystems);
_log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for DataDomain system: %s", storageSystem.getId().toString());
} catch (DataDomainApiException dde) {
detailedStatusMessage = "DiscoverStorage failed" + dde.getMessage();
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString());
throw dde;
} catch (Exception e) {
detailedStatusMessage = "DiscoverStorage failed" + e.getMessage();
_log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString(), e);
throw DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doCheckFSExists.
@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_log.info("checking file system existence on array: ", args.getFsName());
boolean isMtreeExists = true;
try {
DataDomainClient ddClient = getDataDomainClient(storage);
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storagePool.getNativeId(), args.getFs().getNativeId());
if (mtreeInfo != null && (mtreeInfo.id.equals(args.getFsNativeId()))) {
isMtreeExists = true;
}
} catch (DataDomainResourceNotFoundException e) {
_log.info("Mtree not found.", e);
isMtreeExists = false;
}
return isMtreeExists;
}
Aggregations