Esempio n. 1
0
    def queryRecursive(self,
                       header,
                       connection_ids,
                       global_reservation_ids=None):

        self._checkHeader(header)

        header_element = helper.createProviderHeader(
            header.requester_nsa,
            header.provider_nsa,
            reply_to=self.reply_to,
            correlation_id=header.correlation_id,
            security_attributes=header.security_attributes,
            connection_trace=header.connection_trace)

        query_type = nsiconnection.QueryType(connection_ids,
                                             global_reservation_ids)
        body_element = query_type.xml(nsiconnection.queryRecursive)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(self.service_url,
                                   actions.QUERY_RECURSIVE,
                                   payload,
                                   ctx_factory=self.ctx_factory,
                                   headers=self.http_headers)
        d.addCallbacks(lambda sd: None,
                       self._handleErrorReply,
                       errbackArgs=(header, ))
        return d
Esempio n. 2
0
    def querySummarySync(self,
                         header,
                         connection_ids=None,
                         global_reservation_ids=None):
        def gotReply(soap_data):
            header, query_confirmed = helper.parseRequest(soap_data)
            return [
                queryhelper.buildQueryResult(resv, header.provider_nsa)
                for resv in query_confirmed.reservations
            ]

        # don't need to check header here
        header_element = helper.createProviderHeader(
            header.requester_nsa,
            header.provider_nsa,
            reply_to=self.reply_to,
            correlation_id=header.correlation_id,
            security_attributes=header.security_attributes,
            connection_trace=header.connection_trace)

        query_type = nsiconnection.QueryType(connection_ids,
                                             global_reservation_ids)
        body_element = query_type.xml(nsiconnection.querySummarySync)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(self.service_url,
                                   actions.QUERY_SUMMARY_SYNC,
                                   payload,
                                   ctx_factory=self.ctx_factory,
                                   headers=self.http_headers)
        d.addCallbacks(gotReply,
                       self._handleErrorReply,
                       errbackArgs=(header, ))
        return d
Esempio n. 3
0
    def _createGenericRequestType(self, body_element_name, header, connection_id):

        header_element = helper.createProviderHeader(header.requester_nsa, header.provider_nsa, self.reply_to, header.correlation_id,
                                                     header.security_attributes, header.connection_trace)

        body_element = nsiconnection.GenericRequestType(connection_id).xml(body_element_name)

        payload = minisoap.createSoapPayload(body_element, header_element)
        return payload
Esempio n. 4
0
        def createReserveAcknowledgement(connection_id):
            # no reply to / security attrs / trace
            soap_header_element = helper.createProviderHeader(header.requester_nsa, header.provider_nsa, None, header.correlation_id)

            reserve_response = nsiconnection.ReserveResponseType(connection_id)
            reserve_response_element = reserve_response.xml(nsiconnection.reserveResponse)

            payload = minisoap.createSoapPayload(reserve_response_element, soap_header_element)
            return payload
Esempio n. 5
0
        def gotReservations(reservations, header):
            # do reply inline
            soap_header_element = helper.createProviderHeader(header.requester_nsa, header.provider_nsa, correlation_id=header.correlation_id)

            qs_reservations = queryhelper.buildQuerySummaryResultType(reservations)

            qsct = nsiconnection.QuerySummaryConfirmedType(qs_reservations)

            payload = minisoap.createSoapPayload(qsct.xml(nsiconnection.querySummarySyncConfirmed), soap_header_element)
            return payload
Esempio n. 6
0
        def createReserveAcknowledgement(connection_id):
            # no reply to / security attrs / trace
            soap_header_element = helper.createProviderHeader(
                header.requester_nsa, header.provider_nsa, None,
                header.correlation_id)

            reserve_response = nsiconnection.ReserveResponseType(connection_id)
            reserve_response_element = reserve_response.xml(
                nsiconnection.reserveResponse)

            payload = minisoap.createSoapPayload(reserve_response_element,
                                                 soap_header_element)
            return payload
