Merge "update sdnc-image"
[sdnc/oam.git] / installation / sdnc / src / main / scripts / installCerts.py
index 6ca3bbc..2aaa202 100644 (file)
@@ -2,6 +2,7 @@
 #  Copyright (C) 2019 Nordix Foundation.
 # ================================================================================
 #  extended by highstreet technologies GmbH (c) 2020
+#  Copyright (c) 2021 Nokia Intellectual Property.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -51,7 +52,6 @@ zipFileList = []
 
 username = os.environ['ODL_ADMIN_USERNAME']
 password = os.environ['ODL_ADMIN_PASSWORD']
-newpassword = os.environ.get('ODL_ADMIN_NEWPASSWORD')
 TIMEOUT=1000
 INTERVAL=30
 timePassed=0
@@ -283,6 +283,7 @@ def jks_to_p12(file, password):
 def make_cert_chain(cert_chain, pattern):
     cert_list = []
     if cert_chain:
+        cert_chain = cert_chain.decode('utf-8')
         matches = re.findall(pattern, cert_chain, re.DOTALL | re.MULTILINE)
         for cert in matches:
             cert_list.append(cert.strip())
@@ -338,29 +339,6 @@ def process_jks_files(count):
         logging.error("UnExpected Error while processing JKS files at {0}, Caused by: {1}".format(Path, e))
         writeCertInstallStatus("NOTOK")
 
-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")
-
-
 def readCertProperties():
     '''
     This function searches for manually copied zip file
@@ -371,7 +349,6 @@ def readCertProperties():
     connected = makeHealthcheckCall(headers, timePassed)
     logging.info('Connected status: %s', connected)
     if connected:
-        replaceAdminPassword(username, password, newpassword)
         count = 0
         if os.path.isfile(Path + "/certs.properties"):
             with open(Path + "/certs.properties", "r") as f: