How do you access aggregated results from tasks?

Hi Folks,

Can anyone elaborate, perhaps with some examples on how to access results from tasks?
Through trial and error I’ve discovered the below works, but would be great if anyone could expand on exactly what’s going on with the task result objects. For example when trying to access task results directly i usually get an undescriptable error, I suppose this is by design and is part of the nature of the nornir result object?

for host, task_results in lldpneighbors.items():
#Store results from Nornir aggregated result object?
lldp_result = task_results[1].result
#store actual result dicitonary from the Nornir result object?
lldp_detail = lldp_result[‘lldp_neighbors_detail’]

for interface in lldp_detail:
    remotesysid = lldp_detail[interface][0]['remote_chassis_id']
    #and so on

Is there a cleaner way to access results after tasks have been run or do so by hostname as shown here with the task.hostp’config’] ?


I’m not sure how much cleaner mine is, but this is what I’ve been doing to dig down into specific info. This is just a means of extracting the model/manufacturer from facts and updating an empty dictionary:

device_types = {}
facts = = napalm_get, getters = ['facts'])
for dev in facts:
    model = facts[dev].result['facts']['model']
    manufacturer = facts[dev].result['facts']['vendor']
    device_types.update({model: manufacturer})

It just iterates through each device’s results, and I peel the info as needed.

Thanks! this is what I ended up doing and it works well for my needs.