AE-1968: System General Settings API part1

Review Request #976 — Created July 17, 2025 and submitted

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

Problem

Need to port API's for the following section in General Settings API:
‘Host Settings’, ‘System Update’, ‘Systm Time Settings”, “NTP Settings”, “Network”->”Interface”, “DNS Server”, Route

Solution

There were some issues w.r.t python migration from 2-3 while were resolved and the above settings are ported except Network->Interface , Network->DNS Server needs some changes from the CLI side.

Output for the above Settings API's

System:
General Settings


Host Settings:

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/system/HostSettings/_fields' \
-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=bwO17jXsWLzUXAyQeUXgL7BnbiOEhCiv; hive_key=1; django_language=en; csrf_token=bwO17jXsWLzUXAyQeUXgL7BnbiOEhCiv; current_user=array; hive_sess=46cdb5b4-87b6-44cd-87b3-730dd36f8b5b' \
-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: bwO17jXsWLzUXAyQeUXgL7BnbiOEhCiv' \
-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
{"hostname": "AN", "vsite_name": "iAccess"}[root@AN admin]#

System Update:

[root@AN admin]# curl 'http://127.0.0.1:8000/cm/get_system_version' \
-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=7TgIMHBC37CWtNLGsBWqAmBnyCGNObFZ; hive_key=1; django_language=en; csrf_token=7TgIMHBC37CWtNLGsBWqAmBnyCGNObFZ; current_user=array; hive_sess=7601da08-b82d-4ab0-a7d6-e53736db1377' \
-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: 7TgIMHBC37CWtNLGsBWqAmBnyCGNObFZ' \
-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": {"version": "Rel.AMP.3.7.0.12"}

NTP Settings:

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/system/NTPSettings/_fields?fields=[%22enable_ntp%22,%20%22ntp_server%22,%20%22ntp_stats%22]' \
-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=wHMJQL9e0d4OgCxHjCN4TbSbJqCN3kxj; hive_key=1; django_language=en; csrf_token=wHMJQL9e0d4OgCxHjCN4TbSbJqCN3kxj; current_user=array; hive_sess=3b0976eb-3c9a-4205-9848-ca95d25c87d5' \
-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: wHMJQL9e0d4OgCxHjCN4TbSbJqCN3kxj' \
-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
{"enable_ntp": false, "ntp_server": [], "ntp_stats": "", "sysstats_reset": "", "packets_received": "", "bad": "", "auth_failed": "", "declined": "", "restricted": "", "rate_limited": "", "KoD_responses": "", "processed_for_time": ""}

Network

Interface:

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/network/interface/SystemInterface/_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=qZjLzNj1BWnoORDBiQlAvh6DzIj7zhUx; hive_key=1; django_language=en; csrf_token=qZjLzNj1BWnoORDBiQlAvh6DzIj7zhUx; current_user=array; hive_sess=e5e2f7e6-c189-4c13-be59-9fff2e4dd5c8' \
-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: qZjLzNj1BWnoORDBiQlAvh6DzIj7zhUx' \
-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
[]

Default Route

[root@AN admin]# curl 'http://127.0.0.1:8000/api/cm/network/route/DefaultRoutingSetting/_field?field=gateway_ip' \
-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=qZjLzNj1BWnoORDBiQlAvh6DzIj7zhUx; hive_key=1; django_language=en; csrf_token=qZjLzNj1BWnoORDBiQlAvh6DzIj7zhUx; current_user=array; hive_sess=e5e2f7e6-c189-4c13-be59-9fff2e4dd5c8' \
-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: qZjLzNj1BWnoORDBiQlAvh6DzIj7zhUx' \
-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
{"ipv4": "192.168.162.1", "ipv6": ""}

Description From Last Updated

Why we are removing the QuerySet! The framework is designed to use the QuerySet to return the responses.

pmurugaiyanpmurugaiyan
pmurugaiyan
  1. 
      
  2. Why we are removing the QuerySet! The framework is designed to use the QuerySet to return the responses.

    1. QuerySet must actually contain a Query which will be executed later. But here we are just putting values.
      In Python2 this was working because "Older Django didn’t check the type of data as strictly and might just “do its best” when you used custom QuerySets or returned lists from manager methods." .But in Python3 it is much stricter, it is trying to actually execute query which is creating issue.

    2. I agree, its more strict now. What exactly the issue now, to be compatible with the QuerySet model... QuerySet also provides additional python features. Now with our custom response we will lose those advantages, so trying to understand the problem before we are switching the model.

    3. If we want to use QuerySet. We have to make our models extend from Django model then we can you something like
      def _get_query_set(self):
      return self._model.objects.values('name')

      But Since we are inheriting from a custome model(ANModel) which is taking care of functionalities, we can make things work for now and later we can rework on making the whole model classes inherit from Django model and move towards the latest approach.

    4. Sure, can you create the backlog story accordingly!

    5. There is already an existing story for this.. updated it
      AE-1903

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

Status: Closed (submitted)

Loading...