Report sandbox DHCP diagnostics
This commit is contained in:
parent
61ee7be54e
commit
6bbc7ca72f
|
|
@ -52,6 +52,26 @@ def peer_probe(source, own_ip, peer_ip):
|
|||
return 'inconclusive: peer ping failed to execute'
|
||||
|
||||
|
||||
def client_address(guest, network):
|
||||
output = run('pct', 'exec', str(guest), '--', 'ip', '-4', 'addr', 'show', 'dev', 'eth0')
|
||||
try:
|
||||
return address_from_output(output, network)
|
||||
except RuntimeError as exc:
|
||||
print(f'Client {guest} address check: {exc}', file=sys.stderr)
|
||||
print('Interface state:', file=sys.stderr)
|
||||
print(output[:2000], file=sys.stderr)
|
||||
diagnostic = subprocess.run(
|
||||
['pct', 'exec', str(guest), '--', 'sh', '-c',
|
||||
"printf '%s\\n' '-- network configuration'; "
|
||||
"if [ -f /etc/network/interfaces ]; then cat /etc/network/interfaces; else echo 'No /etc/network/interfaces'; fi; "
|
||||
"printf '%s\\n' '-- DHCP processes'; ps | grep '[u]dhcpc' || true"],
|
||||
capture_output=True, text=True, timeout=20)
|
||||
print(diagnostic.stdout[:3000], file=sys.stderr)
|
||||
if diagnostic.returncode:
|
||||
print(f'Client diagnostics exit: {diagnostic.returncode}', file=sys.stderr)
|
||||
raise
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
for command, guest in (('qm', 9100), ('pct', 9110), ('pct', 9111)):
|
||||
|
|
@ -80,8 +100,8 @@ def main():
|
|||
raise RuntimeError(f'{port} has an unexpected sandbox VLAN')
|
||||
ports[port] = sorted(ids)
|
||||
addresses = {
|
||||
9110: address_from_output(run('pct', 'exec', '9110', '--', 'ip', '-4', 'addr', 'show', 'dev', 'eth0'), '172.29.210.0/24'),
|
||||
9111: address_from_output(run('pct', 'exec', '9111', '--', 'ip', '-4', 'addr', 'show', 'dev', 'eth0'), '172.29.220.0/24'),
|
||||
9110: client_address(9110, '172.29.210.0/24'),
|
||||
9111: client_address(9111, '172.29.220.0/24'),
|
||||
}
|
||||
probes = {
|
||||
'vlan10_to_vlan20': peer_probe(9110, addresses[9110], addresses[9111]),
|
||||
|
|
|
|||
Loading…
Reference in New Issue