summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/generate_glusto_config/README.md34
-rw-r--r--tools/generate_glusto_config/examples/sample_glusto_config.yaml20
-rw-r--r--tools/generate_glusto_config/generate_glusto_config.py74
-rw-r--r--tools/generate_glusto_config/glusto_config_template.jinja39
-rw-r--r--tools/generate_glusto_config/setup.py32
5 files changed, 199 insertions, 0 deletions
diff --git a/tools/generate_glusto_config/README.md b/tools/generate_glusto_config/README.md
new file mode 100644
index 000000000..ce0455d69
--- /dev/null
+++ b/tools/generate_glusto_config/README.md
@@ -0,0 +1,34 @@
+# generate_glusto_config
+Tool to generate config file for executing glusto tests.
+
+## Prerequisites
+Python 3.x
+
+## Installation
+1. Change directory to the project directory.
+
+```
+# cd tools/generate_glusto_config
+```
+
+2. Now run the installation script.
+
+```
+# python3 setup.py install
+```
+
+3. To check run:
+
+```
+# generate_glusto_config --help
+```
+
+## Usage
+Pass arguments to the script as shown below:
+
+```
+# generate_glusto_config -c examples/sample_glusto_config.yaml -t glusto_config_template.jinja -o output_config.yml
+```
+
+## Licence
+[GPLv3](https://github.com/gluster/glusto-tests/blob/master/LICENSE)
diff --git a/tools/generate_glusto_config/examples/sample_glusto_config.yaml b/tools/generate_glusto_config/examples/sample_glusto_config.yaml
new file mode 100644
index 000000000..4991b2204
--- /dev/null
+++ b/tools/generate_glusto_config/examples/sample_glusto_config.yaml
@@ -0,0 +1,20 @@
+# 'clients' is list of Hostnames/IP's of clients in the cluster.
+clients: [client_hostname1, client_hostname2]
+
+# 'servers' is list of Hostnames/IP's of servers in the cluster.
+# Each item in list is a dict with 'Hostname/IP' of the server as key.
+# The info should contain the devices to use
+# for creating bricks, brick_root i.e dirname of brick mount point.
+
+servers:
+ - server_hostname1:
+ devices: ["/dev/vdb", "/dev/vdc", "/dev/vdd", "/dev/vde", "/dev/vdf"]
+ brick_root: "/bricks"
+ - server_hostname2:
+ devices: ["/dev/vdb", "/dev/vdc", "/dev/vdd", "/dev/vde", "/dev/vdf"]
+ brick_root: "/bricks"
+
+logfile: "/var/log/glusto_tests.log"
+
+# Mount protocol to use in the current run
+mount_type: ["glusterfs"]
diff --git a/tools/generate_glusto_config/generate_glusto_config.py b/tools/generate_glusto_config/generate_glusto_config.py
new file mode 100644
index 000000000..ca63b1d5a
--- /dev/null
+++ b/tools/generate_glusto_config/generate_glusto_config.py
@@ -0,0 +1,74 @@
+# Copyright (C) 2020 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 3 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.
+
+import argparse
+
+from glusto.core import Glusto as g
+
+
+def handle_configs(config_list):
+ """Load user configuration files"""
+
+ # load user specified configs
+ if config_list:
+ config_files = config_list.split()
+ g.config = g.load_configs(config_files)
+ return True
+
+ return False
+
+
+def parse_args():
+ """Parse arguments with newer argparse module
+ (adds built-in required parm)
+ """
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+ description='Create output file based on template and config files')
+ parser.add_argument("-c", "--config",
+ help="Config file(s) to read.",
+ action="store", dest="config_list",
+ default=None)
+ parser.add_argument("-t", "--template",
+ help="Template file to render",
+ action="store", dest="template_file",
+ default=None)
+ parser.add_argument("-o", "--output",
+ help="Output file for rendered template",
+ action="store", dest="output_file",
+ default=None)
+ return parser.parse_args()
+
+
+def main():
+ """Main function"""
+
+ args = parse_args()
+
+ if args.config_list:
+ handle_configs(args.config_list)
+ g.show_config(g.config)
+
+ output_file = "rendered_template.txt"
+ if args.output_file:
+ output_file = args.output_file
+
+ if args.template_file:
+ g.render_template(args.template_file, g.config, output_file)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/generate_glusto_config/glusto_config_template.jinja b/tools/generate_glusto_config/glusto_config_template.jinja
new file mode 100644
index 000000000..79a3d57e2
--- /dev/null
+++ b/tools/generate_glusto_config/glusto_config_template.jinja
@@ -0,0 +1,39 @@
+log_file: {{logfile}}
+log_level: DEBUG
+remote_user: root
+
+# 'servers' is list of Hostnames/IP's of servers in the cluster.
+servers: &servers_list{% for server_item in servers %}{% for server, value in server_item.items() %}
+ - {{server}}{% endfor %}{% endfor %}
+
+# 'clients' is list of Hostnames/IP's of clients in the cluster.
+clients:{% for client in clients %}
+ - {{client}}{% endfor %}
+
+# 'servers_info' is info about each server in the cluster.
+# each server_info is a dict with 'Hostname/IP' of the server as key.
+# The info should contain the host(Hostname/IP) of server, devices to use
+# for creating bricks, brick_root i.e dirname of brick mount point.
+# Note: Use the same Hostname/IP used in the above 'servers' section.
+
+servers_info:{% for server_item in servers %}
+ {% for server, value in server_item.items() %}
+ {{server}}: &server{{ loop.index }}
+ host: {{server}}
+ devices: {{ value["devices"] }}
+ brick_root: {{ value["brick_root"] }}{% endfor %}{% endfor %}
+
+# 'clients_info' is info about each client in the cluster.
+# each client_info is a dict with 'Hostname/IP' of the client as key.
+# The info should contain the host(Hostname/IP) of client.
+
+clients_info: {% for client in clients %}
+ {{client}}: &client{{ loop.index }}
+ host: {{client}}{% endfor %}
+
+# This is to define what volume types and mount protocols will be run
+# in this current test run.
+
+gluster:
+ running_on_volumes: []
+ running_on_mounts: {{mount_type}}
diff --git a/tools/generate_glusto_config/setup.py b/tools/generate_glusto_config/setup.py
new file mode 100644
index 000000000..f6dcab180
--- /dev/null
+++ b/tools/generate_glusto_config/setup.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+# Copyright (C) 2020 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 3 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.
+
+from setuptools import setup
+
+setup(
+ name='generate_glusto_config',
+ author='Red Hat, Inc.',
+ author_email='gluster-devel@gluster.org',
+ url='http://www.gluster.org',
+ license='GPLv3+',
+ description=("Tool to generate config file for executing glusto tests."),
+ py_modules=['generate_glusto_config'],
+ entry_points="""
+ [console_scripts]
+ generate_glusto_config = generate_glusto_config:main
+ """
+)