From 476b681749027b5e6916cddf9e8bdb4447fe50ae Mon Sep 17 00:00:00 2001 From: Wojtek Porczyk Date: Thu, 2 Jun 2016 17:17:05 +0200 Subject: [PATCH] qubes/vm/qubesvm: return self from methods modifying state This is helpful when writing oneliners. QubesOS/qubes-issues#866 --- qubes/vm/qubesvm.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index ae97d8bf..5e21ce60 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -758,6 +758,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): self.force_shutdown() raise + return self + def shutdown(self, force=False): '''Shutdown domain. @@ -787,6 +789,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): self.libvirt_domain.shutdown() self.storage.stop() + return self + def kill(self): '''Forcefuly shutdown (destroy) domain. @@ -801,6 +805,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): self.libvirt_domain.destroy() self.storage.stop() + return self + def force_shutdown(self, *args, **kwargs): '''Deprecated alias for :py:meth:`kill`''' @@ -809,6 +815,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): DeprecationWarning, stacklevel=2) self.kill(*args, **kwargs) + return self + def suspend(self): '''Suspend (pause) domain. @@ -832,6 +840,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): else: self.libvirt_domain.suspend() + return self + def pause(self): '''Pause (suspend) domain. This currently delegates to \ @@ -842,6 +852,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): self.suspend() + return self + def resume(self): '''Resume suspended domain. @@ -856,6 +868,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): else: self.unpause() + return self + def unpause(self): '''Resume (unpause) a domain''' @@ -864,6 +878,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): self.libvirt_domain.resume() + return self + def run(self, command, user=None, autostart=False, notify_function=None, passio=False, passio_popen=False, passio_stderr=False,