Merge "Fix invalid /etc/hosts edit"
This commit is contained in:
commit
721400682d
|
@ -203,7 +203,8 @@ class TestCheckHostname(BaseTestCase):
|
|||
undercloud._check_hostname()
|
||||
mock_run_command.assert_called_with([
|
||||
'sudo', '/bin/bash', '-c',
|
||||
'echo 127.0.0.1 test.hostname test >> /etc/hosts'],
|
||||
'sed -i "s/127.0.0.1\(\s*\)/127.0.0.1\\1test.hostname test /" '
|
||||
'/etc/hosts'],
|
||||
name='hostname-to-etc-hosts')
|
||||
|
||||
@mock.patch('instack_undercloud.undercloud._run_command')
|
||||
|
@ -219,7 +220,8 @@ class TestCheckHostname(BaseTestCase):
|
|||
undercloud._check_hostname()
|
||||
mock_run_command.assert_called_with([
|
||||
'sudo', '/bin/bash', '-c',
|
||||
'echo 127.0.0.1 test.hostname test >> /etc/hosts'],
|
||||
'sed -i "s/127.0.0.1\(\s*\)/127.0.0.1\\1test.hostname test /" '
|
||||
'/etc/hosts'],
|
||||
name='hostname-to-etc-hosts')
|
||||
|
||||
@mock.patch('instack_undercloud.undercloud._run_command')
|
||||
|
@ -237,7 +239,9 @@ class TestCheckHostname(BaseTestCase):
|
|||
undercloud._check_hostname()
|
||||
mock_run_command.assert_called_with([
|
||||
'sudo', '/bin/bash', '-c',
|
||||
'echo 127.0.0.1 test-hostname.domain test-hostname >> /etc/hosts'],
|
||||
'sed -i "s/127.0.0.1\(\s*\)/'
|
||||
'127.0.0.1\\1test-hostname.domain test-hostname /" '
|
||||
'/etc/hosts'],
|
||||
name='hostname-to-etc-hosts')
|
||||
|
||||
@mock.patch('instack_undercloud.undercloud._run_command')
|
||||
|
|
|
@ -637,9 +637,10 @@ def _check_hostname():
|
|||
if short_hostname == detected_static_hostname:
|
||||
raise RuntimeError('Configured hostname is not fully '
|
||||
'qualified.')
|
||||
echo_cmd = ('echo 127.0.0.1 %s %s >> /etc/hosts' %
|
||||
(detected_static_hostname, short_hostname))
|
||||
args = ['sudo', '/bin/bash', '-c', echo_cmd]
|
||||
sed_cmd = ('sed -i "s/127.0.0.1\(\s*\)/127.0.0.1\\1%s %s /" '
|
||||
'/etc/hosts' %
|
||||
(detected_static_hostname, short_hostname))
|
||||
args = ['sudo', '/bin/bash', '-c', sed_cmd]
|
||||
_run_command(args, name='hostname-to-etc-hosts')
|
||||
LOG.info('Added hostname %s to /etc/hosts',
|
||||
detected_static_hostname)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
fixes:
|
||||
- When the hostname was written to /etc/hosts, it resulted in an invalid
|
||||
/etc/hosts file due to 127.0.0.1 being specified twice on different lines.
|
||||
That issue is now corrected such that the hostnames will be added to the
|
||||
existing line for 127.0.0.1, which results in valid syntax for /etc/hosts.
|
||||
See https://bugs.launchpad.net/tripleo/+bug/1709460
|
Loading…
Reference in New Issue