#include "lib/util/substitute.h"
#include "lib/util/time.h"
-#include "ctdb_logging.h"
#include "ctdb_version.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
#include "common/rb_tree.h"
#include "common/system.h"
#include "common/common.h"
+#include "common/logging.h"
#define ERR_TIMEOUT 20 /* timed out trying to reach node */
#define ERR_NONODE 21 /* node does not exist */
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
int n;
uint32_t i;
- struct ctdb_node_map *nodemap;
+ struct ctdb_node_map_old *nodemap;
int ret;
*nodes = NULL;
uint32_t *dbid, const char **dbname, uint8_t *flags)
{
int i, ret;
- struct ctdb_dbid_map *dbmap=NULL;
+ struct ctdb_dbid_map_old *dbmap=NULL;
bool dbid_given = false, found = false;
uint32_t id;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
for(i=0; i<dbmap->num; i++) {
if (dbid_given) {
- if (id == dbmap->dbs[i].dbid) {
+ if (id == dbmap->dbs[i].db_id) {
found = true;
break;
}
} else {
- ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, tmp_ctx, &name);
+ ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, tmp_ctx, &name);
if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].dbid));
+ DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].db_id));
goto fail;
}
if (strcmp(name, dbarg) == 0) {
- id = dbmap->dbs[i].dbid;
+ id = dbmap->dbs[i].db_id;
found = true;
break;
}
}
if (found && dbid_given && dbname != NULL) {
- ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, tmp_ctx, &name);
+ ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, tmp_ctx, &name);
if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].dbid));
+ DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].db_id));
found = false;
goto fail;
}
static int control_stats(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret;
- struct ctdb_statistics_wire *stats;
+ struct ctdb_statistics_list_old *stats;
int i, num_records = -1;
assert_single_node_only();
static int control_dbstatistics(struct ctdb_context *ctdb, int argc, const char **argv)
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_db_statistics *dbstat;
+ struct ctdb_db_statistics_old *dbstat;
int i;
uint32_t db_id;
int num_hot_keys;
}
-static struct ctdb_node_map *read_nodes_file(TALLOC_CTX *mem_ctx)
+static struct ctdb_node_map_old *read_nodes_file(TALLOC_CTX *mem_ctx)
{
const char *nodes_list;
static int find_node_xpnn(void)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
- struct ctdb_node_map *node_map;
+ struct ctdb_node_map_old *node_map;
int i, pnn;
node_map = read_nodes_file(mem_ctx);
bool ret = false;
if (node->flags == 0) {
- struct ctdb_control_get_ifaces *ifaces;
+ struct ctdb_iface_list_old *ifaces;
if (ctdb_ctrl_get_ifaces(ctdb, TIMELIMIT(), node->pnn,
tmp_ctx, &ifaces) == 0) {
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
int i;
struct ctdb_vnn_map *vnnmap=NULL;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
uint32_t recmode, recmaster, mypnn;
int num_deleted_nodes = 0;
int ret;
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
int i, ret;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
uint32_t * nodes;
uint32_t pnn_mode, mypnn;
return ret;
}
-static struct ctdb_node_map *read_natgw_nodes_file(struct ctdb_context *ctdb,
- TALLOC_CTX *mem_ctx)
-{
- const char *natgw_list;
- struct ctdb_node_map *natgw_nodes = NULL;
-
- natgw_list = getenv("CTDB_NATGW_NODES");
- if (natgw_list == NULL) {
- natgw_list = talloc_asprintf(mem_ctx, "%s/natgw_nodes",
- getenv("CTDB_BASE"));
- if (natgw_list == NULL) {
- DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
- exit(1);
- }
- }
- /* The PNNs/flags will be junk but they're not used */
- natgw_nodes = ctdb_read_nodes_file(mem_ctx, natgw_list);
- if (natgw_nodes == NULL) {
- DEBUG(DEBUG_ERR,
- ("Failed to load natgw node list '%s'\n", natgw_list));
- }
- return natgw_nodes;
-}
-
-
/* talloc off the existing nodemap... */
-static struct ctdb_node_map *talloc_nodemap(struct ctdb_node_map *nodemap)
+static struct ctdb_node_map_old *talloc_nodemap(struct ctdb_node_map_old *nodemap)
{
return talloc_zero_size(nodemap,
- offsetof(struct ctdb_node_map, nodes) +
+ offsetof(struct ctdb_node_map_old, nodes) +
nodemap->num * sizeof(struct ctdb_node_and_flags));
}
-static struct ctdb_node_map *
-filter_nodemap_by_addrs(struct ctdb_context *ctdb,
- struct ctdb_node_map *nodemap,
- struct ctdb_node_map *natgw_nodes)
-{
- int i, j;
- struct ctdb_node_map *ret;
-
- ret = talloc_nodemap(nodemap);
- CTDB_NO_MEMORY_NULL(ctdb, ret);
-
- ret->num = 0;
-
- for (i = 0; i < nodemap->num; i++) {
- for(j = 0; j < natgw_nodes->num ; j++) {
- if (nodemap->nodes[j].flags & NODE_FLAGS_DELETED) {
- continue;
- }
- if (ctdb_same_ip(&natgw_nodes->nodes[j].addr,
- &nodemap->nodes[i].addr)) {
-
- ret->nodes[ret->num] = nodemap->nodes[i];
- ret->num++;
- break;
- }
- }
- }
-
- return ret;
-}
-
-static struct ctdb_node_map *
+static struct ctdb_node_map_old *
filter_nodemap_by_capabilities(struct ctdb_context *ctdb,
- struct ctdb_node_map *nodemap,
+ struct ctdb_node_map_old *nodemap,
uint32_t required_capabilities,
bool first_only)
{
int i;
uint32_t capabilities;
- struct ctdb_node_map *ret;
+ struct ctdb_node_map_old *ret;
ret = talloc_nodemap(nodemap);
CTDB_NO_MEMORY_NULL(ctdb, ret);
return ret;
}
-static struct ctdb_node_map *
+static struct ctdb_node_map_old *
filter_nodemap_by_flags(struct ctdb_context *ctdb,
- struct ctdb_node_map *nodemap,
+ struct ctdb_node_map_old *nodemap,
uint32_t flags_mask)
{
int i;
- struct ctdb_node_map *ret;
+ struct ctdb_node_map_old *ret;
ret = talloc_nodemap(nodemap);
CTDB_NO_MEMORY_NULL(ctdb, ret);
*/
static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **argv)
{
- TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- int i, ret;
- struct ctdb_node_map *natgw_nodes = NULL;
- struct ctdb_node_map *orig_nodemap=NULL;
- struct ctdb_node_map *nodemap;
- uint32_t mypnn, pnn;
- const char *ip;
-
- /* When we have some nodes that could be the NATGW, make a
- * series of attempts to find the first node that doesn't have
- * certain status flags set.
- */
- uint32_t exclude_flags[] = {
- /* Look for a nice healthy node */
- NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_UNHEALTHY,
- /* If not found, an UNHEALTHY/BANNED node will do */
- NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED,
- /* If not found, a STOPPED node will do */
- NODE_FLAGS_DISCONNECTED|NODE_FLAGS_DELETED,
- 0,
- };
-
- /* read the natgw nodes file into a linked list */
- natgw_nodes = read_natgw_nodes_file(ctdb, tmp_ctx);
- if (natgw_nodes == NULL) {
- ret = -1;
- goto done;
- }
-
- ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE,
- tmp_ctx, &orig_nodemap);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node.\n"));
- talloc_free(tmp_ctx);
- return -1;
- }
+ static char prog[PATH_MAX+1] = "";
- /* Get a nodemap that includes only the nodes in the NATGW
- * group */
- nodemap = filter_nodemap_by_addrs(ctdb, orig_nodemap, natgw_nodes);
- if (nodemap == NULL) {
- ret = -1;
- goto done;
- }
-
- ret = 2; /* matches ENOENT */
- pnn = -1;
- ip = "0.0.0.0";
- /* For each flag mask... */
- for (i = 0; exclude_flags[i] != 0; i++) {
- /* ... get a nodemap that excludes nodes with with
- * masked flags... */
- struct ctdb_node_map *t =
- filter_nodemap_by_flags(ctdb, nodemap,
- exclude_flags[i]);
- if (t == NULL) {
- /* No memory */
- ret = -1;
- goto done;
- }
- if (t->num > 0) {
- /* ... and find the first node with the NATGW
- * capability */
- struct ctdb_node_map *n;
- n = filter_nodemap_by_capabilities(ctdb, t,
- CTDB_CAP_NATGW,
- true);
- if (n == NULL) {
- /* No memory */
- ret = -1;
- goto done;
- }
- if (n->num > 0) {
- ret = 0;
- pnn = n->nodes[0].pnn;
- ip = ctdb_addr_to_str(&n->nodes[0].addr);
- break;
- }
- }
- talloc_free(t);
+ if (argc != 0) {
+ usage();
}
- if (options.machinereadable) {
- printm(":Node:IP:\n");
- printm(":%d:%s:\n", pnn, ip);
- } else {
- printf("%d %s\n", pnn, ip);
+ if (!ctdb_set_helper("NAT gateway helper", prog, sizeof(prog),
+ "CTDB_NATGW_HELPER", CTDB_HELPER_BINDIR,
+ "ctdb_natgw")) {
+ DEBUG(DEBUG_ERR, ("Unable to set NAT gateway helper\n"));
+ exit(1);
}
- /* print the pruned list of nodes belonging to this natgw list */
- mypnn = getpnn(ctdb);
- if (options.machinereadable) {
- control_status_header_machine();
- } else {
- printf("Number of nodes:%d\n", nodemap->num);
- }
- for(i=0;i<nodemap->num;i++){
- if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
- continue;
- }
- if (options.machinereadable) {
- control_status_1_machine(ctdb, mypnn, &(nodemap->nodes[i]));
- } else {
- control_status_1_human(ctdb, mypnn, &(nodemap->nodes[i]));
- }
- }
+ execl(prog, prog, "natgwlist", NULL);
-done:
- talloc_free(tmp_ctx);
- return ret;
+ DEBUG(DEBUG_ERR,
+ ("Unable to run NAT gateway helper %s\n", strerror(errno)));
+ exit(1);
}
/*
display the status of the scripts for monitoring (or other events)
*/
static int control_one_scriptstatus(struct ctdb_context *ctdb,
- enum ctdb_eventscript_call type)
+ enum ctdb_event type)
{
- struct ctdb_scripts_wire *script_status;
+ struct ctdb_script_list_old *script_status;
int ret, i;
ret = ctdb_ctrl_getscriptstatus(ctdb, TIMELIMIT(), options.pnn, ctdb, type, &script_status);
int argc, const char **argv)
{
int ret;
- enum ctdb_eventscript_call type, min, max;
+ enum ctdb_event type, min, max;
const char *arg;
if (argc > 1) {
*/
static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
{
- struct ctdb_tcp_connection t;
+ struct ctdb_connection t;
TDB_DATA data;
int ret;
usage();
}
- if (parse_ip_port(argv[0], &t.src_addr) == 0) {
+ if (parse_ip_port(argv[0], &t.src) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
return -1;
}
- if (parse_ip_port(argv[1], &t.dst_addr) == 0) {
+ if (parse_ip_port(argv[1], &t.dst) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
return -1;
}
*/
static int control_del_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
{
- struct ctdb_tcp_connection t;
+ struct ctdb_connection t;
TDB_DATA data;
int ret;
usage();
}
- if (parse_ip_port(argv[0], &t.src_addr) == 0) {
+ if (parse_ip_port(argv[0], &t.src) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
return -1;
}
- if (parse_ip_port(argv[1], &t.dst_addr) == 0) {
+ if (parse_ip_port(argv[1], &t.dst) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
return -1;
}
*/
static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char **argv)
{
- struct ctdb_control_tcp_tickle_list *list;
+ struct ctdb_tickle_list_old *list;
ctdb_sock_addr addr;
int i, ret;
unsigned port = 0;
if (options.machinereadable){
printm(":source ip:port:destination ip:port:\n");
- for (i=0;i<list->tickles.num;i++) {
- if (port && port != ntohs(list->tickles.connections[i].dst_addr.ip.sin_port)) {
+ for (i=0;i<list->num;i++) {
+ if (port && port != ntohs(list->connections[i].dst.ip.sin_port)) {
continue;
}
- printm(":%s:%u", ctdb_addr_to_str(&list->tickles.connections[i].src_addr), ntohs(list->tickles.connections[i].src_addr.ip.sin_port));
- printm(":%s:%u:\n", ctdb_addr_to_str(&list->tickles.connections[i].dst_addr), ntohs(list->tickles.connections[i].dst_addr.ip.sin_port));
+ printm(":%s:%u", ctdb_addr_to_str(&list->connections[i].src), ntohs(list->connections[i].src.ip.sin_port));
+ printm(":%s:%u:\n", ctdb_addr_to_str(&list->connections[i].dst), ntohs(list->connections[i].dst.ip.sin_port));
}
} else {
printf("Tickles for ip:%s\n", ctdb_addr_to_str(&list->addr));
- printf("Num tickles:%u\n", list->tickles.num);
- for (i=0;i<list->tickles.num;i++) {
- if (port && port != ntohs(list->tickles.connections[i].dst_addr.ip.sin_port)) {
+ printf("Num tickles:%u\n", list->num);
+ for (i=0;i<list->num;i++) {
+ if (port && port != ntohs(list->connections[i].dst.ip.sin_port)) {
continue;
}
- printf("SRC: %s:%u ", ctdb_addr_to_str(&list->tickles.connections[i].src_addr), ntohs(list->tickles.connections[i].src_addr.ip.sin_port));
- printf("DST: %s:%u\n", ctdb_addr_to_str(&list->tickles.connections[i].dst_addr), ntohs(list->tickles.connections[i].dst_addr.ip.sin_port));
+ printf("SRC: %s:%u ", ctdb_addr_to_str(&list->connections[i].src), ntohs(list->connections[i].src.ip.sin_port));
+ printf("DST: %s:%u\n", ctdb_addr_to_str(&list->connections[i].dst), ntohs(list->connections[i].dst.ip.sin_port));
}
}
static int move_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr, uint32_t pnn)
{
- struct ctdb_all_public_ips *ips;
+ struct ctdb_public_ip_list_old *ips;
struct ctdb_public_ip ip;
int i, ret;
uint32_t *nodes;
uint32_t disable_time;
TDB_DATA data;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
disable_time = 30;
find_other_host_for_public_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr)
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_all_public_ips *ips;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_public_ip_list_old *ips;
+ struct ctdb_node_map_old *nodemap=NULL;
int i, j, ret;
int pnn;
uint32_t *nodes;
uint32_t disable_time;
TDB_DATA data;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
disable_time = 30;
static int getips_store_callback(void *param, void *data)
{
struct ctdb_public_ip *node_ip = (struct ctdb_public_ip *)data;
- struct ctdb_all_public_ips *ips = param;
+ struct ctdb_public_ip_list_old *ips = param;
int i;
i = ips->num++;
}
static int
-control_get_all_public_ips(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx, struct ctdb_all_public_ips **ips)
+control_get_all_public_ips(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx, struct ctdb_public_ip_list_old **ips)
{
- struct ctdb_all_public_ips *tmp_ips;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_public_ip_list_old *tmp_ips;
+ struct ctdb_node_map_old *nodemap=NULL;
trbt_tree_t *ip_tree;
int i, j, len, ret;
uint32_t count;
count = 0;
trbt_traversearray32(ip_tree, IP_KEYLEN, getips_count_callback, &count);
- len = offsetof(struct ctdb_all_public_ips, ips) +
+ len = offsetof(struct ctdb_public_ip_list_old, ips) +
count*sizeof(struct ctdb_public_ip);
tmp_ips = talloc_zero_size(tmp_ctx, len);
trbt_traversearray32(ip_tree, IP_KEYLEN, getips_store_callback, tmp_ips);
TDB_DATA data;
uint32_t pnn;
uint64_t reply_srvid;
- struct srvid_request request;
- struct srvid_request_data request_data;
+ struct ctdb_srvid_message request;
+ struct ctdb_disable_message request_data;
struct srvid_reply_handler_data reply_data;
struct timeval tv;
} else {
request_data.pnn = pnn;
request_data.srvid = reply_srvid;
- request_data.data = *arg;
+ request_data.timeout = *arg;
data.dptr = (uint8_t *)&request_data;
data.dsize = sizeof(request_data);
reply_data.done = false;
if (wait_for_all) {
- struct ctdb_node_map *nodemap;
+ struct ctdb_node_map_old *nodemap;
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(),
CTDB_CURRENT_NODE, ctdb, &nodemap);
int len, retries = 0;
unsigned mask;
ctdb_sock_addr addr;
- struct ctdb_control_ip_iface *pub;
+ struct ctdb_addr_info_old *pub;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_all_public_ips *ips;
+ struct ctdb_public_ip_list_old *ips;
if (argc != 2) {
*/
alarm(0);
- len = offsetof(struct ctdb_control_ip_iface, iface) + strlen(argv[1]) + 1;
+ len = offsetof(struct ctdb_addr_info_old, iface) + strlen(argv[1]) + 1;
pub = talloc_size(tmp_ctx, len);
CTDB_NO_MEMORY(ctdb, pub);
static int control_delip_all(struct ctdb_context *ctdb, int argc, const char **argv, ctdb_sock_addr *addr)
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_node_map *nodemap=NULL;
- struct ctdb_all_public_ips *ips;
+ struct ctdb_node_map_old *nodemap=NULL;
+ struct ctdb_public_ip_list_old *ips;
int ret, i, j;
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, tmp_ctx, &nodemap);
{
int i, ret;
ctdb_sock_addr addr;
- struct ctdb_control_ip_iface pub;
+ struct ctdb_addr_info_old pub;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_all_public_ips *ips;
+ struct ctdb_public_ip_list_old *ips;
if (argc != 1) {
talloc_free(tmp_ctx);
static int kill_tcp_from_file(struct ctdb_context *ctdb,
int argc, const char **argv)
{
- struct ctdb_tcp_connection *killtcp;
+ struct ctdb_connection *killtcp;
int max_entries, current, i;
struct timeval timeout;
char line[128], src[128], dst[128];
if (current >= max_entries) {
max_entries += 1024;
killtcp = talloc_realloc(ctdb, killtcp,
- struct ctdb_tcp_connection,
+ struct ctdb_connection,
max_entries);
CTDB_NO_MEMORY(ctdb, killtcp);
}
- if (!parse_ip_port(src, &killtcp[current].src_addr)) {
+ if (!parse_ip_port(src, &killtcp[current].src)) {
DEBUG(DEBUG_ERR, ("Bad IP:port on line [%d]: '%s'\n",
linenum, src));
talloc_free(killtcp);
return -1;
}
- if (!parse_ip_port(dst, &killtcp[current].dst_addr)) {
+ if (!parse_ip_port(dst, &killtcp[current].dst)) {
DEBUG(DEBUG_ERR, ("Bad IP:port on line [%d]: '%s'\n",
linenum, dst));
talloc_free(killtcp);
for (i = 0; i < current; i++) {
- data.dsize = sizeof(struct ctdb_tcp_connection);
+ data.dsize = sizeof(struct ctdb_connection);
data.dptr = (unsigned char *)&killtcp[i];
timeout = TIMELIMIT();
static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret;
- struct ctdb_tcp_connection killtcp;
+ struct ctdb_connection killtcp;
assert_single_node_only();
usage();
}
- if (!parse_ip_port(argv[0], &killtcp.src_addr)) {
+ if (!parse_ip_port(argv[0], &killtcp.src)) {
DEBUG(DEBUG_ERR, ("Bad IP:port '%s'\n", argv[0]));
return -1;
}
- if (!parse_ip_port(argv[1], &killtcp.dst_addr)) {
+ if (!parse_ip_port(argv[1], &killtcp.dst)) {
DEBUG(DEBUG_ERR, ("Bad IP:port '%s'\n", argv[1]));
return -1;
}
static int regsrvid(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret;
- struct ctdb_server_id server_id;
+ struct ctdb_client_id server_id;
if (argc < 3) {
usage();
static int unregsrvid(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret;
- struct ctdb_server_id server_id;
+ struct ctdb_client_id server_id;
if (argc < 3) {
usage();
{
uint32_t status = 0;
int ret;
- struct ctdb_server_id server_id;
+ struct ctdb_client_id server_id;
if (argc < 3) {
usage();
static int getsrvids(struct ctdb_context *ctdb, int argc, const char **argv)
{
int i, ret;
- struct ctdb_server_id_list *server_ids;
+ struct ctdb_client_id_list_old *server_ids;
ret = ctdb_ctrl_get_server_id_list(ctdb, ctdb, TIMELIMIT(), options.pnn, &server_ids);
if (ret != 0) {
{
int i, ret;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_all_public_ips *ips;
+ struct ctdb_public_ip_list_old *ips;
if (argc == 1 && strcmp(argv[0], "all") == 0) {
options.pnn = CTDB_BROADCAST_ALL;
}
for (i=1;i<=ips->num;i++) {
- struct ctdb_control_public_ip_info *info = NULL;
+ struct ctdb_public_ip_info_old *info = NULL;
int32_t pnn;
char *aciface = NULL;
char *avifaces = NULL;
int i, ret;
ctdb_sock_addr addr;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_control_public_ip_info *info;
+ struct ctdb_public_ip_info_old *info;
if (argc != 1) {
talloc_free(tmp_ctx);
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
int i;
- struct ctdb_control_get_ifaces *ifaces;
+ struct ctdb_iface_list_old *ifaces;
int ret;
/* read the public ip list from this node */
{
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_control_iface_info info;
+ struct ctdb_iface info;
ZERO_STRUCT(info);
const char *desc,
bool set_flag)
{
- struct ctdb_node_map *nodemap = NULL;
+ struct ctdb_node_map_old *nodemap = NULL;
bool flag_is_set;
int ret;
/* Ban a node */
static bool update_state_banned(struct ctdb_context *ctdb, void *data)
{
- struct ctdb_ban_time *bantime = (struct ctdb_ban_time *)data;
+ struct ctdb_ban_state *bantime = (struct ctdb_ban_state *)data;
int ret;
ret = ctdb_ctrl_set_ban(ctdb, TIMELIMIT(), options.pnn, bantime);
static int control_ban(struct ctdb_context *ctdb, int argc, const char **argv)
{
- struct ctdb_ban_time bantime;
+ struct ctdb_ban_state bantime;
if (argc < 1) {
usage();
/* Unban a node */
static int control_unban(struct ctdb_context *ctdb, int argc, const char **argv)
{
- struct ctdb_ban_time bantime;
+ struct ctdb_ban_state bantime;
bantime.pnn = options.pnn;
bantime.time = 0;
static int control_showban(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret;
- struct ctdb_node_map *nodemap=NULL;
- struct ctdb_ban_time *bantime;
+ struct ctdb_node_map_old *nodemap=NULL;
+ struct ctdb_ban_state *bantime;
/* verify the node exists */
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap);
DEBUG(DEBUG_ERR, ("Unable to get capabilities from node %u\n", options.pnn));
return -1;
}
-
+
if (!options.machinereadable){
printf("RECMASTER: %s\n", (capabilities&CTDB_CAP_RECMASTER)?"YES":"NO");
printf("LMASTER: %s\n", (capabilities&CTDB_CAP_LMASTER)?"YES":"NO");
printf("LVS: %s\n", (capabilities&CTDB_CAP_LVS)?"YES":"NO");
- printf("NATGW: %s\n", (capabilities&CTDB_CAP_NATGW)?"YES":"NO");
} else {
- printm(":RECMASTER:LMASTER:LVS:NATGW:\n");
- printm(":%d:%d:%d:%d:\n",
+ printm(":RECMASTER:LMASTER:LVS:\n");
+ printm(":%d:%d:%d:\n",
!!(capabilities&CTDB_CAP_RECMASTER),
!!(capabilities&CTDB_CAP_LMASTER),
- !!(capabilities&CTDB_CAP_LVS),
- !!(capabilities&CTDB_CAP_NATGW));
+ !!(capabilities&CTDB_CAP_LVS));
}
return 0;
}
static int control_lvs(struct ctdb_context *ctdb, int argc, const char **argv)
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_node_map *orig_nodemap=NULL;
- struct ctdb_node_map *nodemap;
+ struct ctdb_node_map_old *orig_nodemap=NULL;
+ struct ctdb_node_map_old *nodemap;
int i, ret;
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn,
ret = 0;
for (i = 0; lvs_exclude_flags[i] != 0; i++) {
- struct ctdb_node_map *t =
+ struct ctdb_node_map_old *t =
filter_nodemap_by_flags(ctdb, nodemap,
lvs_exclude_flags[i]);
if (t == NULL) {
static int control_lvsmaster(struct ctdb_context *ctdb, int argc, const char **argv)
{
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
int i, ret;
ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn,
}
for (i = 0; lvs_exclude_flags[i] != 0; i++) {
- struct ctdb_node_map *t =
+ struct ctdb_node_map_old *t =
filter_nodemap_by_flags(ctdb, nodemap,
lvs_exclude_flags[i]);
if (t == NULL) {
goto done;
}
if (t->num > 0) {
- struct ctdb_node_map *n;
+ struct ctdb_node_map_old *n;
n = filter_nodemap_by_capabilities(ctdb,
t,
CTDB_CAP_LVS,
static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **argv)
{
int i, ret;
- struct ctdb_dbid_map *dbmap=NULL;
+ struct ctdb_dbid_map_old *dbmap=NULL;
ret = ctdb_ctrl_getdbmap(ctdb, TIMELIMIT(), options.pnn, ctdb, &dbmap);
if (ret != 0) {
bool sticky;
ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn,
- dbmap->dbs[i].dbid, ctdb, &path);
+ dbmap->dbs[i].db_id, ctdb, &path);
ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn,
- dbmap->dbs[i].dbid, ctdb, &name);
+ dbmap->dbs[i].db_id, ctdb, &name);
ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn,
- dbmap->dbs[i].dbid, ctdb, &health);
+ dbmap->dbs[i].db_id, ctdb, &health);
persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
readonly = dbmap->dbs[i].flags & CTDB_DB_FLAGS_READONLY;
sticky = dbmap->dbs[i].flags & CTDB_DB_FLAGS_STICKY;
printm(":0x%08X:%s:%s:%d:%d:%d:%d:\n",
- dbmap->dbs[i].dbid, name, path,
+ dbmap->dbs[i].db_id, name, path,
!!(persistent), !!(sticky),
!!(health), !!(readonly));
}
bool readonly;
bool sticky;
- ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &path);
- ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &name);
- ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &health);
+ ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &path);
+ ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &name);
+ ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &health);
persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
readonly = dbmap->dbs[i].flags & CTDB_DB_FLAGS_READONLY;
sticky = dbmap->dbs[i].flags & CTDB_DB_FLAGS_STICKY;
printf("dbid:0x%08x name:%s path:%s%s%s%s%s\n",
- dbmap->dbs[i].dbid, name, path,
+ dbmap->dbs[i].db_id, name, path,
persistent?" PERSISTENT":"",
sticky?" STICKY":"",
readonly?" READONLY":"",
DEBUG(DEBUG_ERR, ("Unable to get debuglevel response from node %u\n", options.pnn));
return ret;
} else {
- const char *desc = get_debug_by_level(level);
+ enum debug_level log_level = debug_level_from_int(level);
+ const char *desc = debug_level_to_string(log_level);
if (desc == NULL) {
/* This should never happen */
desc = "Unknown";
return 0;
}
-/*
- set the natgw state on/off
- */
-static int control_setnatgwstate(struct ctdb_context *ctdb, int argc, const char **argv)
-{
- int ret;
- uint32_t natgwstate = 0;
-
- if (argc == 0) {
- usage();
- }
-
- if (!strcmp(argv[0], "on")) {
- natgwstate = 1;
- } else if (!strcmp(argv[0], "off")) {
- natgwstate = 0;
- } else {
- usage();
- }
-
- ret = ctdb_ctrl_setnatgwstate(ctdb, TIMELIMIT(), options.pnn, natgwstate);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to set the natgw state for node %u\n", options.pnn));
- return ret;
- }
-
- return 0;
-}
-
/*
set the lmaster role on/off
*/
{
int ret;
int32_t level;
+ enum debug_level log_level;
if (argc == 0) {
printf("You must specify the debug level. Valid levels are:\n");
- print_debug_levels(stdout);
+ printf("\tERROR | WARNING | NOTICE | INFO | DEBUG\n");
return 0;
}
- if (!parse_debug(argv[0], &level)) {
+ if (!debug_level_parse(argv[0], &log_level)) {
printf("Invalid debug level, must be one of\n");
- print_debug_levels(stdout);
+ printf("\tERROR | WARNING | NOTICE | INFO | DEBUG\n");
return -1;
}
+ level = debug_level_to_int(log_level);
+
ret = ctdb_ctrl_set_debuglevel(ctdb, options.pnn, level);
if (ret != 0) {
DEBUG(DEBUG_ERR, ("Unable to set debug level on node %u\n", options.pnn));
uint32_t db_id;
uint8_t flags;
int ret, i, status = 0;
- struct ctdb_node_map *nodemap = NULL;
+ struct ctdb_node_map_old *nodemap = NULL;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
uint32_t recmode;
static int backup_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *private)
{
struct backup_data *bd = talloc_get_type(private, struct backup_data);
- struct ctdb_rec_data *rec;
+ struct ctdb_rec_data_old *rec;
/* add the record */
rec = ctdb_marshall_record(bd->records, 0, key, NULL, data);
TDB_DATA data;
struct db_file_header dbhdr;
struct ctdb_db_context *ctdb_db;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
struct ctdb_vnn_map *vnnmap=NULL;
int i, fh;
- struct ctdb_control_transdb w;
+ struct ctdb_transdb w;
uint32_t *nodes;
uint32_t generation;
struct tm *tm;
w.db_id = ctdb_db->db_id;
- w.transaction_id = generation;
+ w.tid = generation;
data.dptr = (void *)&w;
data.dsize = sizeof(w);
int i, fh;
struct tm *tm;
char tbuf[100];
- struct ctdb_rec_data *rec = NULL;
+ struct ctdb_rec_data_old *rec = NULL;
struct ctdb_marshall_buffer *m;
struct ctdb_dump_db_context c;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
TDB_DATA data;
struct ctdb_db_context *ctdb_db;
- struct ctdb_node_map *nodemap = NULL;
+ struct ctdb_node_map_old *nodemap = NULL;
struct ctdb_vnn_map *vnnmap = NULL;
int i;
- struct ctdb_control_transdb w;
+ struct ctdb_transdb w;
uint32_t *nodes;
uint32_t generation;
uint8_t flags;
}
w.db_id = ctdb_db->db_id;
- w.transaction_id = generation;
+ w.tid = generation;
data.dptr = (void *)&w;
data.dsize = sizeof(w);
{
int ret;
TDB_DATA data;
- struct srvid_request rd;
+ struct ctdb_srvid_message rd;
rd.pnn = ctdb_get_pnn(ctdb);
rd.srvid = getpid();
static int control_listnodes(struct ctdb_context *ctdb, int argc, const char **argv)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
- struct ctdb_node_map *node_map;
+ struct ctdb_node_map_old *node_map;
int i;
assert_single_node_only();
uint32_t node_pnn, int32_t res,
TDB_DATA outdata, void *callback_data)
{
- struct ctdb_node_map **maps =
- talloc_get_type(callback_data, struct ctdb_node_map *);
+ struct ctdb_node_map_old **maps =
+ talloc_get_type(callback_data, struct ctdb_node_map_old *);
- if (outdata.dsize < offsetof(struct ctdb_node_map, nodes) ||
+ if (outdata.dsize < offsetof(struct ctdb_node_map_old, nodes) ||
outdata.dptr == NULL) {
DEBUG(DEBUG_ERR,
(__location__ " Invalid return data: %u %p\n",
("ERROR: Failed to get nodes file from node %u\n", node_pnn));
}
-static struct ctdb_node_map **
+static struct ctdb_node_map_old **
ctdb_get_nodes_files(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx,
struct timeval timeout,
- struct ctdb_node_map *nodemap)
+ struct ctdb_node_map_old *nodemap)
{
uint32_t *nodes;
int ret;
- struct ctdb_node_map **maps;
+ struct ctdb_node_map_old **maps;
- maps = talloc_zero_array(mem_ctx, struct ctdb_node_map *, nodemap->num);
+ maps = talloc_zero_array(mem_ctx, struct ctdb_node_map_old *, nodemap->num);
CTDB_NO_MEMORY_NULL(ctdb, maps);
nodes = list_of_connected_nodes(ctdb, nodemap, mem_ctx, true);
return maps;
}
-static bool node_files_are_identical(struct ctdb_node_map *nm1,
- struct ctdb_node_map *nm2)
+static bool node_files_are_identical(struct ctdb_node_map_old *nm1,
+ struct ctdb_node_map_old *nm2)
{
int i;
static bool check_all_node_files_are_identical(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx,
struct timeval timeout,
- struct ctdb_node_map *nodemap,
- struct ctdb_node_map *file_nodemap)
+ struct ctdb_node_map_old *nodemap,
+ struct ctdb_node_map_old *file_nodemap)
{
- static struct ctdb_node_map **maps;
+ static struct ctdb_node_map_old **maps;
int i;
bool ret = true;
reload the nodes file on the local node
*/
static bool sanity_check_nodes_file_changes(TALLOC_CTX *mem_ctx,
- struct ctdb_node_map *nodemap,
- struct ctdb_node_map *file_nodemap)
+ struct ctdb_node_map_old *nodemap,
+ struct ctdb_node_map_old *file_nodemap)
{
int i;
bool should_abort = false;
static int control_reload_nodes_file(struct ctdb_context *ctdb, int argc, const char **argv)
{
int i, ret;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
- struct ctdb_node_map *file_nodemap;
+ struct ctdb_node_map_old *file_nodemap;
uint32_t *conn;
uint32_t timeout;
{ "scriptstatus", control_scriptstatus, true, false, "show the status of the monitoring scripts (or all scripts)", "[all]"},
{ "enablescript", control_enablescript, true, false, "enable an eventscript", "<script>"},
{ "disablescript", control_disablescript, true, false, "disable an eventscript", "<script>"},
- { "natgwlist", control_natgwlist, true, false, "show the nodes belonging to this natgw configuration"},
+ { "natgwlist", control_natgwlist, false, true, "show the nodes belonging to this natgw configuration"},
{ "xpnn", control_xpnn, false, true, "find the pnn of the local node without talking to the daemon (unreliable)" },
{ "getreclock", control_getreclock, true, false, "Show the reclock file of a node"},
{ "setreclock", control_setreclock, true, false, "Set/clear the reclock file of a node", "[filename]"},
- { "setnatgwstate", control_setnatgwstate, false, false, "Set NATGW state to on/off", "{on|off}"},
{ "setlmasterrole", control_setlmasterrole, false, false, "Set LMASTER role to on/off", "{on|off}"},
{ "setrecmasterrole", control_setrecmasterrole, false, false, "Set RECMASTER role to on/off", "{on|off}"},
{ "setdbprio", control_setdbprio, false, false, "Set DB priority", "<dbname|dbid> <prio:1-3>"},