salt/fix-setting-language-on-suse-systems.patch
Klaus Kämpf ae1540a455 Accepting request 514025 from systemsmanagement:saltstack:testing
- Bugfix: clean up `change` attribute from interface dict (upstream)
  Issue: https://github.com/saltstack/salt/issues/41461
  PR: 1. https://github.com/saltstack/salt/pull/41487
      2. https://github.com/saltstack/salt/pull/41533
Added:
  * clean-up-change-attribute-from-interface-dict.patch

- Bugfix: orchestrate and batches returns false failed information
  https://github.com/saltstack/salt/issues/40635
- speed-up cherrypy by removing sleep call
- wrong os_family grains on SUSE - fix unittests (bsc#1038855)
- fix setting the language on SUSE systems (bsc#1038855)
- Bugfix: unable to use hostname for minion ID as '127' (upstream)
- Bugfix: remove sleep call in CheppryPy API handler (upstream)
- Fix core grains constants for timezone (bsc#1032931)
- Added:
  * bugfix-unable-to-use-127-as-hostname.patch
  * fix-grain-for-os_family-on-suse-series.patch
  * fix-os_family-case-in-unittest.patch
  * fix-setting-language-on-suse-systems.patch
  * fixed-issue-with-parsing-of-master-minion-returns-wh.patch
  * rest_cherrypy-remove-sleep-call.patch
  * use-correct-grain-constants-for-timezone.patch

- Update to 2016.11.4
  See https://docs.saltstack.com/en/develop/topics/releases/2016.11.4.html
  for full changelog
- Changed:
  * add-options-for-dockerng.patch
  * fix-regression-in-file.get_managed-add-unit-tests.patch

OBS-URL: https://build.opensuse.org/request/show/514025
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=89
2017-08-04 10:29:26 +00:00

122 lines
5.5 KiB
Diff

From 2bc2078d8549c277ba40836de4e36953af9efc78 Mon Sep 17 00:00:00 2001
From: Michael Calmer <mc@suse.de>
Date: Thu, 18 May 2017 19:46:50 +0200
Subject: [PATCH] fix setting language on SUSE systems
---
salt/modules/localemod.py | 28 +++++++++++++++-------------
tests/unit/modules/localemod_test.py | 32 +++++++++++++++++---------------
2 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/salt/modules/localemod.py b/salt/modules/localemod.py
index b805cd429f..272aff4cc2 100644
--- a/salt/modules/localemod.py
+++ b/salt/modules/localemod.py
@@ -127,13 +127,14 @@ def get_locale():
salt '*' locale.get_locale
'''
cmd = ''
- if salt.utils.systemd.booted(__context__):
+ if 'Suse' in __grains__['os_family']:
+ # this block applies to all SUSE systems - also with systemd
+ cmd = 'grep "^RC_LANG" /etc/sysconfig/language'
+ elif salt.utils.systemd.booted(__context__):
params = _parse_dbus_locale() if HAS_DBUS else _parse_localectl()
return params.get('LANG', '')
elif 'RedHat' in __grains__['os_family']:
cmd = 'grep "^LANG=" /etc/sysconfig/i18n'
- elif 'Suse' in __grains__['os_family']:
- cmd = 'grep "^RC_LANG" /etc/sysconfig/language'
elif 'Debian' in __grains__['os_family']:
# this block only applies to Debian without systemd
cmd = 'grep "^LANG=" /etc/default/locale'
@@ -161,7 +162,17 @@ def set_locale(locale):
salt '*' locale.set_locale 'en_US.UTF-8'
'''
- if salt.utils.systemd.booted(__context__):
+ if 'Suse' in __grains__['os_family']:
+ # this block applies to all SUSE systems - also with systemd
+ if not __salt__['file.file_exists']('/etc/sysconfig/language'):
+ __salt__['file.touch']('/etc/sysconfig/language')
+ __salt__['file.replace'](
+ '/etc/sysconfig/language',
+ '^RC_LANG=.*',
+ 'RC_LANG="{0}"'.format(locale),
+ append_if_not_found=True
+ )
+ elif salt.utils.systemd.booted(__context__):
return _localectl_set(locale)
elif 'RedHat' in __grains__['os_family']:
if not __salt__['file.file_exists']('/etc/sysconfig/i18n'):
@@ -172,15 +183,6 @@ def set_locale(locale):
'LANG="{0}"'.format(locale),
append_if_not_found=True
)
- elif 'Suse' in __grains__['os_family']:
- if not __salt__['file.file_exists']('/etc/sysconfig/language'):
- __salt__['file.touch']('/etc/sysconfig/language')
- __salt__['file.replace'](
- '/etc/sysconfig/language',
- '^RC_LANG=.*',
- 'RC_LANG="{0}"'.format(locale),
- append_if_not_found=True
- )
elif 'Debian' in __grains__['os_family']:
# this block only applies to Debian without systemd
update_locale = salt.utils.which('update-locale')
diff --git a/tests/unit/modules/localemod_test.py b/tests/unit/modules/localemod_test.py
index b5cedfd8a6..069a3c6503 100644
--- a/tests/unit/modules/localemod_test.py
+++ b/tests/unit/modules/localemod_test.py
@@ -44,19 +44,20 @@ class LocalemodTestCase(TestCase):
Test for Get the current system locale
'''
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}):
- localemod.HAS_DBUS = True
- with patch.object(localemod,
- '_parse_dbus_locale',
- return_value={'LANG': 'A'}):
- self.assertEqual('A', localemod.get_locale())
- localemod._parse_dbus_locale.assert_called_once_with()
-
- localemod.HAS_DBUS = False
- with patch.object(localemod,
- '_parse_localectl',
- return_value={'LANG': 'A'}):
- self.assertEqual('A', localemod.get_locale())
- localemod._parse_localectl.assert_called_once_with()
+ with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}):
+ localemod.HAS_DBUS = True
+ with patch.object(localemod,
+ '_parse_dbus_locale',
+ return_value={'LANG': 'A'}):
+ self.assertEqual('A', localemod.get_locale())
+ localemod._parse_dbus_locale.assert_called_once_with()
+
+ localemod.HAS_DBUS = False
+ with patch.object(localemod,
+ '_parse_localectl',
+ return_value={'LANG': 'A'}):
+ self.assertEqual('A', localemod.get_locale())
+ localemod._parse_localectl.assert_called_once_with()
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}):
with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}):
@@ -82,8 +83,9 @@ class LocalemodTestCase(TestCase):
Test for Sets the current system locale
'''
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}):
- with patch.object(localemod, '_localectl_set', return_value=True):
- self.assertTrue(localemod.set_locale('l'))
+ with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}):
+ with patch.object(localemod, '_localectl_set', return_value=True):
+ self.assertTrue(localemod.set_locale('l'))
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}):
with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}):
--
2.13.0