diff options
author | ecaiyanlinux <martin.c.yan@est.tech> | 2019-08-21 12:10:33 +0000 |
---|---|---|
committer | Daniel Rose <dr695h@att.com> | 2019-08-29 17:35:36 +0000 |
commit | 796e8fe4255036b5785a2071ddd6a0240464556a (patch) | |
tree | b5d9ee29c9c07d91ea4848dafb12c5ae9cd7336d /test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py | |
parent | 190a2f42b5c0af56b8c8da7e05a90ad3999598d3 (diff) |
Add tls-init-container to simulator
1.replace dr-sim/dr-redir-sim cert/key
2.update mr-sim, make it support https
3.update ftpes cert/key
Change-Id: I7bbde98f352d1e7d7c8775acf3d8af89a6ef7bdc
Issue-ID: DCAEGEN2-1702
Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech>
Diffstat (limited to 'test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py')
-rw-r--r-- | test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py b/test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py index 51e0badef..6345ab69f 100644 --- a/test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py +++ b/test/mocks/datafilecollector-testharness/mr-sim/mr-sim.py @@ -1,18 +1,19 @@ import argparse +import json import os -from werkzeug import secure_filename -from flask import Flask, render_template, request -from time import sleep -import time import sys -import json -from flask import Flask +import time +from time import sleep + +from flask import Flask, render_template, request +from werkzeug import secure_filename app = Flask(__name__) #Server info HOST_IP = "0.0.0.0" HOST_PORT = 2222 +HOST_PORT_TLS = 2223 sftp_hosts=[] sftp_ports=[] @@ -1144,7 +1145,7 @@ def getEventHead(groupIndex, changeId, nodename): "changeType": "FileReady", "changeIdentifier": \"""" + changeId + """", "arrayOfNamedHashMap": [ - """ + """ return headStr # Function to build the variable part of an event @@ -1300,7 +1301,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() -#SFTP TCs with single ME +#SFTP TCs with single ME parser.add_argument( '--tc100', action='store_true', @@ -1717,5 +1718,16 @@ if __name__ == "__main__": print("Using up to " + str(num_ftp_servers) + " ftp servers, for each protocol for PNFs.") - app.run(port=HOST_PORT, host=HOST_IP) + def https_app(**kwargs): + import ssl + context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) + context.load_cert_chain('cert/cert.pem', 'cert/key.pem') + app.run(ssl_context=context, **kwargs) + + from multiprocessing import Process + + kwargs = dict(host=HOST_IP) + Process(target=https_app, kwargs=dict(kwargs, port=HOST_PORT_TLS), + daemon=True).start() + app.run(port=HOST_PORT, host=HOST_IP)
\ No newline at end of file |