Merge pull request #34972 from twangboy/int_tests_hosts

Fix hosts integration tests for Windows
This commit is contained in:
Mike Place 2016-07-28 13:36:11 -06:00 committed by GitHub
commit 9adfa4a651
5 changed files with 11 additions and 9 deletions

View File

@ -27,6 +27,12 @@ import salt.utils.sdb as sdb
# Import 3rd-party libs
import salt.ext.six as six
if salt.utils.is_windows():
_HOSTS_FILE = os.path.join(
os.environ['SystemRoot'], 'System32', 'drivers', 'etc', 'hosts')
else:
_HOSTS_FILE = os.path.join(os.sep, 'etc', 'hosts')
log = logging.getLogger(__name__)
__proxyenabled__ = ['*']
@ -65,7 +71,7 @@ DEFAULTS = {'mongo.db': 'salt',
'ldap.attrs': None,
'ldap.binddn': '',
'ldap.bindpw': '',
'hosts.file': '/etc/hosts',
'hosts.file': _HOSTS_FILE,
'aliases.file': '/etc/aliases',
'virt.images': os.path.join(syspaths.SRV_ROOT_DIR, 'salt-images'),
'virt.tunnel': False,

View File

@ -21,10 +21,6 @@ def __get_hosts_filename():
'''
Return the path to the appropriate hosts file
'''
# TODO: Investigate using "%SystemRoot%\system32" for this
if salt.utils.is_windows():
return 'C:\\Windows\\System32\\drivers\\etc\\hosts'
return __salt__['config.option']('hosts.file')

View File

@ -1021,6 +1021,8 @@ class TestDaemon(object):
minion_opts['config_dir'] = TMP_CONF_DIR
minion_opts['root_dir'] = os.path.join(TMP, 'rootdir')
minion_opts['pki_dir'] = os.path.join(TMP, 'rootdir', 'pki')
minion_opts['hosts.file'] = os.path.join(TMP, 'rootdir', 'hosts')
minion_opts['aliases.file'] = os.path.join(TMP, 'rootdir', 'aliases')
# This sub_minion also connects to master
sub_minion_opts = salt.config._read_conf_file(os.path.join(CONF_DIR, 'sub_minion'))
@ -1029,6 +1031,8 @@ class TestDaemon(object):
sub_minion_opts['config_dir'] = TMP_SUB_MINION_CONF_DIR
sub_minion_opts['root_dir'] = os.path.join(TMP, 'rootdir-sub-minion')
sub_minion_opts['pki_dir'] = os.path.join(TMP, 'rootdir-sub-minion', 'pki', 'minion')
sub_minion_opts['hosts.file'] = os.path.join(TMP, 'rootdir', 'hosts')
sub_minion_opts['aliases.file'] = os.path.join(TMP, 'rootdir', 'aliases')
# This is the master of masters
syndic_master_opts = salt.config._read_conf_file(os.path.join(CONF_DIR, 'syndic_master'))

View File

@ -14,8 +14,6 @@ pidfile: minion.pid
# module extension
test.foo: baz
hosts.file: /tmp/salt-tests-tmpdir/hosts
aliases.file: /tmp/salt-tests-tmpdir/aliases
integration.test: True
# Grains addons

View File

@ -14,8 +14,6 @@ pidfile: sub_minion.pid
# module extension
test.foo: baz
hosts.file: /tmp/salt-tests-tmpdir/hosts
aliases.file: /tmp/salt-tests-tmpdir/aliases
integration.test: True
# Grains addons