(include_virtual=False)
| 675 | ch_name, ch = _first_key(chassis) if isinstance(chassis, dict) and 'id' not in chassis else (None, chassis) |
| 676 | if ch_name is None and isinstance(chassis, dict): |
| 677 | ch = chassis |
| 678 | port = info.get('port', {}) |
| 679 | vlan = info.get('vlan', {}) |
| 680 | vlan_id = None |
| 681 | vlan_name = None |
| 682 | if isinstance(vlan, list) and vlan: |
| 683 | vlan = vlan[0] |
| 684 | if isinstance(vlan, dict): |
| 685 | vlan_id = vlan.get('vlan-id') or vlan.get('vlan_id') or _scalar(vlan) |
| 686 | vlan_name = vlan.get('value') if isinstance(vlan.get('value'), str) else None |
| 687 | mgmt = ch.get('mgmt-ip') if isinstance(ch, dict) else None |
| 688 | if isinstance(mgmt, list): |
| 689 | mgmt = ', '.join(str(x) for x in mgmt) |
| 690 | return { |
| 691 | 'local_interface': local_if, |
| 692 | 'protocol': via, |
| 693 | 'switch_name': ch_name or (_scalar(ch.get('name')) if isinstance(ch, dict) else None), |
| 694 | 'switch_descr': _scalar(ch.get('descr')) if isinstance(ch, dict) else None, |
| 695 | 'mgmt_ip': mgmt, |
| 696 | 'port_id': _scalar(port.get('id')) if isinstance(port, dict) else None, |
| 697 | 'port_descr': _scalar(port.get('descr')) if isinstance(port, dict) else None, |
| 698 | 'vlan_id': vlan_id, |
| 699 | 'vlan_name': vlan_name, |
| 700 | 'poe': _parse_poe(port), |
| 701 | } |
| 702 | |
| 703 | |
| 704 | def do_arp_scan(interface=None): |
| 705 | if not _have('arp-scan'): |
| 706 | return {'success': False, |
| 707 | 'error': 'arp-scan is not installed. Click Install to add it.', |
| 708 | 'missing_tool': 'arp-scan', 'hosts': []} |
| 709 | interface = _capture_iface(interface) |
| 710 | if not interface: |
| 711 | return {'success': False, 'hosts': [], |
| 712 | 'error': 'No suitable interface found — pick one explicitly.'} |
no test coverage detected