Martin Betak has posted comments on this change. Change subject: vdsm: Reboot capability for VM ......................................................................
Patch Set 37: (6 comments) .................................................... File vdsm/vm.py Line 1729: self.timeout = max(0, timeout) Line 1730: self.force = force Line 1731: Line 1732: def start(self): Line 1733: try: This was just to guard against any unexpected CallbackChain exceptions. While the current implementation of CallbackChain shouldn't throw, I wanted to make the code more future-resistant. If you want I can remove the try/catch alltogether. Line 1734: self._setGuestEvent() Line 1735: # are there any available methods for shutdown/reboot? Line 1736: if self.chain.callbacks: Line 1737: self.chain.start() Line 1756: self.vm._guestEventTime = time.time() Line 1757: self.vm._guestEvent = self.desc['guestEvent'] Line 1758: Line 1759: @classmethod Line 1760: def create(cls, vm, delay, message, timeout, reboot, force): Done Line 1761: graceful_timeout = int(timeout) Line 1762: agent_user_delay = int(delay) Line 1763: Line 1764: # flag for successful power-down event detection Line 1764: # flag for successful power-down event detection Line 1765: # this flag is common for both shutdown and reboot workflows Line 1766: # because we want to exit the CallbackChain in case either Line 1767: # of them happens Line 1768: vm._powerDownEvent.clear() If you look at some of the older patches, this feature started as being implemented in the Vm.shutdown() method with callbacks being methods of the Vm itself. After lengthy discussions the general consensus was that all this functionality should be encapsulated in one single class (with callbacks and everything) that could be easily moved to a different file. The motivation was in fact to use the Command pattern more in the VM class and split it possibly into multiple files in the future. Line 1769: if reboot: Line 1770: desc = {'action': 'Reboot', Line 1771: 'guestEvent': 'RebootInProgress', Line 1772: 'returnMsg': 'Machine rebooting'} Line 1803: return powerDown Line 1804: Line 1805: def _waitForEvent(self, event): Line 1806: event.wait(self.timeout) Line 1807: return event.is_set() Done Line 1808: Line 1809: # Callbacks for Callback Chain Line 1810: Line 1811: def guestAgentShutdown(self, delay, message): Line 1809: # Callbacks for Callback Chain Line 1810: Line 1811: def guestAgentShutdown(self, delay, message): Line 1812: self.vm.guestAgent.desktopShutdown(delay, message, False) Line 1813: time.sleep(self.delay) Done Line 1814: return self._waitForEvent(self.vm._powerDownEvent) Line 1815: Line 1816: def guestAgentReboot(self, delay, message): Line 1817: self.vm.guestAgent.desktopShutdown(delay, message, True) Line 1838: def forceReboot(self): Line 1839: self.vm.reset() Line 1840: return self._waitForEvent(self.vm._powerDownEvent) Line 1841: Line 1842: # End Callbacks Done Line 1843: Line 1844: Line 1845: class Vm(object): Line 1846: """ -- To view, visit http://gerrit.ovirt.org/15829 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I12737e363a80679ffb1db55f14eaee158312d7da Gerrit-PatchSet: 37 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Betak <mbe...@redhat.com> Gerrit-Reviewer: Antoni Segura Puimedon <asegu...@redhat.com> Gerrit-Reviewer: Ayal Baron <aba...@redhat.com> Gerrit-Reviewer: Better Saggi <bettersa...@gmail.com> Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com> Gerrit-Reviewer: Federico Simoncelli <fsimo...@redhat.com> Gerrit-Reviewer: Giuseppe Vallarelli <gvall...@redhat.com> Gerrit-Reviewer: Greg Padgett <gpadg...@redhat.com> Gerrit-Reviewer: Martin Betak <mbe...@redhat.com> Gerrit-Reviewer: Martin Polednik <mpole...@redhat.com> Gerrit-Reviewer: Martin Sivák <msi...@redhat.com> Gerrit-Reviewer: Michal Skrivanek <michal.skriva...@redhat.com> Gerrit-Reviewer: Omer Frenkel <ofren...@redhat.com> Gerrit-Reviewer: Peter V. Saveliev <p...@redhat.com> Gerrit-Reviewer: Saggi Mizrahi <smizr...@redhat.com> Gerrit-Reviewer: Vinzenz Feenstra <vfeen...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches