@@ -483,6 +483,8 @@ async def create_party_reregistration(self, registration_id=None):
483
483
Take the neccessary steps to re-register this client with the server.
484
484
"""
485
485
486
+ if registration_id is None :
487
+ registration_id = self .registration_id
486
488
await self .create_party_registration (ven_id = self .ven_id , registration_id = registration_id )
487
489
488
490
if not self .registration_id :
@@ -632,10 +634,15 @@ async def create_opt(self, opt_type, opt_reason, targets, vavailability=None, ev
632
634
service = 'EiOpt'
633
635
message = self ._create_message ('oadrCreateOpt' , ** payload )
634
636
response_type , response_payload = await self ._perform_request (service , message )
637
+ logger .info (response_type , response_payload )
635
638
636
639
if 'opt_id' in response_payload :
637
640
# VTN acknowledged the opt message
641
+ logging .info (f"VTN acknowledged the opt message with opt_id { response_payload ['opt_id' ]} " )
638
642
return response_payload ['opt_id' ]
643
+ else :
644
+ logging .error (f"VTN did not acknowledge the opt message" )
645
+ return False
639
646
640
647
# TODO: what to do if the VTN sends an error or does not acknowledge the opt?
641
648
@@ -662,11 +669,16 @@ async def cancel_opt(self, opt_id):
662
669
service = 'EiOpt'
663
670
message = self ._create_message ('oadrCancelOpt' , ** payload )
664
671
response_type , response_payload = await self ._perform_request (service , message )
672
+ logger .info (response_type , response_payload )
665
673
666
674
if 'opt_id' in response_payload :
667
675
# VTN acknowledged the opt cancelation
676
+ logging .info (f"VTN acknowledged the opt cancelation with opt_id { response_payload ['opt_id' ]} " )
668
677
self .opts .remove (opt )
669
678
return True
679
+ else :
680
+ logging .error (f"VTN did not acknowledge the opt cancelation" )
681
+ return False
670
682
671
683
###########################################################################
672
684
# #
@@ -799,13 +811,12 @@ async def create_report(self, response_payload):
799
811
'granularity' : granularity ,
800
812
'job' : job })
801
813
else :
802
- job = None
803
814
self .report_requests .append ({'report_request_id' : report_request_id ,
804
815
'report_specifier_id' : report_specifier_id ,
805
816
'report_back_duration' : report_back_duration ,
806
817
'r_ids' : requested_r_ids ,
807
818
'granularity' : granularity ,
808
- 'job' : job })
819
+ 'job' : None })
809
820
810
821
async def report_callback ():
811
822
await self .update_report (report_request_id )
@@ -823,7 +834,8 @@ async def report_callback():
823
834
message = self ._create_message (message_type ,
824
835
response = {'response_code' : response_code ,
825
836
'response_description' : 'OK' if response_code == 200 else 'ERROR' ,
826
- 'request_id' : response_payload ['request_id' ]},
837
+ 'request_id' : response_payload ['request_id' ] if 'request_id' in response_payload else \
838
+ response_payload ['response' ]['request_id' ]},
827
839
ven_id = self .ven_id ,
828
840
** message_payload )
829
841
await self ._perform_request (service , message )
@@ -1257,9 +1269,9 @@ async def _poll(self):
1257
1269
return
1258
1270
1259
1271
elif response_type == 'oadrRequestReregistration' :
1260
- logger .info ("The VTN required us to re-register. Calling the registration procedure." )
1272
+ logger .info ("The VTN required us to re-register. Calling the re- registration procedure." )
1261
1273
await self .send_response (service = 'EiRegisterParty' )
1262
- await self .create_party_registration ()
1274
+ await self .create_party_reregistration ()
1263
1275
1264
1276
elif response_type == 'oadrDistributeEvent' :
1265
1277
if 'events' in response_payload and len (response_payload ['events' ]) > 0 :
0 commit comments