diff options
| author | Eric Day <eday@oddments.org> | 2010-12-02 09:34:52 -0800 |
|---|---|---|
| committer | Eric Day <eday@oddments.org> | 2010-12-02 09:34:52 -0800 |
| commit | 325e84d4734d381da4a4bef166ec228aa1a4b0a8 (patch) | |
| tree | ef5b16ce14a859e95d2cb49ced6168960e5d0933 | |
| parent | 1bcc4da8bbcfdfee8f5eed80e9115d51803f86e2 (diff) | |
| parent | 644699a21a65dc15d21ea23f46a10f730d317791 (diff) | |
| download | nova-325e84d4734d381da4a4bef166ec228aa1a4b0a8.tar.gz nova-325e84d4734d381da4a4bef166ec228aa1a4b0a8.tar.xz nova-325e84d4734d381da4a4bef166ec228aa1a4b0a8.zip | |
Merged trunk and resolved conflicts. Again.
| -rw-r--r-- | nova/compute/api.py | 2 | ||||
| -rw-r--r-- | nova/tests/compute_unittest.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 83bd7faef..929342a1e 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -182,7 +182,7 @@ class ComputeAPI(base.Base): instance_ref = self.db.instance_create(context, kwargs) inst_id = instance_ref['id'] # Set sane defaults if not specified - if 'display_name' not in kwargs: + if kwargs.get('display_name') is None: display_name = "Server %s" % instance_ref['internal_id'] instance_ref['display_name'] = display_name self.db.instance_update(context, inst_id, diff --git a/nova/tests/compute_unittest.py b/nova/tests/compute_unittest.py index 8f6f35b35..a55449739 100644 --- a/nova/tests/compute_unittest.py +++ b/nova/tests/compute_unittest.py @@ -68,6 +68,17 @@ class ComputeTestCase(test.TrialTestCase): inst['ami_launch_index'] = 0 return db.instance_create(self.context, inst)['id'] + def test_create_instance_defaults_display_name(self): + """Verify that an instance cannot be created without a display_name.""" + cases = [dict(), dict(display_name=None)] + for instance in cases: + ref = self.compute_api.create_instance(self.context, None, + **instance) + try: + self.assertNotEqual(ref.display_name, None) + finally: + db.instance_destroy(self.context, ref['id']) + def test_create_instance_associates_security_groups(self): """Make sure create_instance associates security groups""" inst = {} |
