mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Moved bond-clag-id attr setting from ifenslave.py to addons/clagd.py
Ticket: Reviewed By: Testing Done: <DETAILED DESCRIPTION (REPLACE)> (cherry picked from commit ed008ea9ec176e01b2043b872ad0b8b193f31d0f)
This commit is contained in:
@@ -99,12 +99,7 @@ class ifenslave(moduleBase):
|
||||
'required' : True,
|
||||
'example' : ['bond-slaves swp1 swp2',
|
||||
'bond-slaves glob swp1-2',
|
||||
'bond-slaves regex (swp[1|2)']},
|
||||
'bond-clag-id' :
|
||||
{'help' : 'multi-chassis lag id',
|
||||
'validrange' : ['0', '65535'],
|
||||
'default' : '0',
|
||||
'example' : ['bond-clag-id 1']}}}
|
||||
'bond-slaves regex (swp[1|2)']}}}
|
||||
|
||||
def __init__(self, *args, **kargs):
|
||||
ifupdownaddons.modulebase.moduleBase.__init__(self, *args, **kargs)
|
||||
@@ -231,11 +226,6 @@ class ifenslave(moduleBase):
|
||||
if link_up or ifaceobj.link_type != ifaceLinkType.LINK_NA:
|
||||
rtnetlink_api.rtnl_api.link_set(slave, "up")
|
||||
|
||||
def _set_clag_id(self, ifaceobj):
|
||||
attrval = ifaceobj.get_attr_value_first('bond-clag-id')
|
||||
attrval = attrval if attrval else '0'
|
||||
self.ifenslavecmd.set_clag_id(ifaceobj.name, attrval)
|
||||
|
||||
def _apply_slaves_lacp_bypass_prio(self, ifaceobj):
|
||||
slaves = self.ifenslavecmd.get_slaves(ifaceobj.name)
|
||||
if not slaves:
|
||||
@@ -275,7 +265,6 @@ class ifenslave(moduleBase):
|
||||
if not self.ipcmd.link_exists(ifaceobj.name):
|
||||
self.ifenslavecmd.create_bond(ifaceobj.name)
|
||||
self._apply_master_settings(ifaceobj)
|
||||
self._set_clag_id(ifaceobj)
|
||||
self._add_slaves(ifaceobj)
|
||||
self._apply_slaves_lacp_bypass_prio(ifaceobj)
|
||||
if ifaceobj.addr_method == 'manual':
|
||||
@@ -365,9 +354,7 @@ class ifenslave(moduleBase):
|
||||
'bond-lacp-bypass-period' :
|
||||
self.ifenslavecmd.get_lacp_fallback_period(bondname),
|
||||
'bond-lacp-bypass-priority' :
|
||||
self.ifenslavecmd.get_lacp_fallback_priority(bondname),
|
||||
'bond-clag-id' :
|
||||
self.ifenslavecmd.get_clag_id(bondname)}
|
||||
self.ifenslavecmd.get_lacp_fallback_priority(bondname)}
|
||||
slaves = self.ifenslavecmd.get_slaves(bondname)
|
||||
if slaves:
|
||||
bondattrs['bond-slaves'] = slaves
|
||||
|
@@ -1,4 +1,5 @@
|
||||
pre-up,ifenslave
|
||||
pre-up,clagd
|
||||
pre-up,vlan
|
||||
pre-up,vxlan
|
||||
pre-up,usercmds
|
||||
|
@@ -49,14 +49,11 @@ class ifenslaveutil(utilsBase):
|
||||
linkCache.set_attr([bondname, 'linkinfo', 'ad_sys_mac_addr'],
|
||||
self.read_file_oneline('/sys/class/net/%s/bonding/ad_sys_mac_addr'
|
||||
%bondname))
|
||||
linkCache.set_attr([bondname, 'linkinfo', 'clag_id'],
|
||||
self.get_clag_id_from_clagd(bondname))
|
||||
map(lambda x: linkCache.set_attr([bondname, 'linkinfo', x],
|
||||
self.read_file_oneline('/sys/class/net/%s/bonding/%s'
|
||||
%(bondname, x))),
|
||||
['use_carrier', 'miimon', 'min_links', 'num_unsol_na',
|
||||
'num_grat_arp', 'lacp_bypass_allow', 'lacp_bypass_period',
|
||||
'clag_enable'])
|
||||
'num_grat_arp', 'lacp_bypass_allow', 'lacp_bypass_period'])
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
@@ -194,45 +191,6 @@ class ifenslaveutil(utilsBase):
|
||||
def get_miimon(self, bondname):
|
||||
return self._cache_get([bondname, 'linkinfo', 'miimon'])
|
||||
|
||||
def set_clag_id(self, bondname, clag_id):
|
||||
# this involves -
|
||||
# 1. Setting bond type in the bonding driver
|
||||
# 2. Setting clag id via clagctl
|
||||
clag_enable = '0' if clag_id == '0' else '1'
|
||||
if self._cache_check([bondname, 'linkinfo', 'clag_enable'],
|
||||
clag_enable) == False:
|
||||
self.write_file('/sys/class/net/%s' %bondname +
|
||||
'/bonding/clag_enable', clag_enable)
|
||||
self._cache_update([bondname, 'linkinfo', 'clag_enable'],
|
||||
clag_enable)
|
||||
|
||||
if self.is_process_running('clagd') and \
|
||||
self._cache_check([bondname, 'linkinfo', 'clag_id'],
|
||||
clag_id) == False:
|
||||
self.exec_command('/usr/bin/clagctl setclagid %s %s' % (bondname, clag_id))
|
||||
self._cache_update([bondname, 'linkinfo', 'clag_id'], clag_id)
|
||||
|
||||
def get_clag_id_from_clagd(self, bondname):
|
||||
clag_id = None
|
||||
if self.is_process_running('clagd'):
|
||||
try:
|
||||
output = self.subprocess_check_output(['/usr/bin/clagctl',
|
||||
'showclagid'])
|
||||
pat = re.compile('%s[ \t]+(?P<cid>\d+)' % bondname)
|
||||
if output:
|
||||
obj = pat.search(output)
|
||||
if obj:
|
||||
clag_id = obj.group('cid')
|
||||
except Exception, e:
|
||||
pass
|
||||
return clag_id
|
||||
|
||||
def get_clag_id(self, bondname):
|
||||
return self._cache_get([bondname, 'linkinfo', 'clag_id'])
|
||||
|
||||
def get_clag_enable(self, bondname):
|
||||
return self._cache_get([bondname, 'linkinfo', 'clag_enable'])
|
||||
|
||||
def set_mode(self, bondname, mode, prehook=None):
|
||||
valid_modes = ['balance-rr', 'active-backup', 'balance-xor',
|
||||
'broadcast', '802.3ad', 'balance-tlb', 'balance-alb']
|
||||
|
@@ -51,6 +51,14 @@ class moduleBase(object):
|
||||
else:
|
||||
pass
|
||||
|
||||
def is_process_running(self, procName):
|
||||
try:
|
||||
self.exec_command('/bin/pidof -x %s' % procName)
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def exec_command(self, cmd, cmdenv=None):
|
||||
""" execute command passed as argument.
|
||||
|
||||
|
@@ -36,14 +36,6 @@ class utilsBase(object):
|
||||
self.PERFMODE = kargs.get('perfmode', False)
|
||||
self.CACHE = kargs.get('cache', False)
|
||||
|
||||
def is_process_running(self, procName):
|
||||
try:
|
||||
self.exec_command('/bin/pidof -x %s' % procName)
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def exec_commandl(self, cmdl, cmdenv=None):
|
||||
""" Executes command """
|
||||
|
||||
|
Reference in New Issue
Block a user