Beispiel #1
0
    def reserveConfirmed(self, nsi_header, connection_id, global_reservation_id, description, criteria):

        header_element = helper.createRequesterHeader(nsi_header.requester_nsa, nsi_header.provider_nsa, correlation_id=nsi_header.correlation_id)

        schedule = nsiconnection.ScheduleType(
            xmlhelper.createXMLTime(criteria.schedule.start_time) if criteria.schedule.start_time is not None else None,
            xmlhelper.createXMLTime(criteria.schedule.end_time)   if criteria.schedule.end_time   is not None else None
        )

        sd = criteria.service_def

        # we only support p2p for now
        p2p = p2pservices.P2PServiceBaseType(sd.capacity, sd.directionality, sd.symmetric, sd.source_stp.urn(), sd.dest_stp.urn(), None, [])

        criteria = nsiconnection.ReservationConfirmCriteriaType(criteria.revision, schedule, cnt.EVTS_AGOLE, str(p2pservices.p2ps), p2p)

        reserve_conf = nsiconnection.ReserveConfirmedType(connection_id, global_reservation_id, description, criteria)

        body_element = reserve_conf.xml(nsiconnection.reserveConfirmed)
        payload = minisoap.createSoapPayload(body_element, header_element)

        def gotReply(data):
            # we don't really do anything about these
            return ""

        d = httpclient.soapRequest(nsi_header.reply_to, actions.RESERVE_CONFIRMED, payload, ctx_factory=self.ctx_factory)
        d.addCallbacks(gotReply) #, errReply)
        return d
Beispiel #2
0
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
Beispiel #3
0
    def reserve(self, header, connection_id, global_reservation_id, description, criteria, request_info=None):
        # request_info is local only, so it isn't used

        self._checkHeader(header)

        # payload construction
        header_element = helper.convertProviderHeader(header, self.reply_to)

        schedule = criteria.schedule
        sd = criteria.service_def

        if schedule.start_time is not None:
            assert schedule.start_time.tzinfo is None, 'Start time must NOT have time zone'
            start_time = schedule.start_time.replace(tzinfo=UTC()).isoformat()
        else:
            start_time = None

        if schedule.end_time is not None:
            assert schedule.end_time.tzinfo is None, 'End time must NOT have time zone'
            end_time = schedule.end_time.replace(tzinfo=UTC()).isoformat()
        else:
            end_time = None

        if not type(sd) is nsa.Point2PointService:
            raise ValueError('Cannot create request for service definition of type %s' % str(type(sd)))

        params = [p2pservices.TypeValueType(p[0], p[1]) for p in sd.parameters] if sd.parameters else None
        service_def = p2pservices.P2PServiceBaseType(sd.capacity, sd.directionality, sd.symmetric, sd.source_stp.urn(),
                                                     sd.dest_stp.urn(), sd.ero, params)

        schedule_type = nsiconnection.ScheduleType(start_time, end_time)

        # service_type = str(p2pservices.p2ps)
        service_type = 'http://services.ogf.org/nsi/2013/12/descriptions/EVTS.A-GOLE'
        criteria = nsiconnection.ReservationRequestCriteriaType(criteria.revision, schedule_type, service_type,
                                                                service_def)

        reservation = nsiconnection.ReserveType(connection_id, global_reservation_id, description, criteria)

        body_payload = reservation.xml(nsiconnection.reserve)
        payload = minisoap.createSoapPayload(body_payload, header_element)

        def _handleAck(soap_data):
            header, ack = helper.parseRequest(soap_data)
            return ack.connectionId

        d = httpclient.soapRequest(self.service_url, actions.RESERVE, payload, ctx_factory=self.ctx_factory,
                                   headers=self.http_headers)
        d.addCallbacks(_handleAck, self._handleErrorReply, errbackArgs=(header,))
        return d
Beispiel #4
0
    def buildQueryRecursiveResultCriteriaType(criteria):
        assert type(criteria) is nsa.QueryCriteria, 'Wrong criteria type for buildQueryRecursiveResultCriteriaType: %s' % (str(criteria))

        schedule = nsiconnection.ScheduleType(createXMLTime(criteria.schedule.start_time), createXMLTime(criteria.schedule.end_time))
        #service_type, service_def = buildServiceDefinition(criteria.service_def)
        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