From 291df3a09a9970ad9ab0b236c93afe4d2a46920e Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 29 Jun 2011 09:29:07 -0700 Subject: [PATCH] removed extra stubout, switched to isinstance and catching explicit exception --- nova/compute/api.py | 2 +- nova/scheduler/zone_aware_scheduler.py | 2 +- nova/tests/scheduler/test_zone_aware_scheduler.py | 10 ---------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index b8c76c2f9b1e..39ba06380a09 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -260,7 +260,7 @@ class API(base.Base): elevated = context.elevated() if security_group is None: security_group = ['default'] - if not type(security_group) is list: + if not isinstance(security_group, list): security_group = [security_group] security_groups = [] diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index dcfef6af5dbb..fe033e24e21b 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -194,7 +194,7 @@ class ZoneAwareScheduler(driver.Scheduler): cooked_weight = offset + scale * raw_weight item['weight'] = cooked_weight item['raw_weight'] = raw_weight - except Exception, e: + except KeyError: LOG.exception(_("Bad child zone scaling values " "for Zone: %(zone)s") % locals()) diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index 5c9df7fb0a3f..832d9e6f17a9 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -16,8 +16,6 @@ Tests For Zone Aware Scheduler. """ -import stubout - import nova.db from nova import exception @@ -170,14 +168,6 @@ def fake_zone_get_all(context): class ZoneAwareSchedulerTestCase(test.TestCase): """Test case for Zone Aware Scheduler.""" - def setUp(self): - super(ZoneAwareSchedulerTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() - - def tearDown(self): - self.stubs.UnsetAll() - super(ZoneAwareSchedulerTestCase, self).tearDown() - def test_zone_aware_scheduler(self): """ Create a nested set of FakeZones, ensure that a select call returns the