Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy Manager REST API issues #449

Open
alexrabi opened this issue Dec 12, 2018 · 0 comments
Open

Policy Manager REST API issues #449

alexrabi opened this issue Dec 12, 2018 · 0 comments
Assignees

Comments

@alexrabi
Copy link

After trying out the PM REST API, I encountered a few problems:

Issue: Cannot GET policies from PM using the REST API

How to reproduce:
$ curl localhost:45888/pib/elephant_flows
(or using any existing uid)

The PM responds with:
<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1>Server got itself in trouble</body></html>

The PM also displays the following error:
[INF]: PIB request for uid elephant_flows
[ERR]: Error handling request Traceback (most recent call last): File "/home/alexander/.local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 390, in start resp = await self._request_handler(request) File "/home/alexander/.local/lib/python3.6/site-packages/aiohttp/web_app.py", line 366, in _handle resp = await handler(request) File "/home/alexander/neat/policy/pmrest.py", line 100, in handle_pib text = pib.index[uid].json() AttributeError: 'int' object has no attribute 'json'

After investigating, the issue appears to occur because the handle_pib() function in pmrest.py accesses the index dictionary instead of the policies list of the PIB class (pib.py). As far as I can understand, the index dictionary is used to map uid's to the corresponding indexes in the policies list. I am assuming that what the handle_pib() function is supposed to do is to first find the correct index using the index dictionary, and then use that index to fetch the correct entry in the policies list, instead of trying to access the entry from index directly.

Furthermore, the index dictionary does not appear be handled properly when adding/removing entries in the PIB repository (pib.py). The indexes of other entries need to be updated accordingly when performing these operations. As it stands, the PIB does not update the indexes at all, which can cause problems when getting or removing entries in the PIB repository down the line since some uid's may map to the wrong indexes.

Issue: Cannot list rows of the CIB repository

How to reproduce:
curl localhost:45888/cib/rows

The client gets the following response:
unknown UID

This appears to be because the REST API interprets "rows" as a uid because the URI routing is set up in the wrong order in pmrest.py. This issue should be able to be resolved by simply swapping lines 237 and 238 in pmrest.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants