I would say that bug 726644 is not in fault. You just import it and you hope it will work. But..: If you do: import utils and utils already exist in cache then it is used. Today it is rhnplugin, but tomorrow it will be somebody else. And it will not help you to prepend path to sys.path, since that package is already in cache. See: http://docs.python.org/reference/simple_stmts.html#import Correct way to avoid is to not install packages to /usr/share/vdsm/ but to %{python_sitelib}/vdsm where %if 0%{?rhel} && 0%{?rhel} < 6 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %endif Then you can do: import vdsm.utils and you will have no conflict now nor in future.
I agree on the fact that we should move to %{python_sitelib}/vdsm. Nevertheless we won't face this problem anyway because the imported modules never change sys.path. Also your plugin is not immune by this very same problem: # mkdir rhnplugin-test && cd rhnplugin-test # touch output.py # python >>> import os, sys, yum >>> sys.path.append(os.getcwd()) >>> my = yum.YumBase() >>> cu = my.pkgSack.searchNevra(name='coreutils') Plugin "rhnplugin" can't be imported Loaded plugins: product-id
BZ#726643 Force VDSM_DIR in sys.path Change-Id: I9d951b1263bac52c350fe02012a5cfeeef48ba70 http://gerrit.usersys.redhat.com/766
Checked on sm109.
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.
Technical note updated. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. Diffed Contents: @@ -1 +1 @@ -Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.+Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization Manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2012-0169.html