summaryrefslogtreecommitdiffstats
path: root/events/src/eventsapiconf.py.in
Commit message (Collapse)AuthorAgeFilesLines
* Events: Socket creation after getaddrinfo and IPv4 and IPv6 packet capturesrijan-sivakumar2020-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: Currently, the socket creation is done prior to getaddrinfo function being invoked. This can cause mismatch in the protocol and address families of the created socket and the result of the getaddrinfo api. Also, the glustereventsd UDP server by default only captures IPv4 packets hence IPv6 packets are not even captured. Code Changes: 1. Modified the socket creation in such a way that the parameters taken in are dependent upon the result of the getaddrinfo function. 2. Created a subclass for adding address family in glustereventsd.py for both AF_INET and AF_INET6. 3. Modified addresses in the eventsapiconf.py.in Reasoning behind the approach: 1. If we are using getaddrinfo function then socket creation should happen only after we check if we received back valid addresses. Hence socket creation should come after the call to getaddrinfo 2. The listening server which pushes the events to the webhook has to listen for both IPv4 and IPv6 messages as we would not be sure as to what address family is picked in _gf_event. Fixes: #1377 Change-Id: I568dcd1a977c8832f0fef981e1f81cac7043c760 Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
* events: python2 to python3 compatKotresh HR2018-10-081-1/+2
| | | | | | | | | | 1. Fix imports 2. Use universal_newlines flag in Popen 3. encode msg used in 'sendto' Updates: #411 Change-Id: Ieacdc2ba86953ff3a2e9d9b9a97157e8e0e36836 Signed-off-by: Kotresh HR <khiremat@redhat.com>
* eventsapi: glustereventsd hardcodes working-directoryVishal Pandey2017-11-151-4/+21
| | | | | | | | | | | | | | Issue: Glusterevents daemon hardcodes glusterd working directory even though it can be changed later in .vol file which causes breaks in the code. Fix: Use python subprocess module to get the working directory of gluster daemon in eventsapiconf.py.in. Change-Id: I5e92185604f8c8aeb77dabdc00f9ea0f8e92c88d BUG: 1512455 Signed-off-by: Vishal Pandey <vishpandey2014@gmail.com>
* eventsapi: HTTPS support for WebhooksAravinda VK2017-10-311-0/+1
| | | | | | | | | | | | | | | | | First it tries to call URL with verify=True without specifying the cert path, it succeeds if a webhook is HTTP or HTTPS with CA trusted certificates(for example https://github..). If above call fails with SSL error then it tries to get the server certificate and calls URL again. If call fails with SSL error even after using the certificate, then verification will be disabled and logged in the log file. All other errors will be catched and logged as usual. BUG: 1506903 Change-Id: I86a3390ed48b75dffdc7848022af23a1e1d7f076 Signed-off-by: Aravinda VK <avishwan@redhat.com>
* eventsapi: Log all published events and provide option to disable loggingAravinda VK2016-12-081-2/+2
| | | | | | | | | | | | | | | | | | Log every published event in /var/log/glusterfs/events.log, Disable logging using, gluster-eventsapi config-set disable-events-log true Also changed "log_level" config name to "log-level" Change-Id: Ib354be0c4ca999d1ccd01b810d6cd96ebc72bcd4 BUG: 1386200 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15674 Reviewed-by: Prashanth Pai <ppai@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* eventsapi: JSON output and different error codesAravinda VK2016-12-021-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | JSON outputs are added to all commands, use `--json` to get JSON output. Following error codes are added to differenciate between errors. Any other Unknown errors will have return code 1 ERROR_SAME_CONFIG = 2 ERROR_ALL_NODES_STATUS_NOT_OK = 3 ERROR_PARTIAL_SUCCESS = 4 ERROR_WEBHOOK_ALREADY_EXISTS = 5 ERROR_WEBHOOK_NOT_EXISTS = 6 ERROR_INVALID_CONFIG = 7 ERROR_WEBHOOK_SYNC_FAILED = 8 ERROR_CONFIG_SYNC_FAILED = 9 Also hidden `node-` commands in the help message. BUG: 1357753 Change-Id: I962b5435c8a448b4573059da0eae42f3f93cc97e Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15867 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* eventsapi: Auto convert Boolean and Int attributesAravinda VK2016-10-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before publishing in JSON format, automatically convert the attribute to "bool" or "int" if configured. For example, instead of sending force="1", convert to bool and send as force=True { "event": "VOLUME_START", "name" : "gv1", "force": "1" } Convert to, { "event": "VOLUME_START", "name" : "gv1", "force": true } BUG: 1379328 Change-Id: Iabc51fd61abc267a7c8dcf0aeac6b3c722d89649 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15574 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org>
* eventsapi: Add Init scripts for different distributionsAravinda VK2016-09-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added init scripts for - SysvInit(CentOS 6 or Red Hat 6) - rc.d (FreeBSD) Most of the latest distributions are using systemd. Support to be added for other distributions which are not using systemd. Removed systemctl wrapper functions(start/stop/status) from gluster-eventsapi CLI(peer_eventsapi.py). Status and Reload re-implemented using pid file check. Added pid file support for glustereventsd. Following dependencies removed python-flask - Only used for example dashboard. User can install if required. python-fasteners - Not available for EPEL 6, added custom code using fcntl as replacement. BUG: 1365395 Change-Id: I26792eae9b11e93304f70b3997cd7d8d03b067f4 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15367 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
* eventsapi: Add support for Client side EventsAravinda VK2016-08-301-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Client side gf_event uses ctx->cmd_args.volfile_server to push notifications to the eventsd. Socket server changed from Unix domain socket to UDP to support external events. Following to be addressed in different patch - Port used for eventsd is 24009. Make it configurable Already configurable in Server side. Configurable in gf_event API is required. - Auth Token yet to be added as discussed in https://www.gluster.org/pipermail/gluster-devel/2016-August/050324.html Change-Id: I159acf80b681d10b82d52cfb3ffdf85cb896542d BUG: 1367774 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15189 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
* eventsapi: Fix disable-events issueAravinda VK2016-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Events related sources are not loaded in libglusterfs when configure is run with --disable-events option. Due to this every call of gf_event should be guarded with USE_EVENTS macro. To prevent this, USE_EVENTS macro was included in events.c itself(Patch #15054) Instead of disabling building entire directory "events", selectively disabled the code. So that constants and empty function gf_event is exposed. Code will not fail even if gf_event is called when events is disabled. BUG: 1368042 Change-Id: Ia6abfe9c1e46a7640c4d8ff5ccf0e9c30c87f928 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15198 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
* eventsapi: Gluster Eventing Feature implementationAravinda VK2016-07-181-0/+22
[Depends on http://review.gluster.org/14627] Design is available in `glusterfs-specs`, A change from the design is support of webhook instead of Websockets as discussed in the design http://review.gluster.org/13115 Since Websocket support depends on REST APIs, I will add Websocket support once REST APIs patch gets merged Usage: Run following command to start/stop Eventsapi server in all Peers, which will collect the notifications from any Gluster daemon and emits to configured client. gluster-eventsapi start|stop|restart|reload Status of running services can be checked using, gluster-eventsapi status Events listener is a HTTP(S) server which listens to events emited by the Gluster. Create a HTTP Server to listen on POST and register that URL using, gluster-eventsapi webhook-add <URL> [--bearer-token <TOKEN>] For example, if HTTP Server running in `http://192.168.122.188:9000` then add that URL using, gluster-eventsapi webhook-add http://192.168.122.188:9000 If it expects a Token then specify it using `--bearer-token` or `-t` We can also test Webhook if all peer nodes can send message or not using, gluster-eventsapi webhook-test <URL> [--bearer-token <TOKEN>] Configurations can be viewed/updated using, gluster-eventsapi config-get [--name] gluster-eventsapi config-set <NAME> <VALUE> gluster-eventsapi config-reset <NAME|all> If any one peer node was down during config-set/reset or webhook modifications, Run sync command from good node when a peer node comes back. Automatic update is not yet implemented. gluster-eventsapi sync Basic Events Client(HTTP Server) is included with the code, Start running the client with required port and start listening to the events. /usr/share/glusterfs/scripts/eventsdash.py --port 8080 Default port is 9000, if no port is specified, once it started running then configure gluster-eventsapi to send events to that client. Eventsapi Client can be outside of the Cluster, it can be run event on Windows. But only requirement is the client URL should be accessible by all peer nodes.(Or ngrok(https://ngrok.com) like tools can be used) Events implemented with this patch, - Volume Create - Volume Start - Volume Stop - Volume Delete - Peer Attach - Peer Detach It is easy to add/support more events, since it touches Gluster cmd code and to avoid merge conflicts I will add support for more events once this patch merges. BUG: 1334044 Change-Id: I316827ac9dd1443454df7deffe4f54835f7f6a08 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/14248 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>