BIND 10 trac2121, updated. a9e21b463c8c2e7301e21e05787b25406d53d067 [2121] Address review comments

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jul 13 05:26:52 UTC 2012


The branch, trac2121 has been updated
       via  a9e21b463c8c2e7301e21e05787b25406d53d067 (commit)
      from  5255dd6b43a8469d9614ff86adb38dee3b8d630b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a9e21b463c8c2e7301e21e05787b25406d53d067
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Jul 13 10:54:55 2012 +0530

    [2121] Address review comments
    
    * Newlines have been added to the default values where it returns
      "Unknown" to preserve formatting.
    
    * If a command fails, a failure message is returned instead of
      "Unknown".

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/sysinfo/sysinfo.py            |   69 ++++------------------
 src/lib/python/isc/sysinfo/tests/sysinfo_test.py |   16 ++---
 2 files changed, 20 insertions(+), 65 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/sysinfo/sysinfo.py b/src/lib/python/isc/sysinfo/sysinfo.py
index 0695318..a484749 100644
--- a/src/lib/python/isc/sysinfo/sysinfo.py
+++ b/src/lib/python/isc/sysinfo/sysinfo.py
@@ -41,10 +41,10 @@ class SysInfo:
         self._mem_swap_total = -1
         self._mem_swap_free = -1
         self._platform_distro = 'Unknown'
-        self._net_interfaces = 'Unknown'
-        self._net_routing_table = 'Unknown'
-        self._net_stats = 'Unknown'
-        self._net_connections = 'Unknown'
+        self._net_interfaces = 'Unknown\n'
+        self._net_routing_table = 'Unknown\n'
+        self._net_stats = 'Unknown\n'
+        self._net_connections = 'Unknown\n'
 
     def get_num_processors(self):
         """Returns the number of processors. This is the number of
@@ -230,18 +230,11 @@ class SysInfoLinux(SysInfoPOSIX):
         if self._platform_distro is None:
             self._platform_distro = 'Unknown'
 
-        self._net_interfaces = None
-
         try:
             s = subprocess.check_output(['ip', 'addr'])
             self._net_interfaces = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_interfaces is None:
-            self._net_interfaces = 'Unknown'
-
-        self._net_routing_table = None
+            self._net_interfaces = 'Warning: "ip addr" command failed.\n'
 
         try:
             s = subprocess.check_output(['ip', 'route'])
@@ -250,32 +243,19 @@ class SysInfoLinux(SysInfoPOSIX):
             s = subprocess.check_output(['ip', '-f', 'inet6', 'route'])
             self._net_routing_table += s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_routing_table is None:
-            self._net_routing_table = 'Unknown'
-
-        self._net_stats = None
+            self._net_routing_table = 'Warning: "ip route" or "ip -f inet6 route" command failed.\n'
 
         try:
             s = subprocess.check_output(['netstat', '-s'])
             self._net_stats = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_stats is None:
-            self._net_stats = 'Unknown'
-
-        self._net_connections = None
+            self._net_stats = 'Warning: "netstat -s" command failed.\n'
 
         try:
             s = subprocess.check_output(['netstat', '-apn'])
             self._net_connections = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_connections is None:
-            self._net_connections = 'Unknown'
+            self._net_connections = 'Warning: "netstat -apn" command failed.\n'
 
 class SysInfoBSD(SysInfoPOSIX):
     """Common BSD implementation of the SysInfo class.
@@ -284,17 +264,12 @@ class SysInfoBSD(SysInfoPOSIX):
     def __init__(self):
         super().__init__()
 
-        self._hostname = None
-
         try:
             s = subprocess.check_output(['hostname'])
             self._hostname = s.decode('utf-8').strip()
         except (subprocess.CalledProcessError, OSError):
             pass
 
-        if self._hostname is None:
-            self._hostname = 'Unknown'
-
         try:
             s = subprocess.check_output(['sysctl', '-n', 'kern.boottime'])
             t = s.decode('utf-8').strip()
@@ -350,49 +325,29 @@ class SysInfoOpenBSD(SysInfoBSD):
         except (subprocess.CalledProcessError, OSError):
             pass
 
-        self._net_interfaces = None
-
         try:
             s = subprocess.check_output(['ifconfig'])
             self._net_interfaces = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_interfaces is None:
-            self._net_interfaces = 'Unknown'
-
-        self._net_routing_table = None
+            self._net_interfaces = 'Warning: "ifconfig" command failed.\n'
 
         try:
             s = subprocess.check_output(['route', '-n', 'show'])
             self._net_routing_table = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_routing_table is None:
-            self._net_routing_table = 'Unknown'
-
-        self._net_stats = None
+            self._net_routing_table = 'Warning: "route -n show" command failed.\n'
 
         try:
             s = subprocess.check_output(['netstat', '-s'])
             self._net_stats = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_stats is None:
-            self._net_stats = 'Unknown'
-
-        self._net_connections = None
+            self._net_stats = 'Warning: "netstat -s" command failed.\n'
 
         try:
             s = subprocess.check_output(['netstat', '-an'])
             self._net_connections = s.decode('utf-8')
         except (subprocess.CalledProcessError, OSError):
-            pass
-
-        if self._net_connections is None:
-            self._net_connections = 'Unknown'
+            self._net_connections = 'Warning: "netstat -an" command failed.\n'
 
 class SysInfoTestcase(SysInfo):
     def __init__(self):
diff --git a/src/lib/python/isc/sysinfo/tests/sysinfo_test.py b/src/lib/python/isc/sysinfo/tests/sysinfo_test.py
index 4a7d3e8..0cbf655 100644
--- a/src/lib/python/isc/sysinfo/tests/sysinfo_test.py
+++ b/src/lib/python/isc/sysinfo/tests/sysinfo_test.py
@@ -141,10 +141,10 @@ class SysInfoTest(unittest.TestCase):
         self.assertEqual(-1, s.get_mem_swap_total())
         self.assertEqual(-1, s.get_mem_swap_free())
         self.assertEqual('Unknown', s.get_platform_distro())
-        self.assertEqual('Unknown', s.get_net_interfaces())
-        self.assertEqual('Unknown', s.get_net_routing_table())
-        self.assertEqual('Unknown', s.get_net_stats())
-        self.assertEqual('Unknown', s.get_net_connections())
+        self.assertEqual('Unknown\n', s.get_net_interfaces())
+        self.assertEqual('Unknown\n', s.get_net_routing_table())
+        self.assertEqual('Unknown\n', s.get_net_stats())
+        self.assertEqual('Unknown\n', s.get_net_connections())
 
     def test_sysinfo_factory(self):
         """Test that SysInfoFromFactory returns a valid system-specific
@@ -170,10 +170,10 @@ class SysInfoTest(unittest.TestCase):
         self.assertEqual(-1, s.get_mem_swap_total())
         self.assertEqual(-1, s.get_mem_swap_free())
         self.assertEqual('Unknown', s.get_platform_distro())
-        self.assertEqual('Unknown', s.get_net_interfaces())
-        self.assertEqual('Unknown', s.get_net_routing_table())
-        self.assertEqual('Unknown', s.get_net_stats())
-        self.assertEqual('Unknown', s.get_net_connections())
+        self.assertEqual('Unknown\n', s.get_net_interfaces())
+        self.assertEqual('Unknown\n', s.get_net_routing_table())
+        self.assertEqual('Unknown\n', s.get_net_stats())
+        self.assertEqual('Unknown\n', s.get_net_connections())
 
         platform.system = old_platform_system
 



More information about the bind10-changes mailing list