def _load_existing_mappings(self):
"""Load the existing ARP records for this box from the db.
Returns:
A deferred whose result is a dictionary: { (ip, mac): arpid }
"""
self._logger.debug("Loading open arp records from database")
open_arp_records_queryset = manage.Arp.objects.filter(
netbox__id=self.netbox.id,
end_time__gte=datetime.max).values('id', 'ip', 'mac')
open_arp_records = yield db.run_in_thread(
storage.shadowify_queryset_and_commit,
open_arp_records_queryset)
self._logger.debug("Loaded %d open records from arp",
len(open_arp_records))
open_mappings = dict(((IP(arp['ip']), arp['mac']), arp['id'])
for arp in open_arp_records)
defer.returnValue(open_mappings)
评论列表
文章目录