AE-2022 : Migrate General Settings Tab API’s

Review Request #996 — Created July 29, 2025 and submitted

apoorva.sn
AMP
amp_4_0
AE-2022
ngurunathan, pmurugaiyan, pradeep, shuinvy

Problem

Migrate General Settings Tab API’s

  • Log Location

  • Storage details(Primary and Secondary)

  • Task

  • Administrator:

     - System Administrator
    
     -User Role
    
     -Operation Log
    
  • Extentions

  • Extention Log

  • Device Services

  • HA Management

  • SSL Certificates

Solution

There were some issues w.r.t python migration from 2-3 while were resolved

Storage

[root@AN admin]# curl 'http://127.0.0.1:8000/log/storage?type=secondary' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=EkoCloH4Qv7yGsF5PVzRWdhxYngdoqUq; hive_key=1; django_language=en; csrf_token=EkoCloH4Qv7yGsF5PVzRWdhxYngdoqUq; current_user=array; hive_sess=f84858e9-250d-46fc-b0d6-6dba187cf5fa' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: EkoCloH4Qv7yGsF5PVzRWdhxYngdoqUq' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
{"is_disk_available": false, "message": "There is no secondary disk attached to the system.Please contact Administrator to add additional disk space"}

[root@AN admin]# curl 'http://127.0.0.1:8000/log/archives?location=primary' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=w7e4eDjWPou5vv1hykRgQ6pRg06SuWhI; hive_key=1; django_language=en; csrf_token=w7e4eDjWPou5vv1hykRgQ6pRg06SuWhI; current_user=array; hive_sess=cd802c8e-8d3b-4e46-89ab-2cb880df0e60' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: w7e4eDjWPou5vv1hykRgQ6pRg06SuWhI' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
{"status": "success", "file_list": []}

[root@AN admin]# curl 'http://127.0.0.1:8000/storage/crontab?storage=primary' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=w7e4eDjWPou5vv1hykRgQ6pRg06SuWhI; hive_key=1; django_language=en; csrf_token=w7e4eDjWPou5vv1hykRgQ6pRg06SuWhI; current_user=array; hive_sess=cd802c8e-8d3b-4e46-89ab-2cb880df0e60' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: w7e4eDjWPou5vv1hykRgQ6pRg06SuWhI' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
{"schedule": false, "duration": "30", "percent": "80", "storage": "primary"}[root@AN admin]#

[root@AN admin]# curl 'http://127.0.0.1:8000/storage/crontab' \
-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/json' \
-b 'csrftoken=frnTo8tQ0EOQlebGeRyvqrDsbujItYk9; hive_key=1; django_language=en; csrf_token=frnTo8tQ0EOQlebGeRyvqrDsbujItYk9; current_user=array; hive_sess=6e7cb00e-7b92-4b50-a9f5-4ea90e0143e0' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: frnTo8tQ0EOQlebGeRyvqrDsbujItYk9' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"schedule":true,"duration":"30","percent":"80","storage":"primary"}' \
--insecure
{"schedule": true, "duration": "30", "percent": "80", "storage": "primary"}

Tasks

[root@AN admin]# curl 'http://127.0.0.1:8000/cm/get_task_pagination' \
-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=EkgmYTtZ2M1tWBLqtPy6JVKtXrWAyEK1; hive_key=1; django_language=en; csrf_token=EkgmYTtZ2M1tWBLqtPy6JVKtXrWAyEK1; current_user=array; hive_sess=a0cb6100-dcbc-4f5f-9047-b73fcd42347d' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: EkgmYTtZ2M1tWBLqtPy6JVKtXrWAyEK1' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw 'post_data=%7B%22start%22%3A0%2C%22number%22%3A15%2C%22search%22%3A%7B%7D%7D&csrfmiddlewaretoken=EkgmYTtZ2M1tWBLqtPy6JVKtXrWAyEK1' \
--insecure
{"state": true, "data": [], "total": 0}

