Fix various errors discovered by pylint and pyflakes.
This commit is contained in:
1
Authors
1
Authors
@@ -67,6 +67,7 @@ Lvov Maxim <usrleon@gmail.com>
|
||||
Mark Washenberger <mark.washenberger@rackspace.com>
|
||||
Masanori Itoh <itoumsn@nttdata.co.jp>
|
||||
Matt Dietz <matt.dietz@rackspace.com>
|
||||
Matthew Hooker <matt@cloudscaling.com>
|
||||
Michael Gundlach <michael.gundlach@rackspace.com>
|
||||
Mike Scherbakov <mihgen@gmail.com>
|
||||
Mohammed Naser <mnaser@vexxhost.com>
|
||||
|
||||
@@ -28,6 +28,7 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.scheduler import zone_aware_scheduler
|
||||
from nova import utils
|
||||
from nova import exception
|
||||
|
||||
LOG = logging.getLogger('nova.scheduler.least_cost')
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class ZoneAwareScheduler(driver.Scheduler):
|
||||
decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key)
|
||||
try:
|
||||
json_entry = decryptor(blob)
|
||||
return json.dumps(entry)
|
||||
return json.dumps(json_entry)
|
||||
except M2Crypto.EVP.EVPError:
|
||||
pass
|
||||
return None
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
Tests For Zone Aware Scheduler.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import nova.db
|
||||
|
||||
from nova import exception
|
||||
@@ -327,3 +329,19 @@ class ZoneAwareSchedulerTestCase(test.TestCase):
|
||||
sched._provision_resource_from_blob(None, request_spec, 1,
|
||||
request_spec, {})
|
||||
self.assertTrue(was_called)
|
||||
|
||||
def test_decrypt_blob(self):
|
||||
"""Test that the decrypt method works."""
|
||||
|
||||
fixture = FakeZoneAwareScheduler()
|
||||
test_data = {"foo": "bar"}
|
||||
|
||||
class StubDecryptor(object):
|
||||
def decryptor(self, key):
|
||||
return lambda blob: blob
|
||||
|
||||
self.stubs.Set(zone_aware_scheduler, 'crypto',
|
||||
StubDecryptor())
|
||||
|
||||
self.assertEqual(fixture._decrypt_blob(test_data),
|
||||
json.dumps(test_data))
|
||||
|
||||
@@ -877,6 +877,22 @@ class XenAPIMigrateInstance(test.TestCase):
|
||||
network_info, resize_instance=False)
|
||||
|
||||
|
||||
class XenAPIImageTypeTestCase(test.TestCase):
|
||||
"""Test ImageType class."""
|
||||
|
||||
def test_to_string(self):
|
||||
"""Can convert from type id to type string."""
|
||||
self.assertEquals(
|
||||
vm_utils.ImageType.to_string(vm_utils.ImageType.KERNEL),
|
||||
vm_utils.ImageType.KERNEL_STR)
|
||||
|
||||
def test_from_string(self):
|
||||
"""Can convert from string to type id."""
|
||||
self.assertEquals(
|
||||
vm_utils.ImageType.from_string(vm_utils.ImageType.KERNEL_STR),
|
||||
vm_utils.ImageType.KERNEL)
|
||||
|
||||
|
||||
class XenAPIDetermineDiskImageTestCase(test.TestCase):
|
||||
"""Unit tests for code that detects the ImageType."""
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user