Merge "Stop handling cells v1 for instance naming"

This commit is contained in:
Zuul 2019-05-29 03:56:29 +00:00 committed by Gerrit Code Review
commit 809c367c85
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 default_hostname = 'Server-%s' % instance.uuid
instance.hostname = utils.sanitize_hostname( instance.hostname = utils.sanitize_hostname(
instance.display_name, default_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 old_display_name = instance.display_name
new_display_name = '%s-%d' % (old_display_name, index + 1) new_display_name = '%s-%d' % (old_display_name, index + 1)

View File

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

View File

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

View File

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