baremetal: Add support for mkisofs and xorrisofs for configdrive

Currently, only "genisoimage" is supported. But "genisoimage" might
not be available on all distros (like openSUSE or Debian).
So add support for "mkisofs" and "xorrisofs" which luckily support
the same command line parameters as "genisoimage".

Change-Id: I720f25921f8e52f20a631f238a528dedf65a91c6
This commit is contained in:
Thomas Bechtold 2019-04-09 13:01:22 +02:00
parent e9a5d45e50
commit 8fed470b09
2 changed files with 32 additions and 13 deletions

View File

@ -84,21 +84,32 @@ def pack(path):
:return: configdrive contents as a base64-encoded string.
"""
with tempfile.NamedTemporaryFile() as tmpfile:
try:
p = subprocess.Popen(['genisoimage',
'-o', tmpfile.name,
'-ldots', '-allow-lowercase',
'-allow-multidot', '-l',
'-publisher', 'metalsmith',
'-quiet', '-J',
'-r', '-V', 'config-2',
path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError as e:
# NOTE(toabctl): Luckily, genisoimage, mkisofs and xorrisofs understand
# the same parameters which are currently used.
cmds = ['genisoimage', 'mkisofs', 'xorrisofs']
for c in cmds:
try:
p = subprocess.Popen([c,
'-o', tmpfile.name,
'-ldots', '-allow-lowercase',
'-allow-multidot', '-l',
'-publisher', 'metalsmith',
'-quiet', '-J',
'-r', '-V', 'config-2',
path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError as e:
error = e
else:
error = None
break
if error:
raise RuntimeError(
'Error generating the configdrive. Make sure the '
'"genisoimage" tool is installed. Error: %s' % e)
'"genisoimage", "mkisofs" or "xorrisofs" tool is installed. '
'Error: %s' % error)
stdout, stderr = p.communicate()
if p.returncode != 0:

View File

@ -0,0 +1,8 @@
---
features:
- |
When generating a config drive for baremetal, "mkisofs" and "xorrisofs"
are now supported beside the already available "genisoimage" binary.
This is useful on environment where the "genisoimage" binary is not
available but "mkisofs" and/or "xorrisofs" are available.