use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discoverUnManagedCifsShares.
private void discoverUnManagedCifsShares(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
String detailedStatusMessage = "Discovery of Data Domain Unmanaged Cifs Shares started";
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
// Used to cache UMFS once retrieved from DB
Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
// Used to Save the CIFS ACLs to DB
List<UnManagedCifsShareACL> newUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
List<UnManagedCifsShareACL> oldUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
try {
// Get exports on the array and loop through each export.
DDShareList shareList = ddClient.getShares(storageSystem.getNativeGuid());
for (DDShareInfo shareInfo : shareList.getShares()) {
DDShareInfoDetail share = ddClient.getShare(storageSystem.getNativeGuid(), shareInfo.getId());
if (share.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
continue;
}
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), share.getMtreeId());
// Get UMFS from cache if possible, otherwise try to retrieve from DB
UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
if (unManagedFS == null) {
unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
}
if (unManagedFS != null) {
// Add UMFS to cache
existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
StringSet storagePortIds = unManagedFS.getFileSystemInformation().get(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
StoragePort storagePort = null;
for (String portId : storagePortIds) {
StoragePort sp = _dbClient.queryObject(StoragePort.class, URI.create(portId));
if (sp != null && !sp.getInactive()) {
storagePort = sp;
break;
}
}
associateCifsExportWithFS(unManagedFS, share, storagePort);
unManagedFS.setHasShares(true);
unManagedFS.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_log.debug("Export map for VNX UMFS {} = {}", unManagedFS.getLabel(), unManagedFS.getUnManagedSmbShareMap());
List<UnManagedCifsShareACL> cifsACLs = applyCifsSecurityRules(unManagedFS, share, 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) {
newUnManagedCifsACLs.add(cifsAcl);
} else {
newUnManagedCifsACLs.add(cifsAcl);
existingACL.setInactive(true);
oldUnManagedCifsACLs.add(existingACL);
}
}
// Update the UnManaged file system
_dbClient.persistObject(unManagedFS);
}
if (newUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// create new UnManagedCifsShareACL
_log.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
_dbClient.createObject(newUnManagedCifsACLs);
newUnManagedCifsACLs.clear();
}
if (oldUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
// Update existing UnManagedCifsShareACL
_log.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
_dbClient.persistObject(oldUnManagedCifsACLs);
oldUnManagedCifsACLs.clear();
}
}
if (!newUnManagedCifsACLs.isEmpty()) {
// create new UnManagedCifsShareACL
_log.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
_dbClient.createObject(newUnManagedCifsACLs);
newUnManagedCifsACLs.clear();
}
if (!oldUnManagedCifsACLs.isEmpty()) {
// Update existing UnManagedCifsShareACL
_log.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
_dbClient.persistObject(oldUnManagedCifsACLs);
oldUnManagedCifsACLs.clear();
}
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.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method applyCifsSecurityRules.
private List<UnManagedCifsShareACL> applyCifsSecurityRules(UnManagedFileSystem vnxufs, DDShareInfoDetail share, StoragePort storagePort) {
List<UnManagedCifsShareACL> cifsACLs = new ArrayList<UnManagedCifsShareACL>();
UnManagedCifsShareACL unManagedCifsShareACL = new UnManagedCifsShareACL();
String shareName = share.getName();
unManagedCifsShareACL.setShareName(shareName);
// user
unManagedCifsShareACL.setUser(FileControllerConstants.CIFS_SHARE_USER_EVERYONE);
// permission
unManagedCifsShareACL.setPermission(FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE);
unManagedCifsShareACL.setId(URIUtil.createId(UnManagedCifsShareACL.class));
// filesystem id
unManagedCifsShareACL.setFileSystemId(vnxufs.getId());
cifsACLs.add(unManagedCifsShareACL);
return cifsACLs;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method applyCifsSecurityRules.
private List<UnManagedCifsShareACL> applyCifsSecurityRules(UnManagedFileSystem vnxeufs, String expPath, VNXeCifsShare exp, StoragePort storagePort) {
List<UnManagedCifsShareACL> cifsACLs = new ArrayList<UnManagedCifsShareACL>();
UnManagedCifsShareACL unManagedCifsShareACL = new UnManagedCifsShareACL();
String shareName = exp.getName();
unManagedCifsShareACL.setShareName(shareName);
// user
unManagedCifsShareACL.setUser(FileControllerConstants.CIFS_SHARE_USER_EVERYONE);
// permission
unManagedCifsShareACL.setPermission(FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE);
unManagedCifsShareACL.setId(URIUtil.createId(UnManagedCifsShareACL.class));
// filesystem id
unManagedCifsShareACL.setFileSystemId(vnxeufs.getId());
cifsACLs.add(unManagedCifsShareACL);
return cifsACLs;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method checkUnManagedFsCifsACLExistsInDB.
/**
* check Pre Existing Storage CIFS ACLs exists in DB
*
* @param dbClient
* @param cifsNativeGuid
* @return UnManagedCifsShareACL
* @throws java.io.IOException
*/
protected UnManagedCifsShareACL checkUnManagedFsCifsACLExistsInDB(DbClient dbClient, String cifsACLNativeGuid) {
UnManagedCifsShareACL unManagedCifsAcl = null;
URIQueryResultList result = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileCifsACLNativeGUIdConstraint(cifsACLNativeGuid), result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
URI cifsAclURI = iter.next();
unManagedCifsAcl = dbClient.queryObject(UnManagedCifsShareACL.class, cifsAclURI);
return unManagedCifsAcl;
}
return unManagedCifsAcl;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL in project coprhd-controller by CoprHD.
the class VNXeUnManagedObjectDiscoverer method checkUnManagedFsCifsACLExistsInDB.
/**
* check Pre Existing Storage CIFS ACLs exists in DB
*
* @param dbClient
* @param cifsNativeGuid
* @return UnManagedCifsShareACL
* @throws java.io.IOException
*/
protected UnManagedCifsShareACL checkUnManagedFsCifsACLExistsInDB(DbClient dbClient, String cifsACLNativeGuid) {
UnManagedCifsShareACL unManagedCifsAcl = null;
URIQueryResultList result = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileCifsACLNativeGUIdConstraint(cifsACLNativeGuid), result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
URI cifsAclURI = iter.next();
unManagedCifsAcl = dbClient.queryObject(UnManagedCifsShareACL.class, cifsAclURI);
return unManagedCifsAcl;
}
return unManagedCifsAcl;
}
Aggregations