Stop handling cells v1 for instance naming

Part of blueprint remove-cells-v1

Change-Id: I860bd822ec12d9f0df3aca58752446dc95c6dcfd
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2019-04-04 14:38:43 +01:00
parent 14cc25552a
commit 59784cfa6c
4 changed files with 8 additions and 21 deletions

View File

@ -1661,7 +1661,7 @@ class API(base.Base):
default_hostname = 'Server-%s' % instance.uuid
instance.hostname = utils.sanitize_hostname(
instance.display_name, default_hostname)
elif num_instances > 1 and self.cell_type != 'api':
elif num_instances > 1:
old_display_name = instance.display_name
new_display_name = '%s-%d' % (old_display_name, index + 1)

View File

@ -9936,8 +9936,6 @@ class ComputeAPITestCase(BaseTestCase):
"""Verify building one instance doesn't do anything funky with
the display and host names.
"""
# TODO(stephenfin): Remove cells_enabled parameter when we removed
# cells v1
num_instances = 1
refs, _ = self.compute_api.create(self.context,
self.default_flavor,
@ -9948,12 +9946,10 @@ class ComputeAPITestCase(BaseTestCase):
self.assertEqual(refs[0]['display_name'], name)
self.assertEqual(refs[0]['hostname'], name)
def test_multi_instance_display_name(self, cells_enabled=False):
def test_multi_instance_display_name(self):
"""Verify building two instances at once results in a unique
display and host name.
"""
# TODO(stephenfin): Remove cells_enabled parameter when we removed
# cells v1
num_instances = 2
refs, _ = self.compute_api.create(self.context,
self.default_flavor,
@ -9961,10 +9957,9 @@ class ComputeAPITestCase(BaseTestCase):
min_count=num_instances, max_count=num_instances,
display_name='x')
for i in range(num_instances):
name = 'x' if cells_enabled else 'x-%s' % (i + 1,)
hostname = None if cells_enabled else name
name = 'x-%s' % (i + 1,)
self.assertEqual(refs[i]['display_name'], name)
self.assertEqual(refs[i]['hostname'], hostname)
self.assertEqual(refs[i]['hostname'], name)
def test_instance_architecture(self):
# Test the instance architecture.

View File

@ -5423,19 +5423,13 @@ class _ComputeAPIUnitTestMixIn(object):
params = dict(display_name="vm")
instance = self._create_instance_obj(params=params)
self.compute_api._populate_instance_names(instance, 2, 1)
if self.cell_type != 'api':
self.assertEqual('vm-2', instance.hostname)
else:
self.assertNotIn('hostname', instance)
self.assertEqual('vm-2', instance.hostname)
def test_populate_instance_names_host_name_is_empty_multi(self):
params = dict(display_name=u'\u865a\u62df\u673a\u662f\u4e2d\u6587')
instance = self._create_instance_obj(params=params)
self.compute_api._populate_instance_names(instance, 2, 1)
if self.cell_type != 'api':
self.assertEqual('Server-%s' % instance.uuid, instance.hostname)
else:
self.assertNotIn('hostname', instance)
self.assertEqual('Server-%s' % instance.uuid, instance.hostname)
def test_host_statuses(self):
instances = [

View File

@ -456,12 +456,10 @@ class CellsComputeAPITestCase(test_compute.ComputeAPITestCase):
self.assertEqual(1, mock_msg.call_count)
def test_populate_instance_for_create(self):
super(CellsComputeAPITestCase, self).test_populate_instance_for_create(
num_instances=2)
self.skipTest("Removing cells v1")
def test_multi_instance_display_name(self):
super(CellsComputeAPITestCase,
self).test_multi_instance_display_name(cells_enabled=True)
self.skipTest("Removing cells v1")
@ddt.data(True, False)
def test_rdp_console(self, enabled_consoleauth):