use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverAllExportRules.
public void discoverAllExportRules(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
log.info("discoverAllExportRules for storage system {} - start", storageSystem.getId());
unManagedExportRulesInsert = new ArrayList<UnManagedFileExportRule>();
unManagedExportRulesUpdate = new ArrayList<UnManagedFileExportRule>();
unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
List<VNXeNfsShare> nfsExports = apiClient.getAllNfsShares();
// Verification Utility
UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(dbClient);
for (VNXeNfsShare exp : nfsExports) {
log.info("Discovered fS export {}", 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 nfsShareId = exp.getId();
String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, nfsShareId);
log.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
UnManagedFileExportRule unManagedExportRule = checkUnManagedFsExportRuleExistsInDB(dbClient, fsUnManagedFileExportRuleNativeGuid);
UnManagedFileExportRule unManagedExpRule = null;
List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
if (unManagedExportRule == null) {
unManagedExportRule = new UnManagedFileExportRule();
unManagedExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
unManagedExportRule.setFileSystemId(unManagedFs.getId());
unManagedExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
unManagedExpRule = createExportRules(unManagedFs.getId(), apiClient, exp, unManagedExportRule, mountPath, mountPoint, nfsShareId, storagePort.getPortName());
unManagedExportRulesInsert.add(unManagedExpRule);
} else {
unManagedExpRule = createExportRules(unManagedFs.getId(), apiClient, exp, unManagedExportRule, mountPath, mountPoint, nfsShareId, storagePort.getPortName());
unManagedExportRulesUpdate.add(unManagedExpRule);
}
log.info("Unmanaged File Export Rule : {}", unManagedExportRule);
// Build all export rules list.
unManagedExportRules.add(unManagedExpRule);
// apply as per API SVC Validations.
if (!unManagedExportRules.isEmpty()) {
boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
if (isAllRulesValid) {
log.info("Validating rules success for export {}", unManagedFs.getPath());
unManagedFs.setHasExports(true);
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), Boolean.TRUE.toString());
unManagedFilesystemsUpdate.add(unManagedFs);
log.info("File System {} has Exports and their size is {}", unManagedFs.getId(), unManagedExportRules.size());
} else {
log.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", unManagedFs);
unManagedFs.setInactive(true);
unManagedFilesystemsUpdate.add(unManagedFs);
}
}
} catch (IOException e) {
log.error("IOException occured in discoverAllExportRules()", e);
}
}
}
if (!unManagedExportRulesInsert.isEmpty()) {
// Add UnManage export rules
partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
}
if (!unManagedExportRulesUpdate.isEmpty()) {
// Update UnManage export rules
partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
}
if (!unManagedFilesystemsUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
}
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem 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();
}
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXeApiClient method createCifsShareForSnap.
/**
* Create CIFS share for snapshot
*
* @param snapId
* snapshot id
* @param shareName
* CIFS share name
* @param permission
* READ, CHANGE, FULL
* @return VNXeCommandJob
* @throws VNXeException
*/
public VNXeCommandJob createCifsShareForSnap(String snapId, String shareName, String permission, String path, String fsId) throws VNXeException {
_logger.info("Creating CIFS snapshot share name: {} for path: {}", shareName, path);
// to get NETBIOS of CIFS Server file system is used as for snapshot
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
List<VNXeCifsServer> cifsServers = getCifsServers(fs.getNasServer().getId());
netBios = cifsServers.get(0).getNetbiosName();
CifsShareRequests req = new CifsShareRequests(_khClient);
CifsShareCreateForSnapParam param = new CifsShareCreateForSnapParam();
param.setPath(path);
VNXeBase snap = new VNXeBase();
snap.setId(snapId);
if (!VNXeUtils.isHigherVersion(getBasicSystemInfo().getSoftwareVersion(), VNXeConstants.VNXE_BASE_SOFT_VER)) {
param.setFilesystemSnap(snap);
} else {
param.setSnap(snap);
}
param.setName(shareName);
if (permission != null && !permission.isEmpty() && permission.equalsIgnoreCase(AccessEnum.READ.name())) {
param.setIsReadOnly(true);
} else {
param.setIsReadOnly(false);
}
return req.createShareForSnapshot(param);
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXeApiClient method exportFileSystem.
/**
* NFS export
*
* @param fsId
* file system KH id
* @param endpoints
* list of host ipaddresses export to
* @param access
* access right
* @return VNXeCommandJob
* @throws VNXeException
*/
public VNXeCommandJob exportFileSystem(String fsId, List<String> roEndpoints, List<String> rwEndpoints, List<String> rootEndpoints, AccessEnum access, String path, String shareName, String shareId, String comments) throws VNXeException {
_logger.info("Exporting file system:" + fsId);
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.info("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
String resourceId = fs.getStorageResource().getId();
ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
List<VNXeBase> roHosts = getHosts(roEndpoints);
List<VNXeBase> rwHosts = getHosts(rwEndpoints);
List<VNXeBase> rootHosts = getHosts(rootEndpoints);
VNXeNfsShare nfsShareFound = null;
if (shareName != null) {
nfsShareFound = findNfsShare(fsId, shareName);
} else {
nfsShareFound = getNfsShareById(shareId);
}
String nfsShareId = null;
List<VNXeBase> hosts = new ArrayList<VNXeBase>();
if (nfsShareFound != null) {
nfsShareId = nfsShareFound.getId();
}
NfsShareParam shareParm = new NfsShareParam();
shareParm.setReadOnlyHosts(roHosts);
shareParm.setReadWriteHosts(rwHosts);
shareParm.setRootAccessHosts(rootHosts);
if (comments != null) {
shareParm.setDescription(comments);
}
if (access == null) {
if (nfsShareFound != null) {
hosts.addAll(nfsShareFound.getNoAccessHosts());
hosts.addAll(nfsShareFound.getRootAccessHosts());
hosts.addAll(nfsShareFound.getReadWriteHosts());
hosts.addAll(nfsShareFound.getReadOnlyHosts());
}
NFSShareDefaultAccessEnum nfsShareDefaultAccess = NFSShareDefaultAccessEnum.NONE;
if (nfsShareFound != null) {
nfsShareDefaultAccess = nfsShareFound.getDefaultAccess();
}
if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.ROOT)) {
if (!hosts.isEmpty()) {
shareParm.setRootAccessHosts(hosts);
} else {
shareParm.setRootAccessHosts(null);
}
shareParm.setNoAccessHosts(null);
shareParm.setReadWriteHosts(null);
shareParm.setReadOnlyHosts(null);
} else if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.READONLY)) {
if (!hosts.isEmpty()) {
shareParm.setReadOnlyHosts(hosts);
} else {
shareParm.setReadOnlyHosts(null);
}
shareParm.setNoAccessHosts(null);
shareParm.setReadWriteHosts(null);
shareParm.setRootAccessHosts(null);
} else if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.READWRITE)) {
if (!hosts.isEmpty()) {
shareParm.setReadWriteHosts(hosts);
} else {
shareParm.setReadWriteHosts(null);
}
shareParm.setNoAccessHosts(null);
shareParm.setReadOnlyHosts(null);
shareParm.setRootAccessHosts(null);
} else if (nfsShareDefaultAccess.equals(NFSShareDefaultAccessEnum.NONE)) {
if (!hosts.isEmpty()) {
shareParm.setNoAccessHosts(hosts);
} else {
shareParm.setNoAccessHosts(null);
}
shareParm.setReadWriteHosts(null);
shareParm.setReadOnlyHosts(null);
shareParm.setRootAccessHosts(null);
}
}
if (nfsShareId == null) {
// not found, new export
if (!isUnityClient()) {
shareParm.setDefaultAccess(NFSShareDefaultAccessEnum.NONE);
}
NfsShareCreateParam nfsShareCreateParm = new NfsShareCreateParam();
nfsShareCreateParm.setName(shareName);
nfsShareCreateParm.setPath(path);
nfsShareCreateParm.setNfsShareParameters(shareParm);
List<NfsShareCreateParam> nfsList = new ArrayList<NfsShareCreateParam>();
nfsList.add(nfsShareCreateParm);
modifyFSParm.setNfsShareCreate(nfsList);
} else {
// update export
NfsShareModifyParam nfsShareModifyParam = new NfsShareModifyParam();
VNXeBase nfsShare = new VNXeBase();
nfsShare.setId(nfsShareId);
nfsShareModifyParam.setNfsShare(nfsShare);
nfsShareModifyParam.setNfsShareParameters(shareParm);
List<NfsShareModifyParam> nfsModifyList = new ArrayList<NfsShareModifyParam>();
nfsModifyList.add(nfsShareModifyParam);
modifyFSParm.setNfsShareModify(nfsModifyList);
}
FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
return req.modifyFileSystemAsync(modifyFSParm, resourceId);
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverUnManagedFileSystems.
public void discoverUnManagedFileSystems(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedFilesystems for system {}", accessProfile.getSystemId());
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
unManagedFilesystemsInsert = new ArrayList<UnManagedFileSystem>();
unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
List<VNXeFileSystem> filesystems = apiClient.getAllFileSystems();
if (filesystems != null && !filesystems.isEmpty()) {
Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
for (VNXeFileSystem fs : filesystems) {
StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
StoragePool pool = getStoragePoolOfUnManagedObject(fs.getPool().getId(), storageSystem, pools);
if (null == pool) {
log.error("Skipping unmanaged volume discovery as the file system {} storage pool doesn't exist in ViPR", fs.getId());
continue;
}
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);
unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs, dbClient);
unManagedFilesystemsReturnedFromProvider.add(unManagedFs.getId());
}
if (!unManagedFilesystemsInsert.isEmpty()) {
// Add UnManagedFileSystem
partitionManager.insertInBatches(unManagedFilesystemsInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
}
if (!unManagedFilesystemsUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateAndReIndexInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to
// mark them inactive.
performStorageUnManagedFSBookKeeping(storageSystem, dbClient, partitionManager);
} else {
log.info("There are no file systems found on the system: {}", storageSystem.getId());
}
}
Aggregations