Fixed location of pcaps and bmv2 logs (#161)
* Fixed location of pcaps and bmv2 logs Also added reference to P4Runtime request logs to welcome message * Fixed pcap/log location for Thrift/CLI-based switch class
This commit is contained in:
committed by
Nate Foster
parent
37021092df
commit
08445e0b18
@@ -62,6 +62,7 @@ class P4Switch(Switch):
|
||||
thrift_port = None,
|
||||
pcap_dump = False,
|
||||
log_console = False,
|
||||
log_file = None,
|
||||
verbose = False,
|
||||
device_id = None,
|
||||
enable_debugger = False,
|
||||
@@ -87,6 +88,10 @@ class P4Switch(Switch):
|
||||
self.pcap_dump = pcap_dump
|
||||
self.enable_debugger = enable_debugger
|
||||
self.log_console = log_console
|
||||
if log_file is not None:
|
||||
self.log_file = log_file
|
||||
else:
|
||||
self.log_file = "/tmp/p4s.{}.log".format(self.name)
|
||||
if device_id is not None:
|
||||
self.device_id = device_id
|
||||
P4Switch.device_id = max(P4Switch.device_id, device_id)
|
||||
@@ -119,8 +124,7 @@ class P4Switch(Switch):
|
||||
if not intf.IP():
|
||||
args.extend(['-i', str(port) + "@" + intf.name])
|
||||
if self.pcap_dump:
|
||||
args.append("--pcap")
|
||||
# args.append("--useFiles")
|
||||
args.append("--pcap %s" % self.pcap_dump)
|
||||
if self.thrift_port:
|
||||
args.extend(['--thrift-port', str(self.thrift_port)])
|
||||
if self.nanomsg:
|
||||
@@ -132,13 +136,12 @@ class P4Switch(Switch):
|
||||
args.append("--debugger")
|
||||
if self.log_console:
|
||||
args.append("--log-console")
|
||||
logfile = "/tmp/p4s.{}.log".format(self.name)
|
||||
info(' '.join(args) + "\n")
|
||||
|
||||
pid = None
|
||||
with tempfile.NamedTemporaryFile() as f:
|
||||
# self.cmd(' '.join(args) + ' > /dev/null 2>&1 &')
|
||||
self.cmd(' '.join(args) + ' >' + logfile + ' 2>&1 & echo $! >> ' + f.name)
|
||||
self.cmd(' '.join(args) + ' >' + self.log_file + ' 2>&1 & echo $! >> ' + f.name)
|
||||
pid = int(f.read())
|
||||
debug("P4 switch {} PID is {}.\n".format(self.name, pid))
|
||||
if not self.check_switch_started(pid):
|
||||
|
||||
Reference in New Issue
Block a user