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

move policy not working #15

Closed
onedread23 opened this issue Jan 26, 2020 · 1 comment
Closed

move policy not working #15

onedread23 opened this issue Jan 26, 2020 · 1 comment

Comments

@onedread23
Copy link

Hi

i have problem to move a rule above or after in a policy package.

data1 = {
"option": "after",
"target": "2002",
}

movpolicy = fmg_instance.move('/pm/config/adom/DEV/pkg/default/firewall/policy/2000', **data1)
print(movpolicy)

that is my statement

but i always receive the folllowing error:

(-7, {'status': {'code': -7, 'message': 'Invalid option'}, 'url': '/pm/config/adom/DEV/pkg/default/firewall/policy/2000'})

that is the debug output on the fmg itself

2020-01-26 09:22:31 { "client": "/usr/local/apache2/bin/httpd:3826", "id": 3, "method": "move", "params": [{ "data": { "option": "after", "target": "2002"}, "url": "/pm/config/adom/DEV/pkg/default/firewall/policy/2000", "session": "JIWaOFrcxZI7r+l4j3ctazebq6DXjqRz/WVCez7XdtQklZOG/xRufvmlrwVhwy0lPjAu9mRw+jGWO19WNT0N+B9Drff9PW5E", "src": "XXXX"}
2020-01-26 09:22:31 Request:
2020-01-26 09:22:31 { "client": "/usr/local/apache2/bin/httpd:3826", "id": 3, "method": "move", "params": [{ "data": { "option": "after", "target": "2002"}, "target start": 2, "url": "/pm/config/adom/DEV/pkg/default/firewall/policy/2000", "session": "JIWaOFrcxZI7r+l4j3ctazebq6DXjqRz/WVCez7XdtQklZOG/xRufvmlrwVhwy0lPjAu9mRw+jGWO19WNT0N+B9Drff9PW5E", "src": "XXXX"}
2020-01-26 09:22:31 Chkperm Response:
2020-01-26 09:22:31 { "id": 3, "result": [{ "status": { "code": 0, "message": "OK"}, "url": "/pm/config/adom/DEV/pkg/default/firewall/policy/2000"}], "session": 48717}
2020-01-26 09:22:31 Response:
2020-01-26 09:22:31 { "id": 3, "result": [{ "status": { "code": -7, "message": "Invalid option"}, "url": "/pm/config/adom/DEV/pkg/default/firewall/policy/2000"}]}2020-01-26 09:22:31

I hope you can help me out.

thx in advance

@p4r4n0y1ng
Copy link
Owner

Okay, this one is a bit terrible - it's not that you are doing anything wrong, it's just that the FMG API in this case formats the requirement to move the policy not standard. So you have to use the free_form method instead of move for this sort of function. So, first I'll show you how you need to format the call (if you were to be doing it in Postman or something). It would look like this:

REQUEST
{ "id": 3, "method": "move", "params": [ { "option": "after", "target": "1", "url": "/pm/config/adom/root/pkg/default/firewall/policy/2" } ], "session": CRAZY SESSION KEY HERE }

Notice that there is no "data" attribute and then a dictionary/hash like there normally is for all other calls. WEIRD RIGHT?!!! Well, I know - it's just not standard. I have complained. In any case to fix your issue NOW, this is all you need to do. If I want to move Policy ID 2 AFTER Policy ID 1 I would write this:

data = [{ "option": "after", "target": "1", "url": "/pm/config/adom/{adom}/pkg/default/firewall/policy/2" }] fmg.free_form("move", data=data)

And BAM done!!!

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