LURepairCommand runs a repair command and returns the output of the command (stdout + stderr) as a string
Signed-off-by: Bhimanavajjula Aditya <[email protected]> --- lib/cmdlib/__init__.py | 3 ++- lib/cmdlib/misc.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib/__init__.py b/lib/cmdlib/__init__.py index 5fd9b8d..08d9616 100644 --- a/lib/cmdlib/__init__.py +++ b/lib/cmdlib/__init__.py @@ -126,7 +126,8 @@ from ganeti.cmdlib.network import \ from ganeti.cmdlib.misc import \ LUOobCommand, \ LUExtStorageDiagnose, \ - LURestrictedCommand + LURestrictedCommand, \ + LURepairCommand from ganeti.cmdlib.test import \ LUTestOsParams, \ LUTestDelay, \ diff --git a/lib/cmdlib/misc.py b/lib/cmdlib/misc.py index 62bff52..d0bad88 100644 --- a/lib/cmdlib/misc.py +++ b/lib/cmdlib/misc.py @@ -40,7 +40,11 @@ from ganeti import qlang from ganeti import query from ganeti import utils from ganeti.cmdlib.base import NoHooksLU, QueryBase -from ganeti.cmdlib.common import GetWantedNodes, SupportsOob +from ganeti.cmdlib.common import ( + GetWantedNodes, + SupportsOob, + ExpandNodeUuidAndName +) class LUOobCommand(NoHooksLU): @@ -418,3 +422,35 @@ class LURestrictedCommand(NoHooksLU): result.append((True, nres.payload)) return result + + +class LURepairCommand(NoHooksLU): + """Logical unit for executing repair commands. + + """ + REQ_BGL = False + + def ExpandNames(self): + self.node_uuid, _ = ExpandNodeUuidAndName(self.cfg, None, self.op.node_name) + + self.needed_locks = { + locking.LEVEL_NODE: self.node_uuid, + } + self.share_locks = { + locking.LEVEL_NODE: False, + } + + def CheckPrereq(self): + """Check prerequisites. + + """ + + def Exec(self, feedback_fn): + """Execute restricted command and return output. + + """ + owned_nodes = frozenset(self.owned_locks(locking.LEVEL_NODE)) + assert self.node_uuid in owned_nodes + return self.rpc.call_repair_command(self.op.node_name, + self.op.command, + self.op.input).data[1] -- 2.5.0.457.gab17608
