From a3fffcc63b9502645d20a90efc1b684bd35f9c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Fri, 7 Jan 2011 14:10:48 +0100 Subject: [PATCH] Make it possible to pause/resume sync of mirrored dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/bdev.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/bdev.py b/lib/bdev.py index 13b856625..7904eeab6 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -230,6 +230,20 @@ class BlockDev(object): result = result and child.SetSyncSpeed(speed) return result + def PauseResumeSync(self, pause): + """Pause/Resume the sync of the mirror. + + In case this is not a mirroring device, this is no-op. + + @param pause: Wheater to pause or resume + + """ + result = True + if self._children: + for child in self._children: + result = result and child.PauseResumeSync(pause) + return result + def GetSyncStatus(self): """Returns the sync status of the device. @@ -1488,6 +1502,30 @@ class DRBD8(BaseDRBD): children_result = super(DRBD8, self).SetSyncSpeed(kbytes) return self._SetMinorSyncSpeed(self.minor, kbytes) and children_result + def PauseResumeSync(self, pause): + """Pauses or resumes the sync of a DRBD device. + + @param pause: Wether to pause or resume + @return: the success of the operation + + """ + if self.minor is None: + logging.info("Not attached during PauseSync") + return False + + children_result = super(DRBD8, self).PauseResumeSync(pause) + + if pause: + cmd = "pause-sync" + else: + cmd = "resume-sync" + + result = utils.RunCmd(["drbdsetup", self.dev_path, cmd]) + if result.failed: + logging.error("Can't %s: %s - %s", cmd, + result.fail_reason, result.output) + return not result.failed and children_result + def GetProcStatus(self): """Return device data from /proc. -- GitLab