Update the command to change the hostname

The instance hostname configuration is temporary, it will fail
after resart the instance.

Story: 1742369
Task: 8385

Change-Id: Ibd5891fb2ba7dc825b42a79b7df14d964ee34b1a
This commit is contained in:
caowei 2018-01-10 14:03:49 +08:00 committed by Luigi Toscano
parent 5535350aff
commit b81742028e
1 changed files with 4 additions and 2 deletions

View File

@ -170,11 +170,13 @@ class Engine(object):
def _configure_instance_etc_hosts(self, instance, cluster):
LOG.debug('Configuring "/etc/hosts" of instance.')
hosts_file = cluster_utils.generate_etc_hosts(cluster)
hostname = instance.fqdn()
with instance.remote() as r:
r.write_file_to('etc-hosts', hosts_file)
r.execute_command('sudo hostname %s' % instance.fqdn())
r.write_file_to('etc-hostname', hostname)
r.execute_command('sudo hostname %s' % hostname)
r.execute_command('sudo mv etc-hosts /etc/hosts')
r.execute_command('sudo mv etc-hostname /etc/hostname')
r.execute_command('sudo usermod -s /bin/bash $USER')
def _configure_instance_resolve_conf(self, instance):