mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
netlink: force python to load ifupdown2's nlmanager cpy instead of python-nlmanager
Ticket: CM-13453 Reviewed By: Roopa, Nikhil G, Daniel W Testing Done: ifupdown2-tests We had an issue where python-nlmanager and ifupdown2's nlmanager differed When netd starts it loads ifupdown2's addons, so it also tries to do the imports. Since the current working directy is not /usr/share/ifupdown2 but netd directory it won't load ifupdown2's nlmanager first but python-nlmanager if it exists. Here we insert/hardcode /usr/share/ifupdown2/ first in the path to make sure we load the right nlmanager Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from ifupdownaddons.utilsbase import utilsBase
|
from ifupdownaddons.utilsbase import utilsBase
|
||||||
from nlmanager.nlmanager import NetlinkManager
|
|
||||||
import ifupdown.ifupdownflags as ifupdownflags
|
import ifupdown.ifupdownflags as ifupdownflags
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
@ -17,7 +16,16 @@ class Netlink(utilsBase):
|
|||||||
|
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
utilsBase.__init__(self, *args, **kargs)
|
utilsBase.__init__(self, *args, **kargs)
|
||||||
self._nlmanager_api = NetlinkManager(extra_debug=False)
|
try:
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, '/usr/share/ifupdown2/')
|
||||||
|
from nlmanager.nlmanager import NetlinkManager
|
||||||
|
# this should force the use of the local nlmanager
|
||||||
|
self._nlmanager_api = NetlinkManager(extra_debug=False)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error('cannot initialize ifupdown2\'s '
|
||||||
|
'netlink manager: %s' % str(e))
|
||||||
|
raise
|
||||||
|
|
||||||
def get_iface_index(self, ifacename):
|
def get_iface_index(self, ifacename):
|
||||||
if ifupdownflags.flags.DRYRUN: return
|
if ifupdownflags.flags.DRYRUN: return
|
||||||
|
Reference in New Issue
Block a user