[root@AN admin]# curl 'http://127.0.0.1:8000/cm/get_task_and_log' \
-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=wZmjHyeJNBAzq84fDcY0rHFuf4nXry78; hive_key=1; django_language=en; csrf_token=wZmjHyeJNBAzq84fDcY0rHFuf4nXry78; current_user=array; hive_sess=1119670d-9059-4915-b840-7525aa3d928a' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: wZmjHyeJNBAzq84fDcY0rHFuf4nXry78' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw 'post_data=%7B%22start%22%3A0%2C%22number%22%3A10%7D&csrfmiddlewaretoken=wZmjHyeJNBAzq84fDcY0rHFuf4nXry78' \
--insecure
{"log": {"state": true, "data": [{"username": "system", "client_ip": "localhost", "time": "2025-07-24 09:02:53", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 16}, {"username": "system", "client_ip": "localhost", "time": "2025-07-24 09:00:28", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 15}, {"username": "system", "client_ip": "localhost", "time": "2025-07-23 10:48:02", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 14}, {"username": "system", "client_ip": "localhost", "time": "2025-07-23 10:28:50", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 13}, {"username": "system", "client_ip": "localhost", "time": "2025-07-23 10:26:27", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 12}, {"username": "admin", "client_ip": "127.0.0.1", "time": "2025-07-23 10:12:31", "level": "error", "module": "system", "operation": "An Unexpected error occurred, details: dict object has no attribute has_key", "id": 11}, {"username": "system", "client_ip": "localhost", "time": "2025-07-23 10:11:41", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 10}, {"username": "admin", "client_ip": "127.0.0.1", "time": "2025-07-23 10:08:48", "level": "error", "module": "system", "operation": "An Unexpected error occurred, details: dict object has no attribute has_key", "id": 9}, {"username": "system", "client_ip": "localhost", "time": "2025-07-23 10:07:08", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 8}, {"username": "system", "client_ip": "localhost", "time": "2025-07-23 09:55:33", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 7}], "total": 16}, "task": {"state": true, "data": [], "total": 0}}

Administrator

System Administrator

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/system/user_mgmt/Administrator/_get_list_data' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=TjCPncYPGyqF6pxo1ADCc2Te9FqezWY4; hive_key=1; django_language=en; csrf_token=TjCPncYPGyqF6pxo1ADCc2Te9FqezWY4; current_user=array; hive_sess=b0792999-1b5b-4f2b-acbc-952be7e70d64' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: TjCPncYPGyqF6pxo1ADCc2Te9FqezWY4' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
[{"username": "restapi", "passwords": "XXXXXXXXXL1$gECY3rP1Aoj.eoRgRe8am/pVkTPv9AY.AOw78d0g5NT8K9LWPxsbBJgPmcExn12Am0nDIFowDi3HuEg4ILKyL0", "email": "", "phone_num": "", "level": "config", "user_type": "Common Admin", "role_id": 0, "role_name": "", "root": false, "pk": "{\"username\": \"restapi\"}", "pk_id": "restapi"}]

User Role

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/system/user_mgmt/Role/_get_list_data' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=LrfSU7QCBKicvG1hVTuChzxQP6OSeKnk; hive_key=1; django_language=en; csrf_token=LrfSU7QCBKicvG1hVTuChzxQP6OSeKnk; current_user=array; hive_sess=64c89fa7-181c-45f1-8bdd-3bab50ef514b' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: LrfSU7QCBKicvG1hVTuChzxQP6OSeKnk' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
[]

Operation Logs

[root@AN admin]# curl 'http://127.0.0.1:8000/cm/get_operation_log' \
-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=ImJUwOtZhDCczc9Zn14S87dmsoXHzlhW; hive_key=1; django_language=en; csrf_token=ImJUwOtZhDCczc9Zn14S87dmsoXHzlhW; current_user=array; hive_sess=476ada21-34bb-41fa-9c38-9c3fb21881e1' \
-H 'Origin: http://127.0.0.1:8000' \
-H 'Referer: http://127.0.0.1:8000/app/' \
-H 'X-CSRFToken: ImJUwOtZhDCczc9Zn14S87dmsoXHzlhW' \
--data-raw 'post_data=%7B%22start%22%3A0%2C%22number%22%3A20%2C%22search%22%3A%7B%7D%2C%22sort_predicate%22%3A%22time%22%2C%22sort_reverse%22%3A%22%22%7D&csrfmiddlewaretoken=ImJUwOtZhDCczc9Zn14S87dmsoXHzlhW' \
--insecure
{"state": true, "data": [{"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:52:07", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 77}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:48:40", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 76}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:41:15", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 75}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:39:01", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 74}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:36:10", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 73}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:19:43", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 72}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 11:16:00", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 71}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:44:02", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 70}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:41:41", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 69}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:40:23", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 68}, {"username": "admin", "client_ip": "127.0.0.1", "time": "2025-07-29 10:40:14", "level": "info", "module": "device_group", "operation": "The Filter Role Device Groups action is successfully.", "id": 67}, {"username": "admin", "client_ip": "127.0.0.1", "time": "2025-07-29 10:37:31", "level": "info", "module": "device_group", "operation": "The Filter Role Device Groups action is successfully.", "id": 66}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:37:07", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 65}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:35:10", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 64}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:30:56", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 63}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:24:30", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 62}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:17:31", "level": "info", "module": "login", "operation": "User <admin> login successfully.", "id": 61}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:13:38", "level": "info", "module": "system", "operation": "Update task state. Task name: APV-166-2025_07_29_10:13:35, task result: failed.", "id": 60}, {"username": "system", "client_ip": "localhost", "time": "2025-07-29 10:13:36", "level": "info", "module": "system", "operation": "Update task state. Task name: APV-166-2025_07_29_10:13:35, task result: ongoing.", "id": 59}, {"username": "admin", "client_ip": "127.0.0.1", "time": "2025-07-29 10:13:35", "level": "info", "module": "device", "operation": "<APV-166 - vAPV> has been created.", "id": 58}], "total": 77}

