@defer.inlineCallbacks
    def queryRecursiveConfirmed(self, header, sub_result):

        @defer.inlineCallbacks
        def createCQR(conn, children=None):
            # can we make this generic?
            c = conn

            source_stp = nsa.STP(c.source_network, c.source_port, c.source_label)
            dest_stp = nsa.STP(c.dest_network, c.dest_port, c.dest_label)

            schedule = nsa.Schedule(c.start_time, c.end_time)
            sd = nsa.Point2PointService(source_stp, dest_stp, c.bandwidth, cnt.BIDIRECTIONAL, False, None)

            criteria = nsa.QueryCriteria(c.revision, schedule, sd, children)

            sub_conns = yield self.getSubConnectionsByConnectionKey(c.id)
            if len(sub_conns) == 0: # apparently this can happen
                data_plane_status = (False, 0, False)
            else:
                aggr_active     = all( [ sc.data_plane_active     for sc in sub_conns ] )
                aggr_version    = max( [ sc.data_plane_version    for sc in sub_conns ] ) or 0 # can be None otherwise
                aggr_consistent = all( [ sc.data_plane_consistent for sc in sub_conns ] )
                data_plane_status = (aggr_active, aggr_version, aggr_consistent)

            states = (c.reservation_state, c.provision_state, c.lifecycle_state, data_plane_status)
            notification_id = self.getNotificationId()
            result_id = notification_id

            ci = nsa.ConnectionInfo(c.connection_id, c.global_reservation_id, c.description, cnt.EVTS_AGOLE, [ criteria ],
                                    self.nsa_.urn(), c.requester_nsa, states, notification_id, result_id)
            defer.returnValue(ci)

        # ---

        log.msg('queryRecursiveConfirmed from %s.' % (header.provider_nsa,), system=LOG_SYSTEM)

        if not header.correlation_id in self.query_calls:
            log.msg('queryRecursiveConfirmed could not match correlation id %s' % header.correlation_id, system=LOG_SYSTEM)
            return

        cbh_correlation_id, res = self.query_calls[header.correlation_id]
        if res:
            log.msg('queryRecursiveConfirmed : Already have result for correlation id %s' % header.correlation_id, system=LOG_SYSTEM)
            return

        # update temporary result structure

        self.query_calls[header.correlation_id] = cbh_correlation_id, sub_result

        # done updating

        # check if all sub results have been received
        cb_header, conn, count = self.query_requests[cbh_correlation_id]
        scr = [ res[0] for cbhci, res in self.query_calls.values() if res and cbhci == cbh_correlation_id ]

        if len(scr) == count:
            # all results back, can emit

            # clear temporary structure
            self.query_requests.pop(cbh_correlation_id)
            for k,v in self.query_calls.items():
                cbhci, res = v
                if cbhci == cbh_correlation_id:
                    self.query_calls.pop(k)

            log.msg('QueryRecursive : Emitting to parent requester', system=LOG_SYSTEM)
            results = yield createCQR(conn, scr)
            self.parent_requester.queryRecursiveConfirmed(cb_header, [ results ] )

        else:
            log.msg('QueryRecursive : Still neeed %i/%i results to emit result' % (len(scr)-count, count), system=LOG_SYSTEM)
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/aggregator.py/Aggregator.queryRecursiveConfirmed/swapped operands of `-`