diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dedd352 --- /dev/null +++ b/.gitignore @@ -0,0 +1,124 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don’t work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + diff --git a/bsdpserver.py b/bsdpserver.py index 35e5294..698bd80 100755 --- a/bsdpserver.py +++ b/bsdpserver.py @@ -66,6 +66,7 @@ import signal import errno import json +import netifaces from distutils.dir_util import mkpath from random import randint @@ -145,17 +146,11 @@ def get_ip(iface=''): The get_ip function retrieves the IP for the network interface BSDPY is running on. """ - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sockfd = sock.fileno() - SIOCGIFADDR = 0x8915 - - ifreq = struct.pack('16sH14s', iface, socket.AF_INET, '\x00' * 14) try: - res = fcntl.ioctl(sockfd, SIOCGIFADDR, ifreq) + return str(netifaces.ifaddresses(iface)[netifaces.AF_INET][0]['addr']) except: - return None - ip = struct.unpack('16sH2x4s8x', res)[2] - return socket.inet_ntoa(ip) + print("Failed to get ip address of {}".format(iface)) + raise dockervars = {} redisvars = {} @@ -434,8 +429,10 @@ def getNbiOptions(incoming): else: thisnbi['id'] = nbimageinfo['Index'] - thisnbi['booter'] = \ - find(nbimageinfo['BootFile'], path)[0] + abs_booter_path = find(nbimageinfo['BootFile'], path)[0] + tftp_path = os.path.relpath(abs_booter_path, tftprootpath) + thisnbi['booter'] = '/' + tftp_path + thisnbi['description'] = \ nbimageinfo['Description'] thisnbi['disabledsysids'] = \ diff --git a/pydhcplib/__init__.pyc b/pydhcplib/__init__.pyc deleted file mode 100644 index 39b577f..0000000 Binary files a/pydhcplib/__init__.pyc and /dev/null differ diff --git a/pydhcplib/dhcp_basic_packet.pyc b/pydhcplib/dhcp_basic_packet.pyc deleted file mode 100644 index 95e86e6..0000000 Binary files a/pydhcplib/dhcp_basic_packet.pyc and /dev/null differ diff --git a/pydhcplib/dhcp_constants.pyc b/pydhcplib/dhcp_constants.pyc deleted file mode 100644 index e0a4c5b..0000000 Binary files a/pydhcplib/dhcp_constants.pyc and /dev/null differ diff --git a/pydhcplib/dhcp_network.pyc b/pydhcplib/dhcp_network.pyc deleted file mode 100644 index 23db368..0000000 Binary files a/pydhcplib/dhcp_network.pyc and /dev/null differ diff --git a/pydhcplib/dhcp_packet.pyc b/pydhcplib/dhcp_packet.pyc deleted file mode 100644 index e884a45..0000000 Binary files a/pydhcplib/dhcp_packet.pyc and /dev/null differ diff --git a/pydhcplib/type_hwmac.pyc b/pydhcplib/type_hwmac.pyc deleted file mode 100644 index a066429..0000000 Binary files a/pydhcplib/type_hwmac.pyc and /dev/null differ diff --git a/pydhcplib/type_ipv4.pyc b/pydhcplib/type_ipv4.pyc deleted file mode 100644 index 2176112..0000000 Binary files a/pydhcplib/type_ipv4.pyc and /dev/null differ diff --git a/pydhcplib/type_strlist.pyc b/pydhcplib/type_strlist.pyc deleted file mode 100644 index 16c2450..0000000 Binary files a/pydhcplib/type_strlist.pyc and /dev/null differ diff --git a/requirements.txt b/requirements.txt index b5dcbcc..92d899d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ docopt +netifaces requests redis