Skip to content

Commit 4893aaa

Browse files
authored
Release
[new] version 0.7.2 [info] rewrite code to be more flexible
2 parents 52dd517 + 9af2ec9 commit 4893aaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3369
-2358
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
config.py
2+
run.py
23

34
# PyCharm
45
.idea/

MANIFEST.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include flowapp/static/*
2+
include flowapp/static/js/*
3+
4+
include flowapp/templates/*
5+
include flowapp/templates/errors/*
6+
include flowapp/templates/forms/*
7+
include flowapp/templates/layouts/*
8+
include flowapp/templates/pages/*

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Last part of the system is Guarda service. This systemctl service is running in
5252
* [Local database instalation notes](./docs/DB_LOCAL.md)
5353

5454
## Change Log
55+
- 0.7.2 - Dashboard and Main menu are now customizable in config. App is ready to be packaged using setup.py.
5556
- 0.7.0 - ExaAPI now have two options - HTTP or RabbitMQ. ExaAPI process has been renamed, update of ExaBGP process value is needed for this version.
5657
- 0.6.2 - External config for ExaAPI
5758
- 0.6.0 - Bootstrap 5 in UI

config.example.py

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,72 @@
1-
class Config(object):
1+
class Config():
22
"""
33
Default config options
44
"""
5+
56
# Flask debugging
67
DEBUG = True
78
# Flask testing
89
TESTING = False
910
# SSO auth enabled
1011
SSO_AUTH = False
1112
# SSO LOGOUT
12-
LOGOUT_URL = 'https://flowspec.example.com/Shibboleth.sso/Logout?return=https://shibbo.example.com/idp/profile/Logout'
13+
LOGOUT_URL = "https://flowspec.example.com/Shibboleth.sso/Logout"
1314
# SQL Alchemy config
1415
SQLALCHEMY_TRACK_MODIFICATIONS = False
15-
# URL of the ExaAPI
16-
EXA_API_URL = 'http://localhost:5000/'
16+
17+
# ExaApi configuration
18+
# possible values HTTP, RABBIT
19+
EXA_API = "HTTP"
20+
# for HTTP EXA_API_URL must be specified
21+
EXA_API_URL = "http://localhost:5000/"
22+
# for RABBITMQ EXA_API_RABBIT_* must be specified
23+
EXA_API_RABBIT_HOST = "your rabbit host"
24+
EXA_API_RABBIT_PORT = "rabit port (5672)"
25+
EXA_API_RABBIT_PASS = "some secret password"
26+
EXA_API_RABBIT_USER = "rabbit user"
27+
EXA_API_RABBIT_VHOST = "rabbit vhost"
28+
EXA_API_RABBIT_QUEUE = "exa_api"
1729

1830
# Secret keys for Flask Session and JWT (API and CSRF protection)
19-
JWT_SECRET = 'GenerateSomeLongRandomSequence'
20-
SECRET_KEY = 'GenerateSomeLongRandomSequence'
31+
JWT_SECRET = "GenerateSomeLongRandomSequence"
32+
SECRET_KEY = "GenerateSomeLongRandomSequence"
2133

2234
# LOCAL user parameters - when the app is used without SSO_AUTH
2335
# Defined in User model
24-
LOCAL_USER_UUID = '[email protected]'
36+
LOCAL_USER_UUID = "[email protected]"
2537
# Defined in User model
2638
LOCAL_USER_ID = 1
2739
# Defined in Role model / default 1 - view, 2 - normal user, 3 - admin
28-
LOCAL_USER_ROLES = ['admin']
40+
LOCAL_USER_ROLES = ["admin"]
2941
# Defined in Organization model
3042
# List of organizations for the local user. There can be many of them.
3143
# Define the name and the adress range. The range is then used for first data insert
3244
# after the tables are created with db-init.py script.
3345
LOCAL_USER_ORGS = [
34-
{
35-
'name': 'Example Org.',
36-
'arange': '192.168.0.0/16\n2121:414:1a0b::/48'
37-
},
46+
{"name": "Example Org.", "arange": "192.168.0.0/16\n2121:414:1a0b::/48"},
3847
]
3948
# Defined in Role model / default 1 - view, 2 - normal user, 3 - admin
4049
LOCAL_USER_ROLE_IDS = [3]
4150
# Defined in Organization model
4251
LOCAL_USER_ORG_IDS = [1]
4352
# APP Name - display in main toolbar
44-
APP_NAME = 'ExaFS'
53+
APP_NAME = "ExaFS"
4554
# Route Distinguisher for VRF
46-
# When True set your rd string and label to be used in messages
47-
USE_RD = True
48-
RD_STRING = '7654:3210'
49-
RD_LABEL = 'label for RD'
50-
55+
# When True set your rd string and label to be used in messages
56+
USE_RD = True
57+
RD_STRING = "7654:3210"
58+
RD_LABEL = "label for RD"
5159

5260

5361
class ProductionConfig(Config):
5462
"""
5563
Production config options
5664
"""
65+
5766
# SQL Alchemy config string - mustl include user and pwd
58-
SQLALCHEMY_DATABASE_URI = 'mysql://user:password@localhost/exafs?charset=utf8'
67+
SQLALCHEMY_DATABASE_URI = "Your Productionl Database URI"
5968
# Public IP of the production machine
60-
LOCAL_IP = '127.0.0.1'
69+
LOCAL_IP = "127.0.0.1"
6170
# SSO AUTH enabled in produciion
6271
SSO_AUTH = True
6372
# Set true if you need debug in production
@@ -68,11 +77,11 @@ class DevelopmentConfig(Config):
6877
"""
6978
Development config options - usually for localhost development and debugging process
7079
"""
71-
SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]:3306/exafs?host=127.0.0.1?port=3306?charset=utf8'
72-
LOCAL_IP = '127.0.0.1'
80+
81+
SQLALCHEMY_DATABASE_URI = "Your Local Database URI"
82+
LOCAL_IP = "127.0.0.1"
7383
DEBUG = True
7484

7585

7686
class TestingConfig(Config):
77-
7887
TESTING = True

db-init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
from flask import Flask
3-
from flowapp import app, db
3+
from flowapp import db
44
from flowapp.models import *
55

66
import config

exaapi/config.example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
Add your log settings and rename to config.py
55
"""
66

7-
LOG_FILE = '/var/log/exafs/exa_api.log'
8-
LOG_FORMAT = '%(asctime)s: %(message)s'
7+
LOG_FILE = "/var/log/exafs/exa_api.log"
8+
LOG_FORMAT = "%(asctime)s: %(message)s"
99

1010

11-
# rabbit mq
11+
# rabbit mq
1212
# note - rabbit mq must be enabled in main app config
1313
# credentials and queue must be set here for the same values
14-
EXA_API_RABBIT_HOST = 'localhost'
15-
EXA_API_RABBIT_PORT = '5672'
16-
EXA_API_RABBIT_PASS = 'mysecurepassword'
17-
EXA_API_RABBIT_USER = 'myexaapiuser'
18-
EXA_API_RABBIT_VHOST = '/'
19-
EXA_API_RABBIT_QUEUE = 'my_exa_api_queue'
14+
EXA_API_RABBIT_HOST = "localhost"
15+
EXA_API_RABBIT_PORT = "5672"
16+
EXA_API_RABBIT_PASS = "mysecurepassword"
17+
EXA_API_RABBIT_USER = "myexaapiuser"
18+
EXA_API_RABBIT_VHOST = "/"
19+
EXA_API_RABBIT_QUEUE = "my_exa_api_queue"

exaapi/exa_api_http.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Each command received in the POST request is send to stdout and captured by ExaBGP.
88
"""
99

10-
from flask import Flask, request, abort
10+
from flask import Flask, request
1111
from sys import stdout
1212

1313
import exa_api_logger
@@ -17,15 +17,15 @@
1717
logger = exa_api_logger.create()
1818

1919

20-
@app.route('/', methods=['POST'])
20+
@app.route("/", methods=["POST"])
2121
def command():
22-
cmd = request.form['command']
22+
cmd = request.form["command"]
2323
logger.info(cmd)
24-
stdout.write('%s\n' % cmd)
24+
stdout.write("%s\n" % cmd)
2525
stdout.flush()
2626

27-
return '%s\n' % cmd
27+
return "%s\n" % cmd
2828

2929

30-
if __name__ == '__main__':
30+
if __name__ == "__main__":
3131
app.run()

exaapi/exa_api_logger.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import logging
22
import config
33

4+
45
def create():
56
logger = logging.getLogger(__name__)
67
f_format = logging.Formatter(config.LOG_FORMAT)
78
f_handler = logging.FileHandler(config.LOG_FILE)
89
f_handler.setFormatter(f_format)
910
logger.setLevel(logging.INFO)
1011
logger.addHandler(f_handler)
11-
return logger
12+
return logger

exaapi/exa_api_rabbit.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66
77
Each command received from the queue is send to stdout and captured by ExaBGP.
88
"""
9-
import pika, sys, os
9+
import pika
10+
import sys
11+
import os
1012
from time import sleep
1113

1214
import config
1315
import exa_api_logger
1416

1517
logger = exa_api_logger.create()
1618

19+
1720
def callback(ch, method, properties, body):
18-
body = body.decode("utf-8")
21+
body = body.decode("utf-8")
1922
logger.info(body)
20-
sys.stdout.write('%s\n' % body)
23+
sys.stdout.write("%s\n" % body)
2124
sys.stdout.flush()
2225

2326

@@ -27,24 +30,26 @@ def main():
2730
passwd = config.EXA_API_RABBIT_PASS
2831
queue = config.EXA_API_RABBIT_QUEUE
2932
credentials = pika.PlainCredentials(user, passwd)
30-
parameters = pika.ConnectionParameters(config.EXA_API_RABBIT_HOST,
31-
config.EXA_API_RABBIT_PORT,
32-
config.EXA_API_RABBIT_VHOST,
33-
credentials)
33+
parameters = pika.ConnectionParameters(
34+
config.EXA_API_RABBIT_HOST,
35+
config.EXA_API_RABBIT_PORT,
36+
config.EXA_API_RABBIT_VHOST,
37+
credentials,
38+
)
3439
connection = pika.BlockingConnection(parameters)
3540
channel = connection.channel()
3641

37-
channel.queue_declare(queue=queue)
42+
channel.queue_declare(queue=queue)
3843

3944
channel.basic_consume(queue=queue, on_message_callback=callback, auto_ack=True)
4045

41-
print(' [*] Waiting for messages. To exit press CTRL+C')
46+
print(" [*] Waiting for messages. To exit press CTRL+C")
4247
try:
4348
channel.start_consuming()
4449
except KeyboardInterrupt:
4550
channel.stop_consuming()
4651
connection.close()
47-
print('\nInterrupted')
52+
print("\nInterrupted")
4853
try:
4954
sys.exit(0)
5055
except SystemExit:
@@ -53,6 +58,6 @@ def main():
5358
sleep(15)
5459
continue
5560

56-
if __name__ == '__main__':
61+
62+
if __name__ == "__main__":
5763
main()
58-

exaapi/rabbit_manual.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
passwd = config.EXA_API_RABBIT_PASS
88
queue = config.EXA_API_RABBIT_QUEUE
99
credentials = pika.PlainCredentials(user, passwd)
10-
parameters = pika.ConnectionParameters(config.EXA_API_RABBIT_HOST,
11-
config.EXA_API_RABBIT_PORT,
12-
config.EXA_API_RABBIT_VHOST,
13-
credentials)
10+
parameters = pika.ConnectionParameters(
11+
config.EXA_API_RABBIT_HOST,
12+
config.EXA_API_RABBIT_PORT,
13+
config.EXA_API_RABBIT_VHOST,
14+
credentials,
15+
)
1416

1517
connection = pika.BlockingConnection(parameters)
1618
channel = connection.channel()
17-
channel.queue_declare(queue=queue)
19+
channel.queue_declare(queue=queue)
1820
route = sys.argv[1]
1921

2022
print("got :", route)
2123

22-
channel.basic_publish(exchange='',
23-
routing_key=queue,
24-
body=route)
24+
channel.basic_publish(exchange="", routing_key=queue, body=route)

flowapp/__about__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.7.2"

0 commit comments

Comments
 (0)