@defer.inlineCallbacks
    def querySummary(self, header, connection_ids=None, global_reservation_ids=None, request_info=None):

        log.msg('QuerySummary request from %s. CID: %s. GID: %s' % (header.requester_nsa, connection_ids, global_reservation_ids), system=LOG_SYSTEM)

        try:
            if connection_ids:
                conns = yield database.ServiceConnection.find(where=['requester_nsa = ? AND connection_id IN ?', header.requester_nsa, tuple(connection_ids) ] )
            elif global_reservation_ids:
                conns = yield database.ServiceConnection.find(where=['requester_nsa = ? AND global_reservation_ids IN ?', header.requester_nsa, tuple(global_reservation_ids) ] )
            else:
                conns = yield database.ServiceConnection.find(where=['requester_nsa = ?', header.requester_nsa ] )

            # largely copied from genericbackend, merge later
            reservations = []
            for c in conns:

                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)

                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 = 0

                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)
                reservations.append(ci)

            self.parent_requester.querySummaryConfirmed(header, reservations)

        except Exception as e:
            log.msg('Error during querySummary request: %s' % str(e), system=LOG_SYSTEM)
            raise e
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/aggregator.py/Aggregator.querySummary/original