[SCM] Samba Shared Repository - branch master updated

[email protected] (Amitay Isaacs)
Newsgroups gmane.network.samba.cvs
Message-ID <[email protected]>
The branch, master has been updated
       via  fc28a74 ctdb-daemon: Remove ctdb_event_helper
       via  69b1ae3 ctdb-daemon: Switch to using event daemon
       via  bcd7444 ctdb-daemon: Add functions to talk to event daemon
       via  21cac65 ctdb-daemon: Refactor check for valid events during recovery
       via  c9a0f30 ctdb-protocol: Deprecate eventscript controls
       via  9272cd4 ctdb-protocol: Drop marshaling for eventscript controls
       via  3c74c05 ctdb-client: Drop client code for eventscript controls
       via  def5f4b ctdb-daemon: Drop implementation of eventscript controls
       via  b2d1cea ctdb-tool: Drop disablescript, enablescript and eventscript commands
       via  a652b5c ctdb-tool: Add new command "event" to ctdb tool
       via  ca0894e ctdb-tests: Add tests for event daemon
       via  9cbdb40 ctdb-tool: Add helper for talking to event daemon
       via  b678dfb ctdb-client: Add client api for eventd communication
       via  950110f ctdb-eventd: Add event script handling daemon
       via  7e8ccef ctdb-protocol: Add marshalling for eventd protocol
       via  c0c3433 ctdb-protocol: Add data types for eventd communication
       via  7ae530c ctdb-common: Add sock_daemon abstraction
       via  75a25d1 ctdb-common: Add generic socket I/O
       via  f0ba41e ctdb-common: Add run_proc abstraction
       via  4d3c19d ctdb-protocol: Add marshalling for int32_t
       via  a6ee085 ctdb-protocol: Fix marshalling of string with length
       via  b2b8f1e ctdb-tool: Improve error reporting if helper execution fails
       via  590acdc ctdb-tool: Allow passing multiple command-line arguments to helper
      from  f09f5ae selftest: make sure we always export KRB5CCNAME

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fc28a74254d0263f02d008dcd2e2e6c9d03ccea3
Author: Amitay Isaacs <[email protected]>
Date:   Sun Sep 18 00:24:47 2016 +1000

    ctdb-daemon: Remove ctdb_event_helper
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>
    
    Autobuild-User(master): Amitay Isaacs <[email protected]>
    Autobuild-Date(master): Sun Dec 18 18:10:50 CET 2016 on sn-devel-144

