Skip to content
Snippets Groups Projects
Commit 9b4cb29d authored by Michele Tartara's avatar Michele Tartara
Browse files

Add "reason" as a common parameter for all the RAPI calls


Also, this add an infrastructure for having parameters common to all the
RAPI calls.

Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent da3faf9d
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ from ganeti import errors
from ganeti import compat
from ganeti import constants
from ganeti import pathutils
from ganeti import utils
# Dummy value to detect unchanged parameters
......@@ -496,11 +497,35 @@ class OpcodeResource(ResourceBase):
def _GetDefaultData(self):
return (self.request_body, None)
def _GetRapiOpName(self):
"""Extracts the name of the RAPI operation from the class name
"""
if self.__class__.__name__.startswith("R_2_"):
return self.__class__.__name__[4:]
return self.__class__.__name__
def _GetCommonStatic(self):
"""Return the static parameters common to all the RAPI calls
The reason is a parameter present in all the RAPI calls, and the reason
trail has to be build for all of them, so the parameter is read here and
used to build the reason trail, that is the actual parameter passed
forward.
"""
common_static = {}
trail = []
usr_reason = self._checkStringVariable("reason", default=None)
if usr_reason:
trail.append((constants.OPCODE_REASON_SRC_USER,
usr_reason,
utils.EpochNano()))
reason_src = "%s:%s" % (constants.OPCODE_REASON_SRC_RLIB2,
self._GetRapiOpName())
trail.append((reason_src, "", utils.EpochNano()))
common_static = {
"reason": trail,
}
return common_static
def _GenericHandler(self, opcode, rename, fn):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment