mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
ifquery --running should not show link attributes on logical interfaces
Ticket: CM-6557 Reviewed By: roopa, gospo Testing Done: unit tested ifquery should not show link attributes for interfaces we do not have defaults for. Although somewhat useful, we don't want people saving the bond link attributes to try to use then in a config
This commit is contained in:
@ -101,15 +101,18 @@ class ethtool(moduleBase,utilsBase):
|
||||
(the default will get set).
|
||||
"""
|
||||
for attr in ['speed', 'duplex', 'autoneg']:
|
||||
# autoneg comes from ethtool whereas speed and duplex from /sys/class
|
||||
running_attr = self.get_running_attr(attr, ifaceobj)
|
||||
|
||||
configured = ifaceobj.get_attr_value_first('link-%s'%attr)
|
||||
default = policymanager.policymanager_api.get_iface_default(
|
||||
module_name='ethtool',
|
||||
ifname=ifaceobj.name,
|
||||
attr='link-%s'%attr)
|
||||
# if we have no default, do not bother checking
|
||||
# this avoids ethtool calls on virtual interfaces
|
||||
if not default:
|
||||
continue
|
||||
# autoneg comes from ethtool whereas speed and duplex from /sys/class
|
||||
running_attr = self.get_running_attr(attr, ifaceobj)
|
||||
|
||||
configured = ifaceobj.get_attr_value_first('link-%s'%attr)
|
||||
# there is a case where there is no running config or
|
||||
# (there is no default and it is not configured).
|
||||
# In this case, we do nothing (e.g. eth0 has only a
|
||||
@ -178,9 +181,19 @@ class ethtool(moduleBase,utilsBase):
|
||||
if not self.ipcmd.is_link_up(ifaceobj.name):
|
||||
return
|
||||
for attr in ['speed', 'duplex', 'autoneg']:
|
||||
default_val = policymanager.policymanager_api.get_iface_default(
|
||||
module_name='ethtool',
|
||||
ifname=ifaceobj.name,
|
||||
attr='link-%s'%attr)
|
||||
# do not continue if we have no defaults
|
||||
# this avoids ethtool calls on virtual interfaces
|
||||
if not default_val:
|
||||
continue
|
||||
running_attr = self.get_running_attr(attr, ifaceobj)
|
||||
# show it
|
||||
if (running_attr):
|
||||
# if we can change it (have a default) then show it
|
||||
# otherwise, customers will show the running and save it to startup
|
||||
# which will result in errors (ethtool does not work on bonds, etc.)
|
||||
if running_attr:
|
||||
ifaceobj.update_config('link-%s'%attr, running_attr)
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user