3 # Copyright 2017 Cumulus Networks, Inc. All rights reserved.
5 # Julien Fortin, julien@cumulusnetworks.com
8 # tool to configure network interfaces
14 IFUPDOWN2_ADDON_DROPIN_FOLDER
= '/usr/share/ifupdown2/addons'
17 # ifupdown2/ifupdown/config.py -> we need to use dirname twice.
18 ADDON_MODULES_DIR
= ['%s/addons' % (os
.path
.dirname(os
.path
.dirname(os
.path
.realpath(__file__
))))]
20 if ADDON_MODULES_DIR
[0] != IFUPDOWN2_ADDON_DROPIN_FOLDER
:
21 ADDON_MODULES_DIR
.append(IFUPDOWN2_ADDON_DROPIN_FOLDER
)
22 except Exception as e
:
23 print "debug: error resolving ifupdown2 addons module directory: %s" % str(e
)
24 ADDON_MODULES_DIR
= [IFUPDOWN2_ADDON_DROPIN_FOLDER
]
29 def get_configuration_file_real_path(path_to_file
):
31 When install via pypi or `pip install .` ifupdown2 is install in a virtualenv
32 config file that should be installed in /etc/network/ifupdown2 end-up being
33 installed in /usr/local/lib/python2.7/dist-packages/etc/network/ifupdown2/
35 if not os
.path
.exists(path_to_file
):
36 # we will try to resolve the location of our conf file
37 # otherwise default to the input argument
38 package_dir
= os
.path
.dirname(os
.path
.realpath(__file__
))
39 parent_dir
= os
.path
.dirname(package_dir
)
40 resolved_path
= '%s%s' % (parent_dir
, path_to_file
)
42 if os
.path
.exists(resolved_path
):
48 IFUPDOWN2_CONF_PATH
= get_configuration_file_real_path('/etc/network/ifupdown2/ifupdown2.conf')
49 ADDONS_CONF_PATH
= get_configuration_file_real_path('/etc/network/ifupdown2/addons.conf')
51 resource
.setrlimit(resource
.RLIMIT_CORE
, (0, 0))