Skip to content

Commit

Permalink
Replaced default hostname function from gethostname to getfqdn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Luis Fernandez Alvarez committed Sep 26, 2012
1 parent c367fa5 commit 5dd1553
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nova/compute/manager.py
Expand Up @@ -91,7 +91,7 @@
'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',
Expand Down
2 changes: 1 addition & 1 deletion nova/console/manager.py
Expand Up @@ -37,7 +37,7 @@
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'),
]

Expand Down
2 changes: 1 addition & 1 deletion nova/flags.py
Expand Up @@ -295,7 +295,7 @@ def _get_my_ip():
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 '
Expand Down
2 changes: 1 addition & 1 deletion nova/network/manager.py
Expand Up @@ -143,7 +143,7 @@
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,
Expand Down
2 changes: 1 addition & 1 deletion nova/openstack/common/rpc/impl_zmq.py
Expand Up @@ -64,7 +64,7 @@
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.')
]
Expand Down
8 changes: 4 additions & 4 deletions nova/volume/solidfire.py
Expand Up @@ -167,7 +167,7 @@ def _create_sfaccount(self, nova_project_id):
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...'),
Expand All @@ -194,7 +194,7 @@ def _get_cluster_info(self):
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 = {}
Expand Down Expand Up @@ -304,7 +304,7 @@ def delete_volume(self, volume, is_snapshot=False):
"""

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)
Expand Down Expand Up @@ -352,7 +352,7 @@ def create_export(self, context, volume):
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)
Expand Down
2 changes: 1 addition & 1 deletion tools/conf/extract_opts.py
Expand Up @@ -118,7 +118,7 @@ def _get_my_ip():


MY_IP = _get_my_ip()
HOST = socket.gethostname()
HOST = socket.getfqdn()


def _sanitize_default(s):
Expand Down

0 comments on commit 5dd1553

Please sign in to comment.