def buildQuerySummaryResultType(connection_infos): query_results = [] for ci in connection_infos: criterias = [] for crit in ci.criterias: sched_start_time = createXMLTime( crit.schedule.start_time ) if crit.schedule.start_time is not None else None sched_end_time = createXMLTime( crit.schedule.end_time ) if crit.schedule.end_time is not None else None schedule = nsiconnection.ScheduleType(sched_start_time, sched_end_time) service_type = cnt.EVTS_AGOLE service_def = buildServiceDefinitionType(crit.service_def) children = [] criteria = nsiconnection.QuerySummaryResultCriteriaType( crit.revision, schedule, service_type, children, service_def) criterias.append(criteria) connection_states = buildConnectionStatesType(ci.states) qsrt = nsiconnection.QuerySummaryResultType( ci.connection_id, ci.global_reservation_id, ci.description, criterias, ci.requester_nsa, connection_states, ci.notification_id, ci.result_id) query_results.append(qsrt) return query_results
def buildQueryRecursiveResultType(reservations): def buildQueryRecursiveResultCriteriaType(criteria): assert type( criteria ) is nsa.QueryCriteria, 'Wrong criteria type for buildQueryRecursiveResultCriteriaType: %s' % ( str(criteria)) # handle optional start / end time start_time = createXMLTime( criteria.schedule.start_time ) if criteria.schedule.start_time is not None else None end_time = createXMLTime( criteria.schedule.end_time ) if criteria.schedule.end_time is not None else None schedule = nsiconnection.ScheduleType(start_time, end_time) service_type = str( p2pservices.p2ps ) # we need this to have the bindings working properly service_def = buildServiceDefinitionType(criteria.service_def) crts = [] for idx, child in enumerate(criteria.children): assert type( child ) is nsa.ConnectionInfo, 'Invalid child criteria type for buildQueryRecursiveResultCriteriaType: %s' % str( type(child)) sub_states = buildConnectionStatesType(child.states) sub_qrrct = [ buildQueryRecursiveResultCriteriaType(sc) for sc in child.criterias ] crt = nsiconnection.ChildRecursiveType(idx, child.connection_id, child.provider_nsa, sub_states, sub_qrrct) crts.append(crt) qrrct = nsiconnection.QueryRecursiveResultCriteriaType( criteria.revision, schedule, service_type, crts, service_def) return qrrct query_results = [] for ci in reservations: criterias = [ buildQueryRecursiveResultCriteriaType(c) for c in ci.criterias ] connection_states = buildConnectionStatesType(ci.states) qsrt = nsiconnection.QuerySummaryResultType( ci.connection_id, ci.global_reservation_id, ci.description, criterias, ci.requester_nsa, connection_states, ci.notification_id, ci.result_id) query_results.append(qsrt) return query_results