diff options
author | sayaleeraut <saraut@redhat.com> | 2020-08-19 13:12:33 +0530 |
---|---|---|
committer | Arthy Loganathan <aloganat@redhat.com> | 2020-08-19 10:54:53 +0000 |
commit | 5140b0c1f65a854c3e6cc5e1d1d852569a0abaee (patch) | |
tree | 7b4b65de8339ab5f4c5ba97fb52f01f6cff55d2c /glustolibs-gluster/glustolibs | |
parent | 4fbea671b31c5e4495aa9f4da207576105a52bb7 (diff) |
[LibFix] Fix code to avoid failure
Description:
Earlier, on running a test script which calls get_volume_type(),
the test script displayed below failure message in glusto logs:
"INFO (get_volume_type) Failed to find brick-path
10.70.47.44:/bricks/brick2/testvol_distributed_brick0// for volume
testvol_distributed"
- even though the brick-path was present in the volume.
Checked by directly calling the function as well:
>>> from glusto.core import Glusto as g
>>> from glustolibs.gluster.volume_libs import get_volume_type
>>> ret = get_volume_type('10.70.47.44:/bricks/brick2/vol1-b1/')
>>> print ret
Distribute
>>> ret = get_volume_type('10.70.47.44:/bricks/brick2/vol1-b1//')
>>> print ret
None
Observed that the issue occurs if an extra "/" is present at the end
of the brickdir_path(str) parameter passed to the function. Hence
have added a check for the same.
Change-Id: I01fe2d05b7f206d7767c83e57e714053358dc42c
Signed-off-by: sayaleeraut <saraut@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/volume_libs.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/volume_libs.py b/glustolibs-gluster/glustolibs/gluster/volume_libs.py index 0505edfce..376ac5089 100644 --- a/glustolibs-gluster/glustolibs/gluster/volume_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/volume_libs.py @@ -1686,7 +1686,8 @@ def get_volume_type(brickdir_path): # Adding import here to avoid cyclic imports from glustolibs.gluster.brick_libs import get_all_bricks (host, brick_path_info) = brickdir_path.split(':') - path_info = brick_path_info[:-1] + path_info = (brick_path_info[:-2] if brick_path_info.endswith("//") + else brick_path_info[:-1]) for volume in get_volume_list(host): brick_paths = [brick.split(':')[1] for brick in get_all_bricks(host, volume)] |