use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class VNXeUnManagedObjectDiscoverer method discoverAllCifsShares.
public void discoverAllCifsShares(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxeClient(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.persistObject(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();
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class NetAppFileCommunicationInterface method discoverUnManagedCifsShares.
/**
* discover the unmanaged cifs shares and add shares to vipr db
*
* @param profile
*/
private void discoverUnManagedCifsShares(AccessProfile profile) {
URI systemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemId);
if (null == storageSystem) {
return;
}
String detailedStatusMessage = "Discovery of NetApp Unmanaged Cifs shares started";
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 {
// Used to Save the Acl to DB
List<UnManagedCifsShareACL> unManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
List<UnManagedCifsShareACL> oldunManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
List<Map<String, String>> fileSystemInfo = netAppApi.listVolumeInfo(null, attrs);
List<VFilerInfo> vFilers = netAppApi.listVFilers(null);
// Get All cifs shares and ACLs
List<Map<String, String>> listShares = netAppApi.listShares(null);
if (listShares != null && !listShares.isEmpty()) {
_logger.info("total no of shares in netapp system (s) {}", listShares.size());
}
HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet = null;
// prepare the unmanagedSmbshare
HashMap<String, HashSet<UnManagedSMBFileShare>> unMangedSMBFileShareMapSet = getAllCifsShares(listShares);
for (String key : unMangedSMBFileShareMapSet.keySet()) {
String filesystem = key;
unManagedSMBFileShareHashSet = unMangedSMBFileShareMapSet.get(key);
_logger.info("FileSystem Path {}", filesystem);
String nativeId = null;
if (!filesystem.startsWith(VOL_ROOT_NO_SLASH)) {
nativeId = VOL_ROOT_NO_SLASH + filesystem;
} else {
nativeId = filesystem;
}
// Ignore root volume and don't pull it into ViPR db.
if (filesystem.contains(ROOT_VOL)) {
_logger.info("Ignore and not discover root filesystem {} on NTP array", filesystem);
continue;
}
// Ignore snapshots and don't pull it into ViPR db.
if (filesystem.contains(SNAPSHOT)) {
_logger.info("Ignore exports for snapshot {}", filesystem);
continue;
}
String shareNativeId = getFSPathIfSubDirectoryExport(nativeId);
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), shareNativeId);
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
boolean fsAlreadyExists = unManagedFs == null ? false : true;
if (fsAlreadyExists) {
_logger.info("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 addr = null;
if (vFiler == null || vFiler.isEmpty()) {
// No vfilers, use system storage port
StoragePort port = getStoragePortPool(storageSystem);
addr = port.getPortName();
} else {
// Use IP address of vFiler.
addr = getVfilerAddress(vFiler, vFilers);
}
UnManagedSMBShareMap tempUnManagedSMBShareMap = new UnManagedSMBShareMap();
// add smb shares to FS object
createShareMap(unManagedSMBFileShareHashSet, tempUnManagedSMBShareMap, addr, nativeId);
// add shares to fs object
if (!tempUnManagedSMBShareMap.isEmpty() && tempUnManagedSMBShareMap.size() > 0) {
unManagedFs.setUnManagedSmbShareMap(tempUnManagedSMBShareMap);
unManagedFs.setHasShares(true);
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_logger.debug("SMB Share map for NetApp UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getUnManagedSmbShareMap());
}
List<UnManagedCifsShareACL> tempUnManagedCifsShareAclList = getACLs(unManagedSMBFileShareHashSet, netAppApi, unManagedFs.getId());
// get the acl details for given fileshare
UnManagedCifsShareACL existingACL = null;
for (UnManagedCifsShareACL unManagedCifsShareACL : tempUnManagedCifsShareAclList) {
_logger.info("Unmanaged File share acls : {}", unManagedCifsShareACL);
String fsShareNativeId = unManagedCifsShareACL.getFileSystemShareACLIndex();
_logger.info("UMFS Share ACL index {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
_logger.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
unManagedCifsShareACL.setNativeGuid(fsUnManagedFileShareNativeGuid);
// Check whether the CIFS share ACL was present in ViPR DB.
existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, unManagedCifsShareACL.getNativeGuid());
if (existingACL == null) {
unManagedCifsShareACLList.add(unManagedCifsShareACL);
} else {
// delete the existing acl
existingACL.setInactive(true);
oldunManagedCifsShareACLList.add(existingACL);
// then add new acl
unManagedCifsShareACLList.add(unManagedCifsShareACL);
}
}
// save the object
{
_dbClient.persistObject(unManagedFs);
_logger.info("File System {} has Shares and their Count is {}", unManagedFs.getId(), tempUnManagedSMBShareMap.size());
}
// Adding this additional logic to avoid OOM
if (!unManagedCifsShareACLList.isEmpty() && unManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
_logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
_dbClient.createObject(unManagedCifsShareACLList);
unManagedCifsShareACLList.clear();
}
if (!oldunManagedCifsShareACLList.isEmpty() && oldunManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
_logger.info("Update Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
_dbClient.persistObject(oldunManagedCifsShareACLList);
oldunManagedCifsShareACLList.clear();
}
} else {
_logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + filesystem + " share");
}
}
//
if (!unManagedCifsShareACLList.isEmpty()) {
_logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
_dbClient.createObject(unManagedCifsShareACLList);
}
if (!oldunManagedCifsShareACLList.isEmpty()) {
_logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
_dbClient.persistObject(oldunManagedCifsShareACLList);
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for NetApp: %s", systemId.toString());
} catch (NetAppException ve) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
}
_logger.error("discoverStorage failed. Storage system: " + systemId);
} catch (Exception e) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
}
_logger.error("discoverStorage failed. Storage system: " + systemId, 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.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverUmanagedFileSystems.
private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<>();
List<UnManagedFileQuotaDirectory> newUnManagedFileQuotaDir = new ArrayList<>();
List<UnManagedFileQuotaDirectory> existingUnManagedFileQuotaDir = new ArrayList<>();
List<UnManagedCifsShareACL> newUnManagedCifsShareACLList = new ArrayList<>();
List<UnManagedCifsShareACL> oldUnManagedCifsShareACLList = new ArrayList<>();
List<UnManagedNFSShareACL> newUnManagedNfsShareACLList = new ArrayList<>();
List<UnManagedNFSShareACL> oldUnManagedNfsShareACLList = new ArrayList<>();
List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<>();
List<UnManagedFileExportRule> oldUnManagedExportRules = new ArrayList<>();
_log.debug("Access Profile Details : IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<>();
String detailedStatusMessage = "Discovery of Isilon Unmanaged FileSystem started";
long unmanagedFsCount = 0;
try {
IsilonApi isilonApi = getIsilonDevice(storageSystem);
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
ArrayList<StoragePool> pools = new ArrayList<>();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
if (storagePool != null && !storagePool.getInactive()) {
pools.add(storagePool);
}
}
StoragePool storagePool = null;
if (pools != null && !pools.isEmpty()) {
storagePool = pools.get(0);
}
StoragePort storagePort = getStoragePortPool(storageSystem);
int totalIsilonFSDiscovered = 0;
// get the associated storage port for vnas Server
List<IsilonAccessZone> isilonAccessZones = isilonApi.getAccessZones(null);
Map<String, NASServer> nasServers = validateAndGetNASServer(storageSystem, isilonAccessZones);
// update the path from controller configuration
updateDiscoveryPathForUnManagedFS(nasServers, storageSystem);
// NFSv4 enabled on storage system!!!
boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
List<FileShare> discoveredFS = new ArrayList<>();
String resumeToken = null;
for (String umfsDiscoverPath : _discPathsForUnManaged) {
IsilonAccessZone isilonAccessZone = getAccessZoneCorresDiscoveryPath(isilonAccessZones, umfsDiscoverPath);
String isilonAccessZoneName;
if (isilonAccessZone == null) {
// System access zone
isilonAccessZoneName = null;
} else {
isilonAccessZoneName = isilonAccessZone.getName();
}
// Get All SMB for this path access zone
HashMap<String, HashSet<String>> zoneSMBShares = discoverAccessZoneSMBShares(storageSystem, isilonAccessZoneName);
// Get all NFS Export for this path access zone
HashMap<String, HashSet<Integer>> zoneNFSExports = discoverAccessZoneExports(storageSystem, isilonAccessZoneName);
do {
HashMap<String, Object> discoverdFileDetails = discoverAllFileSystem(storageSystem, resumeToken, umfsDiscoverPath);
IsilonApi.IsilonList<FileShare> discoveredIsilonFS = (IsilonApi.IsilonList<FileShare>) discoverdFileDetails.get(UMFS_DETAILS);
ArrayList<UnManagedFileQuotaDirectory> discoveredUmfsQd = (ArrayList<UnManagedFileQuotaDirectory>) discoverdFileDetails.get(UMFSQD_DETAILS);
HashMap<String, HashSet<String>> umfsfileQuotaMap = (HashMap<String, HashSet<String>>) discoverdFileDetails.get(UMFS_QD_MAP);
resumeToken = discoveredIsilonFS.getToken();
discoveredFS = discoveredIsilonFS.getList();
totalIsilonFSDiscovered += discoveredFS.size();
for (FileShare fs : discoveredFS) {
if (!checkStorageFileSystemExistsInDB(fs.getNativeGuid())) {
// Create UnManaged FS
String fsPathName = fs.getPath();
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fs.getNativeGuid());
if (unManagedFs != null) {
existingUnManagedFileSystems.add(unManagedFs);
}
// get the matched vNAS Server
NASServer nasServer = getMatchedNASServer(nasServers, fsPathName);
if (nasServer != null) {
// Get valid storage port from the NAS server!!!
_log.info("fs path {} and nas server details {}", fs.getPath(), nasServer.toString());
storagePort = getStoragePortFromNasServer(nasServer);
if (storagePort == null) {
_log.info("No valid storage port found for nas server {}", nasServer.toString());
continue;
}
} else {
_log.info("fs path {} and vnas server not found", fs.getPath());
// Skip further ingestion steps on this file share & move to next file share
continue;
}
unManagedFs = createUnManagedFileSystem(unManagedFs, fs.getNativeGuid(), storageSystem, storagePool, nasServer, fs);
unManagedFs.setHasNFSAcl(false);
newUnManagedFileSystems.add(unManagedFs);
/**
* Set and create the NFS ACLs only if the system is enabled with NFSv4!!!
*/
HashMap<String, HashSet<Integer>> exportWithIdMap = getExportsIncludingSubDir(fs.getPath(), zoneNFSExports, umfsfileQuotaMap);
if (isNfsV4Enabled) {
Set<String> fsExportPaths = exportWithIdMap.keySet();
setUnmanagedNfsShareACL(unManagedFs, storageSystem, isilonApi, fsExportPaths, newUnManagedNfsShareACLList, oldUnManagedNfsShareACLList);
}
/**
* Set and Create Export Rules and export Map
*/
if (!exportWithIdMap.keySet().isEmpty()) {
setUnManagedFSExportMap(unManagedFs, exportWithIdMap, storagePort, fs.getPath(), nasServer.getNasName(), isilonApi, storageSystem, newUnManagedExportRules, oldUnManagedExportRules);
_log.info("Number of exports discovered for file system {} is {}", unManagedFs.getId(), newUnManagedExportRules.size());
if (!newUnManagedExportRules.isEmpty()) {
unManagedFs.setHasExports(true);
_log.info("File System {} has Exports and their size is {}", unManagedFs.getId(), newUnManagedExportRules.size());
}
}
/**
* Create and set CIFS ACLS and SMB Share MAP
*/
HashSet<String> shareIDs = getSharesIncludingSubDir(fs.getPath(), zoneSMBShares, umfsfileQuotaMap);
setUnmanagedCifsShareACL(unManagedFs, shareIDs, newUnManagedCifsShareACLList, storagePort, fs.getName(), nasServer.getNasName(), storageSystem, isilonApi, oldUnManagedCifsShareACLList);
_log.info("Number of shares ACLs discovered for file system {} is {}", unManagedFs.getId(), newUnManagedCifsShareACLList.size());
if (unManagedFs.getHasExports() || unManagedFs.getHasShares()) {
_log.info("FS {} is having exports/shares", fs.getPath());
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
} else {
_log.info("FS {} does not have export or share", fs.getPath());
}
/**
* Persist 200 objects and clear them to avoid memory issue
*/
// save bunch of export rules in db
validateSizeLimitAndPersist(newUnManagedExportRules, oldUnManagedExportRules, Constants.DEFAULT_PARTITION_SIZE * 2);
// save bunch of ACLs in db
validateSizeLimitAndPersist(newUnManagedCifsShareACLList, oldUnManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE * 2);
// save bunch of NFS ACLs in db
validateSizeLimitAndPersist(newUnManagedNfsShareACLList, newUnManagedNfsShareACLList, Constants.DEFAULT_PARTITION_SIZE * 2);
allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
// save bunch of file system in db
validateListSizeLimitAndPersist(newUnManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
}
}
for (UnManagedFileQuotaDirectory umfsQd : discoveredUmfsQd) {
if (!checkStorageQuotaDirectoryExistsInDB(umfsQd.getNativeGuid())) {
String fsUnManagedQdNativeGuid = NativeGUIDGenerator.generateNativeGuidForUnManagedQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), umfsQd.getNativeId(), "");
UnManagedFileQuotaDirectory unManagedFileQd = checkUnManagedFileSystemQuotaDirectoryExistsInDB(fsUnManagedQdNativeGuid);
boolean umfsQdExists = (unManagedFileQd == null) ? false : true;
if (umfsQdExists) {
umfsQd.setId(unManagedFileQd.getId());
existingUnManagedFileQuotaDir.add(umfsQd);
} else if (null != umfsQd) {
umfsQd.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
newUnManagedFileQuotaDir.add(umfsQd);
}
}
}
// save bunch of QDs in db
validateSizeLimitAndPersist(newUnManagedFileQuotaDir, existingUnManagedFileQuotaDir, Constants.DEFAULT_PARTITION_SIZE * 2);
} while (resumeToken != null);
}
// Saving bunch of Unmanaged objects!!!
if (!newUnManagedExportRules.isEmpty()) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
_dbClient.createObject(newUnManagedExportRules);
newUnManagedExportRules.clear();
}
if (!oldUnManagedExportRules.isEmpty()) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
_dbClient.updateObject(newUnManagedExportRules);
oldUnManagedExportRules.clear();
}
// save ACLs in db
if (!newUnManagedCifsShareACLList.isEmpty()) {
_log.info("Saving Number of UnManagedCifsShareACL(s) {}", newUnManagedCifsShareACLList.size());
_dbClient.createObject(newUnManagedCifsShareACLList);
newUnManagedCifsShareACLList.clear();
}
// save old acls
if (!oldUnManagedCifsShareACLList.isEmpty()) {
_log.info("Saving Number of UnManagedFileExportRule(s) {}", oldUnManagedCifsShareACLList.size());
_dbClient.updateObject(oldUnManagedCifsShareACLList);
oldUnManagedCifsShareACLList.clear();
}
// save NFS ACLs in db
if (!newUnManagedNfsShareACLList.isEmpty()) {
_log.info("Saving Number of UnManagedNfsShareACL(s) {}", newUnManagedNfsShareACLList.size());
_dbClient.createObject(newUnManagedNfsShareACLList);
newUnManagedNfsShareACLList.clear();
}
// save old acls
if (!oldUnManagedNfsShareACLList.isEmpty()) {
_log.info("Saving Number of NFS UnManagedFileExportRule(s) {}", oldUnManagedNfsShareACLList.size());
_dbClient.updateObject(oldUnManagedNfsShareACLList);
oldUnManagedNfsShareACLList.clear();
}
// save new QDs to DB
if (!newUnManagedFileQuotaDir.isEmpty()) {
_log.info("New unmanaged Isilon file systems QuotaDirecotry count: {}", newUnManagedFileQuotaDir.size());
_dbClient.createObject(newUnManagedFileQuotaDir);
}
// save old QDs
if (!existingUnManagedFileQuotaDir.isEmpty()) {
_log.info("Update unmanaged Isilon file systems QuotaDirectory count: {}", existingUnManagedFileQuotaDir.size());
_dbClient.updateObject(existingUnManagedFileQuotaDir);
}
// save new FS
if (!newUnManagedFileSystems.isEmpty()) {
_dbClient.createObject(newUnManagedFileSystems);
}
// save old FS
if (!existingUnManagedFileSystems.isEmpty()) {
_dbClient.updateObject(existingUnManagedFileSystems);
}
_log.info("Discovered {} Isilon file systems.", totalIsilonFSDiscovered);
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for Isilon: %s; new unmanaged file systems count: %s", storageSystemId.toString(), unmanagedFsCount);
_log.info(detailedStatusMessage);
} catch (IsilonException ex) {
detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), ex.getLocalizedMessage());
_log.error(detailedStatusMessage, ex);
throw ex;
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_log.error(detailedStatusMessage, e);
throw new IsilonCollectionException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.updateObject(storageSystem);
} catch (Exception ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method setUnmanagedCifsShareACL.
/**
* get UnManaged Cifs Shares and their ACLs
*
* @param unManagedFileSystem
* @param smbShares
* @param unManagedCifsShareACLList
* @param fsPath
* @param isilonApi
*/
private void setUnmanagedCifsShareACL(UnManagedFileSystem unManagedFileSystem, HashSet<String> smbShares, List<UnManagedCifsShareACL> unManagedCifsShareACLList, StoragePort storagePort, String fsname, String zoneName, StorageSystem storageSystem, IsilonApi isilonApi, List<UnManagedCifsShareACL> oldUnManagedCifsShareACLList) {
_log.debug("Set CIFS shares and their respective ACL of UMFS: {} from Isilon SMB share details - start", fsname);
if (null != smbShares && !smbShares.isEmpty()) {
UnManagedSMBShareMap unManagedSmbShareMap = null;
if (null == unManagedFileSystem.getUnManagedSmbShareMap()) {
unManagedSmbShareMap = new UnManagedSMBShareMap();
unManagedFileSystem.setUnManagedSmbShareMap(unManagedSmbShareMap);
}
unManagedSmbShareMap = unManagedFileSystem.getUnManagedSmbShareMap();
UnManagedSMBFileShare unManagedSMBFileShare = null;
for (String shareId : smbShares) {
// get smb share details
IsilonSMBShare isilonSMBShare = getIsilonSMBShare(isilonApi, shareId, zoneName);
if (null != isilonSMBShare) {
unManagedSMBFileShare = new UnManagedSMBFileShare();
unManagedSMBFileShare.setName(isilonSMBShare.getName());
unManagedSMBFileShare.setDescription(isilonSMBShare.getDescription());
unManagedSMBFileShare.setNativeId(shareId);
unManagedSMBFileShare.setMountPoint("\\\\" + storagePort.getPortNetworkId() + "\\" + isilonSMBShare.getName());
unManagedSMBFileShare.setPath(isilonSMBShare.getPath());
unManagedSMBFileShare.setMaxUsers(-1);
// setting the dummy permission.This is not used by isilon, but used by other storage system
unManagedSMBFileShare.setPermission(FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE);
unManagedSMBFileShare.setPermissionType(FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW);
// set Unmanaged SMB Share
unManagedSmbShareMap.put(isilonSMBShare.getName(), unManagedSMBFileShare);
_log.info("SMB share id {} ", shareId);
_log.info("SMB share name {} and fs mount point {} ", unManagedSMBFileShare.getName(), unManagedSMBFileShare.getMountPoint());
// process ACL permission
UnManagedCifsShareACL unManagedCifsShareACL = null;
int aclSize = 0;
List<IsilonSMBShare.Permission> permissionList = isilonSMBShare.getPermissions();
for (IsilonSMBShare.Permission permission : permissionList) {
if (FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW.equalsIgnoreCase(permission.getPermissionType())) {
aclSize++;
_log.debug("IsilonSMBShare: [{}] permission details: {}", isilonSMBShare.getName(), permission.toString());
unManagedCifsShareACL = new UnManagedCifsShareACL();
// Set share name
unManagedCifsShareACL.setShareName(isilonSMBShare.getName());
// Set permission
unManagedCifsShareACL.setPermission(permission.getPermission());
// We take only username and we can ignore type and id
// Set user
unManagedCifsShareACL.setUser(permission.getTrustee().getName());
// Set filesystem id
unManagedCifsShareACL.setFileSystemId(unManagedFileSystem.getId());
unManagedCifsShareACL.setId(URIUtil.createId(UnManagedCifsShareACL.class));
String fsShareNativeId = unManagedCifsShareACL.getFileSystemShareACLIndex();
_log.info("UMFS Share ACL index {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
_log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
// set native guid, so each entry unique
unManagedCifsShareACL.setNativeGuid(fsUnManagedFileShareNativeGuid);
// Check whether the CIFS share ACL was present in ViPR DB.
UnManagedCifsShareACL existingCifsShareACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, unManagedCifsShareACL.getNativeGuid());
if (existingCifsShareACL != null) {
// delete the existing acl
existingCifsShareACL.setInactive(true);
oldUnManagedCifsShareACLList.add(existingCifsShareACL);
}
unManagedCifsShareACLList.add(unManagedCifsShareACL);
}
}
_log.debug("ACL size of share: [{}] is {}", isilonSMBShare.getName(), aclSize);
}
}
if (!unManagedSmbShareMap.isEmpty()) {
unManagedFileSystem.setHasShares(true);
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method getACLs.
/**
* get ACLs for smb shares of fs object
*
* @param unManagedSMBFileShareHashSet
* @param netAppClusterApi
* @param fsId
* @return
*/
private List<UnManagedCifsShareACL> getACLs(HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet, NetAppClusterApi netAppClusterApi, StorageSystem storageSystem, URI fsId) {
_logger.info("gets all acls of fileshares given fsid ", fsId);
// get list of acls for given set of shares
UnManagedCifsShareACL unManagedCifsShareACL = null;
List<UnManagedCifsShareACL> unManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
// get acls for each share
List<CifsAcl> cifsAclList = null;
for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBFileShareHashSet) {
// find acl for given share
String unManagedSMBFileShareName = unManagedSMBFileShare.getName();
_logger.info("new smb share name: {} and fs: {}", unManagedSMBFileShareName, fsId);
cifsAclList = netAppClusterApi.listCIFSShareAcl(unManagedSMBFileShareName);
if (cifsAclList != null && !cifsAclList.isEmpty()) {
for (CifsAcl cifsAcl : cifsAclList) {
_logger.info("cifs share ACL: {} ", cifsAcl.toString());
unManagedCifsShareACL = new UnManagedCifsShareACL();
unManagedCifsShareACL.setShareName(unManagedSMBFileShareName);
String user = cifsAcl.getUserName();
if (user != null) {
unManagedCifsShareACL.setUser(user);
} else {
unManagedCifsShareACL.setGroup(cifsAcl.getGroupName());
}
// permission
unManagedCifsShareACL.setPermission(cifsAcl.getAccess().name());
unManagedCifsShareACL.setId(URIUtil.createId(UnManagedCifsShareACL.class));
// filesystem id
unManagedCifsShareACL.setFileSystemId(fsId);
// set the native guid
String fsShareNativeId = unManagedCifsShareACL.getFileSystemShareACLIndex();
// _logger.info("UMFS Share ACL index {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
_logger.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
unManagedCifsShareACL.setNativeGuid(fsUnManagedFileShareNativeGuid);
// add the acl to acl-list
unManagedCifsShareACLList.add(unManagedCifsShareACL);
}
_logger.info("new smb share name-: {} and ACL count: {}", unManagedSMBFileShareName, cifsAclList.size());
}
}
return unManagedCifsShareACLList;
}
Aggregations