commit 69b1ae34231f20d45bff5bdd50c0a2adfc87f90b
Author: Amitay Isaacs <[email protected]>
Date:   Fri Sep 16 20:06:07 2016 +1000

    ctdb-daemon: Switch to using event daemon
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit bcd7444c57447983f571cbbe3ceed7d5558040e9
Author: Amitay Isaacs <[email protected]>
Date:   Sat Aug 27 17:26:28 2016 +1000

    ctdb-daemon: Add functions to talk to event daemon
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 21cac65b67b2f9880586404f6492260541f05e30
Author: Amitay Isaacs <[email protected]>
Date:   Fri Sep 16 18:44:37 2016 +1000

    ctdb-daemon: Refactor check for valid events during recovery
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit c9a0f3015d095946fc91223e5838f3d6c3d4d1cb
Author: Amitay Isaacs <[email protected]>
Date:   Mon Sep 12 11:33:02 2016 +1000

    ctdb-protocol: Deprecate eventscript controls
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 9272cd42aac96f69b574319ffbe5a2acb13abd2e
Author: Amitay Isaacs <[email protected]>
Date:   Wed Nov 23 12:28:24 2016 +1100

    ctdb-protocol: Drop marshaling for eventscript controls
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 3c74c05c7519ebc19f55316b7a89da86e28f6906
Author: Amitay Isaacs <[email protected]>
Date:   Mon Sep 12 11:32:20 2016 +1000

    ctdb-client: Drop client code for eventscript controls
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit def5f4b1bfeeddba97141a3d3c08ac5a1187ce32
Author: Amitay Isaacs <[email protected]>
Date:   Mon Sep 12 11:25:11 2016 +1000

    ctdb-daemon: Drop implementation of eventscript controls
    
    Following controls are now implemented by event daemon
     - RUN_EVENTSCRIPTS
     - GET_EVENT_SCRIPT_STATUS
     - ENABLE_SCRIPT
     - DISABLE_SCRIPT
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit b2d1cea1f3b5b833c4c25b18e4d94e66d2950cbd
Author: Amitay Isaacs <[email protected]>
Date:   Mon Sep 12 11:31:35 2016 +1000

    ctdb-tool: Drop disablescript, enablescript and eventscript commands
    
    These commands are now replaced with ctdb event ...
    
    ctdb scriptstatus is maintained for backward compatibility.
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit a652b5c3515c8cf611f633b95ac894f60e6f4977
Author: Amitay Isaacs <[email protected]>
Date:   Mon Nov 21 14:52:41 2016 +1100

    ctdb-tool: Add new command "event" to ctdb tool
    
    This command covers all the commands to event daemon.
    
      ctdb event run <event>
      ctdb event status [<event>] [lastrun|lastfail|lastpass]
      ctdb event script list
      ctdb event script enable <script>
      ctdb event script disable <script>
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit ca0894e9325e1687a843bc0a79e100a8adc986d4
Author: Amitay Isaacs <[email protected]>
Date:   Tue Sep 6 18:53:02 2016 +1000

    ctdb-tests: Add tests for event daemon
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 9cbdb406129343dac30883f43bfe1e8e046d6041
Author: Amitay Isaacs <[email protected]>
Date:   Mon Nov 21 17:39:02 2016 +1100

    ctdb-tool: Add helper for talking to event daemon
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit b678dfb3a4b2f68c613946217b67598560280a95
Author: Amitay Isaacs <[email protected]>
Date:   Thu Sep 1 01:07:47 2016 +1000

    ctdb-client: Add client api for eventd communication
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 950110f3c19342def662f19f76c1ac8353943341
Author: Amitay Isaacs <[email protected]>
Date:   Sat Aug 27 17:26:52 2016 +1000

    ctdb-eventd: Add event script handling daemon
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 7e8ccef49b8cbc23a3b7317dd60e0f9de288b359
Author: Amitay Isaacs <[email protected]>
Date:   Wed Aug 31 17:02:55 2016 +1000

    ctdb-protocol: Add marshalling for eventd protocol
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit c0c34337d93aca4d683bbe273c67a2303419312d
Author: Amitay Isaacs <[email protected]>
Date:   Wed Aug 31 15:49:27 2016 +1000

    ctdb-protocol: Add data types for eventd communication
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 7ae530c2ab4cf37a51f32bcc6c94628f62493305
Author: Amitay Isaacs <[email protected]>
Date:   Sat Sep 3 23:27:23 2016 +1000

    ctdb-common: Add sock_daemon abstraction
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 75a25d13310c53328f2b99f856abc8c5d023bc52
Author: Amitay Isaacs <[email protected]>
Date:   Fri Sep 16 16:13:18 2016 +1000

    ctdb-common: Add generic socket I/O
    
    This is a generic socket read/write to be used in the ctdb daemon.
    It is based on ctdb_io.c and comm.c.
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit f0ba41e1c5a9b4000b918211fc16c3545d2133ab
Author: Amitay Isaacs <[email protected]>
Date:   Tue Aug 30 17:33:42 2016 +1000

    ctdb-common: Add run_proc abstraction
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 4d3c19d14e938672ca403e1546b131a5e5032aac
Author: Amitay Isaacs <[email protected]>
Date:   Wed Aug 31 15:46:45 2016 +1000

    ctdb-protocol: Add marshalling for int32_t
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit a6ee085845c92d4b8fe26ee4dd75836212930922
Author: Amitay Isaacs <[email protected]>
Date:   Wed Aug 31 01:33:38 2016 +1000

    ctdb-protocol: Fix marshalling of string with length
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit b2b8f1eaed4a50ad2bcd391fef3b66a1ff6e9bfa
Author: Amitay Isaacs <[email protected]>
Date:   Mon Nov 21 17:38:18 2016 +1100

    ctdb-tool: Improve error reporting if helper execution fails
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 590acdc5294eb12259b0112b230418faab575edb
Author: Amitay Isaacs <[email protected]>
Date:   Mon Nov 21 14:36:04 2016 +1100

    ctdb-tool: Allow passing multiple command-line arguments to helper
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/client/client.h                          |   88 +-
 ctdb/client/client_control_sync.c             |  118 --
 ctdb/client/client_event.c                    |  597 ++++++++
 ctdb/client/ctdb_client.c                     |   80 --
 ctdb/common/run_proc.c                        |  527 ++++++++
 ctdb/common/run_proc.h                        |   99 ++
 ctdb/common/sock_daemon.c                     |  831 ++++++++++++
 ctdb/common/sock_daemon.h                     |  204 +++
 ctdb/common/sock_io.c                         |  309 +++++
 ctdb/common/sock_io.h                         |   38 +
 ctdb/doc/ctdb.1.xml                           |  194 ++-
 ctdb/include/ctdb_client.h                    |   11 -
 ctdb/include/ctdb_private.h                   |   22 +-
 ctdb/packaging/RPM/ctdb.spec.in               |    3 +-
 ctdb/protocol/protocol.h                      |   91 +-
 ctdb/protocol/protocol_api.h                  |   40 +-
 ctdb/protocol/protocol_client.c               |   90 --
 ctdb/protocol/protocol_control.c              |   74 -
 ctdb/protocol/protocol_event.c                |  848 ++++++++++++
 ctdb/protocol/protocol_private.h              |    5 +
 ctdb/protocol/protocol_types.c                |   36 +-
 ctdb/server/ctdb_control.c                    |   13 +-
 ctdb/server/ctdb_daemon.c                     |    6 +
 ctdb/server/ctdb_event_helper.c               |  159 ---
 ctdb/server/ctdb_eventd.c                     | 1802 +++++++++++++++++++++++++
 ctdb/server/eventscript.c                     | 1396 +++++++------------
 ctdb/tests/complex/35_cifs_external_tickle.sh |    8 +-
 ctdb/tests/complex/90_debug_hung_script.sh    |   11 +-
 ctdb/tests/cunit/protocol_test_002.sh         |   18 +
 ctdb/tests/cunit/run_proc_001.sh              |  140 ++
 ctdb/tests/cunit/sock_daemon_test_001.sh      |   44 +
 ctdb/tests/eventd/README                      |    1 +
 ctdb/tests/eventd/eventd_001.sh               |   31 +
 ctdb/tests/eventd/eventd_002.sh               |   54 +
 ctdb/tests/eventd/eventd_003.sh               |   54 +
 ctdb/tests/eventd/eventd_004.sh               |   45 +
 ctdb/tests/eventd/eventd_005.sh               |   36 +
 ctdb/tests/eventd/eventd_006.sh               |   37 +
 ctdb/tests/eventd/eventd_007.sh               |   37 +
 ctdb/tests/eventd/eventd_011.sh               |   64 +
 ctdb/tests/eventd/eventd_012.sh               |   53 +
 ctdb/tests/eventd/eventd_013.sh               |   53 +
 ctdb/tests/eventd/eventd_014.sh               |   52 +
 ctdb/tests/eventd/eventd_021.sh               |   40 +
 ctdb/tests/eventd/eventd_022.sh               |   41 +
 ctdb/tests/eventd/eventd_023.sh               |   38 +
 ctdb/tests/eventd/eventd_024.sh               |   47 +
 ctdb/tests/eventd/eventd_031.sh               |   65 +
 ctdb/tests/eventd/eventd_032.sh               |  124 ++
 ctdb/tests/eventd/eventd_033.sh               |  124 ++
 ctdb/tests/eventd/eventd_041.sh               |   48 +
 ctdb/tests/eventd/eventd_042.sh               |   48 +
 ctdb/tests/eventd/eventd_043.sh               |   48 +
 ctdb/tests/eventd/eventd_051.sh               |   23 +
 ctdb/tests/eventd/scripts/local.sh            |  137 ++
 ctdb/tests/run_tests.sh                       |    2 +-
 ctdb/tests/simple/60_recoverd_missing_ip.sh   |    4 +-
 ctdb/tests/simple/scripts/local_daemons.bash  |    3 +-
 ctdb/tests/src/protocol_client_test.c         |  414 +++++-
 ctdb/tests/src/protocol_types_test.c          |  138 ++
 ctdb/tests/src/run_proc_test.c                |  105 ++
 ctdb/tests/src/sock_daemon_test.c             |  632 +++++++++
 ctdb/tools/ctdb.c                             |  334 ++---
 ctdb/tools/ctdb_event.c                       |  532 ++++++++
 ctdb/wscript                                  |   37 +-
 65 files changed, 9500 insertions(+), 1903 deletions(-)
 create mode 100644 ctdb/client/client_event.c
 create mode 100644 ctdb/common/run_proc.c
 create mode 100644 ctdb/common/run_proc.h
 create mode 100644 ctdb/common/sock_daemon.c
 create mode 100644 ctdb/common/sock_daemon.h
 create mode 100644 ctdb/common/sock_io.c
 create mode 100644 ctdb/common/sock_io.h
 create mode 100644 ctdb/protocol/protocol_event.c
 delete mode 100644 ctdb/server/ctdb_event_helper.c
 create mode 100644 ctdb/server/ctdb_eventd.c
 create mode 100755 ctdb/tests/cunit/run_proc_001.sh
 create mode 100755 ctdb/tests/cunit/sock_daemon_test_001.sh
 create mode 100644 ctdb/tests/eventd/README
 create mode 100755 ctdb/tests/eventd/eventd_001.sh
 create mode 100755 ctdb/tests/eventd/eventd_002.sh
 create mode 100755 ctdb/tests/eventd/eventd_003.sh
 create mode 100755 ctdb/tests/eventd/eventd_004.sh
 create mode 100755 ctdb/tests/eventd/eventd_005.sh
 create mode 100755 ctdb/tests/eventd/eventd_006.sh
 create mode 100755 ctdb/tests/eventd/eventd_007.sh
 create mode 100755 ctdb/tests/eventd/eventd_011.sh
 create mode 100755 ctdb/tests/eventd/eventd_012.sh
 create mode 100755 ctdb/tests/eventd/eventd_013.sh
 create mode 100755 ctdb/tests/eventd/eventd_014.sh
 create mode 100755 ctdb/tests/eventd/eventd_021.sh
 create mode 100755 ctdb/tests/eventd/eventd_022.sh
 create mode 100755 ctdb/tests/eventd/eventd_023.sh
 create mode 100755 ctdb/tests/eventd/eventd_024.sh
 create mode 100755 ctdb/tests/eventd/eventd_031.sh
 create mode 100755 ctdb/tests/eventd/eventd_032.sh
 create mode 100755 ctdb/tests/eventd/eventd_033.sh
 create mode 100755 ctdb/tests/eventd/eventd_041.sh
 create mode 100755 ctdb/tests/eventd/eventd_042.sh
 create mode 100755 ctdb/tests/eventd/eventd_043.sh
 create mode 100755 ctdb/tests/eventd/eventd_051.sh
 create mode 100644 ctdb/tests/eventd/scripts/local.sh
 create mode 100644 ctdb/tests/src/run_proc_test.c
 create mode 100644 ctdb/tests/src/sock_daemon_test.c
 create mode 100644 ctdb/tools/ctdb_event.c


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index ea41cbe..f6d3fd3 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -452,11 +452,6 @@ int ctdb_ctrl_del_public_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			    int destnode, struct timeval timeout,
 			    struct ctdb_addr_info *addr_info);
 