Esempio n. 7
0
    def _createGenericRequestType(self, body_element_name, header,
                                  connection_id):

        header_element = helper.createProviderHeader(
            header.requester_nsa, header.provider_nsa, self.reply_to,
            header.correlation_id, header.security_attributes,
            header.connection_trace)

        body_element = nsiconnection.GenericRequestType(connection_id).xml(
            body_element_name)

        payload = minisoap.createSoapPayload(body_element, header_element)
        return payload
Esempio n. 8
0
    def queryRecursive(self, header, connection_ids, global_reservation_ids=None):

        self._checkHeader(header)

        header_element = helper.createProviderHeader(header.requester_nsa, header.provider_nsa, reply_to=self.reply_to, correlation_id=header.correlation_id,
                                                     security_attributes=header.security_attributes, connection_trace=header.connection_trace)

        query_type = nsiconnection.QueryType(connection_ids, global_reservation_ids)
        body_element = query_type.xml(nsiconnection.queryRecursive)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(self.service_url, actions.QUERY_RECURSIVE, payload, ctx_factory=self.ctx_factory, headers=self.http_headers)
        d.addCallbacks(lambda sd : None, self._handleErrorReply, errbackArgs=(header,))
        return d
Esempio n. 9
0
        def gotReservations(reservations, header):
            # do reply inline
            soap_header_element = helper.createProviderHeader(
                header.requester_nsa,
                header.provider_nsa,
                correlation_id=header.correlation_id)

            qs_reservations = queryhelper.buildQuerySummaryResultType(
                reservations)

            qsct = nsiconnection.QuerySummaryConfirmedType(qs_reservations)

            payload = minisoap.createSoapPayload(
                qsct.xml(nsiconnection.querySummarySyncConfirmed),
                soap_header_element)
            return payload
Esempio n. 10
0
    def reserve(self, header, connection_id, global_reservation_id, description, criteria):

        self._checkHeader(header)

        # payload construction

        header_element = helper.createProviderHeader(header.requester_nsa, header.provider_nsa, self.reply_to, header.correlation_id,
                                                     header.security_attributes, header.connection_trace)

        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=tzutc()).isoformat()
        else:
            start_time = None

        assert schedule.end_time.tzinfo is None, 'End time must NOT have time zone'
        end_time = schedule.end_time.replace(tzinfo=tzutc()).isoformat()

        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
Esempio n. 11
0
    def querySummarySync(self, header, connection_ids=None, global_reservation_ids=None):

        def gotReply(soap_data):
            header, query_confirmed = helper.parseRequest(soap_data)
            return [ queryhelper.buildQueryResult(resv, header.provider_nsa) for resv in query_confirmed.reservations ]

        # don't need to check header here
        header_element = helper.createProviderHeader(header.requester_nsa, header.provider_nsa, reply_to=self.reply_to, correlation_id=header.correlation_id,
                                                     security_attributes=header.security_attributes, connection_trace=header.connection_trace)

        query_type = nsiconnection.QueryType(connection_ids, global_reservation_ids)
        body_element = query_type.xml(nsiconnection.querySummarySync)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(self.service_url, actions.QUERY_SUMMARY_SYNC, payload, ctx_factory=self.ctx_factory, headers=self.http_headers)
        d.addCallbacks(gotReply, self._handleErrorReply, errbackArgs=(header,))
        return d
Esempio n. 12
0
    def reserve(self, header, connection_id, global_reservation_id,
                description, criteria):

        self._checkHeader(header)

        # payload construction

        header_element = helper.createProviderHeader(
            header.requester_nsa, header.provider_nsa, self.reply_to,
            header.correlation_id, header.security_attributes,
            header.connection_trace)

        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=tzutc()).isoformat()
        else:
            start_time = None

        assert schedule.end_time.tzinfo is None, 'End time must NOT have time zone'
        end_time = schedule.end_time.replace(tzinfo=tzutc()).isoformat()

        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