mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix ordering of mstpctl attributes by moving to a OrderedDict
Ticket: CM-3737 Reviewed By: Testing Done: Tested with config given in the bug
This commit is contained in:
@@ -715,6 +715,9 @@ class bridge(moduleBase):
|
|||||||
bridge_pvid = None
|
bridge_pvid = None
|
||||||
|
|
||||||
bridgeports = self._get_bridge_port_list(ifaceobj)
|
bridgeports = self._get_bridge_port_list(ifaceobj)
|
||||||
|
if not bridgeports:
|
||||||
|
self.logger.debug('%s: cannot find bridgeports' %ifaceobj.name)
|
||||||
|
return
|
||||||
for bport in bridgeports:
|
for bport in bridgeports:
|
||||||
# Use the brctlcmd bulk set method: first build a dictionary
|
# Use the brctlcmd bulk set method: first build a dictionary
|
||||||
# and then call set
|
# and then call set
|
||||||
|
@@ -136,6 +136,19 @@ class mstpctl(moduleBase):
|
|||||||
'under a port: mstpctl-portbpdufilter yes']},
|
'under a port: mstpctl-portbpdufilter yes']},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
# Maps mstp bridge attribute names to corresponding mstpctl commands
|
||||||
|
# XXX: This can be encoded in the modules dict above
|
||||||
|
_attrs_map = OrderedDict([('mstpctl-treeprio' , 'treeprio'),
|
||||||
|
('mstpctl-ageing' , 'ageing'),
|
||||||
|
('mstpctl-maxage' , 'maxage'),
|
||||||
|
('mstpctl-fdelay' , 'fdelay'),
|
||||||
|
('mstpctl-maxhops' , 'maxhops'),
|
||||||
|
('mstpctl-txholdcount' , 'txholdcount'),
|
||||||
|
('mstpctl-forcevers', 'forcevers'),
|
||||||
|
('mstpctl-hello' , 'hello')])
|
||||||
|
|
||||||
|
# Maps mstp port attribute names to corresponding mstpctl commands
|
||||||
|
# XXX: This can be encoded in the modules dict above
|
||||||
_port_attrs_map = {'mstpctl-portpathcost' : 'portpathcost',
|
_port_attrs_map = {'mstpctl-portpathcost' : 'portpathcost',
|
||||||
'mstpctl-portadminedge' : 'portadminedge',
|
'mstpctl-portadminedge' : 'portadminedge',
|
||||||
'mstpctl-portautoedge' : 'portautoedge' ,
|
'mstpctl-portautoedge' : 'portautoedge' ,
|
||||||
@@ -251,36 +264,27 @@ class mstpctl(moduleBase):
|
|||||||
ifaceobj.get_attr_value_first('mstpctl-hello')
|
ifaceobj.get_attr_value_first('mstpctl-hello')
|
||||||
}.items() if v}
|
}.items() if v}
|
||||||
|
|
||||||
if bridgeattrs:
|
|
||||||
# set bridge attributes
|
# set bridge attributes
|
||||||
for k,v in bridgeattrs.items():
|
for attrname, dstattrname in self._attrs_map.items():
|
||||||
if k == 'treeprio':
|
try:
|
||||||
|
v = ifaceobj.get_attr_value_first(attrname)
|
||||||
|
if not v:
|
||||||
continue
|
continue
|
||||||
try:
|
if attrname == 'mstpctl-treeprio':
|
||||||
if v:
|
|
||||||
self.mstpctlcmd.set_bridge_attr(ifaceobj.name, k,
|
|
||||||
v, check)
|
|
||||||
except Exception, e:
|
|
||||||
self.logger.warn('%s' %str(e))
|
|
||||||
pass
|
|
||||||
if bridgeattrs.get('treeprio'):
|
|
||||||
try:
|
|
||||||
self.mstpctlcmd.set_bridge_treeprio(ifaceobj.name,
|
self.mstpctlcmd.set_bridge_treeprio(ifaceobj.name,
|
||||||
bridgeattrs['treeprio'], check)
|
v, check)
|
||||||
|
else:
|
||||||
|
self.mstpctlcmd.set_bridge_attr(ifaceobj.name,
|
||||||
|
dstattrname, v, check)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.warn('%s' %str(e))
|
self.logger.warn('%s' %str(e))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# set bridge port attributes
|
# set bridge port attributes
|
||||||
for attrname in ['mstpctl-portpathcost', 'mstpctl-portadminedge',
|
for attrname, dstattrname in self._port_attrs_map.items():
|
||||||
'mstpctl-portp2p', 'mstpctl-portrestrrole',
|
|
||||||
'mstpctl-portrestrtcn', 'mstpctl-bpduguard',
|
|
||||||
'mstpctl-treeportprio', 'mstpctl-treeportcost',
|
|
||||||
'mstpctl-portnetwork', 'mstpctl-portbpdufilter']:
|
|
||||||
attrval = ifaceobj.get_attr_value_first(attrname)
|
attrval = ifaceobj.get_attr_value_first(attrname)
|
||||||
if not attrval:
|
if not attrval:
|
||||||
continue
|
continue
|
||||||
dstattrname = attrname.split('-')[1]
|
|
||||||
portlist = self.parse_port_list(attrval)
|
portlist = self.parse_port_list(attrval)
|
||||||
if not portlist:
|
if not portlist:
|
||||||
self.log_warn('%s: error parsing \'%s %s\''
|
self.log_warn('%s: error parsing \'%s %s\''
|
||||||
@@ -336,6 +340,9 @@ class mstpctl(moduleBase):
|
|||||||
%ifaceobj.name + 'specific to ports')
|
%ifaceobj.name + 'specific to ports')
|
||||||
|
|
||||||
bridgeports = self._get_bridge_port_list(ifaceobj)
|
bridgeports = self._get_bridge_port_list(ifaceobj)
|
||||||
|
if not bridgeports:
|
||||||
|
self.logger.debug('%s: cannot find bridgeports' %ifaceobj.name)
|
||||||
|
return
|
||||||
for bport in bridgeports:
|
for bport in bridgeports:
|
||||||
self.logger.info('%s: processing mstp config for port %s'
|
self.logger.info('%s: processing mstp config for port %s'
|
||||||
%(ifaceobj.name, bport))
|
%(ifaceobj.name, bport))
|
||||||
|
Reference in New Issue
Block a user