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

Add missing global statements to make SECRET_KEY and WEB_MGR_API_KEY work #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qris
Copy link
Contributor

@qris qris commented Jun 1, 2016

When the keys are to be created in the .secrets folder and not stored in the config.yml
file, base.py generates them and tries to assign to the global variables
SECRET_KEY and WEB_MGR_API_KEY so that the settings are complete. However this does
not work because the necessary global statements are missing, so the assignment is
to a local variable and does not go into the settings.

This causes the initial syncdb --migrate during installation (following the
instructions) to fail with this error:

$ sudo /opt/ganeti_webmgr/bin/django-admin.py syncdb --migrate --settings=ganeti_webmgr.ganeti_web.settings
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/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

This patch adds the missing global statements.

You might want to consider using Travis CI to ensure that the installation process stays well-tested?

…work

When the keys are to be created in the .secrets folder and not stored in the config.yml
file, base.py generates them and tries to assign to the global variables
SECRET_KEY and WEB_MGR_API_KEY so that the settings are complete. However this does
not work because the necessary `global` statements are missing, so the assignment is
to a local variable and does not go into the settings.

This causes the initial `syncdb --migrate` during installation (following the
instructions) to fail with this error:

	$ sudo /opt/ganeti_webmgr/bin/django-admin.py syncdb --migrate --settings=ganeti_webmgr.ganeti_web.settings
	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/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

This patch adds the missing global statements.

You might want to consider using Travis CI to ensure that the installation process stays well-tested?
@tschuy
Copy link
Contributor

tschuy commented Jun 7, 2016

Hi!

Thanks for the PR. This is actually fixed in 0.11.2 with a slightly different approach. 0.11.2 is currently in rc, but should be ready soon.

@LyonesGamer @Kennric ping on status update on 0.11.2?

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

Successfully merging this pull request may close these issues.

3 participants