summaryrefslogtreecommitdiff
path: root/ctdb/tests
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-12-04 01:01:48 +1100
committerAmitay Isaacs <amitay@samba.org>2016-12-19 04:07:07 +0100
commit6f1419f72a617516f7c198908e85eedcb37e3f72 (patch)
treebdfddc37d0720db936c7913261ac406dfd4cfbfe /ctdb/tests
parent6d97f393540660eac3a663c1b5fa54a941e226de (diff)
downloadsamba-6f1419f72a617516f7c198908e85eedcb37e3f72.tar.gz
ctdb-tests: Implement GET_PUBLIC_IPS control in fake_ctdbd
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rw-r--r--ctdb/tests/src/fake_ctdbd.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
index 56933ac0ec4..dfdef707495 100644
--- a/ctdb/tests/src/fake_ctdbd.c
+++ b/ctdb/tests/src/fake_ctdbd.c
@@ -1936,6 +1936,57 @@ static void control_get_capabilities(TALLOC_CTX *mem_ctx,
client_send_control(req, header, &reply);
}
+static void control_get_public_ips(TALLOC_CTX *mem_ctx,
+ struct tevent_req *req,
+ struct ctdb_req_header *header,
+ struct ctdb_req_control *request)
+{
+ struct client_state *state = tevent_req_data(
+ req, struct client_state);
+ struct ctdbd_context *ctdb = state->ctdb;
+ struct ctdb_reply_control reply;
+ struct ctdb_public_ip_list *ips = NULL;
+
+ reply.rdata.opcode = request->opcode;
+
+ if (ctdb->known_ips == NULL) {
+ /* No IPs defined so create a dummy empty struct and ship it */
+ ips = talloc_zero(mem_ctx, struct ctdb_public_ip_list);;
+ if (ips == NULL) {
+ reply.status = ENOMEM;
+ reply.errmsg = "Memory error";
+ goto done;
+ }
+ goto ok;
+ }
+
+ ips = &ctdb->known_ips[header->destnode];
+
+ if (request->flags & CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE) {
+ /* If runstate is not RUNNING or a node is then return
+ * no available IPs. Don't worry about interface
+ * states here - we're not faking down to that level.
+ */
+ if (ctdb->runstate != CTDB_RUNSTATE_RUNNING) {
+ /* No available IPs: return dummy empty struct */
+ ips = talloc_zero(mem_ctx, struct ctdb_public_ip_list);;
+ if (ips == NULL) {
+ reply.status = ENOMEM;
+ reply.errmsg = "Memory error";
+ goto done;
+ }
+ }
+ }
+
+ok:
+ reply.rdata.data.pubip_list = ips;
+ reply.status = 0;
+ reply.errmsg = NULL;
+
+done:
+ client_send_control(req, header, &reply);
+}
+
static void control_get_nodemap(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
struct ctdb_req_header *header,
@@ -2973,6 +3024,10 @@ static void client_process_control(struct tevent_req *req,
control_get_capabilities(mem_ctx, req, &header, &request);
break;
+ case CTDB_CONTROL_GET_PUBLIC_IPS:
+ control_get_public_ips(mem_ctx, req, &header, &request);
+ break;
+
case CTDB_CONTROL_GET_NODEMAP:
control_get_nodemap(mem_ctx, req, &header, &request);
break;