use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare in project coprhd-controller by CoprHD.
the class PropertySetterUtil method convertUnManagedSMBMapToManaged.
/**
* Extract SMB data from UnManaged to Managed
*
* @param unManagedSMBShareMap
* @return
*/
public static SMBShareMap convertUnManagedSMBMapToManaged(UnManagedSMBShareMap unManagedSMBShareMap, StoragePort storagePort, StorageHADomain dataMover) {
SMBShareMap smbShareMap = new SMBShareMap();
if (unManagedSMBShareMap == null) {
return smbShareMap;
}
SMBFileShare smbshare = null;
for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBShareMap.values()) {
smbshare = new SMBFileShare();
smbshare.setName(unManagedSMBFileShare.getName());
smbshare.setNativeId(unManagedSMBFileShare.getNativeId());
smbshare.setDescription(unManagedSMBFileShare.getDescription());
if (storagePort != null) {
smbshare.setMountPoint("\\\\" + storagePort.getPortNetworkId() + "\\" + unManagedSMBFileShare.getName());
} else {
smbshare.setMountPoint(unManagedSMBFileShare.getMountPoint());
}
smbshare.setPath(unManagedSMBFileShare.getPath());
// need to removed
smbshare.setMaxUsers(unManagedSMBFileShare.getMaxUsers());
smbshare.setPermission(unManagedSMBFileShare.getPermission());
smbshare.setPermissionType(unManagedSMBFileShare.getPermissionType());
smbshare.setPortGroup(storagePort.getPortGroup());
// share name
smbShareMap.put(unManagedSMBFileShare.getName(), smbshare);
}
return smbShareMap;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method associateCifsExportWithFS.
private void associateCifsExportWithFS(UnManagedFileSystem ddufs, DDShareInfoDetail share, StoragePort storagePort) {
try {
// Assign storage port to unmanaged FS
if (storagePort != null) {
StringSet storagePorts = new StringSet();
storagePorts.add(storagePort.getId().toString());
ddufs.getFileSystemInformation().remove(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
ddufs.getFileSystemInformation().put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
}
String shareName = share.getName();
String mountPoint = getMountPount(shareName, storagePort);
UnManagedSMBFileShare unManagedSMBFileShare = new UnManagedSMBFileShare();
unManagedSMBFileShare.setName(shareName);
unManagedSMBFileShare.setMountPoint(mountPoint);
// unManagedSMBFileShare.setDescription(share.ge);
int maxUsers = Integer.MAX_VALUE;
unManagedSMBFileShare.setMaxUsers(maxUsers);
unManagedSMBFileShare.setPortGroup(storagePort.getPortGroup());
unManagedSMBFileShare.setPermission(ShareACL.SupportedPermissions.change.toString());
// setting to default permission type for DDMC
unManagedSMBFileShare.setPermissionType(FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW);
unManagedSMBFileShare.setPath(share.getPath());
UnManagedSMBShareMap currUnManagedShareMap = ddufs.getUnManagedSmbShareMap();
if (currUnManagedShareMap == null) {
currUnManagedShareMap = new UnManagedSMBShareMap();
ddufs.setUnManagedSmbShareMap(currUnManagedShareMap);
}
if (currUnManagedShareMap.get(shareName) == null) {
currUnManagedShareMap.put(shareName, unManagedSMBFileShare);
_log.info("associateCifsExportWithFS - no SMBs already exists for share {}", shareName);
} else {
// Remove the existing and add the new share
currUnManagedShareMap.remove(shareName);
currUnManagedShareMap.put(shareName, unManagedSMBFileShare);
_log.warn("associateSMBShareMapWithFS - Identical export already exists for mount path {} Overwrite", shareName);
}
} catch (Exception ex) {
_log.warn("VNX file share retrieve processor failed for path {}, cause {}", share.getPath(), ex);
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method createSMBShareMap.
/**
* add Unmanaged SMB share to FS Object
*
* @param unManagedSMBFileShareHashSet
* @param unManagedSMBShareMap
* @param addr
* @param nativeid
*/
private void createSMBShareMap(HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet, UnManagedSMBShareMap unManagedSMBShareMap, String addr, String nativeid) {
UnManagedSMBFileShare newUnManagedSMBFileShare = null;
for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBFileShareHashSet) {
String mountPoint = "\\\\" + addr + "\\" + unManagedSMBFileShare.getName();
newUnManagedSMBFileShare = new UnManagedSMBFileShare(unManagedSMBFileShare.getName(), unManagedSMBFileShare.getDescription(), // for netApp c mode permission and permission type is not used ,setting to default
FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW, FileControllerConstants.CIFS_SHARE_PERMISSION_CHANGE, unManagedSMBFileShare.getMaxUsers(), mountPoint);
newUnManagedSMBFileShare.setPath(nativeid);
newUnManagedSMBFileShare.setNativeId(nativeid);
newUnManagedSMBFileShare.setPortGroup(addr);
// add new cifs share to File Object
unManagedSMBShareMap.put(unManagedSMBFileShare.getName(), newUnManagedSMBFileShare);
_logger.info("New SMB share name: {} has mount point : {}", unManagedSMBFileShare.getName(), mountPoint);
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method discoverUnManagedCifsShares.
/**
* discover the unmanaged cifs shares and add shares to ViPR db
*
* @param profile
*/
private void discoverUnManagedCifsShares(AccessProfile profile) {
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
String detailedStatusMessage = "Discovery of NetAppC Unmanaged Cifs started";
NetAppClusterApi netAppCApi = new NetAppClusterApi.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>();
HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet = null;
List<Map<String, String>> fileSystemInfo = netAppCApi.listVolumeInfo(null, attrs);
List<StorageVirtualMachineInfo> svms = netAppCApi.listSVM();
for (StorageVirtualMachineInfo svmInfo : svms) {
netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).svm(svmInfo.getName()).build();
// Get All cifs shares and ACLs
List<Map<String, String>> listShares = netAppCApi.listShares(null);
if (listShares != null && !listShares.isEmpty()) {
_logger.info("total no of shares in netappC system (s) {}", listShares.size());
}
// prepare the unmanagedSmbshare
HashMap<String, HashSet<UnManagedSMBFileShare>> unMangedSMBFileShareMapSet = getAllCifsShares(listShares);
for (String key : unMangedSMBFileShareMapSet.keySet()) {
unManagedSMBFileShareHashSet = unMangedSMBFileShareMapSet.get(key);
String fileSystem = key;
String nativeId = fileSystem;
// get a fileSystem name from the path
int index = fileSystem.indexOf('/', 1);
if (-1 != index) {
fileSystem = fileSystem.substring(0, index);
_logger.info("Unmanaged FileSystem Name {}", fileSystem);
}
// build native id
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fileSystem);
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
boolean fsAlreadyExists = unManagedFs == null ? false : true;
if (fsAlreadyExists) {
_logger.debug("retrieve info for file system: " + fileSystem);
String svm = getOwningSVM(fileSystem, fileSystemInfo);
String addr = getSVMAddress(svm, svms);
UnManagedSMBShareMap tempUnManagedSMBShareMap = new UnManagedSMBShareMap();
// get the SMB shares
createSMBShareMap(unManagedSMBFileShareHashSet, tempUnManagedSMBShareMap, addr, nativeId);
// add shares to fs object and set hasShare to true
if (tempUnManagedSMBShareMap.size() > 0 && !tempUnManagedSMBShareMap.isEmpty()) {
unManagedFs.setUnManagedSmbShareMap(tempUnManagedSMBShareMap);
unManagedFs.setHasShares(true);
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
_logger.debug("SMB Share map for NetAppC UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getUnManagedSmbShareMap());
}
// get the acls details for given fileshare of given fs
UnManagedCifsShareACL existingACL = null;
List<UnManagedCifsShareACL> tempUnManagedCifsShareAclList = getACLs(unManagedSMBFileShareHashSet, netAppCApi, storageSystem, unManagedFs.getId());
if (tempUnManagedCifsShareAclList != null && !tempUnManagedCifsShareAclList.isEmpty()) {
for (UnManagedCifsShareACL unManagedCifsShareACL : tempUnManagedCifsShareAclList) {
// Check whether the CIFS share ACL was present in ViPR DB.
existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, unManagedCifsShareACL.getNativeGuid());
if (existingACL == null) {
// add new acl
unManagedCifsShareACLList.add(unManagedCifsShareACL);
} else {
// delete the existing acl by setting object to inactive to true
existingACL.setInactive(true);
oldunManagedCifsShareACLList.add(existingACL);
// then add new acl and save
unManagedCifsShareACLList.add(unManagedCifsShareACL);
}
}
}
// store or update the FS object into DB
if (unManagedSMBFileShareHashSet != null && !unManagedSMBFileShareHashSet.isEmpty()) {
_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.size() >= MAX_UMFS_RECORD_SIZE) {
_logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
_partitionManager.insertInBatches(unManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
unManagedCifsShareACLList.clear();
}
if (!oldunManagedCifsShareACLList.isEmpty() && oldunManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
_logger.info("Update Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
_partitionManager.updateInBatches(oldunManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
oldunManagedCifsShareACLList.clear();
}
} else {
_logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + fileSystem + " share");
}
}
}
if (unManagedCifsShareACLList != null && !unManagedCifsShareACLList.isEmpty()) {
_logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
_partitionManager.insertInBatches(unManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
unManagedCifsShareACLList.clear();
}
if (oldunManagedCifsShareACLList != null && !oldunManagedCifsShareACLList.isEmpty()) {
_logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
_partitionManager.updateInBatches(oldunManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
oldunManagedCifsShareACLList.clear();
}
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for NetAppC: %s", storageSystemId.toString());
} catch (NetAppCException ve) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
}
_logger.error("discoverStorage failed. Storage system: " + storageSystemId);
} catch (Exception e) {
if (null != storageSystem) {
cleanupDiscovery(storageSystem);
storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
}
_logger.error("discoverStorage failed. Storage system: " + storageSystemId, 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.UnManagedSMBFileShare in project coprhd-controller by CoprHD.
the class NetAppFileCommunicationInterface method getACLs.
/**
* get ACLs for smb shares of fs object
*
* @param unManagedSMBFileShareHashSet
* @param netAppApi
* @param fsId
* @return
*/
private List<UnManagedCifsShareACL> getACLs(HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet, NetAppApi netAppApi, URI 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;
if (unManagedSMBFileShareHashSet != null && !unManagedSMBFileShareHashSet.isEmpty()) {
for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBFileShareHashSet) {
// find acl for given share
String unManagedSMBFileShareName = unManagedSMBFileShare.getName();
_logger.info("New smb share name: {} and fs : {}", unManagedSMBFileShareName, fsId);
cifsAclList = netAppApi.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);
// add the acl to acl-list
unManagedCifsShareACLList.add(unManagedCifsShareACL);
}
}
}
}
return unManagedCifsShareACLList;
}
Aggregations