Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/dns/__init__.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/dns/__init__.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/dns/__init__.py	(working copy)
@@ -24,7 +24,8 @@
             self.cli.set_enable()
             result = self.cli.cmd('show ip nameserver',
                                   RegexParser('name server (?P<server_ip>[0-9|\.|:|\w]+)', MATCHALL, reflags=re.M))
-            return QuerySet(self._model, result)
+            dns_obj = DNSServer(server_ip=result)
+            return [dns_obj]
 
         def _insert(self, instance):
             self.cli.set_config()
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/interface/__init__.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/interface/__init__.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/interface/__init__.py	(working copy)
@@ -192,7 +192,6 @@
                         each['mac'] = result_inter[0]['mac']
                     else:
                         each['mac'] = ''
-                    each["addresses"] = DelayedQuery
-
-                    res.append(each)
-            return QuerySet(self._model, res)
+                    sys_int_obj = SystemInterface(name=each['interface_name'], inf_type=each['inf_type'], mac=each['mac'], addresses=each["addresses"], mtu=each['mac'])
+                    res.append(sys_int_obj)
+            return res
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/route/__init__.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/route/__init__.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/network/route/__init__.py	(working copy)
@@ -37,16 +37,20 @@
             parser = RegexParser('IPv[4|6]\s+route:((?!default).)*?\s+default\s+(?P<gateway_ip_str>[0-9|:|\.|\w]+)',
                                  MATCHALL, reflags=re.S)
             result = self.cli.cmd('show ip route', parser)
-            ret = {'gateway_ip': {'ipv4': '', 'ipv6': ''}}
+            ret_list = []
             if result:
                 for each_res in result:
+                    gateway_dict = {'ipv4': '', 'ipv6': ''}
                     if is_ipv4(each_res['gateway_ip_str']):
-                        ret['gateway_ip']['ipv4'] = each_res['gateway_ip_str']
+                        gateway_dict['ipv4'] = each_res['gateway_ip_str']
                     elif is_ipv6(each_res['gateway_ip_str']):
-                        ret['gateway_ip']['ipv6'] = each_res['gateway_ip_str']
-            data = QuerySet(self._model, [ret])
-            return data
+                        gateway_dict['ipv6'] = each_res['gateway_ip_str']
+                    if gateway_dict:
+                        obj = DefaultRoutingSetting(gateway_ip=gateway_dict)
+                        ret_list.append(obj)
 
+            return ret_list
+
         def _update_gateway_ip(self, instance, old_values):
             self.cli.set_config()
             if instance.gateway_ip:
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/host.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/host.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/host.py	(working copy)
@@ -37,11 +37,8 @@
         def _get_query_set(self):
             self.cli.set_enable()
             output = self.cli.cmd('show host')
-            data = {
-                'hostname': output.strip(),
-                'vsite_name': cm.conf.VSITE_NAME,
-            }
-            return QuerySet(self._model, [data])
+            data = HostSettings(hostname=output.strip(), vsite_name=cm.conf.VSITE_NAME)
+            return [data]
 
         def _update_hostname(self, instance):
             self.cli.set_config()
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/ntp.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/ntp.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/ntp.py	(working copy)
@@ -61,14 +61,11 @@
             result = self.cli.cmd('show ntp',
                                   RegexParser('ntp (?P<enable_ntp>on|off)', MATCHONE, reflags=re.S))
             if result:
-                rtn_dict = {
-                    'enable_ntp': True if result['enable_ntp'] == 'on' else False
-                }
+                rtn_dict = NTPSettings(enable_ntp=True if result['enable_ntp'] == 'on' else False)
             else:
-                rtn_dict = {'enable_ntp': False}
-            self._model._meta.mark_delay_query(rtn_dict)
+                rtn_dict = NTPSettings(enable_ntp=False)
 
