mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
libctdb: add ctdb_getcapabilities()
Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 140fafef23050d40d66f5b5558c7efcb78f80cd2)
This commit is contained in:
parent
110cb67e2a
commit
e05fc0e7b0
@ -584,6 +584,35 @@ ctdb_check_message_handlers_recv(struct ctdb_connection *ctdb,
|
||||
uint8_t *result);
|
||||
|
||||
|
||||
/**
|
||||
* ctdb_getcapabilities_send - read the capabilities of a node
|
||||
* @ctdb: the ctdb_connection from ctdb_connect.
|
||||
* @destnode: the destination node (see below)
|
||||
* @callback: the callback when ctdb replies to our message (typesafe)
|
||||
* @cbdata: the argument to callback()
|
||||
*
|
||||
* There are several special values for destnode, detailed in
|
||||
* ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the
|
||||
* local ctdbd.
|
||||
*/
|
||||
struct ctdb_request *
|
||||
ctdb_getcapabilities_send(struct ctdb_connection *ctdb,
|
||||
uint32_t destnode,
|
||||
ctdb_callback_t callback, void *cbdata);
|
||||
|
||||
/**
|
||||
* ctdb_getcapabilities_recv - read an ctdb_getcapabilities reply from ctdbd
|
||||
* @ctdb: the ctdb_connection from ctdb_connect.
|
||||
* @req: the completed request.
|
||||
* @capabilities: a pointer to the capabilities to fill in
|
||||
*
|
||||
* This returns false if something went wrong, or otherwise fills in
|
||||
* capabilities.
|
||||
*/
|
||||
bool ctdb_getcapabilities_recv(struct ctdb_connection *ctdb,
|
||||
struct ctdb_request *handle,
|
||||
uint32_t *capabilities);
|
||||
|
||||
/**
|
||||
* ctdb_getdbseqnum_send - read the sequence number off a db
|
||||
* @ctdb: the ctdb_connection from ctdb_connect.
|
||||
@ -949,6 +978,23 @@ ctdb_check_message_handlers(struct ctdb_connection *ctdb,
|
||||
uint64_t *mhs,
|
||||
uint8_t *result);
|
||||
|
||||
/**
|
||||
* ctdb_getcapabilities - read the capabilities of a node (synchronous)
|
||||
* @ctdb: the ctdb_connection from ctdb_connect.
|
||||
* @destnode: the destination node (see below)
|
||||
* @capabilities: a pointer to the capabilities to fill in
|
||||
*
|
||||
* There are several special values for destnode, detailed in
|
||||
* ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the
|
||||
* local ctdbd.
|
||||
*
|
||||
* Returns true and fills in *capabilities on success.
|
||||
*/
|
||||
bool ctdb_getcapabilities(struct ctdb_connection *ctdb,
|
||||
uint32_t destnode,
|
||||
uint32_t *capabilities);
|
||||
|
||||
|
||||
/**
|
||||
* ctdb_getdbseqnum - read the seqnum of a database
|
||||
* @ctdb: the ctdb_connection from ctdb_connect.
|
||||
@ -1145,6 +1191,10 @@ void ctdb_free_vnnmap(struct ctdb_vnn_map *vnnmap);
|
||||
ctdb_getpnn_send((ctdb), (destnode), \
|
||||
ctdb_sendcb((cb), (cbdata)), (cbdata))
|
||||
|
||||
#define ctdb_getcapabilities_send(ctdb, destnode, cb, cbdata) \
|
||||
ctdb_getcapabilities_send((ctdb), (destnode), \
|
||||
ctdb_sendcb((cb), (cbdata)), (cbdata))
|
||||
|
||||
#define ctdb_getdbstat_send(ctdb, destnode, db_id, cb, cbdata) \
|
||||
ctdb_getdbstat_send((ctdb), (destnode), (db_id), \
|
||||
ctdb_sendcb((cb), (cbdata)), (cbdata))
|
||||
|
@ -394,14 +394,6 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN
|
||||
#define CTDB_MONITORING_ACTIVE 0
|
||||
#define CTDB_MONITORING_DISABLED 1
|
||||
|
||||
/* The different capabilities of the ctdb daemon. */
|
||||
#define CTDB_CAP_RECMASTER 0x00000001
|
||||
#define CTDB_CAP_LMASTER 0x00000002
|
||||
/* This capability is set if CTDB_LVS_PUBLIC_IP is set */
|
||||
#define CTDB_CAP_LVS 0x00000004
|
||||
/* This capability is set if NATGW is enabled */
|
||||
#define CTDB_CAP_NATGW 0x00000008
|
||||
|
||||
#define NUM_DB_PRIORITIES 3
|
||||
/* main state of the ctdb daemon */
|
||||
struct ctdb_context {
|
||||
|
@ -568,6 +568,17 @@ struct ctdb_node_map {
|
||||
#define NODE_FLAGS_NOIPTAKEOVER 0x01000000 /* this node can takeover any new ip addresses, this flag is ONLY valid within the recovery daemon */
|
||||
|
||||
|
||||
/*
|
||||
* Node capabilities
|
||||
*/
|
||||
#define CTDB_CAP_RECMASTER 0x00000001
|
||||
#define CTDB_CAP_LMASTER 0x00000002
|
||||
/* This capability is set if CTDB_LVS_PUBLIC_IP is set */
|
||||
#define CTDB_CAP_LVS 0x00000004
|
||||
/* This capability is set if NATGW is enabled */
|
||||
#define CTDB_CAP_NATGW 0x00000008
|
||||
|
||||
|
||||
struct ctdb_public_ip {
|
||||
uint32_t pnn;
|
||||
ctdb_sock_addr addr;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#undef ctdb_getdbseqnum_send
|
||||
#undef ctdb_getifaces_send
|
||||
#undef ctdb_getvnnmap_send
|
||||
#undef ctdb_getcapabilities_send
|
||||
|
||||
bool ctdb_getrecmaster_recv(struct ctdb_connection *ctdb,
|
||||
struct ctdb_request *req, uint32_t *recmaster)
|
||||
@ -515,3 +516,30 @@ struct ctdb_request *ctdb_getvnnmap_send(struct ctdb_connection *ctdb,
|
||||
NULL, 0, callback, private_data);
|
||||
}
|
||||
|
||||
bool ctdb_getcapabilities_recv(struct ctdb_connection *ctdb,
|
||||
struct ctdb_request *req, uint32_t *capabilities)
|
||||
{
|
||||
struct ctdb_reply_control *reply;
|
||||
|
||||
reply = unpack_reply_control(req, CTDB_CONTROL_GET_CAPABILITIES);
|
||||
if (!reply) {
|
||||
return false;
|
||||
}
|
||||
if (reply->status == -1) {
|
||||
DEBUG(ctdb, LOG_ERR, "ctdb_getcapabilities_recv: status -1");
|
||||
return false;
|
||||
}
|
||||
*capabilities = *((uint32_t *)reply->data);
|
||||
return true;
|
||||
}
|
||||
|
||||
struct ctdb_request *ctdb_getcapabilities_send(struct ctdb_connection *ctdb,
|
||||
uint32_t destnode,
|
||||
ctdb_callback_t callback,
|
||||
void *private_data)
|
||||
{
|
||||
return new_ctdb_control_request(ctdb, CTDB_CONTROL_GET_CAPABILITIES,
|
||||
destnode,
|
||||
NULL, 0, callback, private_data);
|
||||
}
|
||||
|
||||
|
@ -338,3 +338,20 @@ bool ctdb_getvnnmap(struct ctdb_connection *ctdb,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ctdb_getcapabilities(struct ctdb_connection *ctdb,
|
||||
uint32_t destnode, uint32_t *capabilities)
|
||||
{
|
||||
struct ctdb_request *req;
|
||||
bool done = false;
|
||||
bool ret = false;
|
||||
|
||||
req = synchronous(ctdb,
|
||||
ctdb_getcapabilities_send(ctdb, destnode, set, &done),
|
||||
&done);
|
||||
if (req != NULL) {
|
||||
ret = ctdb_getcapabilities_recv(ctdb, req, capabilities);
|
||||
ctdb_request_free(req);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user