From 47c95694e93b361e3b0738afac8e724557a36c8a Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Garcia Date: Wed, 6 Nov 2013 09:29:05 +0100 Subject: [PATCH] Fix "in" comparisons with one element tuples A single value enclosed in parentheses is not a tuple (it needs a comma after the element) therefore the comparisons like 'if foo in ("bar")' are wrong. Closes-Bug: #1248443 Change-Id: I29a2227c9d83efc17ecfacc86d507d75edd4eaca --- nova/tests/compute/test_virtapi.py | 2 +- nova/virt/libvirt/driver.py | 4 ++-- nova/virt/xenapi/fake.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/tests/compute/test_virtapi.py b/nova/tests/compute/test_virtapi.py index 42d4d0f6ec4f..3e9d46e1c276 100644 --- a/nova/tests/compute/test_virtapi.py +++ b/nova/tests/compute/test_virtapi.py @@ -91,7 +91,7 @@ class FakeVirtAPITest(VirtAPIBaseTest): else: e_args = args - if method in ('block_device_mapping_get_all_by_instance'): + if method == 'block_device_mapping_get_all_by_instance': e_kwargs = {} else: e_kwargs = kwargs diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index bf7609fdd846..ffb1cf9363cb 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2594,7 +2594,7 @@ class LibvirtDriver(driver.ComputeDriver): # In managed mode, the configured device will be automatically # detached from the host OS drivers when the guest is started, # and then re-attached when the guest shuts down. - if CONF.libvirt.virt_type not in ('xen'): + if CONF.libvirt.virt_type != 'xen': # we do manual detach only for xen return try: @@ -2946,7 +2946,7 @@ class LibvirtDriver(driver.ComputeDriver): dev.domain, dev.bus, dev.slot, dev.function = dbsf # only kvm support managed mode - if CONF.libvirt.virt_type in ('xen'): + if CONF.libvirt.virt_type in ('xen',): dev.managed = 'no' if CONF.libvirt.virt_type in ('kvm', 'qemu'): dev.managed = 'yes' diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index 40c654274fcb..91529e985783 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -539,7 +539,7 @@ class SessionBase(object): _db_content['SR'][sr_ref]['uuid'] = sr_uuid _db_content['SR'][sr_ref]['forgotten'] = 0 vdi_per_lun = False - if type in ('iscsi'): + if type == 'iscsi': # Just to be clear vdi_per_lun = True if vdi_per_lun: