def find_listen_pids_namespace(namespace):
 ip = ip_lib.IPWrapper(namespace=namespace)
 pids = set()
 cmd = ['netstat', '-nlp']
 output = ip.netns.execute(cmd, run_as_root=True)
 for line in output.splitlines():
  m = NETSTAT_PIDS_REGEX.match(line)
  if m:
   pids.add(m.group('pid'))
 return pids

def find_listen_pids_namespace ( namespace ) : ip = ip_lib . IPWrapper ( namespace = namespace ) pids = set ( ) cmd = [ 'netstat' , '-nlp' ] output = ip . netns . execute ( cmd , run_as_root = True ) for line in output . splitlines ( ) : m = NETSTAT_PIDS_REGEX . match ( line ) if m : pids . add ( m . group ( 'pid' ) ) return pids
retrieve a list of pids of listening processes within the given netns .