openbmctool: add view-config command

Add following command to listout all LDAP configured properties.
 -view-config

Tested: Tested using below given command
python openbmctool.py -H <BMC_IP> -U root -P <root password>  ldap  view-config

Change-Id: I7e2b7a3bbc7d348f5658284203c459a8cd059a3b
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
diff --git a/thalerj/openbmctool.py b/thalerj/openbmctool.py
index f5404cd..d0d1571 100755
--- a/thalerj/openbmctool.py
+++ b/thalerj/openbmctool.py
@@ -2355,6 +2355,32 @@
         return connectionErrHandler(args.json, "ConnectionError", err)
     return res.text
 
+def viewLDAPConfig(host, args, session):
+    """
+         Called by the ldap function. Prints out LDAP's configured properties
+
+         @param host: string, the hostname or IP address of the bmc
+         @param args: contains additional arguments used by the ldap subcommand
+                args.json: boolean, if this flag is set to true, the output
+                will be provided in json format for programmatic consumption
+         @param session: the active session to use
+         @return returns LDAP's configured properties.
+    """
+    url = "https://"+host+"/xyz/openbmc_project/user/ldap/config"
+    httpHeader = {'Content-Type': 'application/json'}
+    try:
+        res = session.get(url, headers=httpHeader, verify=False, timeout=40)
+    except(requests.exceptions.Timeout):
+        return(connectionErrHandler(args.json, "Timeout", None))
+    except(requests.exceptions.ConnectionError) as err:
+        return connectionErrHandler(args.json, "ConnectionError", err)
+    except(requests.exceptions.RequestException) as err:
+        return connectionErrHandler(args.json, "RequestException", err)
+    if res.status_code == 404:
+        return "LDAP server config has not been created"
+    return res.text
+
+
 def localUsers(host, args, session):
     """
         Enables and disables local BMC users.
@@ -2648,6 +2674,11 @@
     # disable LDAP
     parser_disable_ldap = ldap_sub.add_parser("disable", help="disables the LDAP")
     parser_disable_ldap.set_defaults(func=disableLDAP)
+    # view-config
+    parser_ldap_config = \
+    ldap_sub.add_parser("view-config", help="prints out a list of all \
+                        LDAPS's configured properties")
+    parser_ldap_config.set_defaults(func=viewLDAPConfig)
 
     #create group privilege mapping
     parser_ldap_mapper = ldap_sub.add_parser("privilege-mapper", help="LDAP group privilege controls")