diff options
author | Dan Timoney <dtimoney@att.com> | 2019-05-24 15:18:18 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-05-24 15:18:18 +0000 |
commit | 4757df51de8b114c6846eb82c913e4f1b1cc485e (patch) | |
tree | 413d655ec354bb66f5609f26c6421b1ef04d1ec7 | |
parent | 32f1299ae698cf59f0466653687f724a953e2353 (diff) | |
parent | 2739fc5cf1b15f736e93d884a0b769deeda7b682 (diff) |
Merge "SDNC-766: Refactoring of installCerts.py"
Former-commit-id: fb2f48179f8532e52687ddf1051d1344c8d0f2df
-rw-r--r-- | installation/sdnc/src/main/scripts/installCerts.py | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/installation/sdnc/src/main/scripts/installCerts.py b/installation/sdnc/src/main/scripts/installCerts.py index 1cc74546..17ada4c1 100644 --- a/installation/sdnc/src/main/scripts/installCerts.py +++ b/installation/sdnc/src/main/scripts/installCerts.py @@ -32,9 +32,9 @@ zipFileList = [] username = os.environ['ODL_ADMIN_USERNAME'] password = os.environ['ODL_ADMIN_PASSWORD'] -timeOut=1000 -interval=30 -time=0 +TIMEOUT=1000 +INTERVAL=30 +timePassed=0 postKeystore= "/restconf/operations/netconf-keystore:add-keystore-entry" postPrivateKey= "/restconf/operations/netconf-keystore:add-private-key" @@ -153,38 +153,37 @@ def processFiles(folder, count): makeRestconfPost(conn, json_private_key, postPrivateKey) makeRestconfPost(conn, json_trusted_cert, postTrustedCertificate) -def makeHealthcheckCall(headers, time): - conn = httplib.HTTPConnection("localhost",8181) - req = conn.request("POST", "/restconf/operations/SLI-API:healthcheck",headers=headers) - res = conn.getresponse() - res.read() - if res.status == 200: - print ("Healthcheck Passed in %d seconds." %time) - else: - print ("Sleep: %d seconds before testing if Healtcheck worked. Total wait time up now is: %d seconds. Timeout is: %d seconds" %(interval, time, timeOut)) - return res.status - - -def timeIncrement(time): - time.sleep(interval) - time = time + interval - return time - -def healthcheck(time): +def makeHealthcheckCall(headers, timePassed): + connected = False # WAIT 10 minutes maximum and test every 30 seconds if HealthCheck API is returning 200 - while time < timeOut: + while timePassed < TIMEOUT: try: - status = makeHealthcheckCall(headers, time) - #if status == 200: - connected = True - break + conn = httplib.HTTPConnection("localhost",8181) + req = conn.request("POST", "/restconf/operations/SLI-API:healthcheck",headers=headers) + res = conn.getresponse() + res.read() + if res.status == 200: + print ("Healthcheck Passed in %d seconds." %timePassed) + connected = True + break + else: + print ("Sleep: %d seconds before testing if Healthcheck worked. Total wait time up now is: %d seconds. Timeout is: %d seconds" %(INTERVAL, timePassed, TIMEOUT)) except: - print ("Sleep: %d seconds before testing if Healthcheck worked. Total wait time up now is: %d seconds. Timeout is: %d seconds" %(interval, time, timeOut)) + print ("Cannot execute REST call. Sleep: %d seconds before testing if Healthcheck worked. Total wait time up now is: %d seconds. Timeout is: %d seconds" %(INTERVAL, timePassed, TIMEOUT)) + timePassed = timeIncrement(timePassed) + + if timePassed > TIMEOUT: + print ("TIME OUT: Healthcheck not passed in %d seconds... Could cause problems for testing activities..." %TIMEOUT) + return connected + - time = timeIncrement(time) +def timeIncrement(timePassed): + time.sleep(INTERVAL) + timePassed = timePassed + INTERVAL + return timePassed - if time > timeOut: - print ("TIME OUT: Healthcheck not passed in %d seconds... Could cause problems for testing activities..." %timeOut) +def readCertProperties(): + connected = makeHealthcheckCall(headers, timePassed) if connected: count = 0 @@ -199,8 +198,5 @@ def healthcheck(time): del zipFileList[:] else: print "Error: File not found in path entered" - else: - print "This was a problem here, Healthcheck never passed, please check is your instance up and running." - -healthcheck(time) +readCertProperties() |