RUN pip install connexion[swagger-ui]
-COPY src src
+#install nginx
+RUN apt-get update
+RUN apt-get install -y nginx=1.14.*
+
+#install curl
+RUN apt-get install -y curl
+COPY src src
COPY api api
+COPY nginx.conf nginx.conf
+RUN chmod +x src/start.sh
CMD src/start.sh ${A1_VERSION}
--- /dev/null
+test
\ No newline at end of file
--- /dev/null
+user www-data;
+worker_processes auto;
+pid /run/nginx.pid;
+include /etc/nginx/modules-enabled/*.conf;
+
+events {
+ worker_connections 768;
+ # multi_accept on;
+}
+
+http {
+
+ ##
+ # Basic Settings
+ ##
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ keepalive_timeout 65;
+ types_hash_max_size 2048;
+ # server_tokens off;
+
+ # server_names_hash_bucket_size 64;
+ # server_name_in_redirect off;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ server { # simple reverse-proxy
+ listen 8085;
+ listen [::]:8085;
+ listen 8185 ssl;
+ listen [::]:8185 ssl;
+ server_name localhost;
+ ssl_certificate /usr/src/app/cert/cert.crt;
+ ssl_certificate_key /usr/src/app/cert/key.crt;
+ ssl_password_file /usr/src/app/cert/pass;
+
+ # serve dynamic requests
+ location / {
+ proxy_pass http://localhost:2222;
+ }
+ }
+ ##
+ # SSL Settings
+ ##
+
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
+ ssl_prefer_server_ciphers on;
+
+ ##
+ # Logging Settings
+ ##
+
+ access_log /var/log/nginx/access.log;
+ error_log /var/log/nginx/error.log;
+
+ ##
+ # Gzip Settings
+ ##
+
+ gzip on;
+
+ # gzip_vary on;
+ # gzip_proxied any;
+ # gzip_comp_level 6;
+ # gzip_buffers 16 8k;
+ # gzip_http_version 1.1;
+ # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+
+ ##
+ # Virtual Host Configs
+ ##
+
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+}
+
+
+#mail {
+# # See sample authentication script at:
+# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
+#
+# # auth_http localhost/auth.php;
+# # pop3_capabilities "TOP" "USER";
+# # imap_capabilities "IMAP4rev1" "UIDPLUS";
+#
+# server {
+# listen localhost:110;
+# protocol pop3;
+# proxy on;
+# }
+#
+# server {
+# listen localhost:143;
+# protocol imap;
+# proxy on;
+# }
+#}
\ No newline at end of file
return "Counter name: "+countername+" not found.",404
-port_number = 8085
+port_number = 2222
if len(sys.argv) >= 2:
if isinstance(sys.argv[1], int):
port_number = sys.argv[1]
-port_number_secure=8185
-
app.add_api('a1-openapi.yaml')
-context=get_security_context()
-if (context == None):
- print("Start on non-secure port: "+str(port_number))
- app.run(port=port_number, host="::")
-else:
- print("Start on secure port: "+str(port_number_secure))
- app.run(port=port_number_secure, host="::", ssl_context=context)
\ No newline at end of file
+
+app.run(port=port_number, host="127.0.0.1", threaded=False)
\ No newline at end of file
from jsonschema import validate
from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings, hosts_set
from maincommon import *
+from time import sleep
check_apipath()
app = connexion.FlaskApp(__name__, specification_dir=apipath)
+t=[] ##varialbe for test purpose
+
+#long poll
+@app.route('/long', methods=['GET'])
+def longpoll():
+ global t
+ sleep(10)
+ t.append(1)
+ return Response(str(t), 200, mimetype='text/plain')
+
+#short poll
+@app.route('/short', methods=['GET'])
+def shortpoll():
+ global t
+ t.append(2)
+ return Response(str(t), 200, mimetype='text/plain')
#Check alive function
@app.route('/', methods=['GET'])
else:
return Response("Counter name: "+countername+" not found.",404, mimetype='text/plain')
-port_number = 8085
+port_number = 2222
if len(sys.argv) >= 2:
if isinstance(sys.argv[1], int):
port_number = sys.argv[1]
-port_number_secure=8185
-
app.add_api('openapi.yaml')
-context=get_security_context()
-if (context == None):
- print("Start on non-secure port: "+str(port_number))
- app.run(port=port_number, host="::")
-else:
- print("Start on secure port: "+str(port_number_secure))
- app.run(port=port_number_secure, host="::", ssl_context=context)
\ No newline at end of file
+
+app.run(port=port_number, host="127.0.0.1", threaded=False)
\ No newline at end of file
else:
return Response("Counter name: "+countername+" not found.",404, mimetype='text/plain')
-port_number = 8085
+port_number = 2222
if len(sys.argv) >= 2:
if isinstance(sys.argv[1], int):
port_number = sys.argv[1]
-port_number_secure=8185
-
app.add_api('STD_A1.yaml')
-context=get_security_context()
-if (context == None):
- print("Start on non-secure port: "+str(port_number))
- app.run(port=port_number, host="::")
-else:
- print("Start on secure port: "+str(port_number_secure))
- app.run(port=port_number_secure, host="::", ssl_context=context)
+
+app.run(port=port_number, host="127.0.0.1", threaded=False)
\ No newline at end of file
arr = os.listdir("../")
del arr[arr.index('common')] # Remove the common lib
del arr[arr.index('start.sh')] # Remove the start script
+ arr.sort()
return Response("Current interface: " + str(pp[len(pp)-1]) + " All supported A1 interface yamls in this container: "+str(arr), 200, mimetype='text/plain')
# Remote host lookup and store host name in a set
cd $1
+#start nginx
+nginx -c /usr/src/app/nginx.conf
+
+#start near-rt-ric-simulator
echo "Path to main.py: "$PWD
python -u main.py
#
# Script to build and start the container
-# Args: nonsecure|secure
-
-if [ $# -ne 1 ]; then
- echo "Usage: ./build_and_start.sh nonsecure|secure"
- exit 1
-fi
-if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
- echo "Usage: ./build_and_start.sh nonsecure|secure"
- exit 1
-fi
echo "Building image"
cd ../../
docker build -t a1test .
echo "Starting $1 mode"
-if [ $1 == "nonsecure" ]; then
- #Run the container in interactive mode, unsecure port
- docker run -it -p 8085:8085 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 a1test
-else
- #Run the container in interactive mode, secure port.
- docker run -it -p 8185:8185 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test
-fi
+#Run the container in interactive mode, unsecure port 8085, secure port 8185.
+docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=1.1.x-alpha.2 -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" a1test
do_curl GET / 200
echo "=== Check used and implemented interfaces ==="
-RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'STD_1.1.3', 'OSC_2.1.0']"
+RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'OSC_2.1.0', 'STD_1.1.3']"
do_curl GET /container_interfaces 200
echo "=== Reset simulator instances ==="
echo "=== API: Healthcheck ==="
RESULT=""
-do_curl get /a1-p/healthcheck 200
+do_curl GET /a1-p/healthcheck 200
echo "=== API: Get policy types, shall be empty array =="
RESULT="json:[]"
#
# Script to build and start the container
-# Args: nonsecure|secure
-
-if [ $# -ne 1 ]; then
- echo "Usage: ./build_and_start.sh nonsecure|secure"
- exit 1
-fi
-if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
- echo "Usage: ./build_and_start.sh nonsecure|secure"
- exit 1
-fi
echo "Building image"
cd ../../
docker build -t a1test .
echo "Starting $1 mode"
-if [ $1 == "nonsecure" ]; then
- #Run the container in interactive mode, unsecure port
- docker run -it -p 8085:8085 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 a1test
-else
- #Run the container in interactive mode, secure port.
- docker run -it -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test
-fi
+#Run the container in interactive mode, unsecure port 8085, secure port 8185.
+docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" a1test
do_curl GET / 200
echo "=== Check used and implemented interfaces ==="
-RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'STD_1.1.3', 'OSC_2.1.0']"
+RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'OSC_2.1.0', 'STD_1.1.3']"
do_curl GET /container_interfaces 200
echo "=== Reset simulator instances ==="
#
# Script to build and start the container
-# Args: nonsecure|secure
-
-if [ $# -ne 1 ]; then
- echo "Usage: ./build_and_start.sh nonsecure|secure"
- exit 1
-fi
-if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
- echo "Usage: ./build_and_start.sh nonsecure|secure"
- exit 1
-fi
echo "Building image"
cd ../../
#Build the image
docker build -t a1test .
-echo "Starting $1 mode"
-if [ $1 == "nonsecure" ]; then
- #Run the container in interactive mode, unsecure port
- docker run -it -p 8085:8085 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 a1test
-else
- #Run the container in interactive mode, secure port.
- docker run -it -p 8185:8185 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 --read-only --volume "$PWD/certificate:/usr/src/app/cert" a1test
-fi
\ No newline at end of file
+echo "Starting ric-sim"
+#Run the container in interactive mode, unsecure port 8085, secure port 8185
+docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=STD_1.1.3 -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" a1test
\ No newline at end of file