Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cobbler GUI failing on DJANGO_SETTINGS_MODULE #348

Closed
georgeslee opened this issue Nov 1, 2012 · 8 comments
Closed

Cobbler GUI failing on DJANGO_SETTINGS_MODULE #348

georgeslee opened this issue Nov 1, 2012 · 8 comments

Comments

@georgeslee
Copy link

Installed on Centos 6.3 x86_64
cobbler.noarch 2.2.3-2.el6 @epel
cobbler-web.noarch 2.2.3-2.el6 @epel

cobbler sync works no problem, but the web gui throws this error:

MOD_PYTHON ERROR

ProcessId: 4507
Interpreter: 'cobbler.wil'

ServerName: 'cobbler.wil'
DocumentRoot: '/var/www/html'

URI: '/cobbler_web'
Location: '/cobbler_web'
Directory: None
Filename: '/var/www/html/cobbler_web'
PathInfo: ''

Phase: 'PythonAuthenHandler'
Handler: 'cobbler_web.views'

Traceback (most recent call last):

File "/usr/lib64/python2.6/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/usr/lib64/python2.6/site-packages/mod_python/importer.py", line 1202, in _process_target
module = import_module(module_name, path=path)

File "/usr/lib64/python2.6/site-packages/mod_python/importer.py", line 304, in import_module
return import(module_name, {}, {}, ['*'])

File "/usr/share/cobbler/web/cobbler_web/views.py", line 6, in
from django.shortcuts import render_to_response

File "/usr/lib/python2.6/site-packages/django/shortcuts/init.py", line 10, in
from django.db.models.manager import Manager

File "/usr/lib/python2.6/site-packages/django/db/init.py", line 14, in
if not settings.DATABASES:

File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 276, in getattr
self._setup()

File "/usr/lib/python2.6/site-packages/django/conf/init.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)

ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

@jimi-c
Copy link
Member

jimi-c commented Nov 1, 2012

Have you upgraded recently? It would seem that the WSGI script is not behaving correctly, which is in /usr/share/cobbler/web/cobbler.wsgi

This file should look something like this:

import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
os.environ['PYTHON_EGG_CACHE'] = '/var/lib/cobbler/webui_cache'
sys.path.append('/usr/share/cobbler/web')
sys.path.append('/usr/share/cobbler/web/cobbler_web')
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Did you upgrade from an older version or copy config files over from an older version? Make sure the cobbler_web.conf file matches what is in the master git repository, and make sure there aren't any .rpmnew files in /etc/httpd/conf.d/ related to cobbler.

@georgeslee
Copy link
Author

Thanks! I followed another write up which modified cobbler_web.conf that
was faulty!

On Thu, Nov 1, 2012 at 5:29 AM, James Cammarata notifications@github.comwrote:

Have you upgraded recently? It would seem that the WSGI script is not
behaving correctly, which is in /usr/share/cobbler/web/cobbler.wsgi

This file should look something like this:

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
os.environ['PYTHON_EGG_CACHE'] = '/var/lib/cobbler/webui_cache'
sys.path.append('/usr/share/cobbler/web')
sys.path.append('/usr/share/cobbler/web/cobbler_web')

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Did you upgrade from an older version or copy config files over from an
older version? Make sure the cobbler_web.conf file matches what is in the
master git repository, and make sure there aren't any .rpmnew files in
/etc/httpd/conf.d/ related to cobbler.


Reply to this email directly or view it on GitHubhttps://github.com//issues/348#issuecomment-9978563.

@jimi-c
Copy link
Member

jimi-c commented Nov 2, 2012

No problem, let me know if you have any more problems.

@jimi-c jimi-c closed this as completed Nov 2, 2012
@madkiss
Copy link

madkiss commented Mar 23, 2013

@georgeslee it would have been incredibly helpful could you have left behind a comment on which other write up you found and what exactly was faulty with regards to your cobbler_web.conf.

@eklein
Copy link

eklein commented Nov 5, 2013

Argh, I've hit this too and would love to see the solution as well.

Any ideas?

@jimi-c
Copy link
Member

jimi-c commented Nov 6, 2013

@eklein Make sure you're using the cobbler_web.conf file from the git repo. Are you seeing the exact same error?

@eklein
Copy link

eklein commented Nov 6, 2013

@jimi-c, That's exactly what I ended up having to do. For anyone else who runs into the issue, the main piece I had to fix was related to mod_python vs mod_wsgi in cobbler_web.conf. I had upgraded cobbler and cobbler_web from 2.0 to 2.4. I had to replace everything associated with the mod_python config:

<Location "/cobbler_web">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings
    # PythonOption django.root /cobbler_web
    PythonDebug On
    PythonPath "['/usr/share/cobbler/web/'] + sys.path"
    AuthBasicAuthoritative Off
    AuthType basic
    AuthName "Cobbler"
    Require valid-user
    PythonAuthenHandler cobbler_web.views
</Location>

with:

WSGIScriptAlias /cobbler_web /usr/share/cobbler/web/cobbler.wsgi

My cobbler.conf was still stock (matches what's in the git repo). Once I got that functioning, I went through /etc/cobbler/settings and adapted any changes I had made to the new settings file (was placed in /etc/cobbler/settings.rpmnew). I then replaced /etc/cobbler/settings with the new file that I had modified. Finally, I had to add the following lines to the bottom of my /etc/cobbler/modules.conf:

[tftpd]
module = manage_in_tftpd

Once I'd made all of my changes, I ran a cobbler sync, /etc/init.d/cobblerd restart, as well as a cobbler check to find any lingering problems with my installation.

I appreciate the response, this ended up being a simple solution but was fairly painful to work through :)

@koolipaasha
Copy link

@eklein I tried all the above steps,but still web page shows internal server error with this in error log:

[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] mod_wsgi (pid=16954): Exception occurred processing WSGI script '/usr/share/cobbler/web/cobbler.wsgi'.
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] Traceback (most recent call last):
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 230, in call
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] self.load_middleware()
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 33, in load_middleware
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 269, in getattr
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] self._setup()
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] File "/usr/lib/python2.4/site-packages/django/conf/init.py", line 40, in _setup
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] self._wrapped = Settings(settings_module)
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] File "/usr/lib/python2.4/site-packages/django/conf/init.py", line 108, in init
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] os.environ['TZ'] = self.TIME_ZONE
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] File "/usr/lib64/python2.4/os.py", line 463, in setitem
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] putenv(key, item)
[Wed Sep 10 19:22:57 2014] [error] [client X.X.X.135] TypeError: putenv() argument 2 must be string, not None

Can you tell me whats wrong here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants