mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: vrf: drop ssh connections over eth0 on enable or disable
Ticket: CM-9881 Reviewed By: Roopa Prabhu Testing Done: yes This patch is the second version of drop ssh sessions changes: added try catch around os.setsid() Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
import errno
|
||||||
import subprocess
|
import subprocess
|
||||||
import atexit
|
import atexit
|
||||||
from ifupdown.iface import *
|
from ifupdown.iface import *
|
||||||
@@ -269,12 +270,10 @@ class vrf(moduleBase):
|
|||||||
|
|
||||||
def _up_vrf_slave(self, ifacename, vrfname, ifaceobj=None,
|
def _up_vrf_slave(self, ifacename, vrfname, ifaceobj=None,
|
||||||
ifaceobj_getfunc=None, vrf_exists=False):
|
ifaceobj_getfunc=None, vrf_exists=False):
|
||||||
self.logger.info("Roopa: ifacename = %s, vrfname = %s\n" %(ifacename, vrfname))
|
|
||||||
try:
|
try:
|
||||||
if vrf_exists or self.ipcmd.link_exists(vrfname):
|
if vrf_exists or self.ipcmd.link_exists(vrfname):
|
||||||
upper = self.ipcmd.link_get_upper(ifacename)
|
upper = self.ipcmd.link_get_upper(ifacename)
|
||||||
if not upper or upper != vrfname:
|
if not upper or upper != vrfname:
|
||||||
self.logger.info("Roopa: vrfname = %s\n" %vrfname)
|
|
||||||
if ifaceobj and vrfname == 'mgmt':
|
if ifaceobj and vrfname == 'mgmt':
|
||||||
self._kill_ssh(ifaceobj.name)
|
self._kill_ssh(ifaceobj.name)
|
||||||
if ifaceobj and self._is_dhcp_slave(ifaceobj):
|
if ifaceobj and self._is_dhcp_slave(ifaceobj):
|
||||||
@@ -570,7 +569,6 @@ class vrf(moduleBase):
|
|||||||
shell=False).split()[2]
|
shell=False).split()[2]
|
||||||
self.logger.info("%s: killing active ssh sessions: %s"
|
self.logger.info("%s: killing active ssh sessions: %s"
|
||||||
%(ifacename, str(proc)))
|
%(ifacename, str(proc)))
|
||||||
os.setsid()
|
|
||||||
for id in proc:
|
for id in proc:
|
||||||
if id != pid:
|
if id != pid:
|
||||||
try:
|
try:
|
||||||
@@ -578,6 +576,11 @@ class vrf(moduleBase):
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
continue
|
continue
|
||||||
if pid in proc:
|
if pid in proc:
|
||||||
|
try:
|
||||||
|
os.setsid()
|
||||||
|
except OSError, (err_no, err_message):
|
||||||
|
self.logger.info("os.setsid failed: errno=%d: %s" % (err_no, err_message))
|
||||||
|
self.logger.info("pid=%d pgid=%d" % (os.getpid(), os.getpgid(0)))
|
||||||
try:
|
try:
|
||||||
self.logger.info("%s: killing our session: %s"
|
self.logger.info("%s: killing our session: %s"
|
||||||
%(ifacename, str(proc)))
|
%(ifacename, str(proc)))
|
||||||
|
Reference in New Issue
Block a user