Extensions

[root@AN admin]# curl 'http://127.0.0.1:8000/get_available_extension' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=U3pDR4B1izZkeHHJaGO1MLsNwN1HIoON; hive_key=1; django_language=en; csrf_token=U3pDR4B1izZkeHHJaGO1MLsNwN1HIoON; current_user=array; hive_sess=a4ebfa90-632d-4b25-83a8-2d9c5b2aefab' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: U3pDR4B1izZkeHHJaGO1MLsNwN1HIoON' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
{"state": true, "data": []}

Extention Log

[root@AN admin]# curl 'http://127.0.0.1:8000/cm/get_extension_log' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-b 'csrftoken=LPR0uzZ7vRlJ0FNqEre7H4sdTdkLZ6KH; hive_key=1; django_language=en; csrf_token=LPR0uzZ7vRlJ0FNqEre7H4sdTdkLZ6KH; current_user=array; hive_sess=b3b2455d-6c74-464e-913c-81bc5fe4a64d' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: LPR0uzZ7vRlJ0FNqEre7H4sdTdkLZ6KH' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--insecure
{"state": true, "data": []}

SSL Certificates

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/device_mgmt/device_group/RoleDeviceGroup/_perform' \
-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=Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi; hive_key=1; django_language=en; csrf_token=Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi; current_user=array; hive_sess=cca25ffc-1017-41db-bc82-b3f614c9f134' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw 'action=FilterRoleDeviceGroups&options=%7B%22role_id%22%3A%220%22%7D&csrfmiddlewaretoken=Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi' \
--insecure
[true, {"result": [{"group_name": "apv-grp2", "device_list": []}, {"group_name": "apv-grp", "device_list": [{"id": "953679f5-6c36-11f0-a370-0050568d64ef", "zone": "default", "name": "APV-166", "ip": "192.168.162.166", "protocol": "restapi", "restapi_port": 9997, "connection": true, "status": true, "license_key": "3ece94cb-15c95c69-3f6cb2e8-0426831e-017e89f2-33380080-1454d8ab-20250604-20250902", "gateway_domain": "", "location": "", "firewall_ip": "", "intranet_ip": "", "type": "vAPV", "extend_fields": null, "own": "", "log_enable": 1, "snmp_general": {"snmp_enable": false, "community": ""}, "webui_port": 8888, "device_group": "apv-grp", "enable_password": "", "backup_enable": false, "restapi_account": {"restapi_username": "restapi", "restapi_password": null}, "console_account": {"console_username": "array", "console_password": null}, "host_name": "AN", "system_cpu": "Intel(R) Xeon(R) CPU", "system_ram": "3879500 kbytes.", "system_boot_time": "Sun Jun 15 18:55:09 GMT (+0000) 2025", "system_up_time": "43 days, 9 hrs, 52 mins", "platform_bld_date": "Tue Apr 16 13:12:36 GMT 2024", "ssl_hw": "No HW Available", "compression_hw": "No HW Available", "network_interface": "4 x 10Gigabit Ethernet fiber", "model": "Array vAPV", "serial_number": "75FA684AA3D6C00005012643240734", "build_version": "ArrayOS Rel.APV.10.7.0.16 build on Thu Apr 11 10:58:07 2024", "license_limit": "vCPUs(x4), NICs(x4), RAM(8 GB), Bandwidth(1000 Mbps)", "license_date": "Expires on Sep 02 2025", "license_feature": "WebWall, Clustering, L4SLB, L7SLB, Caching, SSL, tProxy, SwCompression, LLB, QoS, MultiLang, DynRoute, IPv6, SWMaintenance", "group_name_from": ""}]}], "config_change": true, "refresh_page": false, "msg": ""}]

[root@AN admin]# curl 'http://127.0.0.1:8000/proxy_req_dev/rest/cli_extend' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'CM-Data: 953679f5-6c36-11f0-a370-0050568d64ef' \
-H 'CM-Type: device' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-b 'csrftoken=Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi; hive_key=1; django_language=en; csrf_token=Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi; current_user=array; hive_sess=cca25ffc-1017-41db-bc82-b3f614c9f134' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: Nh55oe1zGieBD0rJiSZ4X0qq2nb3C5bi' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"cmd":"show slb virtual all"}' \
--insecure
{"contents": "slb virtual https \"vs1\" 192.168.162.109 443 arp 0\n"}

