def device_setup(hostname, data, env_vars, que): device = Router(hostname=hostname, mgmt_ip=data['mgmt'], vendor=data['vendor'], os=data['os']) for name, interface in data['interfaces'].items(): device.add_interface(name=name, ip=ipaddress.IPv4Interface(interface['ipaddr']), description=interface['description'], status=interface['state']) # BGP all_neighbors = [] for neighbor in data['bgp']['neighbors']: all_neighbors.append((neighbor['ipaddr'], neighbor['remote_asn'])) redistribute_options = [] if 'redistribute' in data['bgp']: for option in data['bgp']['redistribute']: redistribute_options.append(option) device.add_bgp(rid=data['bgp']['rid'], asn=data['bgp']['asn'], redistribute=redistribute_options, neighbors=all_neighbors) open_device = connect_to_device(device, env_vars) que.put((device, open_device))