-def replaceAdminPassword(username, password, newpassword):
- if newpassword is None:
- logging.info('Not to replace password for user %s', username)
- else:
- logging.info('Replace password for user %s', username)
- try:
- jsondata = '{\"password\": \"{newpassword}\"}'.format(newpassword=newpassword)
- url = '/auth/v1/users/{username}@sdn'.format(username=username)
- loggin.info("Url %s data $s", url, jsondata)
- conn = http.client.HTTPConnection("localhost",odl_port)
- req = conn.request("PUT", url, jsondata, headers=headers)
- res = conn.getresponse()
- res.read()
- httpStatus = res.status
- if httpStatus == 200:
- logging.debug("New password provided successfully for user %s", username)
- else:
- logging.debug("Password change was not possible. Problem code was: %d", httpStatus)
- except:
- logging.error("Cannot execute REST call to set password.")
- writeCertInstallStatus("NOTOK")
-
-