Skip to content

Commit

Permalink
[ccloud] adds tftpmap for pxe
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhipfel committed May 4, 2022
1 parent 662791d commit bee6355
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Empty file added ironic/pxe/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions ironic/pxe/tftpmap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import re, os, stat

patterns = [ (re.compile(a), b) for a, b in [
(r'^(/tftpboot/)', r'/tftpboot/'),
(r'^/tftpboot/', r'/tftpboot/'),
(r'^(^/)', r'/tftpboot/\1'),
(r'^([^/])', r'/tftpboot/\1')
]]

# filename -> (stream, size)
def handle(self, filename):
for pattern, replacement in patterns:
if pattern.search(filename):
new_filename = pattern.sub(replacement, filename)
return open(new_filename, 'rb'), os.stat(new_filename)[stat.ST_SIZE]

0 comments on commit bee6355

Please sign in to comment.