Merge "get_undercloud_registry() - Default to: 'localhost:8787'"

This commit is contained in:
Zuul 2019-10-23 04:25:49 +00:00 committed by Gerrit Code Review
commit 236ecbd9c7
2 changed files with 9 additions and 7 deletions

View File

@ -106,10 +106,12 @@ def get_undercloud_registry():
out, err = process.communicate()
if process.returncode != 0:
raise ImageUploaderException('No entry for %s in /etc/hosts'
% ctlplane_hostname)
address = out.split()[1]
LOG.warning('No entry for %s in /etc/hosts. Falling back to use the '
'default (localhost) undercloud registry.'
% ctlplane_hostname)
address = 'localhost'
else:
address = out.split()[1]
return '%s:%s' % (address, '8787')

View File

@ -118,15 +118,15 @@ class TestImageUploadManager(base.TestCase):
image_uploader.get_undercloud_registry())
@mock.patch('subprocess.Popen', autospec=True)
@mock.patch('socket.gethostname', return_value='undercloud.somedomain')
@mock.patch('socket.gethostname', return_value='localhost.localdomain')
def test_get_undercloud_registry_no_etc_hosts(self, mock_gethostname,
mock_popen):
mock_process = mock.Mock()
mock_process.communicate.return_value = ('', '')
mock_process.returncode = 2
mock_popen.return_value = mock_process
self.assertRaises(ImageUploaderException,
image_uploader.get_undercloud_registry)
self.assertEqual('localhost:8787',
image_uploader.get_undercloud_registry())
@mock.patch('subprocess.Popen', autospec=True)
@mock.patch('socket.gethostname', return_value='undercloud.somedomain')