encoding errors are raised by cobbler when non-ascii characters are used in a snippet on satellite 5.6

Solution Verified - Updated -

Environment

  • Red Hat Satellite 5.6
  • Red Hat Satellite 5.7

Issue

  • encoding errors are raised by cobbler when non-ascii characters are used in a snippet on satellite 5.6
Unexpected remote error, check the server side logs for further info
<type 'exceptions.UnicodeDecodeError'>:'ascii' codec can't decode byte 0xc3 in position 1101: ordinal not in range(128)

Resolution

Workaround

Using the webui :

Go to each kickstart profile affected and replace non-ascii characters with alternatives or remove them.
This needs to be done for snippets and scripts :
- snippets : systems > kickstart > kickstart snippets
- scripts : systems > kikckstart > profiles > *click on the profile* > scripts

Using the api :

For snippets the two calls
- kickstart.snippet.lostAll
- kickstart.snippet.createOrUpdate
can be used to respectively read the snippets and update them, and for the scripts you can use these 3 calls:
- kickstart.profile.listScripts
- kickstart.profile.removeScript
- kickstart.profile.addScript
can be used to list scripts (fetching their content), remove them and add the fixed versions.

Fix

Root Cause

Encoding issue with non-ascii characters in the database while cobbler expects ascii only.

Diagnostic Steps

in apache

[Tue May 06 14:25:56 2014] [error] possible cheetah template error

in cobbler, on the affected kickstart toto:1:sampleorg the command

cobbler profile getks validateks --name=toto:1:sampleorg

gives if a snippet has a non-ascii character

# *** ERROR ***
#
# There is a templating error preventing this file from rendering correctly.
#
# This is most likely not due to a bug in Cobbler and is something you can fix.
#
# Look at the message below to see what things are causing problems.
#
# (1) Does the template file reference a $variable that is not defined?
# (2) is there a formatting error in a Cheetah directive?
# (3) Should dollar signs ($) be escaped that are not being escaped?
#
# Try fixing the problem and then investigate to see if this message goes
# away or changes.
#
#
# 'ascii' codec can't decode byte 0xc3 in position 8008: ordinal not in range(128)
#   File "/usr/lib/python2.6/site-packages/cobbler/templar.py", line 126, in render
#     data_out = t.respond()
#
#   File "cheetah_DynamicallyCompiledCheetahTemplate_1399363129_91_69957.py", line 367, in respond
#
#   File "cheetah_DynamicallyCompiledCheetahTemplate_1399363129_91_69957.py", line 130, in __errorCatcher10
#
#   File "<string>", line 1, in <module>
#
#   File "/usr/lib/python2.6/site-packages/cobbler/template_api.py", line 333, in SNIPPET
#     result = BuiltinTemplate.SNIPPET(self, file)
#
#   File "DynamicallyCompiledCheetahTemplate.py", line 85, in SNIPPET
#
#   File "/usr/lib64/python2.6/site-packages/Cheetah/Template.py", line 1583, in _handleCheetahInclude
#     nestedTemplateClass = compiler.compile(source=source, file=file)
#
#   File "/usr/lib/python2.6/site-packages/cobbler/template_api.py", line 289, in compile
#     return Cheetah.Template.Template.compile(*args, **kwargs)
#
#   File "/usr/lib64/python2.6/site-packages/Cheetah/Template.py", line 737, in compile
#     settings=(compilerSettings or {}))
#
#   File "/usr/lib/python2.6/site-packages/cobbler/template_api.py", line 129, in __init__
#     Cheetah.Compiler.ModuleCompiler.__init__(self, *args, **kwargs)
#
#   File "/usr/lib64/python2.6/site-packages/Cheetah/Compiler.py", line 1575, in __init__
#     source = unicode(source)
#

or with just a non-ascii character in a script

### ERROR ###
Unexpected remote error, check the server side logs for further info
<type 'exceptions.UnicodeDecodeError'>:'ascii' codec can't decode byte 0xc3 in position 1101: ordinal not in range(128)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments