mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: ethtool: add support for "ethtool_ignore_errors" policy
The goal of this policy is to ignore ethtool related errors, this is useful for specific scenario like VMs. This policy is off by default. To turn it on simply set: "module_globals" : { "ethtool_ignore_errors": true } under the ethtool top object. Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@ -143,6 +143,11 @@ class ethtool(moduleBase,utilsBase):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
|
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
|
||||||
|
|
||||||
|
self.ethtool_ignore_errors = policymanager.policymanager_api.get_module_globals(
|
||||||
|
module_name=self.__class__.__name__,
|
||||||
|
attr='ethtool_ignore_errors'
|
||||||
|
)
|
||||||
|
|
||||||
def do_fec_settings(self, ifaceobj):
|
def do_fec_settings(self, ifaceobj):
|
||||||
feccmd = ''
|
feccmd = ''
|
||||||
|
|
||||||
@ -192,6 +197,7 @@ class ethtool(moduleBase,utilsBase):
|
|||||||
(utils.ethtool_cmd, ifaceobj.name, feccmd))
|
(utils.ethtool_cmd, ifaceobj.name, feccmd))
|
||||||
utils.exec_command(feccmd)
|
utils.exec_command(feccmd)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
if not self.ethtool_ignore_errors:
|
||||||
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
|
self.log_error('%s: %s' %(ifaceobj.name, str(e)), ifaceobj)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -286,6 +292,7 @@ class ethtool(moduleBase,utilsBase):
|
|||||||
cmd = ('%s -s %s %s' % (utils.ethtool_cmd, ifaceobj.name, cmd))
|
cmd = ('%s -s %s %s' % (utils.ethtool_cmd, ifaceobj.name, cmd))
|
||||||
utils.exec_command(cmd)
|
utils.exec_command(cmd)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
if not self.ethtool_ignore_errors:
|
||||||
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
|
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
|
||||||
|
|
||||||
def _pre_up(self, ifaceobj, operation='post_up'):
|
def _pre_up(self, ifaceobj, operation='post_up'):
|
||||||
@ -460,6 +467,7 @@ class ethtool(moduleBase,utilsBase):
|
|||||||
running_attr = self.read_file_oneline('/sys/class/net/%s/%s' % \
|
running_attr = self.read_file_oneline('/sys/class/net/%s/%s' % \
|
||||||
(ifaceobj.name, attr))
|
(ifaceobj.name, attr))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if not self.ethtool_ignore_errors:
|
||||||
# for nonexistent interfaces, we get an error (rc = 256 or 19200)
|
# for nonexistent interfaces, we get an error (rc = 256 or 19200)
|
||||||
self.logger.debug('ethtool: problems calling ethtool or reading'
|
self.logger.debug('ethtool: problems calling ethtool or reading'
|
||||||
' /sys/class on iface %s for attr %s: %s' %
|
' /sys/class on iface %s for attr %s: %s' %
|
||||||
|
Reference in New Issue
Block a user