Example #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
Example #2
0
    def reserveTimeout(
        self,
        requester_url,
        requester_nsa,
        provider_nsa,
        correlation_id,
        connection_id,
        notification_id,
        timestamp,
        timeout_value,
        originating_connection_id,
        originating_nsa,
    ):

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

        reserve_timeout = nsiconnection.ReserveTimeoutRequestType(
            connection_id,
            notification_id,
            xmlhelper.createXMLTime(timestamp),
            timeout_value,
            originating_connection_id,
            originating_nsa,
        )

        body_element = reserve_timeout.xml(nsiconnection.reserveTimeout)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(requester_url, actions.RESERVE_TIMEOUT, payload, ctx_factory=self.ctx_factory)
        return d
Example #3
0
    def dataPlaneStateChange(
        self,
        requester_url,
        requester_nsa,
        provider_nsa,
        correlation_id,
        connection_id,
        notification_id,
        timestamp,
        active,
        version,
        consistent,
    ):

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

        data_plane_status = nsiconnection.DataPlaneStatusType(active, version, consistent)
        dps = nsiconnection.DataPlaneStateChangeRequestType(
            connection_id, notification_id, xmlhelper.createXMLTime(timestamp), data_plane_status
        )

        body_element = dps.xml(nsiconnection.dataPlaneStateChange)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(
            requester_url, actions.DATA_PLANE_STATE_CHANGE, payload, ctx_factory=self.ctx_factory
        )
        return d
Example #4
0
    def _createGenericRequestType(self, body_element_name, header, connection_id):

        header_element = helper.convertProviderHeader(header, self.reply_to)
        body_element = nsiconnection.GenericRequestType(connection_id).xml(body_element_name)

        payload = minisoap.createSoapPayload(body_element, header_element)
        return payload
Example #5
0
    def _createGenericRequestType(self, body_element_name, header, connection_id):

        header_element = helper.createHeader(header.requester_nsa, header.provider_nsa, reply_to=self.reply_to, correlation_id=header.correlation_id)
        body_element = nsiconnection.GenericRequestType(connection_id).xml(body_element_name)

        payload = minisoap.createSoapPayload(body_element, header_element)
        return payload
Example #6
0
        def createReserveAcknowledgement(connection_id):
            soap_header = nsiframework.CommonHeaderType(cnt.CS2_SERVICE_TYPE, header.correlation_id, header.requester_nsa, header.provider_nsa, None, header.session_security_attrs)
            soap_header_element = soap_header.xml(nsiframework.nsiHeader)

            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
Example #7
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
Example #8
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
Example #9
0
def createGenericAcknowledgement(header):

    soap_header = nsiframework.CommonHeaderType(cnt.CS2_SERVICE_TYPE, header.correlation_id, header.requester_nsa, header.provider_nsa, None, header.session_security_attrs)
    soap_header_element = soap_header.xml(nsiframework.nsiHeader)

    generic_confirm = nsiconnection.GenericAcknowledgmentType()
    generic_confirm_element = generic_confirm.xml(nsiconnection.acknowledgment)

    payload = minisoap.createSoapPayload(generic_confirm_element, soap_header_element)
    return payload
Example #10
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
Example #11
0
    def queryRecursiveConfirmed(self, requester_url, requester_nsa, provider_nsa, correlation_id, reservations):

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

        qr_reservations = queryhelper.buildQueryRecursiveResultType(reservations)
        qrct = nsiconnection.QueryRecursiveConfirmedType(qr_reservations)

        payload = minisoap.createSoapPayload(qrct.xml(nsiconnection.queryRecursiveConfirmed), header_element)
        d = httpclient.soapRequest(requester_url, actions.QUERY_RECURSIVE_CONFIRMED, payload, ctx_factory=self.ctx_factory)
        return d
Example #12
0
        def gotReservations(reservations):
            # do reply inline
            soap_header = nsiframework.CommonHeaderType(cnt.CS2_SERVICE_TYPE, header.correlation_id, header.requester_nsa, header.provider_nsa, None, header.session_security_attrs)
            soap_header_element = soap_header.xml(nsiframework.nsiHeader)

            query_summary_result = helper.buildQuerySummaryResultType(reservations)
            qsr_elements = [ qsr.xml(nsiconnection.reservation) for qsr in query_summary_result ]

            payload = minisoap.createSoapPayload(qsr_elements, soap_header_element)
            return payload
Example #13
0
def _createGenericAcknowledgement(header, protocol_type=None):

    # we do not put reply to, security attributes or connection traces in the acknowledgement
    soap_header_element = _createHeader(header.requester_nsa, header.provider_nsa, correlation_id=header.correlation_id, protocol_type=protocol_type)

    generic_confirm = nsiconnection.GenericAcknowledgmentType()
    generic_confirm_element = generic_confirm.xml(nsiconnection.acknowledgment)

    payload = minisoap.createSoapPayload(generic_confirm_element, soap_header_element)
    return payload
Example #14
0
    def queryRecursive(self, header, connection_ids, global_reservation_ids=None, request_info=None):

        self._checkHeader(header)

        header_element = helper.convertProviderHeader(header, self.reply_to)

        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
