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

Issue after 7.4.5 upgrade #80

Open
Kottejimmy opened this issue Oct 23, 2024 · 4 comments
Open

Issue after 7.4.5 upgrade #80

Kottejimmy opened this issue Oct 23, 2024 · 4 comments

Comments

@Kottejimmy
Copy link

Hi,
Ive upgraded some Fortigates from 7.2.10 to 7.4.5.

Im running VDOMs in all the firewalls and using tokenlogin as login method.

7.2.10 works fine but the Firewalls with 7.4.5 has stopped working with the following error:
line 266, in tokenlogin self._fortiversion = resp_lic['version'] TypeError: 'Response' object is not subscriptable

In the debug logs Im seeing this:
2024-10-23 15:46:46,965 fortiosapi DEBUG self._https is True
2024-10-23 15:46:46,965 fortiosapi DEBUG host is XXXXXXX
2024-10-23 15:46:46,965 fortiosapi DEBUG vdom is: global
2024-10-23 15:46:46,965 fortiosapi DEBUG urlbuild is https://XXXXXXX/api/v2/cmdb/system/status?global=1 with crsf: {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive', 'Authorization': 'XXXXXXX'}
2024-10-23 15:46:46,965 fortiosapi DEBUG Calling GET ( https://XXXXXXX/api/v2/cmdb/system/status?global=1, None)
2024-10-23 15:46:47,164 fortiosapi DEBUG in GET function
2024-10-23 15:46:47,165 fortiosapi DEBUG formating response
2024-10-23 15:46:47,165 fortiosapi DEBUG response content type : application/json
2024-10-23 15:46:47,165 fortiosapi DEBUG Request : GET on url : https://XXXXXXX/api/v2/cmdb/system/status?global=1
2024-10-23 15:46:47,165 fortiosapi DEBUG Response : http code 404 reason : Not Found
2024-10-23 15:46:47,165 fortiosapi DEBUG raw response: b'{\n "status":"error",\n "http_status":404,\n "path":"system",\n "name":"status",\n "serial":"XXXXXXX",\n "version":"v7.4.5",\n "build":2702,\n "http_method":"GET"\n}'
2024-10-23 15:46:47,165 fortiosapi WARNING in formatresponse res.content does not exist, should not occur
2024-10-23 15:46:47,165 fortiosapi DEBUG response system/status : <Response [404]>

I believe the issue is caused by a depricated API URL described in the below KB.
https://community.fortinet.com/t5/FortiGate/Technical-Tip-API-error-404-after-upgrading-to-7-4-4/ta-p/344457

Could you guys please fix this issue?

@jamesdreid
Copy link

I don't use this lib but I believe the fix was fairly easy. I have committed a change in #81 that shoud fix it.

@Kottejimmy
Copy link
Author

@jamesdreid, first of all thanks for the support!

Ive made the changes as you suggested but once i do I get another error:
_2024-11-29 15:28:19,115 fortiosapi DEBUG self.https is True
2024-11-29 15:28:19,115 fortiosapi DEBUG host is XXXXXXX
2024-11-29 15:28:19,115 fortiosapi DEBUG vdom is: global
2024-11-29 15:28:19,116 fortiosapi DEBUG in monitor url is https://XXXXXXX/api/v2/monitor/system/status?global=1
2024-11-29 15:28:19,353 fortiosapi DEBUG in MONITOR function
2024-11-29 15:28:19,354 fortiosapi DEBUG formating response
2024-11-29 15:28:19,354 fortiosapi DEBUG response content type : application/json
2024-11-29 15:28:19,354 fortiosapi DEBUG Request : GET on url : https://xxxxx/api/v2/monitor/system/status?global=1
2024-11-29 15:28:19,355 fortiosapi DEBUG Response : http code 200 reason : OK
2024-11-29 15:28:19,355 fortiosapi DEBUG raw response: b'{\n "http_method":"GET",\n "results":{\n "model_name":"FortiGate",\n "model_number":"70F",\n "model":"FGT70F",\n "hostname":"XXXXXXX",\n "log_disk_status":"not_available"\n },\n "vdom":"root",\n "path":"system",\n "name":"status",\n "status":"success",\n "serial":"XXXXXXX",\n "version":"v7.4.5",\n "build":2702\n}'
2024-11-29 15:28:19,355 fortiosapi WARNING in formatresponse res.content does not exist, should not occur
2024-11-29 15:28:19,355 fortiosapi DEBUG response system/status : <Response [200]>

Any ideas?

@jamesdreid
Copy link

The PR does seem to fix the issue with the "tokenlogin" function, but it defaults to the "global" vdom so it appears in your response output to be hitting the "global exception loop" referenced in line 132 of the "formatresponse" function. Implicitly setting the VDOM in the "tokenlogin" setup corrects the issue.

fgt.tokenlogin('1.2.3.4','validtokenapikeyhere',verify=False, vdom='root')

Or, try the default call against a FGT with VDOMs enabled.

@Kottejimmy
Copy link
Author

@jamesdreid,
Im having issues with my FNDN account. Once I get it working again I will answer on your latest comment there!

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