From add247d62212e6b5557f4bbc45d6303809f13c19 Mon Sep 17 00:00:00 2001 From: brent s Date: Fri, 29 Nov 2019 07:37:00 -0500 Subject: [PATCH] can't start an active guest and vice versa --- libvirt/better_virsh.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libvirt/better_virsh.py b/libvirt/better_virsh.py index eb14d5d..8be73b4 100755 --- a/libvirt/better_virsh.py +++ b/libvirt/better_virsh.py @@ -121,14 +121,14 @@ class LV(object): return(results) def restart(self, target, *args, **kwargs): - self.stop(target, **kwargs) - self.start(target, **kwargs) + self.stop(target, state = 'active', **kwargs) + self.start(target, state = 'inactive', **kwargs) return() def start(self, target, **kwargs): if not self.conn: self.startConn() - targets = self._getTargets(target, **kwargs) + targets = self._getTargets(target, state = 'inactive', **kwargs) for t in targets: t.create() return() @@ -136,7 +136,7 @@ class LV(object): def stop(self, target, force = False, *args, **kwargs): if not self.conn: self.startConn() - targets = self._getTargets(target, **kwargs) + targets = self._getTargets(target, state = 'active', **kwargs) for t in targets: if not force: t.shutdown() @@ -218,5 +218,6 @@ def main(): print('\n'.join(f)) return() + if __name__ == '__main__': main()