]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
modulebase: add ifaceobj.set_status calls in log_error and log_warn
authorRoopa Prabhu <roopa@cumulusnetworks.com>
Thu, 10 Mar 2016 00:29:48 +0000 (16:29 -0800)
committerRoopa Prabhu <roopa@cumulusnetworks.com>
Thu, 10 Mar 2016 19:10:50 +0000 (11:10 -0800)
Ticket:
Reviewed By: trivial
Testing Done:

This can be used by callers to set iface object status.

ifupdownaddons/modulebase.py

index 1452548ae43f25997e9ef1730f7f47248061bff3..9b6bd7fb9e6467a09ea7975d35f2dcec2a304131 100644 (file)
@@ -34,19 +34,23 @@ class moduleBase(object):
         self.CACHE = kargs.get('cache', False)
         self.CACHE_FLAGS = kargs.get('cacheflags', 0x0)
 
-    def log_warn(self, str):
+    def log_warn(self, str, ifaceobj=None):
         """ log a warning if err str is not one of which we should ignore """
         if not self.ignore_error(str):
             if self.logger.getEffectiveLevel() == logging.DEBUG:
                 traceback.print_stack()
             self.logger.warn(str)
+            if ifaceobj:
+                ifaceobj.set_status(ifaceStatus.WARNING)
         pass
 
-    def log_error(self, str):
+    def log_error(self, str, ifaceobj=None):
         """ log an err if err str is not one of which we should ignore and raise an exception """
         if not self.ignore_error(str):
             if self.logger.getEffectiveLevel() == logging.DEBUG:
                 traceback.print_stack()
+            if ifaceobj:
+                ifaceobj.set_status(ifaceStatus.ERROR)
             raise Exception(str)
         else:
             pass