Skip to content

Commit

Permalink
Added sosvollist and added --name flag to sosvolinfo
Browse files Browse the repository at this point in the history
Signed-off-by: Aravinda VK <avishwan@redhat.com>
  • Loading branch information
aravindavk committed Nov 21, 2017
1 parent f8177c0 commit aa749b6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 6 additions & 2 deletions glustertool/cli.py
Expand Up @@ -39,7 +39,10 @@ def parse_tool_json(path):

def handle_list():
print ("List of available tools, `glustertool doc <TOOLNAME>` "
"or `glustertool <TOOLNAME> -h` for more details about the tool.")
"or `glustertool <TOOLNAME> --help` for more details "
"about the tool.\n")
i = 0

for d in sorted(os.listdir(SUBCMD_DIR)):
if d.startswith("__init__"):
continue
Expand All @@ -50,7 +53,8 @@ def handle_list():
if d.endswith(".py"):
d = d.replace(".py", "")

print (d)
i += 1
print("%5d %s" % (i, d))


def handle_doc(subcommand=None):
Expand Down
5 changes: 5 additions & 0 deletions glustertool/plugins/sosvolinfo.py
Expand Up @@ -72,12 +72,17 @@ def cmdargs(parser):
# Add arguments for your tool using parser object
# For example, parser.add_argument("--name", help="Name")
parser.add_argument("path", help="Sosreport path")
parser.add_argument("--name", help="Volume Name")


def run(args):
volsdir = os.path.join(args.path, "var/lib/glusterd/vols")

for v in os.listdir(volsdir):
# If volume name is specified
if args.name is not None and args.name != v:
continue

info_file = os.path.join(volsdir, v, "info")
volinfo = None
with open(info_file) as f:
Expand Down
18 changes: 18 additions & 0 deletions glustertool/plugins/sosvollist.py
@@ -0,0 +1,18 @@
#!/usr/bin/env python
"""
Extracts Volumes list from the given sosreport path and displays
"""
import os


def cmdargs(parser):
# Add arguments for your tool using parser object
# For example, parser.add_argument("--name", help="Name")
parser.add_argument("path", help="Sosreport path")


def run(args):
volsdir = os.path.join(args.path, "var/lib/glusterd/vols")

for v in os.listdir(volsdir):
print(v)

0 comments on commit aa749b6

Please sign in to comment.