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 buildServiceDefinitionType(service_def):
    if type(service_def) is nsa.Point2PointService:
        sd = service_def
        p2ps = p2pservices.P2PServiceBaseType(sd.capacity, sd.directionality, sd.symmetric, sd.source_stp.urn(), sd.dest_stp.urn(), None, [])
        return p2ps
    else:
        log.msg('Cannot build query service definition for %s (not P2PService)' % str(service_def), system=LOG_SYSTEM)
        return None
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