1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

addons: mstpctl: reset (default) bridge mstpctl options when users remove settings

Ticket: CM-8401
Reviewed By: Roopa, Julien
Testing Done: tested on all bridge mstpctl attributes.

This patch resets th following bridge attributes to defauls when
users remove settings from interface config file.

mstpctl-treeprio
mstpctl-ageing
mstpctl-fdelay
mstpctl-maxhops
mstpctl-maxage
mstpctl-txholdcount
mstpctl-forcevers
mstpctl-hello

Added an api in policy manager to get policy default value of any
module attribute.

Added a cache for bridge attributes to save some runtime

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
This commit is contained in:
Nikhil
2016-12-07 09:53:33 -08:00
parent 3841234069
commit e3089aa898
3 changed files with 90 additions and 33 deletions

View File

@@ -144,7 +144,7 @@ class mstpctl(moduleBase):
'validrange' : ['0', '255'],
'default' : '2',
'required' : False,
'jsonAttr': 'portHelloTime',
'jsonAttr': 'helloTime',
'example' : ['mstpctl-hello 2']},
'mstpctl-portnetwork' :
{ 'help' : 'enable/disable bridge assurance capability for a port',
@@ -329,16 +329,32 @@ class mstpctl(moduleBase):
try:
# set bridge attributes
for attrname, dstattrname in self._attrs_map.items():
config_val = ifaceobj.get_attr_value_first(attrname)
default_val = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, ifname=ifaceobj.name, attr=attrname)
if not default_val:
default_val = self.get_mod_subattr(attrname,'default')
jsonAttr = self.get_mod_subattr(attrname, 'jsonAttr')
try:
running_val = self.mstpctlcmd.get_bridge_attr(
ifaceobj.name, jsonAttr)
except:
self.logger.info('%s: could not get running %s value'
%(ifaceobj.name, attrname))
running_val = None
if (not config_val and default_val and (running_val != default_val)):
# this happens when users remove an attribute from a port
# and expect the default to be restored with ifreload.
config_val = default_val
elif not config_val:
# there is nothing configured and no default to reset
continue
try:
v = ifaceobj.get_attr_value_first(attrname)
if not v:
continue
if attrname == 'mstpctl-treeprio':
self.mstpctlcmd.set_bridge_treeprio(ifaceobj.name,
v, check)
config_val, check)
else:
self.mstpctlcmd.set_bridge_attr(ifaceobj.name,
dstattrname, v, check)
dstattrname, config_val, check)
except Exception, e:
self.logger.warn('%s' %str(e))
pass
@@ -415,7 +431,10 @@ class mstpctl(moduleBase):
else:
return 'yes'
else:
return self.get_mod_subattr(attr,'default')
default_val = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, ifname=ifaceobj.name, attr=attr)
if not default_val:
return self.get_mod_subattr(attr,'default')
return default_val
def _apply_bridge_port_settings(self, ifaceobj, bridgename=None,
bridgeifaceobj=None,