From 31c5878750fd3f4486e42d457fcb9ee3ebbdc101 Mon Sep 17 00:00:00 2001 From: roopa Date: Mon, 5 May 2014 13:39:00 -0700 Subject: [PATCH] Change mstpctl show output parsing code (Use mstpctl show using param-id). Its less prone to problems. Ticket: CM-1438 Reviewed By: Testing Done: - Also add bpdufilter support - This also gets rid of caching for mstpctl output --- pkg/ifupdownmain.py | 18 +++++++++--------- sbin/ifupdown | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/ifupdownmain.py b/pkg/ifupdownmain.py index b868567..36532bf 100644 --- a/pkg/ifupdownmain.py +++ b/pkg/ifupdownmain.py @@ -538,8 +538,7 @@ class ifupdownMain(ifupdownBase): if not ifaceobjs: err_iface += ' ' + i if err_iface: - self.logger.error('cannot find interfaces: %s' %err_iface) - return False + raise Exception('cannot find interfaces:%s' %err_iface) return True def _iface_whitelisted(self, auto, allow_classes, excludepats, ifacename): @@ -630,8 +629,7 @@ class ifupdownMain(ifupdownBase): if ifacenames: # If iface list is given by the caller, always check if iface # is present - if not self._validate_ifaces(ifacenames): - raise Exception('all or some interfaces not found') + self._validate_ifaces(ifacenames) # if iface list not given by user, assume all from config file if not ifacenames: ifacenames = self.ifaceobjdict.keys() @@ -674,7 +672,6 @@ class ifupdownMain(ifupdownBase): self.read_old_iface_config() else: # If no old state available - self.logger.info('Loading current iface config file') try: self.read_iface_config() except Exception, e: @@ -682,8 +679,12 @@ class ifupdownMain(ifupdownBase): if ifacenames: # If iface list is given by the caller, always check if iface # is present - if not self._validate_ifaces(ifacenames): - raise Exception('interface(s) was probably never up') + try: + self._validate_ifaces(ifacenames) + except Exception, e: + raise Exception('%s' %str(e) + + ' (interface was probably never up ?)') + # if iface list not given by user, assume all from config file if not ifacenames: ifacenames = self.ifaceobjdict.keys() @@ -736,8 +737,7 @@ class ifupdownMain(ifupdownBase): if ifacenames and ops[0] != 'query-running': # If iface list is given, always check if iface is present - if not self._validate_ifaces(ifacenames): - raise Exception('all or some interfaces not found') + self._validate_ifaces(ifacenames) # if iface list not given by user, assume all from config file if not ifacenames: ifacenames = self.ifaceobjdict.keys() diff --git a/sbin/ifupdown b/sbin/ifupdown index fa10db1..336f552 100755 --- a/sbin/ifupdown +++ b/sbin/ifupdown @@ -392,7 +392,7 @@ def main(argv): else: print str(e) if args and not args.debug: - print '\nRerun the command with \'-d\' for a detailed errormsg' + print '\nrerun the command with \'-d\' for a detailed errormsg' exit(1) finally: deinit()