From c9ed3914657747baa27cbb8e0eb963133c79dd23 Mon Sep 17 00:00:00 2001 From: Sanoj Unnikrishnan Date: Fri, 8 Jun 2018 14:52:20 +0530 Subject: Quota: Fixing quota libs in glusto - added quota_libs.py with quota_validate library - Removed redundant function in quota_ops. - changed naming of quota_ops to be consistent and intutive w.r.t cli Change-Id: I4faf448ea308c9e04b548d6174d900fcf56978a5 Signed-off-by: Sanoj Unnikrishnan --- .../glustolibs/gluster/quota_libs.py | 63 ++++++ glustolibs-gluster/glustolibs/gluster/quota_ops.py | 233 ++++----------------- .../glustolibs/gluster/volume_libs.py | 8 +- tests/functional/bvt/test_cvt.py | 24 +-- tests/functional/quota/list_path_values.py | 16 +- tests/functional/quota/test_negative_quota.py | 14 +- tests/functional/quota/test_non_existent_dir.py | 10 +- 7 files changed, 142 insertions(+), 226 deletions(-) create mode 100644 glustolibs-gluster/glustolibs/gluster/quota_libs.py diff --git a/glustolibs-gluster/glustolibs/gluster/quota_libs.py b/glustolibs-gluster/glustolibs/gluster/quota_libs.py new file mode 100644 index 000000000..fc4275c18 --- /dev/null +++ b/glustolibs-gluster/glustolibs/gluster/quota_libs.py @@ -0,0 +1,63 @@ +# Copyright (C) 2018 Red Hat, Inc. +# +# 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: Module for gluster quota related helper functions. """ + + +from glusto.core import Glusto as g +from glustolibs.gluster.quota_ops import (quota_fetch_list) + + +def quota_validate(mnode, volname, path, **kwargs): + """ Validate if the hard limit, soft limit, usage match the expected values. + If any of the arguments are None, they are not verified. + + Args: + mnode (str) : Node on which command has to be executed. + volname (str) : volume name. + path (str) : Path to be verified. + kwargs + hard_limit(int) : hard limit is verified with this value. + soft_limit_percent(int) : soft limit (in %) is verified with this value + used_space(int) : if set, usage as displayed in quota list is + verified with expected value. + avail_space(int) : if set, usage as displayed in quota list is + verified with expected value. + sl_exceeded(bool) : expected value of soft limit flag. + hl_exceeded(bool) : expected value of hard limit flag. + + """ + + if kwargs is None: + g.log.error("No arguments given for validation") + return False + + quotalist = quota_fetch_list(mnode, volname, path) + + if path not in quotalist: + g.log.error("Path not found (script issue)") + return False + else: + listinfo = quotalist[path] + + ret = True + for key, value in kwargs.iteritems(): + if key and listinfo[key] != value: + g.log.error("%s = %s does not match with expected value %s", + key, str(listinfo[key]), str(value)) + ret = False + + return ret diff --git a/glustolibs-gluster/glustolibs/gluster/quota_ops.py b/glustolibs-gluster/glustolibs/gluster/quota_ops.py index 314d6de9b..f56471f59 100644 --- a/glustolibs-gluster/glustolibs/gluster/quota_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/quota_ops.py @@ -18,18 +18,16 @@ """ Description: Library for gluster quota operations. """ - -from glusto.core import Glusto as g -from glustolibs.gluster.exceptions import ExecutionError, ExecutionParseError -from glustolibs.gluster.volume_ops import get_volume_options - try: import xml.etree.cElementTree as etree except ImportError: import xml.etree.ElementTree as etree +from glusto.core import Glusto as g +from glustolibs.gluster.volume_ops import get_volume_options + -def enable_quota(mnode, volname): +def quota_enable(mnode, volname): """Enables quota on given volume Args: @@ -48,14 +46,14 @@ def enable_quota(mnode, volname): of the command execution. Example: - enable_quota("abc.xyz.com", testvol) + quota_enable("abc.xyz.com", testvol) """ cmd = "gluster volume quota %s enable" % volname return g.run(mnode, cmd) -def disable_quota(mnode, volname): +def quota_disable(mnode, volname): """Disables quota on given volume Args: @@ -74,7 +72,7 @@ def disable_quota(mnode, volname): of the command execution. Example: - disable_quota("abc.xyz.com", testvol) + quota_disable("abc.xyz.com", testvol) """ cmd = "gluster volume quota %s disable --mode=script" % volname @@ -100,15 +98,15 @@ def is_quota_enabled(mnode, volname): if output is None: return False - g.log.info("Quota Status in volume %s %s" - % (volname, output["features.quota"])) + g.log.info("Quota Status in volume %s %s", + volname, output["features.quota"]) if output["features.quota"] != 'on': return False return True -def check_quota_deem_statfs(mnode, volname): +def quota_check_deem_statfs(mnode, volname): """Checks if quota-deem-statfs is enabled on given volume @@ -121,7 +119,7 @@ def check_quota_deem_statfs(mnode, volname): False, if quota-deem-statfs is disabled Example: - check_quota_deem_statfs(mnode, testvol) + quota_check_deem_statfs(mnode, testvol) """ output = get_volume_options(mnode, volname, @@ -148,41 +146,8 @@ def check_quota_deem_statfs(mnode, volname): return False -def quota_list(mnode, volname, path=None): - """Executes quota list command for given volume - - Args: - mnode (str): Node on which cmd has to be executed. - volname (str): volume name - - Kwargs: - path (str): Quota path - - Returns: - tuple: Tuple containing three elements (ret, out, err). - The first element 'ret' is of type 'int' and is the return value - of command execution. - - The second element 'out' is of type 'str' and is the stdout value - of the command execution. - - The third element 'err' is of type 'str' and is the stderr value - of the command execution. - - Example: - quota_list(mnode, testvol) - """ - - if not path: - path = '' - - cmd = "gluster volume quota %s list %s" % (volname, path) - ret = g.run(mnode, cmd) - return ret - - -def set_quota_limit_usage(mnode, volname, path='/', limit='100GB', - soft_limit=''): +def quota_limit_usage(mnode, volname, path='/', limit='100GB', + soft_limit=''): """Sets limit-usage on the path of the specified volume to specified limit @@ -208,7 +173,7 @@ def set_quota_limit_usage(mnode, volname, path='/', limit='100GB', of the command execution. Examples: - >>> set_quota_limit_usage("abc.com", "testvol") + >>> quota_limit_usage("abc.com", "testvol") """ @@ -217,7 +182,7 @@ def set_quota_limit_usage(mnode, volname, path='/', limit='100GB', return g.run(mnode, cmd) -def get_quota_list(mnode, volname, path=None): +def quota_fetch_list(mnode, volname, path=None): """Parse the output of 'gluster quota list' command. Args: @@ -232,7 +197,7 @@ def get_quota_list(mnode, volname, path=None): dict: dict on success. Examples: - >>> get_quota_list('abc.lab.eng.xyz.com', "testvol") + >>> quota_fetch_list('abc.lab.eng.xyz.com', "testvol") {'/': {'used_space': '0', 'hl_exceeded': 'No', 'soft_limit_percent': '60%', 'avail_space': '2147483648', 'soft_limit_value': '1288490188', 'sl_exceeded': 'No', 'hard_limit': '2147483648'}} @@ -259,100 +224,22 @@ def get_quota_list(mnode, volname, path=None): if elem.tag == "path": path = elem.text quotalist[path] = {} + elif elem.tag in ("hard_limit", "soft_limit_value", + "used_space", "avail_space"): + quotalist[path][elem.tag] = int(elem.text) + elif elem.tag == "soft_limit_percent": + quotalist[path][elem.tag] = int(elem.text[:-1]) + elif elem.tag in ("sl_exceeded", "hl_exceeded"): + quotalist[path][elem.tag] = bool(elem.text == 'Yes') else: - quotalist[path][elem.tag] = elem.text + g.log.error("Failed to parse the gluster quota" + "list xml output.") + return None return quotalist -def is_hard_limit_exceeded(mnode, volname, path=None): - """Parse the output of 'gluster quota list' command. - - Args: - mnode (str): Node on which command has to be executed. - volname (str): volume name - - Kwargs: - path (str): Quota path - - Returns: - boolean: True if exceeded, False if not. - - Examples: - >>> get_quota_list('abc.lab.eng.xyz.com', "testvol") - {'/': {'used_space': '0', 'hl_exceeded': 'No', 'soft_limit_percent': - '60%', 'avail_space': '2147483648', 'soft_limit_value': '1288490188', - 'sl_exceeded': 'No', 'hard_limit': '2147483648'}} - """ - if not path: - path = '' - - cmd = "gluster volume quota %s list %s --xml" % (volname, path) - ret, out, _ = g.run(mnode, cmd) - if ret != 0: - g.log.error("Failed to execute 'quota list' on node %s. " - "Hence failed to get the quota list." % - mnode) - raise ExecutionError("Quota list --xml command failed") - else: - try: - root = etree.XML(out) - except etree.ParseError: - raise ExecutionParseError("Failed to parse the gluster quota " - "list xml output.") - else: - for path in root.findall("volQuota/limit"): - for elem in path.getchildren(): - if elem.tag == 'hl_exceeded': - if elem.text == 'Yes': - return True - return False - - -def is_soft_limit_exceeded(mnode, volname, path=None): - """Parse the output of 'gluster quota list' command. - - Args: - mnode (str): Node on which command has to be executed. - volname (str): volume name - - Kwargs: - path (str): Quota path - - Returns: - boolean: True if exceeded, False if not. - Examples: - >>> get_quota_list('abc.lab.eng.xyz.com', "testvol") - {'/': {'used_space': '0', 'hl_exceeded': 'No', 'soft_limit_percent': - '60%', 'avail_space': '2147483648', 'soft_limit_value': '1288490188', - 'sl_exceeded': 'No', 'hard_limit': '2147483648'}} - """ - if not path: - path = '' - - cmd = "gluster volume quota %s list %s --xml" % (volname, path) - ret, out, _ = g.run(mnode, cmd) - if ret != 0: - g.log.error("Failed to execute 'quota list' on node %s. " - "Hence failed to get the quota list." % - mnode) - raise ExecutionError("Quota list --xml command failed") - if ret == 0: - try: - root = etree.XML(out) - except etree.ParseError: - raise ExecutionParseError("Failed to parse the gluster quota " - "list xml output.") - else: - for path in root.findall("volQuota/limit"): - for elem in path.getchildren(): - if elem.tag == 'sl_exceeded': - if elem.text == 'Yes': - return True - return False - - -def set_quota_limit_objects(mnode, volname, path='/', limit='10', - soft_limit=''): +def quota_limit_objects(mnode, volname, path='/', limit='10', + soft_limit=''): """Sets limit-objects on the path of the specified volume to specified limit @@ -378,7 +265,7 @@ def set_quota_limit_objects(mnode, volname, path='/', limit='10', of the command execution. Examples: - >>> set_quota_limit_objects("abc.com", "testvol") + >>> quota_limit_objects("abc.com", "testvol") """ @@ -387,41 +274,7 @@ def set_quota_limit_objects(mnode, volname, path='/', limit='10', return g.run(mnode, cmd) -def quota_list_objects(mnode, volname, path=None): - """Executes quota list command for given volume - - Args: - mnode (str): Node on which cmd has to be executed. - volname (str): volume name - - Kwargs: - path (str): Quota path - - Returns: - tuple: Tuple containing three elements (ret, out, err). - The first element 'ret' is of type 'int' and is the return value - of command execution. - - The second element 'out' is of type 'str' and is the stdout value - of the command execution. - - The third element 'err' is of type 'str' and is the stderr value - of the command execution. - - Example: - quota_list_objects("abc.com", testvol) - - """ - - if not path: - path = '' - - cmd = "gluster volume quota %s list-objects %s" % (volname, path) - ret = g.run(mnode, cmd) - return ret - - -def get_quota_list_objects(mnode, volname, path=None): +def quota_fetch_list_objects(mnode, volname, path=None): """Parse the output of 'gluster quota list-objects' command. Args: @@ -436,7 +289,7 @@ def get_quota_list_objects(mnode, volname, path=None): dict: dict of dict on success. Examples: - >>> get_quota_list_objects('abc.lab.eng.xyz.com', "testvol") + >>> quota_fetch_list_objects('abc.lab.eng.xyz.com', "testvol") {'/': {'available': '7', 'hl_exceeded': 'No', 'soft_limit_percent': '80%', 'soft_limit_value': '8', 'dir_count': '3', 'sl_exceeded': 'No', 'file_count': '0', 'hard_limit': '10'}} @@ -469,7 +322,7 @@ def get_quota_list_objects(mnode, volname, path=None): return quotalist -def set_quota_alert_time(mnode, volname, time): +def quota_set_alert_time(mnode, volname, time): """Sets quota alert time Args: @@ -489,7 +342,7 @@ def set_quota_alert_time(mnode, volname, time): of the command execution. Examples: - >>> set_quota_alert_time("abc.com", "testvol", ) + >>> quota_set_alert_time("abc.com", "testvol", ) """ @@ -498,7 +351,7 @@ def set_quota_alert_time(mnode, volname, time): return g.run(mnode, cmd) -def set_quota_soft_timeout(mnode, volname, timeout): +def quota_set_soft_timeout(mnode, volname, timeout): """Sets quota soft timeout Args: @@ -518,7 +371,7 @@ def set_quota_soft_timeout(mnode, volname, timeout): of the command execution. Examples: - >>> set_quota_soft_timeout("abc.com", "testvol", ) + >>> quota_set_soft_timeout("abc.com", "testvol", ) """ @@ -527,7 +380,7 @@ def set_quota_soft_timeout(mnode, volname, timeout): return g.run(mnode, cmd) -def set_quota_hard_timeout(mnode, volname, timeout): +def quota_set_hard_timeout(mnode, volname, timeout): """Sets quota hard timeout Args: @@ -547,7 +400,7 @@ def set_quota_hard_timeout(mnode, volname, timeout): of the command execution. Examples: - >>> set_quota_hard_timeout("abc.com", "testvol", ) + >>> quota_set_hard_timeout("abc.com", "testvol", ) """ @@ -556,7 +409,7 @@ def set_quota_hard_timeout(mnode, volname, timeout): return g.run(mnode, cmd) -def set_quota_default_soft_limit(mnode, volname, timeout): +def quota_set_default_soft_limit(mnode, volname, timeout): """Sets quota default soft limit Args: @@ -576,7 +429,7 @@ def set_quota_default_soft_limit(mnode, volname, timeout): of the command execution. Examples: - >>> set_quota_default_soft_limit("abc.com", "testvol", + >>> quota_set_default_soft_limit("abc.com", "testvol", ) """ @@ -586,7 +439,7 @@ def set_quota_default_soft_limit(mnode, volname, timeout): return g.run(mnode, cmd) -def remove_quota(mnode, volname, path): +def quota_remove(mnode, volname, path): """Removes quota for the given path Args: @@ -607,7 +460,7 @@ def remove_quota(mnode, volname, path): of the command execution. Examples: - >>> remove_quota("abc.com", "testvol", ) + >>> quota_remove("abc.com", "testvol", ) """ @@ -615,7 +468,7 @@ def remove_quota(mnode, volname, path): return g.run(mnode, cmd) -def remove_quota_objects(mnode, volname, path): +def quota_remove_objects(mnode, volname, path): """Removes quota objects for the given path Args: @@ -636,7 +489,7 @@ def remove_quota_objects(mnode, volname, path): of the command execution. Examples: - >>> remove_quota_objects("abc.com", "testvol", ) + >>> quota_remove_objects("abc.com", "testvol", ) """ diff --git a/glustolibs-gluster/glustolibs/gluster/volume_libs.py b/glustolibs-gluster/glustolibs/gluster/volume_libs.py index 9eab8c7d4..88a8c1807 100644 --- a/glustolibs-gluster/glustolibs/gluster/volume_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/volume_libs.py @@ -33,7 +33,7 @@ from glustolibs.gluster.volume_ops import (volume_create, volume_start, from glustolibs.gluster.tiering_ops import (add_extra_servers_to_cluster, tier_attach, is_tier_process_running) -from glustolibs.gluster.quota_ops import (enable_quota, set_quota_limit_usage, +from glustolibs.gluster.quota_ops import (quota_enable, quota_limit_usage, is_quota_enabled) from glustolibs.gluster.uss_ops import enable_uss, is_uss_enabled from glustolibs.gluster.snap_ops import snap_delete_by_volumename @@ -315,7 +315,7 @@ def setup_volume(mnode, all_servers_info, volume_config, force=False): # Enable Quota if ('quota' in volume_config and 'enable' in volume_config['quota'] and volume_config['quota']['enable']): - ret, _, _ = enable_quota(mnode=mnode, volname=volname) + ret, _, _ = quota_enable(mnode=mnode, volname=volname) if ret != 0: g.log.error("Unable to set quota on the volume %s", volname) return False @@ -336,8 +336,8 @@ def setup_volume(mnode, all_servers_info, volume_config, force=False): size = "100GB" # Set quota_limit_usage - ret, _, _ = set_quota_limit_usage(mnode=mnode, volname=volname, - path=path, limit=size) + ret, _, _ = quota_limit_usage(mnode=mnode, volname=volname, + path=path, limit=size) if ret != 0: g.log.error("Unable to set quota limit on the volume %s", volname) return False diff --git a/tests/functional/bvt/test_cvt.py b/tests/functional/bvt/test_cvt.py index 3c05bb51a..16ff577bb 100644 --- a/tests/functional/bvt/test_cvt.py +++ b/tests/functional/bvt/test_cvt.py @@ -49,10 +49,10 @@ from glustolibs.gluster.brick_libs import (select_bricks_to_bring_offline, bring_bricks_online, are_bricks_offline) from glustolibs.gluster.heal_libs import monitor_heal_completion -from glustolibs.gluster.quota_ops import (enable_quota, disable_quota, - set_quota_limit_usage, +from glustolibs.gluster.quota_ops import (quota_enable, quota_disable, + quota_limit_usage, is_quota_enabled, - get_quota_list) + quota_fetch_list) from glustolibs.gluster.snap_ops import (snap_create, get_snap_list, snap_activate, snap_deactivate) from glustolibs.misc.misc_libs import upload_scripts @@ -397,7 +397,7 @@ class TestQuotaSanity(GlusterBasicFeaturesSanityBaseClass): """ # Enable Quota g.log.info("Enabling quota on the volume %s", self.volname) - ret, _, _ = enable_quota(self.mnode, self.volname) + ret, _, _ = quota_enable(self.mnode, self.volname) self.assertEqual(ret, 0, ("Failed to enable quota on the volume %s", self.volname)) g.log.info("Successfully enabled quota on the volume %s", self.volname) @@ -416,17 +416,17 @@ class TestQuotaSanity(GlusterBasicFeaturesSanityBaseClass): # Set Quota limit on the root of the volume g.log.info("Set Quota Limit on the path %s of the volume %s", path, self.volname) - ret, _, _ = set_quota_limit_usage(self.mnode, self.volname, - path=path, limit="1GB") + ret, _, _ = quota_limit_usage(self.mnode, self.volname, + path=path, limit="1GB") self.assertEqual(ret, 0, ("Failed to set quota limit on path %s of " " the volume %s", path, self.volname)) g.log.info("Successfully set the Quota limit on %s of the volume %s", path, self.volname) - # get_quota_list + # quota_fetch_list g.log.info("Get Quota list for path %s of the volume %s", path, self.volname) - quota_list = get_quota_list(self.mnode, self.volname, path=path) + quota_list = quota_fetch_list(self.mnode, self.volname, path=path) self.assertIsNotNone(quota_list, ("Failed to get the quota list for " "path %s of the volume %s", path, self.volname)) @@ -439,7 +439,7 @@ class TestQuotaSanity(GlusterBasicFeaturesSanityBaseClass): # Disable quota g.log.info("Disable quota on the volume %s", self.volname) - ret, _, _ = disable_quota(self.mnode, self.volname) + ret, _, _ = quota_disable(self.mnode, self.volname) self.assertEqual(ret, 0, ("Failed to disable quota on the volume %s", self.volname)) g.log.info("Successfully disabled quota on the volume %s", @@ -455,7 +455,7 @@ class TestQuotaSanity(GlusterBasicFeaturesSanityBaseClass): # Enable Quota g.log.info("Enabling quota on the volume %s", self.volname) - ret, _, _ = enable_quota(self.mnode, self.volname) + ret, _, _ = quota_enable(self.mnode, self.volname) self.assertEqual(ret, 0, ("Failed to enable quota on the volume %s", self.volname)) g.log.info("Successfully enabled quota on the volume %s", self.volname) @@ -468,10 +468,10 @@ class TestQuotaSanity(GlusterBasicFeaturesSanityBaseClass): g.log.info("Successfully Validated quota is enabled on volume %s", self.volname) - # get_quota_list + # quota_fetch_list g.log.info("Get Quota list for path %s of the volume %s", path, self.volname) - quota_list = get_quota_list(self.mnode, self.volname, path=path) + quota_list = quota_fetch_list(self.mnode, self.volname, path=path) self.assertIsNotNone(quota_list, ("Failed to get the quota list for " "path %s of the volume %s", path, self.volname)) diff --git a/tests/functional/quota/list_path_values.py b/tests/functional/quota/list_path_values.py index 29dd167d7..5c9bf81d4 100644 --- a/tests/functional/quota/list_path_values.py +++ b/tests/functional/quota/list_path_values.py @@ -17,9 +17,9 @@ from glusto.core import Glusto as g from glustolibs.gluster.gluster_base_class import (GlusterBaseClass, runs_on) -from glustolibs.gluster.quota_ops import (enable_quota, - set_quota_limit_usage, - get_quota_list) +from glustolibs.gluster.quota_ops import (quota_enable, + quota_limit_usage, + quota_fetch_list) from glustolibs.gluster.exceptions import ExecutionError @@ -85,7 +85,7 @@ class QuotaListPathValues(GlusterBaseClass): # Enable Quota g.log.info("Enabling quota on the volume %s", self.volname) - ret, _, _ = enable_quota(self.mnode, self.volname) + ret, _, _ = quota_enable(self.mnode, self.volname) self.assertEqual(ret, 0, ("Failed to enable quota on the volume " "%s", self.volname)) g.log.info("Successfully enabled quota on the volume %s", self.volname) @@ -96,8 +96,8 @@ class QuotaListPathValues(GlusterBaseClass): # Set Quota limit on the root of the volume g.log.info("Set Quota Limit on the path %s of the volume %s", path, self.volname) - ret, _, _ = set_quota_limit_usage(self.mnode, self.volname, - path=path, limit="2GB") + ret, _, _ = quota_limit_usage(self.mnode, self.volname, + path=path, limit="2GB") self.assertEqual(ret, 0, ("Failed to set quota limit on path %s of " " the volume %s", path, self.volname)) g.log.info("Successfully set the Quota limit on %s of the volume " @@ -116,7 +116,7 @@ class QuotaListPathValues(GlusterBaseClass): # Get Quota list without specifying the path g.log.info("Get Quota list for the volume %s", self.volname) - quota_list1 = get_quota_list(self.mnode, self.volname, path=None) + quota_list1 = quota_fetch_list(self.mnode, self.volname, path=None) self.assertIsNotNone(quota_list1, ("Failed to get the quota list for " "the volume %s", self.volname)) self.assertIn(path, quota_list1.keys(), @@ -129,7 +129,7 @@ class QuotaListPathValues(GlusterBaseClass): # Get Quota List with path mentioned in the command g.log.info("Get Quota list for path %s of the volume %s", path, self.volname) - quota_list2 = get_quota_list(self.mnode, self.volname, path=path) + quota_list2 = quota_fetch_list(self.mnode, self.volname, path=path) self.assertIsNotNone(quota_list2, ("Failed to get the quota list for " "path %s of the volume %s", path, self.volname)) diff --git a/tests/functional/quota/test_negative_quota.py b/tests/functional/quota/test_negative_quota.py index d1bb807ff..d420dd153 100644 --- a/tests/functional/quota/test_negative_quota.py +++ b/tests/functional/quota/test_negative_quota.py @@ -18,9 +18,9 @@ import uuid from glusto.core import Glusto as g from glustolibs.gluster.gluster_base_class import (GlusterBaseClass, runs_on) -from glustolibs.gluster.quota_ops import (enable_quota, - set_quota_soft_timeout, - set_quota_hard_timeout) +from glustolibs.gluster.quota_ops import (quota_enable, + quota_set_soft_timeout, + quota_set_hard_timeout) from glustolibs.gluster.exceptions import ExecutionError @@ -91,7 +91,7 @@ class TestNegativeQuota(GlusterBaseClass): """ g.log.info("enabling quota for %s volume", self.volname) - ret, _, _ = enable_quota(self.mnode, self.volname) + ret, _, _ = quota_enable(self.mnode, self.volname) self.assertEqual(ret, 0, "Error in enabling quota") # test to disable quota by spell mistake @@ -117,14 +117,14 @@ class TestNegativeQuota(GlusterBaseClass): """ This testcase try to enable soft/hard timeouts by giving huge value , all cases has to return false """ - ret, _, err = enable_quota(self.mnode, self.volname) + ret, _, err = quota_enable(self.mnode, self.volname) self.assertEqual(ret, 0, "Error in enabling quota for %s" % (self.volname)) # now try to enable timeout with more time time_in_secs = 100 * 60 * 60 g.log.info("Setting up soft timeout with %d secs", time_in_secs) - ret, _, err = set_quota_soft_timeout(self.mnode, + ret, _, err = quota_set_soft_timeout(self.mnode, self.volname, str(time_in_secs)) errmsg = ("quota command failed : '%d' in " @@ -135,7 +135,7 @@ class TestNegativeQuota(GlusterBaseClass): # now try to enable hard timeout with more time g.log.info("Setting up hard timeout with %d secs", time_in_secs) - ret, _, err = set_quota_hard_timeout(self.mnode, + ret, _, err = quota_set_hard_timeout(self.mnode, self.volname, str(time_in_secs)) errmsg = ("quota command failed : '%d' in " diff --git a/tests/functional/quota/test_non_existent_dir.py b/tests/functional/quota/test_non_existent_dir.py index 666e75279..380576ac1 100644 --- a/tests/functional/quota/test_non_existent_dir.py +++ b/tests/functional/quota/test_non_existent_dir.py @@ -17,8 +17,8 @@ from glusto.core import Glusto as g from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on from glustolibs.gluster.volume_libs import log_volume_info_and_status -from glustolibs.gluster.quota_ops import (enable_quota, - set_quota_limit_usage) +from glustolibs.gluster.quota_ops import (quota_enable, + quota_limit_usage) from glustolibs.gluster.exceptions import ExecutionError @@ -53,7 +53,7 @@ class QuotaNonExistentDir(GlusterBaseClass): # Enable Quota g.log.info("Enabling quota on the volume %s", self.volname) - ret, _, _ = enable_quota(self.mnode, self.volname) + ret, _, _ = quota_enable(self.mnode, self.volname) self.assertEqual(ret, 0, ("Failed to enable quota on the volume %s", self.volname)) g.log.info("Successfully enabled quota on the volume %s", self.volname) @@ -64,8 +64,8 @@ class QuotaNonExistentDir(GlusterBaseClass): # Set Quota limit on the root of the volume g.log.info("Set Quota Limit on the path %s of the volume %s", path, self.volname) - ret, _, err = set_quota_limit_usage(self.mnode, self.volname, - path=path, limit="1GB") + ret, _, err = quota_limit_usage(self.mnode, self.volname, + path=path, limit="1GB") self.assertIn("No such file or directory", err, "Quota limit set " "on path /foo which does not exist") -- cgit