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

ifupdown2: mstpctl: check mstpd running just once during init of mstpctl modules

Ticket: CM-8035
Reviewed By: wkok
Testing Done: Tested mstp commands in interfaces file

(cherry picked from commit 2c3471f2082c8adbdcc395cbd0066680f280b9e5)
This commit is contained in:
Roopa Prabhu
2015-11-27 19:31:25 -08:00
committed by Sam Tannous
parent eca54a3e5a
commit 5f8c03e7a1
2 changed files with 17 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ from ifupdownaddons.modulebase import moduleBase
from ifupdownaddons.bridgeutils import brctl from ifupdownaddons.bridgeutils import brctl
from ifupdownaddons.iproute2 import iproute2 from ifupdownaddons.iproute2 import iproute2
from ifupdownaddons.mstpctlutil import mstpctlutil from ifupdownaddons.mstpctlutil import mstpctlutil
import traceback from ifupdownaddons.systemutils import systemUtils
class mstpctlFlags: class mstpctlFlags:
PORT_PROCESSED = 0x1 PORT_PROCESSED = 0x1
@@ -171,6 +171,8 @@ class mstpctl(moduleBase):
self.name = self.__class__.__name__ self.name = self.__class__.__name__
self.brctlcmd = None self.brctlcmd = None
self.mstpctlcmd = None self.mstpctlcmd = None
self.mstpd_running = (True if systemUtils.is_process_running('mstpd')
else False)
def _is_bridge(self, ifaceobj): def _is_bridge(self, ifaceobj):
if (ifaceobj.get_attr_value_first('mstpctl-ports') or if (ifaceobj.get_attr_value_first('mstpctl-ports') or
@@ -371,8 +373,7 @@ class mstpctl(moduleBase):
# Check if bridge port # Check if bridge port
bridgename = self.ipcmd.bridge_port_get_bridge_name(ifaceobj.name) bridgename = self.ipcmd.bridge_port_get_bridge_name(ifaceobj.name)
if bridgename: if bridgename:
mstpd_running = (True if self.mstpctlcmd.is_mstpd_running() mstpd_running = self.mstpd_running
else False)
stp_running_on = self._is_running_userspace_stp_state_on(bridgename) stp_running_on = self._is_running_userspace_stp_state_on(bridgename)
applied = self._apply_bridge_port_settings(ifaceobj, bridgename, applied = self._apply_bridge_port_settings(ifaceobj, bridgename,
None, stp_running_on, None, stp_running_on,
@@ -416,7 +417,7 @@ class mstpctl(moduleBase):
self.brctlcmd.set_stp) self.brctlcmd.set_stp)
else: else:
stp = self.brctlcmd.get_stp(ifaceobj.name) stp = self.brctlcmd.get_stp(ifaceobj.name)
if (self.mstpctlcmd.is_mstpd_running() and if (self.mstpd_running and
(stp == 'yes' or stp == 'on')): (stp == 'yes' or stp == 'on')):
self._apply_bridge_settings(ifaceobj) self._apply_bridge_settings(ifaceobj)
self._apply_bridge_port_settings_all(ifaceobj, self._apply_bridge_port_settings_all(ifaceobj,

View File

@@ -42,3 +42,15 @@ class systemUtils():
# XXX: check for subprocess errors vs os error # XXX: check for subprocess errors vs os error
return False return False
return True return True
@classmethod
def is_process_running(self, processname):
if not processname:
return False
utilsobj = utilsBase()
try:
utilsobj.exec_command('/bin/pidof %s' %processname)
except:
return False
else:
return True