Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/

19 changes: 8 additions & 11 deletions bsdpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import signal
import errno
import json
import netifaces
from distutils.dir_util import mkpath
from random import randint

Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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'] = \
Expand Down
Binary file removed pydhcplib/__init__.pyc
Binary file not shown.
Binary file removed pydhcplib/dhcp_basic_packet.pyc
Binary file not shown.
Binary file removed pydhcplib/dhcp_constants.pyc
Binary file not shown.
Binary file removed pydhcplib/dhcp_network.pyc
Binary file not shown.
Binary file removed pydhcplib/dhcp_packet.pyc
Binary file not shown.
Binary file removed pydhcplib/type_hwmac.pyc
Binary file not shown.
Binary file removed pydhcplib/type_ipv4.pyc
Binary file not shown.
Binary file removed pydhcplib/type_strlist.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docopt
netifaces
requests
redis