def __init__(self, replies_data=None): global _REPLIES _REPLIES = replies_data self._server = socketserver.UnixStreamServer(self._SOCK, CollectdHandler) self._started = threading.Event() self._stopped = threading.Event() self._thread = threading.Thread(target=self.serve) self._thread.daemon = True self._running = False
stdout=subprocess.PIPE) has_names = False try: ver_tuple = re.search(r'\s(\d+)\.(\d+)(\.\d*|\s*$)', ovs_version.stdout.readline().decode()).groups() if int(ver_tuple[0]) > 2 or \ int(ver_tuple[0]) == 2 and int(ver_tuple[1]) >= 8: has_names = True except AttributeError: pass outpath = '../packet_data' socketdir = tempfile.mkdtemp() socketname = os.path.join(socketdir, 'ovs') server = socketserver.UnixStreamServer(socketname, MyVerboseHandler if verbose else MyHandler) if debug or verbose: print("Serving at %s" % socketname) for msg in MESSAGES: bundled = msg.get('bundled', False) for v in msg['versions']: cmdargs = [ofctl_cmd, '-O', 'OpenFlow%2d' % (v + 9)] if verbose: cmdargs.append('-v') if has_names: cmdargs.append('--no-names') if bundled: cmdargs.append('--bundle') cmdargs.append(msg['cmd'])