demo of portfoward as a service with OpenStack netns arch ,aio-http service using tornado
pip install tornado==4.4.1
python portfoward.py -log_file_prefix=portforward.log &
sample:
python>
>>> import requests
>>> url_add = "http://127.0.0.1:39696/addportforward"
>>> send = {"router_id":"eadb6bac-fb21-477a-8b16-cc4660c9f516","router_port":"222","protocol":"tcp","vm_ip":"10.1.100.14","vm_port":"22"}
>>> r = requests.post( url_add , send )
>>> r.text
u'{\n "msg": "add portforward rule success", \n "code": 200\n}'
>>> url_del = "http://127.0.0.1:39696/delportforward"
>>> r2 = requests.post( url_del , send )
>>> r2.text
u'{\n "msg": "del portforward rule success", \n "code": 200\n}'
this is a demo http service, think twice before applying in production environment
please considerate more about data storage using DB instead
and data consistency , recovery just as Neutron did