>From 29570e51f7eefc7bb986159542b2b89f3a942a44 Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzeleny@redhat.com>
Date: Wed, 6 Jun 2012 05:11:44 -0400
Subject: [PATCH 11/12] Primary server support: new option in IPA provider

This patch adds support for new config option ipa_backup_server. The
description of this option's functionality is included in man page in
one of previous patches.
---
 src/config/SSSDConfig/__init__.py.in    |    1 +
 src/config/etc/sssd.api.d/sssd-ipa.conf |    1 +
 src/man/sssd-ipa.5.xml                  |    2 +-
 src/providers/ipa/ipa_common.h          |    1 +
 src/providers/ipa/ipa_init.c            |    8 ++++----
 src/providers/ipa/ipa_opts.h            |    1 +
 6 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index a0b8b9646b1df3fa5b7c09f230d039e4de56e3e8..5c01f133f8af8cc13a4e53d1a7a16b283d658034 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -125,6 +125,7 @@ option_strings = {
     # [provider/ipa]
     'ipa_domain' : _('IPA domain'),
     'ipa_server' : _('IPA server address'),
+    'ipa_backup_server' : _('Address of backup IPA server'),
     'ipa_hostname' : _('IPA client hostname'),
     'ipa_dyndns_update' : _("Whether to automatically update the client's DNS entry in FreeIPA"),
     'ipa_dyndns_iface' : _("The interface whose IP should be used for dynamic DNS updates"),
diff --git a/src/config/etc/sssd.api.d/sssd-ipa.conf b/src/config/etc/sssd.api.d/sssd-ipa.conf
index 7a44bfe7e4ccb4b2bb4c72c0caad4151fd049927..8a289702f06a3b58e8e9d8d04614e92dc1ecedf7 100644
--- a/src/config/etc/sssd.api.d/sssd-ipa.conf
+++ b/src/config/etc/sssd.api.d/sssd-ipa.conf
@@ -1,6 +1,7 @@
 [provider/ipa]
 ipa_domain = str, None, false
 ipa_server = str, None, false
+ipa_backup_server = str, None, false
 ipa_hostname = str, None, false
 ipa_dyndns_update = bool, None, false
 ipa_dyndns_iface = str, None, false
diff --git a/src/man/sssd-ipa.5.xml b/src/man/sssd-ipa.5.xml
index f31001cb059526e7608ed5a7e8700ef81a3c11c2..2e7da1349f4cbf7e40bbc7e1653fe9b040fbfdb0 100644
--- a/src/man/sssd-ipa.5.xml
+++ b/src/man/sssd-ipa.5.xml
@@ -80,7 +80,7 @@
                 </varlistentry>
 
                 <varlistentry>
-                    <term>ipa_server (string)</term>
+                    <term>ipa_server, ipa_backup_server (string)</term>
                     <listitem>
                         <para>
                             The comma-separated list of IP addresses or hostnames of the
diff --git a/src/providers/ipa/ipa_common.h b/src/providers/ipa/ipa_common.h
index b094459579132c9628fb7bdc78f132822ef570f5..01e140325900d7b881b5abaab305be1da23b63c0 100644
--- a/src/providers/ipa/ipa_common.h
+++ b/src/providers/ipa/ipa_common.h
@@ -35,6 +35,7 @@ struct ipa_service {
 enum ipa_basic_opt {
     IPA_DOMAIN = 0,
     IPA_SERVER,
+    IPA_BACKUP_SERVER,
     IPA_HOSTNAME,
     IPA_DYNDNS_UPDATE,
     IPA_DYNDNS_IFACE,
diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c
index 4f889c34f4920ecd3f68cbb57b956ecea2a2f462..43b75f9a51e01f33f224922d9312a6b7cb815005 100644
--- a/src/providers/ipa/ipa_init.c
+++ b/src/providers/ipa/ipa_init.c
@@ -84,6 +84,7 @@ struct bet_ops ipa_subdomains_ops = {
 int common_ipa_init(struct be_ctx *bectx)
 {
     const char *ipa_servers;
+    const char *ipa_backup_servers;
     int ret;
 
     ret = ipa_get_options(bectx, bectx->cdb,
@@ -94,11 +95,10 @@ int common_ipa_init(struct be_ctx *bectx)
     }
 
     ipa_servers = dp_opt_get_string(ipa_options->basic, IPA_SERVER);
-    if (!ipa_servers) {
-        DEBUG(1, ("Missing ipa_server option - using service discovery!\n"));
-    }
+    ipa_backup_servers = dp_opt_get_string(ipa_options->basic, IPA_BACKUP_SERVER);
 
-    ret = ipa_service_init(ipa_options, bectx, ipa_servers, NULL, ipa_options,
+    ret = ipa_service_init(ipa_options, bectx, ipa_servers,
+                           ipa_backup_servers, ipa_options,
                            &ipa_options->service);
     if (ret != EOK) {
         DEBUG(0, ("Failed to init IPA failover service!\n"));
diff --git a/src/providers/ipa/ipa_opts.h b/src/providers/ipa/ipa_opts.h
index bf1b7a33d9e7b6f0a6be3d165168843e46d13691..0f66d2f63206065076f95c887923a7f30a70be5e 100644
--- a/src/providers/ipa/ipa_opts.h
+++ b/src/providers/ipa/ipa_opts.h
@@ -32,6 +32,7 @@
 struct dp_option ipa_basic_opts[] = {
     { "ipa_domain", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ipa_server", DP_OPT_STRING, NULL_STRING, NULL_STRING },
+    { "ipa_backup_server", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ipa_hostname", DP_OPT_STRING, NULL_STRING, NULL_STRING },
     { "ipa_dyndns_update", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE },
     { "ipa_dyndns_iface", DP_OPT_STRING, NULL_STRING, NULL_STRING},
-- 
1.7.7.6

