...
Create NBI listeners, mind the IP of the endpoint which will be listening for NBI updates
Code Block |
---|
|
curl --header "Content-Type: application/json" -X POST -d @register-nbi-listeners http://nbi.api.simpledemo.onap.org:30274/nbi/api/v3/hub |
...
e.g. cat register-nbi-listeners |
...
...
"callback": "http://172.30.0.130:5000/serviceOrderStateListener/listener/v1/", |
...
"query":"eventType = ServiceOrderStateChangeNotification,ServiceOrderCreationNotification,ServiceOrderItemStateChangeNotification,ServiceCreationNotification,ServiceAttributeValueChangeNotification,ServiceRemoveNotification" |
...
...
Right after posting your endpoint to NBI make sure it's configured properly by running |
...
curl --header "Content-Type: application/json" http://nbi.api.simpledemo.onap.org:30274/nbi/api/v3/hub |
Create a configuration file named bng.conf under /tmp with this content
cat /
Code Block |
---|
|
cat /tmp/bng.conf |
...
...
...
...
...
...
onap-nbi-url = http://nbi.api.simpledemo.onap.org:30274/nbi/api/v3/ |
...
onap-dcae-ves-collector-url = http://172.30.0.93:30235/eventListener/v5/ |
...
onap-message-router = http://mr.api.simpledemo.openecomp.org:30227/events/AAI-EVENT/T/T2?timeout=10000&limit=1 |
Update config file of nginx /etc/nginx/sites-available/default with this content. A reverse proxy is needed to avoid CORS issues##
# You should look at the following
Code Block |
---|
|
##
# You should look at the following URL's in order to grasp a solid understanding |
...
# of Nginx configuration files in order to fully unleash the power of Nginx. |
...
# http://wiki.nginx.org/Pitfalls |
...
# http://wiki.nginx.org/QuickStart |
...
# http://wiki.nginx.org/Configuration |
...
...
# Generally, you will want to move this file somewhere, and start with a clean |
...
# file but keep this around for reference. Or just disable in sites-enabled. |
...
...
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. |
...
...
# Default server configuration |
...
...
...
listen 80 default_server; |
...
listen [::]:80 default_server; |
...
...
...
# listen 443 ssl default_server; |
...
# listen [::]:443 ssl default_server; |
...
...
# Note: You should disable gzip for SSL traffic. |
...
# See: https://bugs.debian.org/773332 |
...
...
# Read up on ssl_ciphers to ensure a secure configuration. |
...
# See: https://bugs.debian.org/765782 |
...
...
# Self signed certs generated by the ssl-cert package |
...
# Don't use them in a production server! |
...
...
# include snippets/snakeoil.conf; |
...
...
# Add index.php to the list if you are using PHP |
...
index index.html index.htm index.nginx-debian.html; |
...
...
...
# First attempt to serve request as file, then |
...
# as directory, then fall back to displaying a 404. |
...
try_files $uri $uri/ =404; |
...
if ($request_method = 'OPTIONS') { |
...
add_header 'Access-Control-Allow-Origin' '*'; |
...
...
...
...
add_header 'Access-Control-Allow-Credentials' 'true'; |
...
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
...
...
# Custom headers and headers various browsers *should* be OK with but aren't |
...
...
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
...
...
# Tell client that this pre-flight info is valid for 20 days |
...
...
add_header 'Access-Control-Max-Age' 1728000; |
...
add_header 'Content-Type' 'text/plain charset=UTF-8'; |
...
add_header 'Content-Length' 0; |
...
...
...
if ($request_method = 'POST') { |
...
add_header 'Access-Control-Allow-Origin' '*'; |
...
add_header 'Access-Control-Allow-Credentials' 'true'; |
...
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
...
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
...
...
if ($request_method = 'GET') { |
...
add_header 'Access-Control-Allow-Origin' '*'; |
...
add_header 'Access-Control-Allow-Credentials' 'true'; |
...
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
...
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
...
...
...
...
...
...
server_name default_server; |
...
...
proxy_pass http://127.0.0.1:5010/; |
...
...
proxy_set_header Host $host; |
...
proxy_set_header X-Real-IP $remote_addr; |
...
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
...
#proxy_set_header Host $host; |
...
#proxy_set_header X-Real-IP $remote_addr; |
...
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
...
proxy_set_header X-Forwarded-Proto $scheme; |
...
client_max_body_size 10m; |
...
client_body_buffer_size 128k; |
...
proxy_connect_timeout 90; |
...
...
...
...
...
proxy_busy_buffers_size 64k; |
...
proxy_temp_file_write_size 64k; |
...
if ($request_method = 'OPTIONS') { |
...
add_header 'Access-Control-Allow-Origin' '*'; |
...
...
...
...
add_header 'Access-Control-Allow-Credentials' 'true'; |
...
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
...
...
# Custom headers and headers various browsers *should* be OK with but aren't |
...
...
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
...
...
# Tell client that this pre-flight info is valid for 20 days |
...
...
add_header 'Access-Control-Max-Age' 1728000; |
...
add_header 'Content-Type' 'text/plain charset=UTF-8'; |
...
add_header 'Content-Length' 0; |
...
...
...
if ($request_method = 'POST') { |
...
add_header 'Access-Control-Allow-Origin' '*'; |
...
add_header 'Access-Control-Allow-Credentials' 'true'; |
...
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
...
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
...
...
if ($request_method = 'GET') { |
...
add_header 'Access-Control-Allow-Origin' '*'; |
...
add_header 'Access-Control-Allow-Credentials' 'true'; |
...
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
...
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
...
...
...
Install latest docker daemon e.g.
https://linuxize.com/post/how-to-install-and-use-docker-on-ubuntu-18-04/
Install mysql docker serverserver
Code Block |
---|
|
sudo docker run --name bbs-mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 --volume=/var/lib/mysqlbackup:/var/lib/mysql -d mysql |
Create database
Code Block |
---|
|
mysql -u root -proot -e "create database bbs" |
Import database schema, either with "docker cp .." or get into the container e.g.
Code Block |
---|
|
sudo docker cp ./db.sql bbs-mysql:/tmp/db.sql |
...
sudo docker exec -it bbs-mysql sh -c 'exec mysql -u root -proot bbs < /tmp/db.sql' |
Install mysql-connector-python, flask and gunicorn
Code Block |
---|
|
sudo pip3 install mysql-connector-python flask gunicorn |
Test running bss backend and access using curl
Code Block |
---|
|
sudo python3 app.py |
...
curl http://localhost:5000/products |
If you get "error-1698-28000-access-denied-for-user-rootlocalhost" check this
https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost
Copy frontend to nginx root web dir
Code Block |
---|
|
~/onap-bbs-fe-be/bss-fe$ sudo cp -fr * /var/www/html/ |
Modify the IP of the backend server configured in the fe (dirty hack to avoid rebuilding the frontend)
Code Block |
---|
|
vim /var/www/html/static/js/app.187d63f8300bfc4299b5.js |
...
search for "baseURL" and configure the IP e.g. baseURL:"http://172.30.0.130:5000" |
Open app.py and set the template_id / service_id UUID, and user
Code Block |
---|
|
Line 106, replace "TemplateID" value with "Service BBS_E2E_Service:UUID" |
...
...
"relatedParty": [ { "id": "6f486438-87b5-4bee-8f85-30090c760501" (global-customer-id) |
...
"serviceSpecification": { "id": "0187be8c-8efb-4531-97fa-dbe984ed9cdb" (Service BBS_E2E_Service:UUID) |
Run bss backend with gunicorn, make sure you update to point to the right path
Code Block |
---|
|
/usr/bin/python3 /usr/local/bin/gunicorn -w 2 -b 0.0.0.0:5010 --access-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-access.log --error-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-error.log app:app --daemon |
Run AAI events consumer in the background
Code Block |
---|
|
sudo nohup python3 events.py & |
Verify if both processes are running
Code Block |
---|
|
ubuntu@onap-rancher-daily:~/onap-bbs-fe-be/bss-be$ ps aux | grep -i guni |
...
ubuntu 22003 0.1 0.2 62020 18808 ? S 08:59 0:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 2 -b 0.0.0.0:5010 --access-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-access.log --error-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-error.log app:app --daemon |
...
ubuntu 22006 4.1 0.5 137016 42700 ? S 08:59 0:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 2 -b 0.0.0.0:5010 --access-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-access.log --error-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-error.log app:app --daemon |
...
ubuntu 22008 3.6 0.5 137020 42688 ? S 08:59 0:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 2 -b 0.0.0.0:5010 --access-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-access.log --error-logfile /home/ubuntu/onap-bbs-fe-be/bss-be/gunicorn-error.log app:app --daemon |
...
ubuntu 22013 0.0 0.0 14856 1008 pts/1 R+ 08:59 0:00 grep --color=auto -i guni |
...
ubuntu@onap-rancher-daily:~/onap-bbs-fe-be/bss-be$ |
...
ubuntu@onap-rancher-daily:~/onap-bbs-fe-be/bss-be$ |
...
ubuntu@onap-rancher-daily:~/onap-bbs-fe-be/bss-be$ ps aux | grep -i event |
...
root 21992 0.0 0.0 63972 4304 pts/1 S 08:58 0:00 sudo nohup python3 events.py |
...
root 21993 0.2 0.4 114084 35952 pts/1 S 08:58 0:00 python3 events.py |
...
ubuntu 22015 0.0 0.0 14856 1048 pts/1 R+ 08:59 0:00 grep --color=auto -i event |