Merge "Fix distribution compatability for configdrive build" into stable/wallaby
This commit is contained in:
commit
7a776462cc
|
@ -267,20 +267,30 @@ def make_configdrive(path):
|
||||||
with tempfile.NamedTemporaryFile() as tmpfile:
|
with tempfile.NamedTemporaryFile() as tmpfile:
|
||||||
with tempfile.NamedTemporaryFile() as tmpzipfile:
|
with tempfile.NamedTemporaryFile() as tmpzipfile:
|
||||||
publisher = 'ironicclient-configdrive 0.1'
|
publisher = 'ironicclient-configdrive 0.1'
|
||||||
try:
|
# NOTE(toabctl): Luckily, genisoimage, mkisofs and xorrisofs
|
||||||
p = subprocess.Popen(['genisoimage', '-o', tmpfile.name,
|
# understand the same parameters which are currently used.
|
||||||
'-ldots', '-allow-lowercase',
|
cmds = ['genisoimage', 'mkisofs', 'xorrisofs']
|
||||||
'-allow-multidot', '-l',
|
for c in cmds:
|
||||||
'-publisher', publisher,
|
try:
|
||||||
'-quiet', '-J',
|
p = subprocess.Popen([c, '-o', tmpfile.name,
|
||||||
'-r', '-V', 'config-2',
|
'-ldots', '-allow-lowercase',
|
||||||
path],
|
'-allow-multidot', '-l',
|
||||||
stdout=subprocess.PIPE,
|
'-publisher', publisher,
|
||||||
stderr=subprocess.PIPE)
|
'-quiet', '-J',
|
||||||
except OSError as e:
|
'-r', '-V', 'config-2',
|
||||||
|
path],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
except OSError as e:
|
||||||
|
error = e
|
||||||
|
else:
|
||||||
|
error = None
|
||||||
|
break
|
||||||
|
if error:
|
||||||
raise exc.CommandError(
|
raise exc.CommandError(
|
||||||
_('Error generating the config drive. Make sure the '
|
_('Error generating the config drive. Make sure the '
|
||||||
'"genisoimage" tool is installed. Error: %s') % e)
|
'"genisoimage", "mkisofs", or "xorriso" tool is '
|
||||||
|
'installed. Error: %s') % error)
|
||||||
|
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
|
|
|
@ -265,6 +265,20 @@ class MakeConfigDriveTest(test_utils.BaseTestCase):
|
||||||
'-quiet', '-J', '-r', '-V',
|
'-quiet', '-J', '-r', '-V',
|
||||||
'config-2', mock.ANY]
|
'config-2', mock.ANY]
|
||||||
|
|
||||||
|
self.mkisofs_cmd = ['mkisofs', '-o', mock.ANY,
|
||||||
|
'-ldots', '-allow-lowercase',
|
||||||
|
'-allow-multidot', '-l',
|
||||||
|
'-publisher', 'ironicclient-configdrive 0.1',
|
||||||
|
'-quiet', '-J', '-r', '-V',
|
||||||
|
'config-2', mock.ANY]
|
||||||
|
|
||||||
|
self.xorrisofs_cmd = ['xorrisofs', '-o', mock.ANY,
|
||||||
|
'-ldots', '-allow-lowercase',
|
||||||
|
'-allow-multidot', '-l',
|
||||||
|
'-publisher', 'ironicclient-configdrive 0.1',
|
||||||
|
'-quiet', '-J', '-r', '-V',
|
||||||
|
'config-2', mock.ANY]
|
||||||
|
|
||||||
def test_make_configdrive(self, mock_popen):
|
def test_make_configdrive(self, mock_popen):
|
||||||
fake_process = mock.Mock(returncode=0)
|
fake_process = mock.Mock(returncode=0)
|
||||||
fake_process.communicate.return_value = ('', '')
|
fake_process.communicate.return_value = ('', '')
|
||||||
|
@ -278,6 +292,24 @@ class MakeConfigDriveTest(test_utils.BaseTestCase):
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
fake_process.communicate.assert_called_once_with()
|
fake_process.communicate.assert_called_once_with()
|
||||||
|
|
||||||
|
def test_make_configdrive_fallsback(self, mock_popen):
|
||||||
|
fake_process = mock.Mock(returncode=0)
|
||||||
|
fake_process.communicate.return_value = ('', '')
|
||||||
|
mock_popen.side_effect = iter([OSError('boom'),
|
||||||
|
OSError('boom'),
|
||||||
|
fake_process])
|
||||||
|
with utils.tempdir() as dirname:
|
||||||
|
utils.make_configdrive(dirname)
|
||||||
|
mock_popen.assert_has_calls([
|
||||||
|
mock.call(self.genisoimage_cmd, stderr=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE),
|
||||||
|
mock.call(self.mkisofs_cmd, stderr=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE),
|
||||||
|
mock.call(self.xorrisofs_cmd, stderr=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
])
|
||||||
|
fake_process.communicate.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch.object(os, 'access', autospec=True)
|
@mock.patch.object(os, 'access', autospec=True)
|
||||||
def test_make_configdrive_non_readable_dir(self, mock_access, mock_popen):
|
def test_make_configdrive_non_readable_dir(self, mock_access, mock_popen):
|
||||||
mock_access.return_value = False
|
mock_access.return_value = False
|
||||||
|
@ -292,9 +324,14 @@ class MakeConfigDriveTest(test_utils.BaseTestCase):
|
||||||
|
|
||||||
self.assertRaises(exc.CommandError, utils.make_configdrive, 'fake-dir')
|
self.assertRaises(exc.CommandError, utils.make_configdrive, 'fake-dir')
|
||||||
mock_access.assert_called_once_with('fake-dir', os.R_OK)
|
mock_access.assert_called_once_with('fake-dir', os.R_OK)
|
||||||
mock_popen.assert_called_once_with(self.genisoimage_cmd,
|
mock_popen.assert_has_calls([
|
||||||
stderr=subprocess.PIPE,
|
mock.call(self.genisoimage_cmd, stderr=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE),
|
||||||
|
mock.call(self.mkisofs_cmd, stderr=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE),
|
||||||
|
mock.call(self.xorrisofs_cmd, stderr=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
])
|
||||||
|
|
||||||
@mock.patch.object(os, 'access', autospec=True)
|
@mock.patch.object(os, 'access', autospec=True)
|
||||||
def test_make_configdrive_non_zero_returncode(self, mock_access,
|
def test_make_configdrive_non_zero_returncode(self, mock_access,
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Embedded configuration drive generation support has been updated to
|
||||||
|
support ``mkisofs`` and ``xorrisofs`` in adition to the previously
|
||||||
|
supported ``genisoimage`` utility. This is as distributions such as
|
||||||
|
Debian and OpenSUSE do not ship ``genisoimage``.
|
Loading…
Reference in New Issue