kimchi-project / kimchi

An HTML5 management interface for KVM guests
https://github.com/kimchi-project/kimchi/releases/latest
Other
3.09k stars 365 forks source link

Kimchi depends on system-dependent python magic library #1178

Open bocajspear1 opened 6 years ago

bocajspear1 commented 6 years ago

I'm running Wok/Kimchi in Alpine Linux 3.6.2. I installed it via packages by the edge testing branch (I know, a bit off the supported distro list), and after a bit of work, I got it to kind of work. However, when I try to create a template, I get this in the logs:

[30/Sep/2017:23:01:40] HTTP 
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 220, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 60, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/site-packages/wok/control/base.py", line 450, in index
    result = self.create(params, *args)
  File "/usr/lib/python2.7/site-packages/wok/control/base.py", line 355, in create
    name = create(*args)
  File "/usr/lib/python2.7/site-packages/wok/plugins/kimchi/model/templates.py", line 97, in create
    file_type = magic.open(magic.MAGIC_NONE)
AttributeError: 'module' object has no attribute 'open'

It appears kimchi is depending on a version python magic from a package, which is not available on all systems, such as Alpine. As a test, I created a Ubuntu 14.04 container, and ran the following:

root@pytest:~# apt-get install python-magic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-magic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@pytest:~# python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> ms = magic.open(magic.MAGIC_NONE)
>>> 
root@pytest:~# apt-get remove python-magic
root@pytest:~# pip install python-magic
Downloading/unpacking python-magic
  Downloading python_magic-0.4.13-py2.py3-none-any.whl
Installing collected packages: python-magic
Successfully installed python-magic
Cleaning up...
root@pytest:~# python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> ms = magic.open(magic.MAGIC_NONE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'open'
>>> f = magic.Magic(uncompress=True)
>>> 

Note that the package version has open while the PIP version does not. I would expect people attempting to build from source will expect the PIP version, as it is more readily available and is available across most distros with access to PIP, while the packaged version is not.

I've patched the file to use the PIP version on my own instance, and it appears to work.

Versions: gingerbase 2.2.1 kimchi 2.5.0 wok 2.5.0

fahadysf commented 6 years ago

I can confirm this behavior on Alpine Linux 3.6.2

[10/Nov/2017:14:58:10] HTTP
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 220, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 60, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/site-packages/wok/control/base.py", line 450, in index
    result = self.create(params, *args)
  File "/usr/lib/python2.7/site-packages/wok/control/base.py", line 355, in create
    name = create(*args)
  File "/usr/lib/python2.7/site-packages/wok/plugins/kimchi/model/templates.py", line 97, in create
    file_type = magic.open(magic.MAGIC_NONE)
AttributeError: 'module' object has no attribute 'open'