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:
parent
37021092df
commit
08445e0b18
@ -62,6 +62,7 @@ class P4Switch(Switch):
|
|||||||
thrift_port = None,
|
thrift_port = None,
|
||||||
pcap_dump = False,
|
pcap_dump = False,
|
||||||
log_console = False,
|
log_console = False,
|
||||||
|
log_file = None,
|
||||||
verbose = False,
|
verbose = False,
|
||||||
device_id = None,
|
device_id = None,
|
||||||
enable_debugger = False,
|
enable_debugger = False,
|
||||||
@ -87,6 +88,10 @@ class P4Switch(Switch):
|
|||||||
self.pcap_dump = pcap_dump
|
self.pcap_dump = pcap_dump
|
||||||
self.enable_debugger = enable_debugger
|
self.enable_debugger = enable_debugger
|
||||||
self.log_console = log_console
|
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:
|
if device_id is not None:
|
||||||
self.device_id = device_id
|
self.device_id = device_id
|
||||||
P4Switch.device_id = max(P4Switch.device_id, device_id)
|
P4Switch.device_id = max(P4Switch.device_id, device_id)
|
||||||
@ -119,8 +124,7 @@ class P4Switch(Switch):
|
|||||||
if not intf.IP():
|
if not intf.IP():
|
||||||
args.extend(['-i', str(port) + "@" + intf.name])
|
args.extend(['-i', str(port) + "@" + intf.name])
|
||||||
if self.pcap_dump:
|
if self.pcap_dump:
|
||||||
args.append("--pcap")
|
args.append("--pcap %s" % self.pcap_dump)
|
||||||
# args.append("--useFiles")
|
|
||||||
if self.thrift_port:
|
if self.thrift_port:
|
||||||
args.extend(['--thrift-port', str(self.thrift_port)])
|
args.extend(['--thrift-port', str(self.thrift_port)])
|
||||||
if self.nanomsg:
|
if self.nanomsg:
|
||||||
@ -132,13 +136,12 @@ class P4Switch(Switch):
|
|||||||
args.append("--debugger")
|
args.append("--debugger")
|
||||||
if self.log_console:
|
if self.log_console:
|
||||||
args.append("--log-console")
|
args.append("--log-console")
|
||||||
logfile = "/tmp/p4s.{}.log".format(self.name)
|
|
||||||
info(' '.join(args) + "\n")
|
info(' '.join(args) + "\n")
|
||||||
|
|
||||||
pid = None
|
pid = None
|
||||||
with tempfile.NamedTemporaryFile() as f:
|
with tempfile.NamedTemporaryFile() as f:
|
||||||
# self.cmd(' '.join(args) + ' > /dev/null 2>&1 &')
|
# 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())
|
pid = int(f.read())
|
||||||
debug("P4 switch {} PID is {}.\n".format(self.name, pid))
|
debug("P4 switch {} PID is {}.\n".format(self.name, pid))
|
||||||
if not self.check_switch_started(pid):
|
if not self.check_switch_started(pid):
|
||||||
|
@ -37,6 +37,7 @@ class P4RuntimeSwitch(P4Switch):
|
|||||||
verbose = False,
|
verbose = False,
|
||||||
device_id = None,
|
device_id = None,
|
||||||
enable_debugger = False,
|
enable_debugger = False,
|
||||||
|
log_file = None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
Switch.__init__(self, name, **kwargs)
|
Switch.__init__(self, name, **kwargs)
|
||||||
assert (sw_path)
|
assert (sw_path)
|
||||||
@ -75,6 +76,10 @@ class P4RuntimeSwitch(P4Switch):
|
|||||||
self.pcap_dump = pcap_dump
|
self.pcap_dump = pcap_dump
|
||||||
self.enable_debugger = enable_debugger
|
self.enable_debugger = enable_debugger
|
||||||
self.log_console = log_console
|
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:
|
if device_id is not None:
|
||||||
self.device_id = device_id
|
self.device_id = device_id
|
||||||
P4Switch.device_id = max(P4Switch.device_id, device_id)
|
P4Switch.device_id = max(P4Switch.device_id, device_id)
|
||||||
@ -99,7 +104,7 @@ class P4RuntimeSwitch(P4Switch):
|
|||||||
if not intf.IP():
|
if not intf.IP():
|
||||||
args.extend(['-i', str(port) + "@" + intf.name])
|
args.extend(['-i', str(port) + "@" + intf.name])
|
||||||
if self.pcap_dump:
|
if self.pcap_dump:
|
||||||
args.append("--pcap")
|
args.append("--pcap %s" % self.pcap_dump)
|
||||||
if self.nanomsg:
|
if self.nanomsg:
|
||||||
args.extend(['--nanolog', self.nanomsg])
|
args.extend(['--nanolog', self.nanomsg])
|
||||||
args.extend(['--device-id', str(self.device_id)])
|
args.extend(['--device-id', str(self.device_id)])
|
||||||
@ -119,10 +124,10 @@ class P4RuntimeSwitch(P4Switch):
|
|||||||
cmd = ' '.join(args)
|
cmd = ' '.join(args)
|
||||||
info(cmd + "\n")
|
info(cmd + "\n")
|
||||||
|
|
||||||
logfile = "/tmp/p4s.{}.log".format(self.name)
|
|
||||||
pid = None
|
pid = None
|
||||||
with tempfile.NamedTemporaryFile() as f:
|
with tempfile.NamedTemporaryFile() as f:
|
||||||
self.cmd(cmd + ' >' + logfile + ' 2>&1 & echo $! >> ' + f.name)
|
self.cmd(cmd + ' >' + self.log_file + ' 2>&1 & echo $! >> ' + f.name)
|
||||||
pid = int(f.read())
|
pid = int(f.read())
|
||||||
debug("P4 switch {} PID is {}.\n".format(self.name, pid))
|
debug("P4 switch {} PID is {}.\n".format(self.name, pid))
|
||||||
if not self.check_switch_started(pid):
|
if not self.check_switch_started(pid):
|
||||||
|
@ -357,7 +357,7 @@ class ExerciseRunner:
|
|||||||
print('Welcome to the BMV2 Mininet CLI!')
|
print('Welcome to the BMV2 Mininet CLI!')
|
||||||
print('======================================================================')
|
print('======================================================================')
|
||||||
print('Your P4 program is installed into the BMV2 software switch')
|
print('Your P4 program is installed into the BMV2 software switch')
|
||||||
print('and your initial configuration is loaded. You can interact')
|
print('and your initial runtime configuration is loaded. You can interact')
|
||||||
print('with the network using the mininet CLI below.')
|
print('with the network using the mininet CLI below.')
|
||||||
print('')
|
print('')
|
||||||
if self.switch_json:
|
if self.switch_json:
|
||||||
@ -371,6 +371,11 @@ class ExerciseRunner:
|
|||||||
print('To view the switch output pcap, check the pcap files in %s:' % self.pcap_dir)
|
print('To view the switch output pcap, check the pcap files in %s:' % self.pcap_dir)
|
||||||
print(' for example run: sudo tcpdump -xxx -r s1-eth1.pcap')
|
print(' for example run: sudo tcpdump -xxx -r s1-eth1.pcap')
|
||||||
print('')
|
print('')
|
||||||
|
if 'grpc' in self.bmv2_exe:
|
||||||
|
print('To view the P4Runtime requests sent to the switch, check the')
|
||||||
|
print('corresponding txt file in %s:' % self.log_dir)
|
||||||
|
print(' for example run: cat %s/s1-p4runtime-requests.txt' % self.log_dir)
|
||||||
|
print('')
|
||||||
|
|
||||||
CLI(self.net)
|
CLI(self.net)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user