Add command to change local user password

Modifies the password of the local user specified using -U
with the password specified using -p

Tested:
-bash-4.2$ python openbmctool.py -H xx.xx.xx.xx -U root -P 0penbmc set_password -p '0penBmc'
Attempting login...
{
  "data": null,
  "message": "200 OK",
  "status": "ok"
}

Change-Id: I64c435c0f5c6286144682767149610a1ff3efbe5
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/thalerj/openbmctool.py b/thalerj/openbmctool.py
index 1cc2c7c..7829603 100755
--- a/thalerj/openbmctool.py
+++ b/thalerj/openbmctool.py
@@ -2447,6 +2447,32 @@
 
     return output
 
+def setPassword(host, args, session):
+    """
+         Set local user password
+         @param host: string, the hostname or IP address of the bmc
+         @param args: contains additional arguments used by the logging sub
+                command
+         @param session: the active session to use
+         @param args.json: boolean, if this flag is set to true, the output
+                will be provided in json format for programmatic consumption
+         @return: Session object
+    """
+    url = "https://" + host + "/xyz/openbmc_project/user/" + args.user + \
+        "/action/SetPassword"
+    httpHeader = {'Content-Type': 'application/json'}
+    try:
+        res = session.post(url, headers=httpHeader,
+                           json={"data": [args.password]}, verify=False,
+                           timeout=30)
+    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)
+    return res.text
+
 def createCommandParser():
     """
          creates the parser for the command line along with help for each command and subcommand
@@ -2704,6 +2730,13 @@
     parser_ldap_mapper_delete.add_argument("-g","--groupName",required=True,help="Group Name")
     parser_ldap_mapper_delete.set_defaults(func=deletePrivilegeMapping)
 
+    # set local user password
+    parser_set_password = subparsers.add_parser("set_password",
+        help="Set password of local user")
+    parser_set_password.add_argument( "-p", "--password", required=True,
+        help="Password of local user")
+    parser_set_password.set_defaults(func=setPassword)
+
     return parser
 
 def main(argv=None):