Revision 9b4cb29d

b/lib/rapi/baserlib.py
36 36
from ganeti import compat
37 37
from ganeti import constants
38 38
from ganeti import pathutils
39
from ganeti import utils
39 40

  
40 41

  
41 42
# Dummy value to detect unchanged parameters
......
496 497
  def _GetDefaultData(self):
497 498
    return (self.request_body, None)
498 499

  
500
  def _GetRapiOpName(self):
501
    """Extracts the name of the RAPI operation from the class name
502

  
503
    """
504
    if self.__class__.__name__.startswith("R_2_"):
505
      return self.__class__.__name__[4:]
506
    return self.__class__.__name__
507

  
499 508
  def _GetCommonStatic(self):
500 509
    """Return the static parameters common to all the RAPI calls
501 510

  
511
    The reason is a parameter present in all the RAPI calls, and the reason
512
    trail has to be build for all of them, so the parameter is read here and
513
    used to build the reason trail, that is the actual parameter passed
514
    forward.
515

  
502 516
    """
503
    common_static = {}
517
    trail = []
518
    usr_reason = self._checkStringVariable("reason", default=None)
519
    if usr_reason:
520
      trail.append((constants.OPCODE_REASON_SRC_USER,
521
                    usr_reason,
522
                    utils.EpochNano()))
523
    reason_src = "%s:%s" % (constants.OPCODE_REASON_SRC_RLIB2,
524
                            self._GetRapiOpName())
525
    trail.append((reason_src, "", utils.EpochNano()))
526
    common_static = {
527
      "reason": trail,
528
      }
504 529
    return common_static
505 530

  
506 531
  def _GenericHandler(self, opcode, rename, fn):

Also available in: Unified diff