Replaced default hostname function from gethostname to getfqdn

Fixes bug 1055503

The standard behaviour of the 'gethostname' function in Python differs from
Linux to Windows. A common Linux configuration returns the FQDN, while a
Windows one returns only the host name.

To resolve inconsistent node naming in deployments that mix windows and
Linux, it is proposed to use 'getfqdn' as default function instead of
'gethostname'. This is function is more predictable in all cases.

Change-Id: I3164d9a36df2b8484bbf9a57879c31fa0e342503
This commit is contained in:
Luis Fernandez Alvarez 2012-09-25 17:33:59 +02:00
parent c367fa5e4a
commit 5dd1553cca
7 changed files with 10 additions and 10 deletions

View File

@ -91,7 +91,7 @@ compute_opts = [
'fake.FakeDriver, baremetal.BareMetalDriver, '
'vmwareapi.VMWareESXDriver'),
cfg.StrOpt('console_host',
default=socket.gethostname(),
default=socket.getfqdn(),
help='Console proxy host to use to connect '
'to instances on this host.'),
cfg.IntOpt('live_migration_retry_count',

View File

@ -37,7 +37,7 @@ console_manager_opts = [
default=False,
help='Stub calls to compute worker for tests'),
cfg.StrOpt('console_public_hostname',
default=socket.gethostname(),
default=socket.getfqdn(),
help='Publicly visible name for this console host'),
]

View File

@ -295,7 +295,7 @@ global_opts = [
default='nova.scheduler.manager.SchedulerManager',
help='full class name for the Manager for scheduler'),
cfg.StrOpt('host',
default=socket.gethostname(),
default=socket.getfqdn(),
help='Name of this node. This can be an opaque identifier. '
'It is not necessarily a hostname, FQDN, or IP address. '
'However, the node name must be valid within '

View File

@ -143,7 +143,7 @@ network_opts = [
default=False,
help='Autoassigning floating ip to VM'),
cfg.StrOpt('network_host',
default=socket.gethostname(),
default=socket.getfqdn(),
help='Network host to use for ip allocation in flat modes'),
cfg.BoolOpt('fake_call',
default=False,

View File

@ -64,7 +64,7 @@ zmq_opts = [
cfg.StrOpt('rpc_zmq_ipc_dir', default='/var/run/openstack',
help='Directory for holding IPC sockets'),
cfg.StrOpt('rpc_zmq_host', default=socket.gethostname(),
cfg.StrOpt('rpc_zmq_host', default=socket.getfqdn(),
help='Name of this node. Must be a valid hostname, FQDN, or '
'IP address. Must match "host" option, if running Nova.')
]

View File

@ -167,7 +167,7 @@ class SolidFire(SanISCSIDriver):
just return it. If not, then create it.
"""
sf_account_name = socket.gethostname() + '-' + nova_project_id
sf_account_name = socket.getfqdn() + '-' + nova_project_id
sfaccount = self._get_sfaccount_by_name(sf_account_name)
if sfaccount is None:
LOG.debug(_('solidfire account: %s does not exist, create it...'),
@ -194,7 +194,7 @@ class SolidFire(SanISCSIDriver):
def _do_export(self, volume):
"""Gets the associated account, retrieves CHAP info and updates."""
sfaccount_name = '%s-%s' % (socket.gethostname(), volume['project_id'])
sfaccount_name = '%s-%s' % (socket.getfqdn(), volume['project_id'])
sfaccount = self._get_sfaccount_by_name(sfaccount_name)
model_update = {}
@ -304,7 +304,7 @@ class SolidFire(SanISCSIDriver):
"""
LOG.debug(_("Enter SolidFire delete_volume..."))
sf_account_name = socket.gethostname() + '-' + volume['project_id']
sf_account_name = socket.getfqdn() + '-' + volume['project_id']
sfaccount = self._get_sfaccount_by_name(sf_account_name)
if sfaccount is None:
raise exception.SfAccountNotFound(account_name=sf_account_name)
@ -352,7 +352,7 @@ class SolidFire(SanISCSIDriver):
def _do_create_snapshot(self, snapshot, snapshot_name):
"""Creates a snapshot."""
LOG.debug(_("Enter SolidFire create_snapshot..."))
sf_account_name = socket.gethostname() + '-' + snapshot['project_id']
sf_account_name = socket.getfqdn() + '-' + snapshot['project_id']
sfaccount = self._get_sfaccount_by_name(sf_account_name)
if sfaccount is None:
raise exception.SfAccountNotFound(account_name=sf_account_name)

View File

@ -118,7 +118,7 @@ def _get_my_ip():
MY_IP = _get_my_ip()
HOST = socket.gethostname()
HOST = socket.getfqdn()
def _sanitize_default(s):