[virt-tools-list] [PATCH virt-manager 13/14] domain: use else/elif since the conditions are mutually exclusive

Marc Hartmayer mhartmay at linux.ibm.com
Tue Dec 18 13:45:02 UTC 2018


Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
 virtManager/domain.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 3abec880285c..2de75403e151 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1108,8 +1108,7 @@ class vmmDomain(vmmLibvirtObject):
         flags = 0
         if redefine:
             flags = (flags | libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)
-
-        if not redefine:
+        else:
             logging.debug("Creating snapshot flags=%s xml=\n%s", flags, xml)
         self._backend.snapshotCreateXML(xml, flags)
 
@@ -1180,7 +1179,7 @@ class vmmDomain(vmmLibvirtObject):
             if info["mac"] == iface.macaddr:
                 if info["type"] == 0:
                     ipv4 = info["ipaddr"]
-                if info["type"] == 1:
+                elif info["type"] == 1:
                     ipv6 = info["ipaddr"]
             return ipv4, ipv6
 
@@ -1283,11 +1282,11 @@ class vmmDomain(vmmLibvirtObject):
         for b in boot_order:
             if b == "network" and net:
                 ret.append(net.get_xml_id())
-            if b == "hd" and disk:
+            elif b == "hd" and disk:
                 ret.append(disk.get_xml_id())
-            if b == "cdrom" and cdrom:
+            elif b == "cdrom" and cdrom:
                 ret.append(cdrom.get_xml_id())
-            if b == "fd" and floppy:
+            elif b == "fd" and floppy:
                 ret.append(floppy.get_xml_id())
         return ret
 
-- 
2.17.0




More information about the virt-tools-list mailing list