AA-2979: Login API and Add device API's incorporate in amp 4
Review Request #959 — Created July 7, 2025 and submitted
| Information | |
|---|---|
| apoorva.sn | |
| AMP | |
| AMP_4_0 | |
| AA-2979 | |
| Reviewers | |
| ngurunathan, pmurugaiyan, pradeep, shuinvy | |
Problem
As migrating AMP from centos to Rocky linux the Django and python was also upgraded
As part of this migrating the Login and device Add API as wellSolution
Fixed the issues w.r.t to login and Add device API after the migration and for now both are returning proper response
[root@AN admin]# curl -v 'http://127.0.0.1:8000/login_app' -H 'Accept: application/json, text/plain, /' -H 'Accept-Language: en-GB,en;q=0.9' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' -H 'Origin: http://127.0.0.1:8000' -H 'Referer: http://127.0.0.1:8000/app/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' -H 'sec-ch-ua: "Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24"' -H 'sec-ch-ua-mobile: ?0' -H 'sec-ch-ua-platform: "macOS"' --data 'username=admin&password=admin' --insecure * Trying 127.0.0.1:8000... * Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
POST /login_app HTTP/1.1
Host: 127.0.0.1:8000
Accept: application/json, text/plain, /
Accept-Language: en-GB,en;q=0.9
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Origin: http://127.0.0.1:8000
Referer: http://127.0.0.1:8000/app/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
sec-ch-ua: "Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
Content-Length: 29
- Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Mon, 07 Jul 2025 05:36:46 GMT
< Server: WSGIServer/0.2 CPython/3.13.0
< Content-Type: application/json
< Vary: Accept-Language, Cookie
< Content-Language: en-gb
< X-Frame-Options: DENY
< Content-Length: 255
< Set-Cookie: django_language=en; Path=/; Secure
< Set-Cookie: hive_sess=ddd995f5-6e0a-4b07-9845-fcda5623074a; Path=/; Secure
< Set-Cookie: csrf_token=CE3Pw6oO0Jxlc7N23U5BQtI1BNDrdgOSLPjjN9OFTgzL6sMOuNWD4dbckHBbSrJV; Path=/; Secure
< Set-Cookie: hive_key=1; Path=/; Secure
< Set-Cookie: current_user=admin; Path=/; Secure
< Set-Cookie: csrftoken=jlqErdA13HcA4v9WB31coUDlT48UPl5d; expires=Mon, 06 Jul 2026 05:36:46 GMT; Max-Age=31449600; Path=/; SameSite=Lax; Secure
<- Connection #0 to host 127.0.0.1 left intact
{"error_code": 0, "hive_key": 1, "user_info": {"django_language": "en", "csrf_token": "CE3Pw6oO0Jxlc7N23U5BQtI1BNDrdgOSLPjjN9OFTgzL6sMOuNWD4dbckHBbSrJV", "hive_key": "1", "current_user": "admin"}, "msg": "Logging in successfully.", "check_license": false}[root@AN admin]#
[root@AN admin]#
[root@AN admin]#
[root@AN admin]#
[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/device_mgmt/device/Device/_add' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' \
-b 'csrftoken=jlqErdA13HcA4v9WB31coUDlT48UPl5d; django_language=en; hive_key=1; csrf_token=jlqErdA13HcA4v9WB31coUDlT48UPl5d; current_user=admin; hive_sess=ddd995f5-6e0a-4b07-9845-fcda5623074a' \
-H 'Origin: http://127.0.0.1:8000' \
-H 'Referer: http://127.0.0.1:8000/app/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: jlqErdA13HcA4v9WB31coUDlT48UPl5d' \
-H 'sec-ch-ua: "Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw 'post_data=%7B%22name%22%3A%22APV-166%22%2C%22type%22%3A%22vAPV%22%2C%22ip%22%3A%7B%22ipv4%22%3A%22192.168.162.166%22%7D%2C%22protocol%22%3A%22restapi%22%2C%22restapi_port%22%3A9997%2C%22restapi_account%22%3A%7B%22restapi_username%22%3A%22restapi%22%2C%22restapi_password%22%3A%22restuser%40123%22%7D%2C%22firewall_ip%22%3A%7B%7D%2C%22intranet_ip%22%3A%7B%7D%2C%22console_account%22%3A%7B%22console_username%22%3A%22array%22%2C%22console_password%22%3A%22admin%22%7D%2C%22group_name_from%22%3A%22created%22%2C%22device_group%22%3A%5B%7B%22name%22%3A%22apv-grp%22%7D%5D%2C%22webui_port%22%3A8888%2C%22log_enable%22%3Atrue%2C%22backup_enable%22%3Atrue%7D&csrfmiddlewaretoken=jlqErdA13HcA4v9WB31coUDlT48UPl5d' \
--insecure
[true, "id=%22%22&name=%22APV-166%22&type=%22vAPV%22", []]
| Description | From | Last Updated |
|---|---|---|
|
why we are replacing the find() with 'in' - find / index works better with strings. 'in' works with strings … |
|
|
|
Do we need all the funcions from these packages! Too much usage of * might lead to memory leak. |
|
|
|
We can do the import at the top of the file to maintain it better and clean. |
|
|
|
How we are handling the hive_search_init now? I could see apps.py, where it is used! Does the new approach handles … |
|
-
-
branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/device_mgmt/device/__init__.py (Diff revision 1) why we are replacing the find() with 'in' - find / index works better with strings. 'in' works with strings too but primarily built for list/dict. Just want to understand the change here.
-
-
branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/router.py (Diff revision 1) We can do the import at the top of the file to maintain it better and clean.
-
branches/amp_4_0/src/webui/webui/htdocs/new/src/manage.py (Diff revision 1) How we are handling the hive_search_init now? I could see apps.py, where it is used!
Does the new approach handles the hive routes also?
