MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / do_interfaces

Function do_interfaces

network_diagnostics.py:677–709  ·  view source on GitHub ↗
(include_virtual=False)

Source from the content-addressed store, hash-verified

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
704def 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.'}

Callers 4

do_ispFunction · 0.85
do_iperf3_serverFunction · 0.85
do_locate_portFunction · 0.85
net_interfacesFunction · 0.85

Calls 8

_list_iface_namesFunction · 0.85
_iface_link_detailsFunction · 0.85
_iface_addrsFunction · 0.85
_iface_vpn_infoFunction · 0.85
_is_wirelessFunction · 0.85
_iface_ethtoolFunction · 0.85
_iface_ip_methodFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected