View Issue Details

IDProjectCategoryView StatusLast Update
0001332bareos-coreGeneralpublic2023-07-31 14:51
Reporterloli10K Assigned Tobruno-at-bareos  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version20.0.1 
Summary0001332: BareosDirPluginBaseclass.py still importing removed "bareos_dir_consts" module
DescriptionI've been using python2 dir plugins to monitor bareos since 2018 (see issue 0000821)

Recently i had to reinstall bareos on a different distro providing python3 binaries: unfortunately when i tried to install my plugin i found that "bareos_dir_consts.py" has been removed (https://github.com/bareos/bareos/commit/b961063ef95ffe64b47318c512251764ce73add6 "python-dir: move constants into python-dir module") but is still being used by the plugin base class (https://github.com/bareos/bareos/blob/Release/20.0.1/core/src/plugins/dird/python/pyfiles/BareosDirPluginBaseclass.py#L28): this seems to break every python dir plugin.
Steps To Reproduce1. Clean bareos-20.0.1-3 install on Ubuntu-20.04 (with bareos-director-python* packages)
2. Enable python3 support in "/etc/bareos/bareos-dir.d/director/bareos-dir.conf"
3. Enable custom Dir Plugin in Job definition (DIR Plugin Options = "python3:module_path=/usr/lib/bareos/plugins:module_name=bareos-dir-my-plugin-name")
4. Run Job
5. Job results in error, logs show:

bareos-dir JobId 5: Fatal error: bareosdir: Traceback (most recent call last):
File "/usr/lib/bareos/plugins/bareos-dir-my-plugin-name.py", line 39, in
import BareosDirPluginMyPluginName
File "/usr/lib/bareos/plugins/BareosDirPluginMyPluginName.py", line 34, in
import BareosDirPluginBaseclass
File "/usr/lib/bareos/plugins/BareosDirPluginBaseclass.py", line 28, in
from bareos_dir_consts import bDirEventType, brDirVariable, bRCs
ModuleNotFoundError: No module named 'bareos_dir_consts'
Additional Informationroot@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
root@ubuntu:~# dpkg -l | grep bareos
ii bareos 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - metapackage
ii bareos-bconsole 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - text console
ii bareos-client 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - client metapackage
ii bareos-common 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - common files
ii bareos-database-common 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - common catalog files
ii bareos-database-postgresql 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - PostgreSQL backend
ii bareos-database-tools 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - database tools
ii bareos-director 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - director daemon
ii bareos-director-python-plugins-common 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - director Python plugin common files
ii bareos-director-python3-plugin 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - director Python plugin
ii bareos-filedaemon 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - file daemon
ii bareos-storage 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - storage daemon
ii bareos-tools 20.0.1-3 amd64 Backup Archiving Recovery Open Sourced - common tools
ii bareos-webui 20.0.1-3 all Backup Archiving Recovery Open Sourced - webui
root@ubuntu:~# dpkg -L bareos-director-python3-plugin
/.
/usr
/usr/lib
/usr/lib/bareos
/usr/lib/bareos/plugins
/usr/lib/bareos/plugins/python3-dir.so
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/bareosdir.cpython-38-x86_64-linux-gnu.so
/usr/share
/usr/share/doc
/usr/share/doc/bareos-director-python3-plugin
/usr/share/doc/bareos-director-python3-plugin/changelog.Debian.gz
/usr/share/doc/bareos-director-python3-plugin/copyright
root@ubuntu:~# dpkg -L bareos-director-python-plugins-common
/.
/usr
/usr/lib
/usr/lib/bareos
/usr/lib/bareos/plugins
/usr/lib/bareos/plugins/BareosDirPluginBaseclass.py
/usr/lib/bareos/plugins/BareosDirWrapper.py
/usr/lib/bareos/plugins/bareos-dir-class-plugin.py
/usr/share
/usr/share/doc
/usr/share/doc/bareos-director-python-plugins-common
/usr/share/doc/bareos-director-python-plugins-common/changelog.Debian.gz
/usr/share/doc/bareos-director-python-plugins-common/copyright
root@ubuntu:~# grep -r bareos_dir_consts /usr/lib/bareos/plugins
/usr/lib/bareos/plugins/BareosDirPluginBaseclass.py:from bareos_dir_consts import bDirEventType, brDirVariable, bRCs
/usr/lib/bareos/plugins/bareos-dir-class-plugin.py:import bareos_dir_consts
/usr/lib/bareos/plugins/bareos-dir-class-plugin.py: return bareos_dir_consts.bRCs["bRC_OK"]
root@ubuntu:~# python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bareosdir
>>> from bareos_dir_consts import bDirEventType, brDirVariable, bRCs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bareos_dir_consts'
>>>
TagsNo tags attached.

Activities

bruno-at-bareos

bruno-at-bareos

2023-07-31 14:51

manager   ~0005281

did you try to see how the python3 module has changed, and what you need to adapt to your plugin.
See by example https://github.com/bareos/bareos/blob/master/core/src/plugins/dird/python/pyfiles/BareosDirPluginBaseclass.py
for example you don't need addtionnal module to have bareosdir.bRC_OK defined.

See also our documentation https://docs.bareos.org/bareos-22/DeveloperGuide/PythonPluginAPI.html#python-plugin-api

Issue History

Date Modified Username Field Change
2021-03-23 18:18 loli10K New Issue
2023-07-31 14:51 bruno-at-bareos Assigned To => bruno-at-bareos
2023-07-31 14:51 bruno-at-bareos Status new => closed
2023-07-31 14:51 bruno-at-bareos Resolution open => no change required
2023-07-31 14:51 bruno-at-bareos Note Added: 0005281