diff options
author | Shwetha Panduranga <spandura@redhat.com> | 2017-02-08 18:52:37 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2017-02-27 04:45:08 -0500 |
commit | daca62f4b7f876bf675e5b29b643e3d472903597 (patch) | |
tree | 2d036166d6e5fe51e43edea5e97d1befac178352 /glustolibs-gluster/glustolibs/gluster/nfs_libs.py | |
parent | bc30c6a7eebc20416e6c7fe5c7b080f4e96b5f57 (diff) |
Adding a new test to VVT:
1) glusterbaseclass:
- Making changes in glusterbaseclass to not necessarily have volume_type
and mount_type.
2) volume_libs:
- setup_volume don't have to export the volume. It just creates starts
and setup's any operation on the volume.
- Moved the sharing/exporting the volume to BaseClass
3) Renaming samba_ops to samba_libs to have better naming practice.
4) Adding nfs_ganesha_libs for any nfs related helper functions
5) Adding a new vvt case which creates, deteles, creates the volume.
Change-Id: I238c349df7165d669d3bc7234d97845dba2f51a6
Signed-off-by: Shwetha Panduranga <spandura@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/nfs_libs.py')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/nfs_libs.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/nfs_libs.py b/glustolibs-gluster/glustolibs/gluster/nfs_libs.py new file mode 100644 index 000000000..003ebc2d0 --- /dev/null +++ b/glustolibs-gluster/glustolibs/gluster/nfs_libs.py @@ -0,0 +1,63 @@ +# Copyright (C) 2015-2016 Red Hat, Inc. <http://www.redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" + Description: Libraries for gluster nfs operations. +""" +import time +from glusto.core import Glusto as g +from glustolibs.gluster.volume_libs import is_volume_exported + + +def export_volume_through_nfs(mnode, volname, enable_ganesha=False, + time_delay=30): + """Export the volume through nfs + + Args: + mnode (str): Node on which cmd has to be executed. + volname (str): volume name + enable_ganesha (bool): Enable ganesha for the volume. + time_delay (int): Time to wait after the volume set operations + to validate whether the volume is exported or not. + + Returns: + bool: If volume is successfully exported through nfs returns True. + False Otherwise. + """ + # Enable nfs on the volume + cmd = ("gluster volume set %s nfs.disable off --mode=script" % volname) + ret, _, _ = g.run(mnode, cmd) + if ret != 0: + g.log.error("Failed to enable nfs for the volume %s", volname) + return False + + # Enable ganesha on the volume if enable_ganesha is True + if enable_ganesha: + cmd = ("gluster volume set %s ganesha.enable on --mode=script" % + volname) + ret, _, _ = g.run(mnode, cmd) + if ret != 0: + g.log.error("Failed to enable nfs ganesha for volume %s", volname) + return False + + time.sleep(time_delay) + # Verify if volume is exported + ret = is_volume_exported(mnode, volname, "nfs") + if not ret: + g.log.info("Volume %s is not exported as 'nfs' export", volname) + return False + + return True |