[root@AN admin]# curl 'http://127.0.0.1:8000/proxy_req_dev/rest/cli_extend' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'CM-Data: 953679f5-6c36-11f0-a370-0050568d64ef' \
-H 'CM-Type: device' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-b 'csrftoken=zI6TVacqDd28sKf1jeYPfgK9RC3jhGQ1; hive_key=1; django_language=en; csrf_token=zI6TVacqDd28sKf1jeYPfgK9RC3jhGQ1; current_user=array; hive_sess=985974e7-3bdc-4a7f-8a8d-929750f7abad' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: zI6TVacqDd28sKf1jeYPfgK9RC3jhGQ1' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"cmd":"show ssl host"}' \
--insecure
{"contents": "ssl host virtual \"vh1\" \"vs1\"\n"}

[root@AN admin]# curl 'http://127.0.0.1:8000/proxy_req_dev/rest/cli_extend' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'CM-Data: 953679f5-6c36-11f0-a370-0050568d64ef' \
-H 'CM-Type: device' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-b 'csrftoken=ZyxQTY0WGJbAYs1l3RqEjWd9bwDtjTn3; hive_key=1; django_language=en; csrf_token=ZyxQTY0WGJbAYs1l3RqEjWd9bwDtjTn3; current_user=array; hive_sess=74f613b0-ee6b-402b-92be-c40bcd40e1de' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: ZyxQTY0WGJbAYs1l3RqEjWd9bwDtjTn3' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"cmd":"show ssl status host"}' \
--insecure
{"contents": "virtual host \"vh1\" is active\n"}

[root@AN admin]# curl 'http://127.0.0.1:8000/proxy_req_dev/rest/cli_extend' \
-H 'Accept: application/json, text/plain, /' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'CM-Data: 953679f5-6c36-11f0-a370-0050568d64ef' \
-H 'CM-Type: device' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-b 'csrftoken=hAiWhrEoB8Nfs3D6EgMb9makQtaWagKs; hive_key=1; django_language=en; csrf_token=hAiWhrEoB8Nfs3D6EgMb9makQtaWagKs; current_user=array; hive_sess=d7a3a974-9dd4-4ccf-9d1d-d0c5082ec7ea' \
-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/138.0.0.0 Safari/537.36' \
-H 'X-CSRFToken: hAiWhrEoB8Nfs3D6EgMb9makQtaWagKs' \
-H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"cmd":"show slb virtual all"}' \
--insecure
{"contents": "slb virtual https \"vs1\" 192.168.162.109 443 arp 0\n"}

shuinvy
  1. 
      
  2. Will it better?
    from hive.model.fields.builtin import ( FieldGroup, CharField, PasswordField, EnumField, IntegerField, BooleanField, JSONField )

  3. branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/user_mgmt/__init__.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     

    I recommend you can try to optimize the code:
    `
    username = item_name.get('username')
    user = Administrator()

    Defaults

    defaults = {
    'username': username,
    'passwords': item_name.get('passwords'),
    'level': item_name.get('level'),
    'user_type': "Common Admin",
    'role_id': 0,
    'role_name': "",
    'root': False,
    'email': "",
    'phone_num': ""
    }
    for key, value in defaults.items():
    setattr(user, key, value)
    Because it set many lines, original code you need to useuser.everytime you set an attribute. If you think the attributeusername,passwords, andlevel` does not belongs to default part,
    you can let these three out of the dictionary and set it in original way.

  4. Is the 'or "Common Admin"' needed?
    Or just:
    user.user_type = user_auth_entry.get('user_type', "Common Admin")
    is okay?

    1. Incase key is None or '' so in this case we might need the 'or'

  5. Maybe you can just use:
    user.role_id = user_auth_entry.get('role_id', 0)
    I guess no need for "or 0" in the end

    1. Incase key is None or '' so in this case we might need the 'or'

  6. Maybe you can just use:
    user.role_name = user_auth_entry.get('role_name', "")
    the second parameter of get function for dictionary is the default value if there is no key (first parameter of get function)

    1. Incase key is None or '' so in this case we might need the 'or'

  7. 
      
shuinvy
  1. Ship It!
  2. 
      
pmurugaiyan
  1. Ship It!
  2. 
      
apoorva.sn
shuinvy
  1. Ship It!
  2. 
      
apoorva.sn
Review request changed

Status: Closed (submitted)

Loading...