<s> """<STR_LIT>""" <EOL> from opennsa import constants as cnt <EOL> from opennsa . shared import xmlhelper <EOL> from opennsa . protocols . shared import minisoap , httpclient <EOL> from opennsa . protocols . nsi2 import helper , queryhelper <EOL> from opennsa . protocols . nsi2 . bindings import actions , nsiconnection , p2pservices <EOL> class ProviderClient : <EOL> def __init__ ( self , ctx_factory = None ) : <EOL> self . ctx_factory = ctx_factory <EOL> def _genericConfirm ( self , element_name , requester_url , action , correlation_id , requester_nsa , provider_nsa , connection_id ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> confirm = nsiconnection . GenericConfirmedType ( connection_id ) <EOL> body_element = confirm . xml ( element_name ) <EOL> payload = minisoap . createSoapPayload ( body_element , header_element ) <EOL> def gotReply ( data ) : <EOL> return <EOL> d = httpclient . soapRequest ( requester_url , action , payload , ctx_factory = self . ctx_factory ) <EOL> d . addCallbacks ( gotReply ) <EOL> return d <EOL> def _genericFailure ( self , requester_url , action , message_name , requester_nsa , provider_nsa , correlation_id , <EOL> connection_id , connection_states , err ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> active , version , consistent = connection_states [ <NUM_LIT:3> ] <EOL> data_plane_state = nsiconnection . DataPlaneStatusType ( active , version , consistent ) <EOL> connection_states = nsiconnection . ConnectionStatesType ( connection_states [ <NUM_LIT:0> ] , connection_states [ <NUM_LIT:1> ] , connection_states [ <NUM_LIT:2> ] , data_plane_state ) <EOL> se = helper . createServiceException ( err , provider_nsa ) <EOL> failure = nsiconnection . GenericFailedType ( connection_id , connection_states , se ) <EOL> body_element = failure . xml ( message_name ) <EOL> payload = minisoap . createSoapPayload ( body_element , header_element ) <EOL> def gotReply ( data ) : <EOL> return <EOL> d = httpclient . soapRequest ( requester_url , action , payload , ctx_factory = self . ctx_factory ) <EOL> d . addCallbacks ( gotReply ) <EOL> return d <EOL> def reserveConfirmed ( self , nsi_header , connection_id , global_reservation_id , description , criteria ) : <EOL> header_element = helper . createRequesterHeader ( nsi_header . requester_nsa , nsi_header . provider_nsa , correlation_id = nsi_header . correlation_id ) <EOL> schedule = nsiconnection . ScheduleType ( <EOL> xmlhelper . createXMLTime ( criteria . schedule . start_time ) if criteria . schedule . start_time is not None else None , <EOL> xmlhelper . createXMLTime ( criteria . schedule . end_time ) if criteria . schedule . end_time is not None else None <EOL> ) <EOL> sd = criteria . service_def <EOL> p2p = p2pservices . P2PServiceBaseType ( sd . capacity , sd . directionality , sd . symmetric , sd . source_stp . urn ( ) , sd . dest_stp . urn ( ) , None , [ ] ) <EOL> criteria = nsiconnection . ReservationConfirmCriteriaType ( criteria . revision , schedule , cnt . EVTS_AGOLE , str ( p2pservices . p2ps ) , p2p ) <EOL> reserve_conf = nsiconnection . ReserveConfirmedType ( connection_id , global_reservation_id , description , criteria ) <EOL> body_element = reserve_conf . xml ( nsiconnection . reserveConfirmed ) <EOL> payload = minisoap . createSoapPayload ( body_element , header_element ) <EOL> def gotReply ( data ) : <EOL> return "<STR_LIT>" <EOL> d = httpclient . soapRequest ( nsi_header . reply_to , actions . RESERVE_CONFIRMED , payload , ctx_factory = self . ctx_factory ) <EOL> d . addCallbacks ( gotReply ) <EOL> return d <EOL> def reserveFailed ( self , nsi_header , connection_id , connection_states , err ) : <EOL> return self . _genericFailure ( nsi_header . reply_to , actions . RESERVE_FAILED , nsiconnection . reserveFailed , <EOL> nsi_header . requester_nsa , nsi_header . provider_nsa , nsi_header . correlation_id , <EOL> connection_id , connection_states , err ) <EOL> def reserveCommitConfirmed ( self , requester_url , requester_nsa , provider_nsa , correlation_id , connection_id ) : <EOL> return self . _genericConfirm ( nsiconnection . reserveCommitConfirmed , requester_url , actions . RESERVE_COMMIT_CONFIRMED , <EOL> correlation_id , requester_nsa , provider_nsa , connection_id ) <EOL> def reserveCommitFailed ( self , nsi_header , connection_id , connection_states , err ) : <EOL> return self . _genericFailure ( nsi_header . reply_to , actions . RESERVE_COMMIT_FAILED , nsiconnection . reserveCommitFailed , <EOL> nsi_header . requester_nsa , nsi_header . provider_nsa , nsi_header . correlation_id , <EOL> connection_id , connection_states , err ) <EOL> def reserveAbortConfirmed ( self , requester_url , requester_nsa , provider_nsa , correlation_id , connection_id ) : <EOL> return self . _genericConfirm ( nsiconnection . reserveAbortConfirmed , requester_url , actions . RESERVE_ABORT_CONFIRMED , <EOL> correlation_id , requester_nsa , provider_nsa , connection_id ) <EOL> def provisionConfirmed ( self , requester_url , correlation_id , requester_nsa , provider_nsa , connection_id ) : <EOL> return self . _genericConfirm ( nsiconnection . provisionConfirmed , requester_url , actions . PROVISION_CONFIRMED , <EOL> correlation_id , requester_nsa , provider_nsa , connection_id ) <EOL> def releaseConfirmed ( self , requester_url , correlation_id , requester_nsa , provider_nsa , connection_id ) : <EOL> return self . _genericConfirm ( nsiconnection . releaseConfirmed , requester_url , actions . RELEASE_CONFIRMED , <EOL> correlation_id , requester_nsa , provider_nsa , connection_id ) <EOL> def terminateConfirmed ( self , requester_url , correlation_id , requester_nsa , provider_nsa , connection_id ) : <EOL> return self . _genericConfirm ( nsiconnection . terminateConfirmed , requester_url , actions . TERMINATE_CONFIRMED , <EOL> correlation_id , requester_nsa , provider_nsa , connection_id ) <EOL> def reserveTimeout ( self , requester_url , requester_nsa , provider_nsa , correlation_id , <EOL> connection_id , notification_id , timestamp , timeout_value , originating_connection_id , originating_nsa ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> reserve_timeout = nsiconnection . ReserveTimeoutRequestType ( connection_id , notification_id , xmlhelper . createXMLTime ( timestamp ) , timeout_value , originating_connection_id , originating_nsa ) <EOL> body_element = reserve_timeout . xml ( nsiconnection . reserveTimeout ) <EOL> payload = minisoap . createSoapPayload ( body_element , header_element ) <EOL> d = httpclient . soapRequest ( requester_url , actions . RESERVE_TIMEOUT , payload , ctx_factory = self . ctx_factory ) <EOL> return d <EOL> def dataPlaneStateChange ( self , requester_url , requester_nsa , provider_nsa , correlation_id , <EOL> connection_id , notification_id , timestamp , active , version , consistent ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> data_plane_status = nsiconnection . DataPlaneStatusType ( active , version , consistent ) <EOL> dps = nsiconnection . DataPlaneStateChangeRequestType ( connection_id , notification_id , xmlhelper . createXMLTime ( timestamp ) , data_plane_status ) <EOL> body_element = dps . xml ( nsiconnection . dataPlaneStateChange ) <EOL> payload = minisoap . createSoapPayload ( body_element , header_element ) <EOL> d = httpclient . soapRequest ( requester_url , actions . DATA_PLANE_STATE_CHANGE , payload , ctx_factory = self . ctx_factory ) <EOL> return d <EOL> def errorEvent ( self , requester_url , requester_nsa , provider_nsa , correlation_id , <EOL> connection_id , notification_id , timestamp , event , info , service_ex ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> if service_ex : <EOL> nsa_id , connection_id , error_id , text , variables , child_ex = service_ex <EOL> service_exception = nsiconnection . ServiceExceptionType ( nsa_id , connection_id , error_id , text , None , None ) <EOL> else : <EOL> service_exception = None <EOL> org_connection_id = None <EOL> org_nsa_id = None <EOL> additional_info = None <EOL> error_event = nsiconnection . ErrorEventType ( connection_id , notification_id , xmlhelper . createXMLTime ( timestamp ) , event , <EOL> org_connection_id , org_nsa_id , additional_info , service_exception ) <EOL> body_element = error_event . xml ( nsiconnection . errorEvent ) <EOL> payload = minisoap . createSoapPayload ( body_element , header_element ) <EOL> d = httpclient . soapRequest ( requester_url , actions . ERROR_EVENT , payload , ctx_factory = self . ctx_factory ) <EOL> return d <EOL> def querySummaryConfirmed ( self , requester_url , requester_nsa , provider_nsa , correlation_id , reservations ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> qs_reservations = queryhelper . buildQuerySummaryResultType ( reservations ) <EOL> qsct = nsiconnection . QuerySummaryConfirmedType ( qs_reservations ) <EOL> payload = minisoap . createSoapPayload ( qsct . xml ( nsiconnection . querySummaryConfirmed ) , header_element ) <EOL> d = httpclient . soapRequest ( requester_url , actions . QUERY_SUMMARY_CONFIRMED , payload , ctx_factory = self . ctx_factory ) <EOL> return d <EOL> def queryRecursiveConfirmed ( self , requester_url , requester_nsa , provider_nsa , correlation_id , reservations ) : <EOL> header_element = helper . createRequesterHeader ( requester_nsa , provider_nsa , correlation_id = correlation_id ) <EOL> qr_reservations = queryhelper . buildQueryRecursiveResultType ( reservations ) <EOL> qrct = nsiconnection . QueryRecursiveConfirmedType ( qr_reservations ) <EOL> payload = minisoap . createSoapPayload ( qrct . xml ( nsiconnection . queryRecursiveConfirmed ) , header_element ) <EOL> d = httpclient . soapRequest ( requester_url , actions . QUERY_RECURSIVE_CONFIRMED , payload , ctx_factory = self . ctx_factory ) <EOL> return d </s>