-            return QuerySet(self._model, [rtn_dict])
+            return [rtn_dict]
 
         def _update_enable_ntp(self, instance):
             self.cli.set_config()
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/time.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/time.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/system/time.py	(working copy)
@@ -58,11 +58,8 @@
             return result['tz']
 
         def _get_query_set(self):
-            result = [{
-                'system_time': self._get_system_time(),
-                'system_timezone': self._get_system_timezone(),
-            }]
-            return QuerySet(self._model, result)
+            result = TimeSettings(system_time=self._get_system_time(), system_timezone=self._get_system_timezone())
+            return [result]
 
         def _update_system_timezone(self, instance):
             self.cli.set_config()
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/legacycli.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/legacycli.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/legacycli.py	(working copy)
@@ -298,13 +298,30 @@
 
     def cmd_direct(self, cmd, *args):
         cmd = cmd.strip()
-        f_eop = chr(252)
         username = self._username
         cmd = escapeshellarg(cmd)
 
-        cmd = '/ca/bin/backend -u ' + username + ' -c ' + cmd
-        (status, output) = subprocess.getstatusoutput(cmd)
-        output = output.strip(f_eop)
+        # Prepare the argument for the backend (as bytes)
+        backend_bin = b'/ca/bin/backend'
+        username_bytes = username.encode('utf-8')
+        # Compose the command list for subprocess (all bytes)
+        full_cmd = [
+            backend_bin,
+            b'-u',
+            username_bytes,
+            b'-c',
+            cmd.encode('utf-8') + F_EOP  # Append EOP byte
+        ]
+        # Run the process
+        result = subprocess.run(full_cmd, capture_output=True)
+        output = result.stdout.rstrip(F_EOP)  # Remove trailing EOP
+
+        # Convert output to string if needed (try utf-8, else latin-1 fallback)
+        try:
+            output = output.decode('utf-8')
+        except UnicodeDecodeError:
+            output = output.decode('latin-1')
+
         if len(args) == 0:
             return output
         elif len(args) == 1:
@@ -340,9 +357,10 @@
         cmd_len = 1024 - len(session_id.encode('utf-8')) - len(self._username.encode('utf-8')) - 3
 
         # XXX check first \n less than cmd_len
-
+        f_eop = chr(252)
         if isinstance(cmd, str):
             cmd_str = cmd.encode('utf-8')
+            cmd += f_eop
 
         while len(cmd_str) > 0:
             each_cmd = (
@@ -361,6 +379,7 @@
 
         output = self._receive(F_EOP)
         andebug('an.model.cli', 'cli command execution: "%s", output: "%s"' % (cmd, output))
+
         # For now, as a limitation of webui_agent, we always establish new TCP connection
         # for every command execution
         self._disconnect()
@@ -702,6 +721,8 @@
         self._result = result
 
     def parse(self, cmd_output):
+        if isinstance(cmd_output, bytes):
+            cmd_output = cmd_output.decode('utf-8', errors='replace')
         if self._mode == MATCHONE:
             match_obj = self._regex.search(cmd_output)
 
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/manager.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/manager.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/manager.py	(working copy)
@@ -490,6 +490,9 @@
     # 2. only a field expires, directly call get_field_by_instance() which further updates the cache
     def get_field(self, pk_dict=None, field_name=None):
         assert field_name, "field_name must be specified"
+        if isinstance(field_name, list):
+            if len(field_name) != 0:
+                field_name = field_name[0]
         if check_expire(self._model, pk_dict, field_name):
             try:
                 instance = self._get(pk_dict)
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/options.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/options.py	(revision 2671)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/options.py	(working copy)
@@ -540,6 +540,10 @@
 
         Uses a cache internally, so after the first access, this is very fast.
         """
+        if isinstance(name, list):
+            if len(name) == 0:
+                raise fields.FieldDoesNotExist('%s has not object named %r (empty list)' % (self.object_name, name))
+            name = name[0]
         try:
             try:
                 return self._name_map[name]
