├── INSTALL ├── ChangeLog ├── Makefile.am ├── src ├── api_tier.py ├── api_brick.py ├── api_logrotate.py ├── api_heal.py ├── gunicorn_config.py.in ├── api_bitrot.py ├── __init__.py ├── api_peer.py ├── api_snapshot.py ├── Makefile.am ├── conf.py.in ├── api_quota.py ├── main.py ├── api_georep.py ├── api_volume.py ├── utils.py └── peer_restapi.py ├── extras ├── config.json ├── glusterrestd.service.in ├── glusterrestd-FreeBSD.in ├── Makefile.am └── glusterrestd-RedHat.in ├── TODO.org ├── .gitignore ├── autogen.sh ├── configure.ac ├── Design.md ├── apis.yaml ├── README.md └── COPYING /INSTALL: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = 2 | SUBDIRS = src extras 3 | -------------------------------------------------------------------------------- /src/api_tier.py: -------------------------------------------------------------------------------- 1 | # Attach 2 | # Detach Start 3 | # Detach Stop 4 | # Detach Commit 5 | # Detach Status 6 | -------------------------------------------------------------------------------- /src/api_brick.py: -------------------------------------------------------------------------------- 1 | # Add Brick 2 | # Remove Brick Start 3 | # Remove Brick Stop 4 | # Remove Brick Status 5 | # Remove Brick Commit 6 | # Replace Brick 7 | -------------------------------------------------------------------------------- /extras/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth-enabled": true, 3 | "https": false, 4 | "port": 8080, 5 | "csr": "/etc/glusterrest/server.csr", 6 | "key": "/etc/glusterrest/server.key", 7 | "num-workers": 2 8 | } 9 | -------------------------------------------------------------------------------- /TODO.org: -------------------------------------------------------------------------------- 1 | ** DONE Initial code base 2 | CLOSED: [2016-09-28 Wed 20:53] 3 | ** DONE gluster-restapi CLI 4 | CLOSED: [2016-09-28 Wed 20:53] 5 | ** TODO Usage Doc 6 | ** TODO API Doc 7 | ** TODO Documentation as github pages repo 8 | 9 | -------------------------------------------------------------------------------- /src/api_logrotate.py: -------------------------------------------------------------------------------- 1 | # volume log rotate [BRICK] - rotate the log file for corresponding volume/brick 2 | # volume log rotate [BRICK] - rotate the log file for corresponding volume/brick NOTE: This is an old syntax, will be deprecated from next release. 3 | -------------------------------------------------------------------------------- /src/api_heal.py: -------------------------------------------------------------------------------- 1 | # volume heal [enable | disable | full |statistics [heal-count [replica ]] |info [healed | heal-failed | split-brain] |split-brain {bigger-file | latest-mtime |source-brick []}] - self-heal commands on volume specified by 2 | -------------------------------------------------------------------------------- /src/gunicorn_config.py.in: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.insert(1, '@GLUSTER_LIBEXECDIR@/') 3 | 4 | from glusterrest.utils import get_config, load_config 5 | 6 | load_config() 7 | 8 | bind = ":" + str(get_config("port", 8080)) 9 | workers = get_config("num_workers", 2) 10 | errorlog = "/var/log/glusterrest/errors.log" 11 | accesslog = "/var/log/glusterrest/access.log" 12 | -------------------------------------------------------------------------------- /src/api_bitrot.py: -------------------------------------------------------------------------------- 1 | # volume bitrot {enable|disable} | 2 | # volume bitrot scrub-throttle {lazy|normal|aggressive} | 3 | # volume bitrot scrub-frequency {hourly|daily|weekly|biweekly|monthly} | 4 | # volume bitrot scrub {pause|resume|status} - Bitrot translator specific operation. For more information about bitrot command type 'man gluster' 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | glusterrest.egg-info 2 | build 3 | dist 4 | *.pyc 5 | *.pyo 6 | conf.py 7 | aclocal.m4 8 | autom4te.cache 9 | config.log 10 | configure 11 | install-sh 12 | missing 13 | config.status 14 | Makefile.in 15 | Makefile 16 | config.guess 17 | config.sub 18 | extras/glusterrestd-FreeBSD 19 | extras/glusterrestd-RedHat 20 | extras/glusterrestd.service 21 | py-compile 22 | src/gunicorn_config.py 23 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (c) 2016 Red Hat, Inc. 4 | # This file is part of GlusterFS. 5 | # 6 | # This file is licensed to you under your choice of the GNU Lesser 7 | # General Public License, version 3 or any later version (LGPLv3 or 8 | # later), or the GNU General Public License, version 2 (GPLv2), in all 9 | # cases as published by the Free Software Foundation. 10 | # 11 | -------------------------------------------------------------------------------- /src/api_peer.py: -------------------------------------------------------------------------------- 1 | from utils import auth 2 | from flask import Blueprint 3 | 4 | peer_api = Blueprint('peer_api', __name__) 5 | 6 | 7 | @peer_api.route("/", methods=["PUT"]) 8 | @auth 9 | def api_peer_attach(fqdn): 10 | pass 11 | 12 | 13 | @peer_api.route("/", methods=["DELETE"]) 14 | @auth 15 | def api_peer_detach(fqdn): 16 | pass 17 | 18 | 19 | @peer_api.route("", methods=["GET"]) 20 | @auth 21 | def api_peer_info(): 22 | pass 23 | -------------------------------------------------------------------------------- /extras/glusterrestd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Gluster REST APIs 3 | After=syslog.target network.target 4 | 5 | [Service] 6 | Type=simple 7 | ExecReload=/bin/kill -SIGHUP $MAINPID 8 | KillMode=control-group 9 | ExecStart=/usr/bin/gunicorn -c @SYSCONF_DIR@/glusterrest/gunicorn_config.py main:app --pid /var/run/glusterrest.pid --chdir @GLUSTER_LIBEXECDIR@/glusterrest 10 | PIDFile=/var/run/glusterrestd.pid 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | -------------------------------------------------------------------------------- /extras/glusterrestd-FreeBSD.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # $FreeBSD$ 4 | # 5 | 6 | # PROVIDE: glusterrestd 7 | 8 | . /etc/rc.subr 9 | 10 | name="glusterrestd" 11 | rcvar=`set_rcvar` 12 | command=/usr/bin/gunicorn 13 | pidfile="/var/run/${name}.pid" 14 | glusterrestd_flags="-D -c @SYSCONF_DIR@/glusterrest/gunicorn_config.py main:app --pid /var/run/${name}.pid --chdir @GLUSTER_LIBEXECDIR@/glusterrest" 15 | start_cmd="$command ${glusterrestd_flags}" 16 | 17 | load_rc_config $name 18 | run_rc_command "$1" 19 | -------------------------------------------------------------------------------- /extras/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = glusterrestd.service.in glusterrestd-FreeBSD.in \ 2 | glusterrestd-RedHat.in config.json 3 | 4 | CLEANFILES = glusterrestd.service glusterrestd-FreeBSD \ 5 | glusterrestd-RedHat 6 | 7 | restapiconfdir = $(sysconfdir)/glusterrest 8 | restapiconf_DATA = config.json 9 | 10 | if USE_SYSTEMD 11 | systemd_DATA = glusterrestd.service 12 | endif 13 | 14 | $(GF_DISTRIBUTION): 15 | @if [ ! -d $(SYSTEMD_DIR) ]; then \ 16 | $(mkdir_p) $(DESTDIR)$(INIT_DIR); \ 17 | $(INSTALL_PROGRAM) glusterrestd-$(GF_DISTRIBUTION) $(DESTDIR)$(INIT_DIR)/glusterrestd; \ 18 | fi 19 | 20 | install-exec-local: $(GF_DISTRIBUTION) 21 | 22 | install-data-hook: 23 | $(INSTALL) -d -m 755 $(DESTDIR)/var/log/glusterrest 24 | -------------------------------------------------------------------------------- /src/api_snapshot.py: -------------------------------------------------------------------------------- 1 | # snapshot activate [force] - Activate snapshot volume. 2 | # snapshot clone - Snapshot Clone. 3 | # snapshot config [volname] ([snap-max-hard-limit ] [snap-max-soft-limit ]) | ([auto-delete ])| ([activate-on-create ]) - Snapshot Config. 4 | # snapshot create [no-timestamp] [description ] [force] - Snapshot Create. 5 | # snapshot deactivate - Deactivate snapshot volume. 6 | # snapshot delete (all | snapname | volume ) - Snapshot Delete. 7 | # snapshot help - display help for snapshot commands 8 | # snapshot info [(snapname | volume )] - Snapshot Info. 9 | # snapshot list [volname] - Snapshot List. 10 | # snapshot restore - Snapshot Restore. 11 | # snapshot status [(snapname | volume )] - Snapshot Status. 12 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = api_bitrot.py api_georep.py api_logrotate.py api_quota.py \ 2 | api_tier.py cli.py __init__.py peer_restapi.py utils.py api_brick.py \ 3 | api_heal.py api_peer.py api_snapshot.py api_volume.py conf.py.in \ 4 | gunicorn_config.py glusterrest.py 5 | 6 | CLEANFILES = conf.py 7 | 8 | restapiconfdir = $(sysconfdir)/glusterrest 9 | restapiconf_DATA = gunicorn_config.py 10 | 11 | restapidir = $(gluster_libexecdir)/glusterrest 12 | restapi_PYTHON = api_bitrot.py api_georep.py api_logrotate.py api_quota.py \ 13 | api_tier.py __init__.py utils.py api_brick.py api_heal.py api_peer.py \ 14 | api_snapshot.py api_volume.py conf.py main.py 15 | 16 | restapipeerscriptdir = $(libexecdir)/glusterfs 17 | restapipeerscript_SCRIPTS = peer_restapi.py 18 | 19 | 20 | install-exec-hook: 21 | $(mkdir_p) $(DESTDIR)$(sbindir) 22 | rm -f $(DESTDIR)$(sbindir)/gluster-restapi 23 | ln -s $(libexecdir)/glusterfs/peer_restapi.py \ 24 | $(DESTDIR)$(sbindir)/gluster-restapi 25 | 26 | uninstall-hook: 27 | rm -f $(DESTDIR)$(sbindir)/gluster-restapi 28 | -------------------------------------------------------------------------------- /src/conf.py.in: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (c) 2016 Red Hat, Inc. 4 | # This file is part of GlusterFS. 5 | # 6 | # This file is licensed to you under your choice of the GNU Lesser 7 | # General Public License, version 3 or any later version (LGPLv3 or 8 | # later), or the GNU General Public License, version 2 (GPLv2), in all 9 | # cases as published by the Free Software Foundation. 10 | # 11 | 12 | GLUSTER_LIBEXECDIR = "@GLUSTER_LIBEXECDIR@" 13 | GLUSTERD_WORKDIR = "@glusterd_workdir@" 14 | DEFAULT_CONFIG_FILE = "@SYSCONF_DIR@/glusterrest/config.json" 15 | CUSTOM_CONFIG_FILE_TO_SYNC = "/glusterrest/config.json" 16 | CUSTOM_CONFIG_FILE = GLUSTERD_WORKDIR + CUSTOM_CONFIG_FILE_TO_SYNC 17 | APPS_FILE_TO_SYNC = "/glusterrest/apps.json" 18 | APPS_FILE = GLUSTERD_WORKDIR + APPS_FILE_TO_SYNC 19 | LOG_FILE = "/var/log/glusterrest/rest.log" 20 | ACCESS_LOG_FILE = "/var/log/glusterrest/access.log" 21 | RESTD = "glusterrestd" 22 | CONFIG_KEYS = ["auth-enabled", "https", "port", "csr", "key", "log-level", 23 | "num-workers"] 24 | BOOL_CONFIGS = ["auth-enabled", "https"] 25 | INT_CONFIGS = ["port", "num-workers"] 26 | RESTART_CONFIGS = ["num-workers"] 27 | PID_FILE = "/var/run/glusterrest.pid" 28 | VERSION = "/v1" 29 | -------------------------------------------------------------------------------- /src/api_quota.py: -------------------------------------------------------------------------------- 1 | # volume quota {enable|disable|list [ ...]| list-objects [ ...] | remove | remove-objects | default-soft-limit } | 2 | # volume quota {limit-usage []} | 3 | # volume quota {limit-objects []} | 4 | # volume quota {alert-time|soft-timeout|hard-timeout} {