osuosl / ganeti_webmgr

Ganeti Web Manager is a Django based web application that allows administrators and clients access to their ganeti clusters. It includes a permissions and quota system that allows administrators to grant access to both clusters and virtual machines. It also includes user groups for structuring access to organizations.
https://code.osuosl.org/projects/ganeti-webmgr
GNU General Public License v2.0
64 stars 32 forks source link

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

Open qris opened 8 years ago

qris commented 8 years ago

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 commented 8 years ago

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?