def schedule_router(self, plugin, context, r_hd_binding_db):
        candidates = self._filtered_candidates(plugin, context,
                                               r_hd_binding_db)
        if len(candidates) == 0:
            # report unsuccessful scheduling
            return
        # determine oldest candidates considered equally old
        oldest_candidates = []
        minute_limit = timedelta(minutes=EQUIVALENCE_TIME_DIFF)
        for candidate in candidates:
            if candidate[1] - candidates[0][1] < minute_limit:
                oldest_candidates.append(candidate)
            else:
                # we're only interested in the longest running devices
                break
        # sort on least number of used slots
        sorted_candidates = sorted(oldest_candidates, key=itemgetter(2))
        return sorted_candidates[0]
dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/plugins/cisco/l3/schedulers/l3_router_hosting_device_scheduler.py/L3RouterHostingDeviceLongestRunningScheduler.schedule_router/original