use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.
the class FileProvider method getNFSMountsForHost.
@Asset("mountedNFSExport")
@AssetDependencies("linuxFileHost")
public List<AssetOption> getNFSMountsForHost(AssetOptionsContext ctx, URI host) {
List<AssetOption> options = Lists.newArrayList();
List<MountInfo> hostMounts = api(ctx).fileSystems().getNfsMountsByHost(host);
for (MountInfo mountInfo : hostMounts) {
String mountString = mountInfo.getMountString();
options.add(new AssetOption(mountString, getDisplayMount(ctx, mountInfo)));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.
the class MachineTagUtils method getMountInfo.
public static MountInfo getMountInfo(String strMountInfo) {
if (strMountInfo != null && !strMountInfo.isEmpty()) {
MountInfo mountInfo = new MountInfo();
String[] mountAttrs = strMountInfo.split(";");
if (mountAttrs.length > 0) {
mountInfo.setHostId(URIUtil.uri(mountAttrs[0]));
}
if (mountAttrs.length > 1) {
mountInfo.setFsId(URIUtil.uri(mountAttrs[1]));
}
if (mountAttrs.length > 2) {
mountInfo.setSecurityType(mountAttrs[2]);
}
if (mountAttrs.length > 3) {
mountInfo.setMountPath(mountAttrs[3]);
}
if (mountAttrs.length > 4) {
mountInfo.setSubDirectory(mountAttrs[4]);
if (StringUtils.isEmpty(mountAttrs[4])) {
mountInfo.setSubDirectory(null);
}
}
return mountInfo;
}
return null;
}
use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.
the class UnmountNFSExportHelper method unmountExports.
public void unmountExports() {
for (MountInfo mount : mountList) {
logInfo("linux.mount.file.export.unmount", mount.getMountPath(), hostname);
FileStorageUtils.unmountNFSExport(mount.getFsId(), mount.getHostId(), mount.getMountPath());
}
}
use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.
the class FileOperationUtils method queryDBHostMounts.
/**
* Method to get the list file system mounts which are mount on a host
*
* @param host
* host system URI
* @return List<MountInfo> List of mount infos
*/
public static List<MountInfo> queryDBHostMounts(URI host, DbClient dbClient) {
_log.info("Querying NFS mounts for host {}", host);
List<MountInfo> hostMounts = new ArrayList<MountInfo>();
try {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getHostFileMountsConstraint(host);
List<FileMountInfo> fileMounts = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileMountInfo.class, containmentConstraint);
if (fileMounts != null && !fileMounts.isEmpty()) {
for (FileMountInfo dbMount : fileMounts) {
MountInfo mountInfo = new MountInfo();
getMountInfo(dbMount, mountInfo);
hostMounts.add(mountInfo);
}
}
return hostMounts;
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return hostMounts;
}
use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method updateExportRules.
@Override
public void updateExportRules(URI storage, URI uri, FileExportUpdateParams param, boolean unmountExport, String opId) throws ControllerException {
FileObject fileObj = null;
String stepDescription = null;
String successMessage = null;
String opName = null;
TaskCompleter completer = null;
if (URIUtil.isType(uri, FileShare.class)) {
completer = new FileWorkflowCompleter(uri, opId);
fileObj = s_dbClient.queryObject(FileShare.class, uri);
stepDescription = String.format("Updating file system : %s export rules: %s", uri, param.toString());
successMessage = String.format("Updating file system : %s export rules: %s finished successfully.", uri, param.toString());
opName = ResourceOperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SYSTEM.getName();
} else {
completer = new FileSnapshotWorkflowCompleter(uri, opId);
fileObj = s_dbClient.queryObject(Snapshot.class, uri);
stepDescription = String.format("Updating file system : %s export rules: %s", uri, param.toString());
successMessage = String.format("Updating file system : %s export rules: %s finished successfully.", uri, param.toString());
opName = ResourceOperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SNAPSHOT.getName();
}
try {
Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_FILESYSTEM_EXPORT_RULES_WF_NAME, false, opId, completer);
String waitFor = null;
// Check if the export should be unmounted before deleting
if (unmountExport) {
// get all the mounts and generate steps for unmounting them
List<MountInfo> mountList = _fileDeviceController.getMountedExports(uri, param.getSubDir(), param);
for (MountInfo mount : mountList) {
Object[] args = new Object[] { mount.getHostId(), mount.getFsId(), mount.getMountPath() };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, UNMOUNT_FILESYSTEM_EXPORT_METHOD, null, "Unmounting path:" + mount.getMountPath(), storage, args);
}
} else if (URIUtil.isType(uri, FileShare.class)) {
// Check if the export rule is mounted and throw an error if mounted
Object[] args = new Object[] { uri, param };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, VERIFY_MOUNT_DEPENDENCIES_METHOD, null, "Verifying mount dependencies", storage, args);
}
Object[] args = new Object[] { storage, uri, param };
_fileDeviceController.createMethod(workflow, waitFor, UPDATE_FILESYSTEM_EXPORT_RULES_METHOD, null, stepDescription, storage, args);
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error(String.format("Updating file system : %s export rules: %s failed.", uri, param.toString()), ex);
ServiceError serviceError = DeviceControllerException.errors.updateFileShareExportRulesFailed(fileObj.toString(), opName, ex);
completer.error(s_dbClient, _locker, serviceError);
}
}
Aggregations