mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
ifupdownmain: return proper error code on syntax check errors
Ticket: CM-7168 Reviewed By: julien Testing Done: Tested ifupdown2 negative testcases and ran ifupdown2 smoke Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
@@ -1136,6 +1136,8 @@ class ifupdownMain(ifupdownBase):
|
||||
if syntaxcheck:
|
||||
if not iface_read_ret:
|
||||
raise Exception()
|
||||
elif self._any_iface_errors(filtered_ifacenames):
|
||||
raise Exception()
|
||||
return
|
||||
|
||||
ret = None
|
||||
@@ -1592,6 +1594,16 @@ class ifupdownMain(ifupdownBase):
|
||||
else:
|
||||
self._reload_default(*args, **kargs)
|
||||
|
||||
def _any_iface_errors(self, ifacenames):
|
||||
for i in ifacenames:
|
||||
ifaceobjs = self.get_ifaceobjs(i)
|
||||
if not ifaceobjs: continue
|
||||
for ifaceobj in ifaceobjs:
|
||||
if (ifaceobj.status == ifaceStatus.NOTFOUND or
|
||||
ifaceobj.status == ifaceStatus.ERROR):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _pretty_print_ordered_dict(self, prefix, argdict):
|
||||
outbuf = prefix + ' {\n'
|
||||
for k, vlist in argdict.items():
|
||||
|
||||
Reference in New Issue
Block a user