-int ctdb_ctrl_run_eventscripts(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			       struct ctdb_client_context *client,
-			       int destnode, struct timeval timeout,
-			       const char *event);
-
 int ctdb_ctrl_get_capabilities(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			       struct ctdb_client_context *client,
 			       int destnode, struct timeval timeout,
@@ -482,13 +477,6 @@ int ctdb_ctrl_get_nodemap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			  int destnode, struct timeval timeout,
 			  struct ctdb_node_map **nodemap);
 
-int ctdb_ctrl_get_event_script_status(TALLOC_CTX *mem_ctx,
-				      struct tevent_context *ev,
-				      struct ctdb_client_context *client,
-				      int destnode, struct timeval timeout,
-				      enum ctdb_event event,
-				      struct ctdb_script_list **slist);
-
 int ctdb_ctrl_traverse_kill(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			    struct ctdb_client_context *client,
 			    int destnode, struct timeval timeout,
@@ -517,16 +505,6 @@ int ctdb_ctrl_set_recmasterrole(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 				int destnode, struct timeval timeout,
 				uint32_t recmaster_role);
 
-int ctdb_ctrl_enable_script(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			    struct ctdb_client_context *client,
-			    int destnode, struct timeval timeout,
-			    const char *script);
-
-int ctdb_ctrl_disable_script(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			     struct ctdb_client_context *client,
-			     int destnode, struct timeval timeout,
-			     const char *script);
-
 int ctdb_ctrl_set_ban_state(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			    struct ctdb_client_context *client,
 			    int destnode, struct timeval timeout,
@@ -846,4 +824,70 @@ int ctdb_server_id_exists(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			  struct ctdb_client_context *client,
 			  struct ctdb_server_id *sid, bool *exists);
 
+/* from client/client_event.c */
+
+struct ctdb_event_context;
+
+int ctdb_event_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+		    const char *sockpath, struct ctdb_event_context **out);
+
+void ctdb_event_set_disconnect_callback(struct ctdb_event_context *eclient,
+					ctdb_client_callback_func_t callback,
+					void *private_data);
+
+struct tevent_req *ctdb_event_msg_send(TALLOC_CTX *mem_ctx,
+				       struct tevent_context *ev,
+				       struct ctdb_event_context *eclient,
+				       struct ctdb_event_request *request);
+
+bool ctdb_event_msg_recv(struct tevent_req *req, int *perr,
+			 TALLOC_CTX *mem_ctx,
+			 struct ctdb_event_reply **reply);
+
+struct tevent_req *ctdb_event_run_send(TALLOC_CTX *mem_ctx,
+				       struct tevent_context *ev,
+				       struct ctdb_event_context *eclient,
+				       enum ctdb_event event,
+				       uint32_t timeout, const char *arg_str);
+
+bool ctdb_event_run_recv(struct tevent_req *req, int *perr, int32_t *result);
+
+struct tevent_req *ctdb_event_status_send(TALLOC_CTX *mem_ctx,
+					  struct tevent_context *ev,
+					  struct ctdb_event_context *eclient,
+					  enum ctdb_event event,
+					  enum ctdb_event_status_state state);
+
+bool ctdb_event_status_recv(struct tevent_req *req, int *perr,
+			    int32_t *result, int *event_result,
+			    TALLOC_CTX *mem_ctx,
+			    struct ctdb_script_list **script_list);
+
+struct tevent_req *ctdb_event_script_list_send(
+					TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct ctdb_event_context *eclient);
+
+bool ctdb_event_script_list_recv(struct tevent_req *req, int *perr,
+				 int32_t *result, TALLOC_CTX *mem_ctx,
+				 struct ctdb_script_list **script_list);
+
+struct tevent_req *ctdb_event_script_enable_send(
+					TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct ctdb_event_context *eclient,
+					const char *script_name);
+
+bool ctdb_event_script_enable_recv(struct tevent_req *req, int *perr,
+				   int32_t *result);
+
+struct tevent_req *ctdb_event_script_disable_send(
+					TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct ctdb_event_context *eclient,
+					const char *script_name);
+
+bool ctdb_event_script_disable_recv(struct tevent_req *req, int *perr,
+				    int32_t *result);
+
 #endif /* __CTDB_CLIENT_H__ */
diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index ac453b0..d59767b 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -1437,35 +1437,6 @@ int ctdb_ctrl_del_public_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	return 0;
 }
 
