Fixes bug 862637 -- make instance_name_template more flexible
Allow use of %(uuid)s in the template.. along with any other Instance attribute. Change-Id: I0c0ed8cf51d5cfc632c957c4559014eb1d7844d1
This commit is contained in:
@@ -1411,6 +1411,34 @@ class ComputeTestCase(test.TestCase):
|
|||||||
self.assertEqual(instance['reservation_id'], resv_id)
|
self.assertEqual(instance['reservation_id'], resv_id)
|
||||||
db.instance_destroy(self.context, instance['id'])
|
db.instance_destroy(self.context, instance['id'])
|
||||||
|
|
||||||
|
def test_instance_name_template(self):
|
||||||
|
"""Test the instance_name template"""
|
||||||
|
self.flags(instance_name_template='instance-%d')
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
i_ref = db.instance_get(self.context, instance_id)
|
||||||
|
self.assertEqual(i_ref['name'], 'instance-%d' % i_ref['id'])
|
||||||
|
db.instance_destroy(self.context, i_ref['id'])
|
||||||
|
|
||||||
|
self.flags(instance_name_template='instance-%(uuid)s')
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
i_ref = db.instance_get(self.context, instance_id)
|
||||||
|
self.assertEqual(i_ref['name'], 'instance-%s' % i_ref['uuid'])
|
||||||
|
db.instance_destroy(self.context, i_ref['id'])
|
||||||
|
|
||||||
|
self.flags(instance_name_template='%(id)d-%(uuid)s')
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
i_ref = db.instance_get(self.context, instance_id)
|
||||||
|
self.assertEqual(i_ref['name'], '%d-%s' %
|
||||||
|
(i_ref['id'], i_ref['uuid']))
|
||||||
|
db.instance_destroy(self.context, i_ref['id'])
|
||||||
|
|
||||||
|
# not allowed.. default is uuid
|
||||||
|
self.flags(instance_name_template='%(name)s')
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
i_ref = db.instance_get(self.context, instance_id)
|
||||||
|
self.assertEqual(i_ref['name'], i_ref['uuid'])
|
||||||
|
db.instance_destroy(self.context, i_ref['id'])
|
||||||
|
|
||||||
|
|
||||||
class ComputeTestMinRamMinDisk(test.TestCase):
|
class ComputeTestMinRamMinDisk(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user