diff options
| author | Nirmal Ranganathan <nirmal.ranganathan@rackspace.coom> | 2011-02-28 18:59:34 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-02-28 18:59:34 +0000 |
| commit | 78bd53a44a529f0c6641357fa001d4d037fbc375 (patch) | |
| tree | ab54f7b07b0da07a4277eb5aef8ca1459af4db5d /nova | |
| parent | 4aa2ffe87744d3653c741d4d3e019114e3e9e5bf (diff) | |
| parent | a457595224a5ca5cdb0191ba2f6fa542d16e18f5 (diff) | |
| download | nova-78bd53a44a529f0c6641357fa001d4d037fbc375.tar.gz nova-78bd53a44a529f0c6641357fa001d4d037fbc375.tar.xz nova-78bd53a44a529f0c6641357fa001d4d037fbc375.zip | |
Wrapped the instance_types comparison with an int and added a test case for it. Removed the inadvertently added newline
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/compute/instance_types.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_compute.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py index 309313fd0..7a2a5baa3 100644 --- a/nova/compute/instance_types.py +++ b/nova/compute/instance_types.py @@ -45,6 +45,6 @@ def get_by_type(instance_type): def get_by_flavor_id(flavor_id): for instance_type, details in INSTANCE_TYPES.iteritems(): - if details['flavorid'] == flavor_id: + if details['flavorid'] == int(flavor_id): return instance_type return FLAGS.default_instance_type diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b049ac943..949b5e6eb 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -30,6 +30,7 @@ from nova import log as logging from nova import test from nova import utils from nova.auth import manager +from nova.compute import instance_types LOG = logging.getLogger('nova.tests.compute') @@ -266,3 +267,10 @@ class ComputeTestCase(test.TestCase): self.assertEqual(ret_val, None) self.compute.terminate_instance(self.context, instance_id) + + def test_get_by_flavor_id(self): + type = instance_types.get_by_flavor_id(1) + self.assertEqual(type, 'm1.tiny') + + type = instance_types.get_by_flavor_id("1") + self.assertEqual(type, 'm1.tiny') |
