Modify

Ticket #1028 (closed enhancement: fixed)

Opened 12 years ago

Last modified 12 years ago

Add support to LANG=es_ES in the chkconfig plugin

Reported by: https://www.google.com/accounts/o8/id?id=AItOawlJa6QJcUnwqaUiOAgop4U4wANp_y0hDu4 Owned by: solj
Priority: major Milestone: Bcfg2 1.2.0 Release
Component: bcfg2-client Version: 1.0
Keywords: Cc: [email protected]

Description

If I run the chkconfig command in a es_ES locale environment the status output is different from what the plugin wants and the service checks always fail:

ec4:~# chkconfig --list
NetworkManager  0:desactivado   1:desactivado   2:desactivado   3:desactivado   4:desactivado   5:desactivado   6:desactivado
acpid           0:desactivado   1:desactivado   2:activo        3:activo        4:activo        5:activo        6:desactivado

"on" == "activo" "off" == "desactivado"

Perhaps a solution could be unsetting the LANG environment variable before the chkconfig execution.

Attachments

Change History

comment:1 Changed 12 years ago by solj

  • Cc [email protected] added
  • Owner changed from desai to solj
  • Status changed from new to accepted

That's an interesting idea. So, does this work for you?

diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py
index 7bf176f..8b32a18 100644
--- a/src/lib/Client/Tools/Chkconfig.py
+++ b/src/lib/Client/Tools/Chkconfig.py
@@ -4,6 +4,8 @@
 """This is chkconfig support."""
 __revision__ = '$Revision$'
 
+import os
+
 import Bcfg2.Client.Tools
 import Bcfg2.Client.XML
 
@@ -14,6 +16,10 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool):
     __execs__ = ['/sbin/chkconfig']
     __handles__ = [('Service', 'chkconfig')]
     __req__ = {'Service': ['name', 'status']}
+    try:
+        del os.environ['LANG']
+    except KeyError:
+        pass
 
     def get_svc_command(self, service, action):
         return "/sbin/service %s %s" % (service.get('name'), action)

comment:2 Changed 12 years ago by https://www.google.com/accounts/o8/id?id=AItOawlJa6QJcUnwqaUiOAgop4U4wANp_y0hDu4

Yes, it's works.

Although I'm not sure what is best, unset the variable or set it to LANG=C. I think that is safer to set it to C instead of unsetting it (that is what I said at the beginning, sorry).

In http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_02 this document I read the following: "If the LANG environment variable is not set or is set to the empty string, the implementation-defined default locale shall be used". So I suppose is better to set some value to LANG.

comment:3 Changed 12 years ago by solj

try #2

diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py
index 7bf176f..12d1a34 100644
--- a/src/lib/Client/Tools/Chkconfig.py
+++ b/src/lib/Client/Tools/Chkconfig.py
@@ -4,6 +4,8 @@
 """This is chkconfig support."""
 __revision__ = '$Revision$'
 
+import os
+
 import Bcfg2.Client.Tools
 import Bcfg2.Client.XML
 
@@ -14,6 +16,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool):
     __execs__ = ['/sbin/chkconfig']
     __handles__ = [('Service', 'chkconfig')]
     __req__ = {'Service': ['name', 'status']}
+    os.environ['LANG'] = 'C'
 
     def get_svc_command(self, service, action):
         return "/sbin/service %s %s" % (service.get('name'), action)

comment:4 Changed 12 years ago by https://www.google.com/accounts/o8/id?id=AItOawlJa6QJcUnwqaUiOAgop4U4wANp_y0hDu4

Yes, it works too.

comment:5 Changed 12 years ago by solj

  • Status changed from accepted to closed
  • Resolution set to fixed

WARNING! You need to establish a session before you can create or edit tickets. Otherwise the ticket will get treated as spam.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.