提交 232eb64a 编写于 作者: D Daniel Gustafsson

Add config option to choose fqdn or hostname and use socket module

The new option spells out fully_qualified_domain_name since fqdn is
such a mouthful of an abbreviation. In order to retrieve the fqdn or
hostname in a portable manner the Python socket module seems the best
bet. It also avoids the overhead of opening a command interpreter and
pipe to get the information.
上级 c550b9ca
......@@ -51,6 +51,7 @@ except Exception, e:
import hashlib
import datetime,getpass,os,signal,socket,subprocess,threading,time,traceback,re
import uuid
import socket
thePlatform = platform.system()
if thePlatform in ['Windows', 'Microsoft']:
......@@ -1628,15 +1629,13 @@ class gpload:
# do default host, the current one
if not local_hostname:
try:
pipe = subprocess.Popen("hostname",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
result = pipe.communicate();
except OSError, e:
self.log(self.ERROR, "command failed: " + str(e))
local_hostname = [result[0].strip()]
# if fully_qualified_domain_name is defined and set to true we want to
# resolve the fqdn rather than just grabbing the hostname.
fqdn = self.getconfig(name+':fully_qualified_domain_name', bool, False)
if fqdn:
local_hostname = socket.getfqdn()
else:
local_hostname = socket.gethostname()
# build gpfdist parameters
popenList = ['gpfdist']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册