-int ctdb_ctrl_run_eventscripts(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			       struct ctdb_client_context *client,
-			       int destnode, struct timeval timeout,
-			       const char *event)
-{
-	struct ctdb_req_control request;
-	struct ctdb_reply_control *reply;
-	int ret;
-
-	ctdb_req_control_run_eventscripts(&request, event);
-	ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-				  &request, &reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control RUN_EVENTSCRIPTS failed to node %u, ret=%d\n",
-		       destnode, ret));
-		return ret;
-	}
-
-	ret = ctdb_reply_control_run_eventscripts(reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control RUN_EVENTSCRIPTS failed, ret=%d\n", ret));
-		return ret;
-	}
-
-	return 0;
-}
-
 int ctdb_ctrl_get_capabilities(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			       struct ctdb_client_context *client,
 			       int destnode, struct timeval timeout,
@@ -1611,37 +1582,6 @@ int ctdb_ctrl_get_nodemap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	return 0;
 }
 
-int ctdb_ctrl_get_event_script_status(TALLOC_CTX *mem_ctx,
-				      struct tevent_context *ev,
-				      struct ctdb_client_context *client,
-				      int destnode, struct timeval timeout,
-				      enum ctdb_event event,
-				      struct ctdb_script_list **slist)
-{
-	struct ctdb_req_control request;
-	struct ctdb_reply_control *reply;
-	int ret;
-
-	ctdb_req_control_get_event_script_status(&request, event);
-	ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-				  &request, &reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control GET_EVENT_SCRIPT_STATUS failed to node %u, ret=%d\n",
-		       destnode, ret));
-		return ret;
-	}
-
-	ret = ctdb_reply_control_get_event_script_status(reply, mem_ctx, slist);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control GET_EVENT_SCRIPT_STATUS failed, ret=%d\n", ret));
-		return ret;
-	}
-
-	return 0;
-}
-
 int ctdb_ctrl_traverse_kill(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			    struct ctdb_client_context *client,
 			    int destnode, struct timeval timeout,
@@ -1814,64 +1754,6 @@ int ctdb_ctrl_set_recmasterrole(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	return 0;
 }
 
-int ctdb_ctrl_enable_script(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			    struct ctdb_client_context *client,
-			    int destnode, struct timeval timeout,
-			    const char *script)
-{
-	struct ctdb_req_control request;
-	struct ctdb_reply_control *reply;
-	int ret;
-
-	ctdb_req_control_enable_script(&request, script);
-	ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-				  &request, &reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control ENABLE_SCRIPT failed to node %u, ret=%d\n",
-		       destnode, ret));
-		return ret;
-	}
-
-	ret = ctdb_reply_control_enable_script(reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control ENABLE_SCRIPT failed, ret=%d\n", ret));
-		return ret;
-	}
-
-	return 0;
-}
-
-int ctdb_ctrl_disable_script(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			     struct ctdb_client_context *client,
-			     int destnode, struct timeval timeout,
-			     const char *script)
-{
-	struct ctdb_req_control request;
-	struct ctdb_reply_control *reply;
-	int ret;
-
-	ctdb_req_control_disable_script(&request, script);
-	ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-				  &request, &reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control DISABLE_SCRIPT failed to node %u, ret=%d\n",
-		       destnode, ret));
-		return ret;
-	}
-
-	ret = ctdb_reply_control_disable_script(reply);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,
-		      ("Control DISABLE_SCRIPT failed, ret=%d\n", ret));
-		return ret;
-	}
-
-	return 0;
-}
-
 int ctdb_ctrl_set_ban_state(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			    struct ctdb_client_context *client,
 			    int destnode, struct timeval timeout,
diff --git a/ctdb/client/client_event.c b/ctdb/client/client_event.c
new file mode 100644
index 0000000..6397259
--- /dev/null
+++ b/ctdb/client/client_event.c
@@ -0,0 +1,597 @@
+/*
+   Eventd client api
+
+   Copyright (C) Amitay Isaacs  2016
+
+   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
+   (at your option) 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/network.h"
+
+#include <talloc.h>
+#include <tevent.h>
+
+#include "lib/util/debug.h"
+#include "lib/util/tevent_unix.h"
+
+#include "common/logging.h"
+#include "common/reqid.h"
+#include "common/comm.h"
+
+#include "protocol/protocol_api.h"
+
+#include "client/client.h"
+
+struct ctdb_event_context {
+	struct reqid_context *idr;
+	struct comm_context *comm;
+	int fd;
+
+	ctdb_client_callback_func_t callback;
+	void *private_data;
+};
+
+static int ctdb_event_connect(struct ctdb_event_context *eclient,
+			      struct tevent_context *ev,
+			      const char *sockpath);
+
+static int ctdb_event_context_destructor(struct ctdb_event_context *eclient);
+
+int ctdb_event_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+		    const char *sockpath, struct ctdb_event_context **out)
+{
+	struct ctdb_event_context *eclient;
+	int ret;
+
+	eclient = talloc_zero(mem_ctx, struct ctdb_event_context);
+	if (eclient == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " memory allocation error\n"));
+		return ENOMEM;
+	}
+
+	ret = reqid_init(eclient, INT_MAX-200, &eclient->idr);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR, ("reqid_init() failed, ret=%d\n", ret));
+		talloc_free(eclient);
+		return ret;
+	}
+
+	eclient->fd = -1;
+
+	ret = ctdb_event_connect(eclient, ev, sockpath);
+	if (ret != 0) {
+		talloc_free(eclient);
+		return ret;
+	}
+
+	talloc_set_destructor(eclient, ctdb_event_context_destructor);
+
+	*out = eclient;
+	return 0;
+}
+
+static int ctdb_event_context_destructor(struct ctdb_event_context *eclient)
+{
+	if (eclient->fd != -1) {
+		close(eclient->fd);
+		eclient->fd = -1;
+	}
+	return 0;
+}
+
+static void event_read_handler(uint8_t *buf, size_t buflen,
+			       void *private_data);
+static void event_dead_handler(void *private_data);
+
+static int ctdb_event_connect(struct ctdb_event_context *eclient,
+			      struct tevent_context *ev, const char *sockpath)
+{
+	struct sockaddr_un addr;
+	size_t len;
+	int fd, ret;
+
+	if (sockpath == NULL) {
+		DEBUG(DEBUG_ERR, ("socket path cannot be NULL\n"));
+		return EINVAL;
+	}
+
+	memset(&addr, 0, sizeof(addr));
+	addr.sun_family = AF_UNIX;
+	len = strlcpy(addr.sun_path, sockpath, sizeof(addr.sun_path));
+	if (len >= sizeof(addr.sun_path)) {
+		DEBUG(DEBUG_ERR, ("socket path too long, len=%zu\n",
+				  strlen(sockpath)));
+		return ENAMETOOLONG;
+	}
+
+	fd = socket(AF_UNIX, SOCK_STREAM, 0);
+	if (fd == -1) {
+		ret = errno;
+		DEBUG(DEBUG_ERR, ("socket() failed, errno=%d\n", ret));
+		return ret;
+	}
+
+	ret = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
+	if (ret == -1) {
+		ret = errno;
+		DEBUG(DEBUG_ERR, ("connect() failed, errno=%d\n", ret));
+		close(fd);
+		return ret;
+	}
+	eclient->fd = fd;
+
+	ret = comm_setup(eclient, ev, fd, event_read_handler, eclient,
+			 event_dead_handler, eclient, &eclient->comm);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR, ("comm_setup() failed, ret=%d\n", ret));
+		close(fd);
+		eclient->fd = -1;
+		return ret;
+	}
+
+	return 0;
+}
+
+static void ctdb_event_msg_reply(struct ctdb_event_context *eclient,
+				 uint8_t *buf, size_t buflen);
+
+static void event_read_handler(uint8_t *buf, size_t buflen,
+			       void *private_data)
+{
+	struct ctdb_event_context *eclient = talloc_get_type_abort(
+		private_data, struct ctdb_event_context);
+
+	ctdb_event_msg_reply(eclient, buf, buflen);
+}
+
+static void event_dead_handler(void *private_data)
+{
+	struct ctdb_event_context *eclient = talloc_get_type_abort(
+		private_data, struct ctdb_event_context);
+	ctdb_client_callback_func_t callback = eclient->callback;
+	void *callback_data = eclient->private_data;
+
+	talloc_free(eclient);
+	if (callback != NULL) {
+		callback(callback_data);
+		return;
+	}
+
+	DEBUG(DEBUG_NOTICE, ("connection to daemon closed, exiting\n"));
+	exit(1);
+}
+
+void ctdb_event_set_disconnect_callback(struct ctdb_event_context *eclient,
+					ctdb_client_callback_func_t callback,
+					void *private_data)
+{
+	eclient->callback = callback;
+	eclient->private_data = private_data;
+}
+
+/*
+ * Handle eventd_request and eventd_reply
+ */
+
+struct ctdb_event_msg_state {
+	struct ctdb_event_context *eclient;
+
+	uint32_t reqid;
+	struct tevent_req *req;
+	struct ctdb_event_reply *reply;
+};
+
+static int ctdb_event_msg_state_destructor(struct ctdb_event_msg_state *state);
+static void ctdb_event_msg_done(struct tevent_req *subreq);
+
+struct tevent_req *ctdb_event_msg_send(TALLOC_CTX *mem_ctx,
+				       struct tevent_context *ev,
+				       struct ctdb_event_context *eclient,
+				       struct ctdb_event_request *request)
+{
+	struct tevent_req *req, *subreq;
+	struct ctdb_event_msg_state *state;
+	uint8_t *buf;
+	size_t buflen;
+	int ret;
+
+	req = tevent_req_create(mem_ctx, &state, struct ctdb_event_msg_state);
+	if (req == NULL) {
+		return NULL;
+	}
+
+	state->eclient = eclient;
+
+	state->reqid = reqid_new(eclient->idr, state);
+	if (state->reqid == REQID_INVALID) {
+		talloc_free(req);
+		return NULL;
+	}
+	state->req = req;
+
+	talloc_set_destructor(state, ctdb_event_msg_state_destructor);
+
+	ctdb_event_header_fill(&request->header, state->reqid);
+
+	buflen = ctdb_event_request_len(request);
+	buf = talloc_size(state, buflen);
+	if (tevent_req_nomem(buf, req)) {
+		return tevent_req_post(req, ev);
+	}


-- 
Samba Shared Repository
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.