Revision 26d502d0 lib/rpc.py

b/lib/rpc.py
434 434
    """Entry point for automatically generated RPC wrappers.
435 435

  
436 436
    """
437
    (procedure, _, _, argdefs, _, _) = cdef
437
    (procedure, _, _, argdefs, postproc_fn, _) = cdef
438 438

  
439 439
    body = serializer.DumpJson(map(self._encoder,
440 440
                                   zip(map(compat.snd, argdefs), args)),
441 441
                               indent=False)
442 442

  
443
    return self._proc(node_list, procedure, body, read_timeout=timeout)
443
    result = self._proc(node_list, procedure, body, read_timeout=timeout)
444

  
445
    if postproc_fn:
446
      return postproc_fn(result)
447
    else:
448
      return result
444 449

  
445 450

  
446 451
def _ObjectToDict(value):
......
615 620
    """
616 621
    return self._InstDict(instance, osp=osparams)
617 622

  
618
  @staticmethod
619
  def _MigrationStatusPostProc(result):
620
    if not result.fail_msg and result.payload is not None:
621
      result.payload = objects.MigrationStatus.FromDict(result.payload)
622
    return result
623

  
624
  @staticmethod
625
  def _BlockdevFindPostProc(result):
626
    if not result.fail_msg and result.payload is not None:
627
      result.payload = objects.BlockDevStatus.FromDict(result.payload)
628
    return result
629

  
630
  @staticmethod
631
  def _BlockdevGetMirrorStatusPostProc(result):
632
    if not result.fail_msg:
633
      result.payload = [objects.BlockDevStatus.FromDict(i)
634
                        for i in result.payload]
635
    return result
636

  
637
  @staticmethod
638
  def _BlockdevGetMirrorStatusMultiPostProc(result):
639
    for nres in result.values():
640
      if nres.fail_msg:
641
        continue
642

  
643
      for idx, (success, status) in enumerate(nres.payload):
644
        if success:
645
          nres.payload[idx] = (success, objects.BlockDevStatus.FromDict(status))
646

  
647
    return result
648

  
649
  @staticmethod
650
  def _OsGetPostProc(result):
651
    if not result.fail_msg and isinstance(result.payload, dict):
652
      result.payload = objects.OS.FromDict(result.payload)
653
    return result
654

  
655
  @staticmethod
656
  def _ImpExpStatusPostProc(result):
657
    """Post-processor for import/export status.
658

  
659
    @rtype: Payload containing list of L{objects.ImportExportStatus} instances
660
    @return: Returns a list of the state of each named import/export or None if
661
             a status couldn't be retrieved
662

  
663
    """
664
    if not result.fail_msg:
665
      decoded = []
666

  
667
      for i in result.payload:
668
        if i is None:
669
          decoded.append(None)
670
          continue
671
        decoded.append(objects.ImportExportStatus.FromDict(i))
672

  
673
      result.payload = decoded
674

  
675
    return result
676

  
677 623
  #
678 624
  # Begin RPC calls
679 625
  #

Also available in: Unified diff