Example #15
0
    def querySummary(self, header, connection_ids=None, global_reservation_ids=None):

        self._checkHeader(header)

        header_element = helper.createHeader(header.requester_nsa, header.provider_nsa, reply_to=self.reply_to, correlation_id=header.correlation_id)

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

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(self.service_url, actions.QUERY_SUMMARY, payload, ctx_factory=self.ctx_factory, headers=self.http_headers)
        d.addCallbacks(lambda sd : None, self._handleErrorReply, errbackArgs=(header,))
        return d
Example #16
0
    def _genericConfirm(self, element_name, requester_url, action, correlation_id, requester_nsa, provider_nsa, connection_id):

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

        confirm = nsiconnection.GenericConfirmedType(connection_id)
        body_element   = confirm.xml(element_name)

        payload = minisoap.createSoapPayload(body_element, header_element)

        def gotReply(data):
            # for now we just ignore this, as long as we get an okay
            return

        d = httpclient.soapRequest(requester_url, action, payload, ctx_factory=self.ctx_factory)
        d.addCallbacks(gotReply) #, errReply)
        return d
Example #17
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
Example #18
0
    def querySummarySync(self, header, connection_ids=None, global_reservation_ids=None, request_info=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.convertProviderHeader(header, self.reply_to)

        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
Example #19
0
    def errorEvent(
        self,
        requester_url,
        requester_nsa,
        provider_nsa,
        correlation_id,
        connection_id,
        notification_id,
        timestamp,
        event,
        info,
        service_ex,
    ):

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

        if service_ex:
            nsa_id, connection_id, error_id, text, variables, child_ex = service_ex
            service_exception = nsiconnection.ServiceExceptionType(nsa_id, connection_id, error_id, text, None, None)
        else:
            service_exception = None

        org_connection_id = None
        org_nsa_id = None
        additional_info = None
        error_event = nsiconnection.ErrorEventType(
            connection_id,
            notification_id,
            xmlhelper.createXMLTime(timestamp),
            event,
            org_connection_id,
            org_nsa_id,
            additional_info,
            service_exception,
        )

        body_element = error_event.xml(nsiconnection.errorEvent)

        payload = minisoap.createSoapPayload(body_element, header_element)

        d = httpclient.soapRequest(requester_url, actions.ERROR_EVENT, payload, ctx_factory=self.ctx_factory)
        return d
Example #20
0
    def reserve(self, header, connection_id, global_reservation_id, description, criteria):

        self._checkHeader(header)

        # payload construction

        header_payload = helper.createHeader(header.requester_nsa, header.provider_nsa, reply_to=self.reply_to,
                                             correlation_id=header.correlation_id, connection_trace=header.connection_trace)

        schedule = criteria.schedule
        sd = criteria.service_def

        assert schedule.start_time.tzinfo is None, 'Start time must NOT have time zone'
        assert schedule.end_time.tzinfo   is None, 'End time must NOT have time zone'

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

        src_stp_id = helper.createSTPID(sd.source_stp)
        dst_stp_id = helper.createSTPID(sd.dest_stp)

        service_def = p2pservices.P2PServiceBaseType(sd.capacity, sd.directionality, sd.symmetric, src_stp_id, dst_stp_id, sd.ero, None)

        schedule_type = nsiconnection.ScheduleType(schedule.start_time.replace(tzinfo=tzutc()).isoformat(),
                                                   schedule.end_time.replace(tzinfo=tzutc()).isoformat())

        criteria = nsiconnection.ReservationRequestCriteriaType(criteria.revision, schedule_type, str(p2pservices.p2ps), service_def )

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

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

        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
Example #21
0
    def querySummarySync(self, header, connection_ids=None, global_reservation_ids=None):

        def gotReply(soap_data):
            header, query_confirmed = helper.parseRequest(soap_data)
            if query_confirmed is None:
                return []
            elif type(query_confirmed) is list:
                return [ helper.buildQuerySummaryResult(qc) for qc in query_confirmed ]
            else:
                return [ helper.buildQuerySummaryResult(query_confirmed) ]

        # don't need to check header here

        header_element = helper.createHeader(header.requester_nsa, header.provider_nsa, reply_to=self.reply_to, correlation_id=header.correlation_id)

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

        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
Example #22
0
    def _genericFailure(self, requester_url, action, message_name, requester_nsa, provider_nsa, correlation_id,
                        connection_id, connection_states, err):

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

        active, version, consistent = connection_states[3]
        data_plane_state = nsiconnection.DataPlaneStatusType(active, version, consistent)
        connection_states = nsiconnection.ConnectionStatesType(connection_states[0], connection_states[1], connection_states[2], data_plane_state)

        se = helper.createServiceException(err, provider_nsa)

        failure = nsiconnection.GenericFailedType(connection_id, connection_states, se)

        body_element = failure.xml(message_name)

        payload = minisoap.createSoapPayload(body_element, header_element)

        def gotReply(data):
            # for now we just ignore this, as long as we get an okay
            return

        d = httpclient.soapRequest(requester_url, action, payload, ctx_factory=self.ctx_factory)
        d.addCallbacks(gotReply) #, errReply)
        return d