ValueError: Key cannot be the null string - django-admin.py syncdb --migrate

363 views
Skip to first unread message

Daniel Townend

unread,
Aug 6, 2015, 10:28:39 AM8/6/15
to ganeti-webmgr
I've set up a mysql database and user and everything is correct in the config file. But when I run 'django-admin.py syncdb --migrate' to initialise the database I get the following error,

Traceback (most recent call last):
  File "/opt/ganeti_webmgr/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/south/management/commands/__init__.py", line 10, in <module>
    import django.template.loaders.app_directories
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/template/loaders/app_directories.py", line 21, in <module>
    mod = import_module(app)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/haystack/__init__.py", line 154, in <module>
    handle_registrations()
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/haystack/__init__.py", line 151, in handle_registrations
    search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/ganeti_webmgr/search_sites.py", line 2, in <module>
    haystack.autodiscover()
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/haystack/__init__.py", line 121, in autodiscover
    importlib.import_module("%s.search_indexes" % app)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/ganeti_webmgr/ganeti_web/search_indexes.py", line 3, in <module>
    from ganeti_webmgr.virtualmachines.models import VirtualMachine
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/ganeti_webmgr/virtualmachines/models.py", line 5, in <module>
    from ganeti_webmgr.clusters.models import CachedClusterObject
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/ganeti_webmgr/clusters/models.py", line 297, in <module>
    class Cluster(CachedClusterObject):
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/ganeti_webmgr/clusters/models.py", line 309, in Cluster
    max_length=128, blank=True)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/django_fields/fields.py", line 50, in __init__
    self.cipher = self.cipher_object.new(settings.SECRET_KEY[:32])
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/Crypto/Cipher/AES.py", line 95, in new
    return AESCipher(key, *args, **kwargs)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/Crypto/Cipher/AES.py", line 59, in __init__
    blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
  File "/opt/ganeti_webmgr/local/lib/python2.7/site-packages/Crypto/Cipher/blockalgo.py", line 141, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
ValueError: Key cannot be the null string

Am I being stupid and missing something obvious?

Evan Tschuy

unread,
Aug 6, 2015, 11:58:40 AM8/6/15
to ganeti...@googlegroups.com
That error generally means that either the WEB_MGR_API_KEY or the
SECRET_KEY isn't set to anything.
> --
> You received this message because you are subscribed to the Google Groups
> "ganeti-webmgr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ganeti-webmg...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Daniel Townend

unread,
Aug 7, 2015, 6:05:40 AM8/7/15
to ganeti...@googlegroups.com
They both exist in .secret and have a generated random key in both files?

You received this message because you are subscribed to a topic in the Google Groups "ganeti-webmgr" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ganeti-webmgr/KQ6GH6BHqZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ganeti-webmg...@googlegroups.com.

Evan Tschuy

unread,
Aug 7, 2015, 12:16:51 PM8/7/15
to ganeti...@googlegroups.com
Ah, ok. I think I've found the issue -- it turns out that there's a
bug in loading the credentials after they've been generated.

For now, if you're using a custom settings.py or config.yml file, you
can define SECRET_KEY or WEB_MGR_API_KEY in there and that should
work. I'm also going to get a fix pushed that you'll be able to use;
that should be available later today my time.

Thanks for the bug report!

Evan

Evan Tschuy

unread,
Aug 11, 2015, 3:15:11 PM8/11/15
to ganeti...@googlegroups.com
A fix is available in the develop branch. There are a few more changes
I want to make before we cut a new release, but there's no breaking
changes.

https://github.com/osuosl/ganeti_webmgr/tree/develop

Daniel Townend

unread,
Aug 12, 2015, 4:20:31 AM8/12/15
to ganeti...@googlegroups.com
That great Evan, thanks for your help :)

Daniel Townend

unread,
Aug 14, 2015, 6:42:44 AM8/14/15
to ganeti...@googlegroups.com
I'm still getting the error after switching branches. Here are the commands I'm running, am I missing something?

apt-get install python-dev libffi-dev libmysqlclient-dev mysql-server -y
cd ~ && git clone -b develop https://github.com/osuosl/ganeti_webmgr.git
cd ganeti_webmgr
VERSION="0.11.1"
git checkout $VERSION
./scripts/setup.sh -D mysql
cp ~/ganeti_webmgr/scripts/vncauthproxy/init-ubuntu /etc/init.d/vncauthproxy
pip install service_identity
cp /root/ganeti_webmgr/ganeti_webmgr/ganeti_web/settings/config.yml.dist /opt/ganeti_webmgr/config/config.yml
# Set up database
mysql
CREATE DATABASE ganeti_webmgr;
CREATE USER 'ganeti_webmgr'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON ganeti_webmgr.* TO 'ganeti_webmgr'@'localhost';
FLUSH PRIVILEGES;
exit
vi /opt/ganeti_webmgr/config/config.yml
# Finish configuring
source /opt/ganeti_webmgr/bin/activate
export DJANGO_SETTINGS_MODULE="ganeti_webmgr.ganeti_web.settings"
django-admin.py $CMD --settings "ganeti_webmgr.ganeti_web.settings"

(ganeti_webmgr)root@ganetiweb:~# django-admin.py syncdb --migrate

Evan Tschuy

unread,
Aug 14, 2015, 1:26:21 PM8/14/15
to ganeti...@googlegroups.com
Looks like you're checking out 0.11.1 after you clone onto develop,
and 0.11.1 doesn't contain the fix.

I ran through the rest of your setup process and everything appears to
work other than that. (You may need to change the language code from
en-US to en_US, however.)

Daniel Townend

unread,
Aug 17, 2015, 6:02:11 AM8/17/15
to ganeti...@googlegroups.com
Okay thanks. Might sound like a stupid question but how do I check what versions are in what branches?

Evan Tschuy

unread,
Aug 17, 2015, 2:24:59 PM8/17/15
to ganeti...@googlegroups.com
In general we have release/0.major.minor release branches, and the
latest version available version is 0.11.1. We're preparing some
changes for the next release and this fix will be included in that
release. For now, since it isn't a release yet, it's only available on
develop.

We don't bump the version on releases until just before we actually
cut the release, but to see what version a branch is building from,
you can look in ganeti_webmgr/ganeti_web/constants.py:
https://github.com/osuosl/ganeti_webmgr/blob/develop/ganeti_webmgr/ganeti_web/constants.py#L18
Reply all
Reply to author
Forward
0 new messages