summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreindenbom <eindenbom@gmail.com>2010-06-17 16:09:36 +0400
committerStephen Gallagher <sgallagh@redhat.com>2010-07-09 11:44:06 -0400
commitfaace4bdd6b84f60d2f707c00d31a84c0e84d375 (patch)
tree1dc5b3e6ac3c021498d7fc8de2188bac8861b1cb
parenta2cabe1873c4d01c18ef6617b6b1f10a0ce3560e (diff)
downloadsssd-faace4bdd6b84f60d2f707c00d31a84c0e84d375.tar.gz
sssd-faace4bdd6b84f60d2f707c00d31a84c0e84d375.tar.xz
sssd-faace4bdd6b84f60d2f707c00d31a84c0e84d375.zip
Added an interface to query number of configured (and currently resolved through SRV records) failover servers.
-rw-r--r--src/providers/data_provider_fo.c21
-rw-r--r--src/providers/dp_backend.h1
-rw-r--r--src/providers/fail_over.c13
-rw-r--r--src/providers/fail_over.h5
4 files changed, 40 insertions, 0 deletions
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
index 1654e2227..21059d394 100644
--- a/src/providers/data_provider_fo.c
+++ b/src/providers/data_provider_fo.c
@@ -277,6 +277,27 @@ int be_fo_add_srv_server(struct be_ctx *ctx, const char *service_name,
return EOK;
}
+int be_fo_get_server_count(struct be_ctx *ctx, const char *service_name)
+{
+ struct be_svc_data *svc_data;
+
+ if (!ctx->be_fo) {
+ return 0;
+ }
+
+ DLIST_FOR_EACH(svc_data, ctx->be_fo->svcs) {
+ if (strcmp(svc_data->name, service_name) == 0) {
+ break;
+ }
+ }
+
+ if (!svc_data) {
+ return 0;
+ }
+
+ return fo_get_server_count(svc_data->fo_service);
+}
+
int be_fo_add_server(struct be_ctx *ctx, const char *service_name,
const char *server, int port, void *user_data)
{
diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h
index 61917b99d..69872b6c4 100644
--- a/src/providers/dp_backend.h
+++ b/src/providers/dp_backend.h
@@ -165,6 +165,7 @@ int be_fo_add_service(struct be_ctx *ctx, const char *service_name);
int be_fo_service_add_callback(TALLOC_CTX *memctx,
struct be_ctx *ctx, const char *service_name,
be_svc_callback_fn_t *fn, void *private_data);
+int be_fo_get_server_count(struct be_ctx *ctx, const char *service_name);
int be_fo_add_srv_server(struct be_ctx *ctx, const char *service_name,
const char *query_service, const char *proto,
void *user_data);
diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c
index c965c0e3a..f364a8c5f 100644
--- a/src/providers/fail_over.c
+++ b/src/providers/fail_over.c
@@ -585,6 +585,19 @@ create_fo_server(struct fo_service *service, const char *name,
}
int
+fo_get_server_count(struct fo_service *service)
+{
+ struct fo_server *server;
+ int count = 0;
+
+ DLIST_FOR_EACH(server, service->server_list) {
+ count++;
+ }
+
+ return count;
+}
+
+int
fo_add_server(struct fo_service *service, const char *name, int port,
void *user_data)
{
diff --git a/src/providers/fail_over.h b/src/providers/fail_over.h
index a31ace21e..24b2c1f5f 100644
--- a/src/providers/fail_over.h
+++ b/src/providers/fail_over.h
@@ -100,6 +100,11 @@ int fo_get_service(struct fo_ctx *ctx,
struct fo_service **_service);
/*
+ * Get number of servers registered for the 'service'.
+ */
+int fo_get_server_count(struct fo_service *service);
+
+/*
* Adds a server 'name' to the 'service'. Port 'port' will be used for
* connection. If 'name' is NULL, no server resolution will be done.
*/