netlink ip link set up/down may silently fail, adding try/except statements

Ticket: CM-12609
Reviewed By: Roopa, Nikhil G
Testing Done: ifupdown2 smoke tests

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin 2016-08-24 14:20:45 -07:00
parent 781b55c5b0
commit 707aeb7378
4 changed files with 41 additions and 28 deletions

View File

@ -338,6 +338,7 @@ class address(moduleBase):
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
ifaceobj.set_status(ifaceStatus.ERROR)
try:
hwaddress = self._get_hwaddress(ifaceobj)
if hwaddress:
running_hwaddress = None
@ -360,12 +361,10 @@ class address(moduleBase):
for l in ifaceobj.lowerifaces:
netlink.link_set_updown(l, "up")
try:
# Handle special things on a bridge
self._process_bridge(ifaceobj, True)
except Exception, e:
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
pass
if addr_method != "dhcp":
gateways = ifaceobj.get_attr_value('gateway')

View File

@ -1214,7 +1214,10 @@ class bridge(moduleBase):
pass
if ifaceobj.addr_method == 'manual':
try:
netlink.link_set_updown(ifaceobj.name, "up")
except Exception as e:
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
if err:
raise Exception(errstr)
@ -1229,7 +1232,7 @@ class bridge(moduleBase):
map(lambda p: netlink.link_set_updown(p, "down"),
ports)
except Exception, e:
self.log_error(str(e))
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
def _query_running_vidinfo_compat(self, ifaceobjrunning, ports):
running_attrs = {}

View File

@ -146,7 +146,10 @@ class vlan(moduleBase):
netlink.link_add_vlan(vlanrawdevice, ifaceobj.name, vlanid)
self._bridge_vid_add_del(ifaceobj, vlanrawdevice, vlanid)
if ifaceobj.addr_method == 'manual':
try:
netlink.link_set_updown(ifaceobj.name, "up")
except Exception as e:
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
def _down(self, ifaceobj):
vlanid = self._get_vlan_id(ifaceobj)

View File

@ -129,7 +129,11 @@ class ifupdownMain(ifupdownBase):
return
if not self.link_exists(ifaceobj.name):
return
try:
self.link_up(ifaceobj.name)
except Exception as e:
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
ifaceobj.set_status(ifaceStatus.ERROR)
def run_down(self, ifaceobj):
if ((ifaceobj.link_kind & ifaceLinkKind.VRF) or
@ -153,7 +157,11 @@ class ifupdownMain(ifupdownBase):
return
if not self.link_exists(ifaceobj.name):
return
try:
self.link_down(ifaceobj.name)
except Exception as e:
self.logger.error('%s: %s' % (ifaceobj.name, str(e)))
ifaceobj.set_status(ifaceStatus.ERROR)
# ifupdown object interface operation handlers
ops_handlers = OrderedDict([('up', run_up),