ironic-python-agent 9.4.2__py3-none-any.whl → 9.4.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ironic_python_agent/hardware.py +40 -27
- ironic_python_agent/tests/unit/base.py +1 -0
- ironic_python_agent/tests/unit/extensions/test_clean.py +13 -7
- ironic_python_agent/tests/unit/extensions/test_deploy.py +13 -7
- ironic_python_agent/tests/unit/test_hardware.py +61 -10
- ironic_python_agent/tests/unit/test_utils.py +37 -6
- ironic_python_agent/utils.py +28 -0
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/METADATA +1 -1
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/RECORD +15 -15
- ironic_python_agent-9.4.3.dist-info/pbr.json +1 -0
- ironic_python_agent-9.4.2.dist-info/pbr.json +0 -1
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/AUTHORS +0 -0
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/LICENSE +0 -0
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/WHEEL +0 -0
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/entry_points.txt +0 -0
- {ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/top_level.txt +0 -0
ironic_python_agent/hardware.py
CHANGED
|
@@ -2958,46 +2958,65 @@ def _collect_udev(io_dict):
|
|
|
2958
2958
|
io_dict[f'udev/{kname}'] = buf
|
|
2959
2959
|
|
|
2960
2960
|
|
|
2961
|
-
def
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2961
|
+
def _compare_managers(hwm1, hwm2):
|
|
2962
|
+
return hwm2['support'] - hwm1['support']
|
|
2963
|
+
|
|
2964
|
+
|
|
2965
|
+
def _get_extensions():
|
|
2966
|
+
return stevedore.ExtensionManager(
|
|
2967
|
+
namespace='ironic_python_agent.hardware_managers',
|
|
2968
|
+
invoke_on_load=True
|
|
2969
|
+
)
|
|
2965
2970
|
|
|
2966
2971
|
|
|
2967
2972
|
def get_managers():
|
|
2968
2973
|
"""Get a list of hardware managers in priority order.
|
|
2969
2974
|
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
in a list. The resulting list is cached in _global_managers.
|
|
2975
|
+
This exists as a backwards compatibility shim, returning a simple list
|
|
2976
|
+
of managers where expected. New usages should use get_managers_detail.
|
|
2973
2977
|
|
|
2974
2978
|
:returns: Priority-sorted list of hardware managers
|
|
2975
2979
|
:raises HardwareManagerNotFound: if no valid hardware managers found
|
|
2976
2980
|
"""
|
|
2981
|
+
return [hwm['manager'] for hwm in get_managers_detail()]
|
|
2982
|
+
|
|
2983
|
+
|
|
2984
|
+
def get_managers_detail():
|
|
2985
|
+
"""Get detailed information about hardware managers
|
|
2986
|
+
|
|
2987
|
+
Use stevedore to find all eligible hardware managers, sort them based on
|
|
2988
|
+
self-reported (via evaluate_hardware_support()) priorities, and return a
|
|
2989
|
+
dict containing the manager object, it's class name, and hardware support
|
|
2990
|
+
value. The resulting list is cached in _global_managers.
|
|
2991
|
+
|
|
2992
|
+
:returns: list of dictionaries representing hardware managers and metadata
|
|
2993
|
+
:raises HardwareManagerNotFound: if no valid hardware managers found
|
|
2994
|
+
"""
|
|
2977
2995
|
global _global_managers
|
|
2978
2996
|
|
|
2979
2997
|
if not _global_managers:
|
|
2980
|
-
extension_manager = stevedore.ExtensionManager(
|
|
2981
|
-
namespace='ironic_python_agent.hardware_managers',
|
|
2982
|
-
invoke_on_load=True)
|
|
2983
|
-
|
|
2984
|
-
# There will always be at least one extension available (the
|
|
2985
|
-
# GenericHardwareManager).
|
|
2986
|
-
extensions = sorted(extension_manager,
|
|
2987
|
-
key=functools.cmp_to_key(_compare_extensions))
|
|
2988
2998
|
|
|
2989
2999
|
preferred_managers = []
|
|
2990
3000
|
|
|
2991
|
-
for extension in
|
|
2992
|
-
|
|
2993
|
-
|
|
3001
|
+
for extension in _get_extensions():
|
|
3002
|
+
hwm = extension.obj
|
|
3003
|
+
hardware_support = hwm.evaluate_hardware_support()
|
|
3004
|
+
if hardware_support > 0:
|
|
3005
|
+
preferred_managers.append({
|
|
3006
|
+
'name': hwm.__class__.__name__,
|
|
3007
|
+
'manager': hwm,
|
|
3008
|
+
'support': hardware_support
|
|
3009
|
+
})
|
|
2994
3010
|
LOG.info('Hardware manager found: %s',
|
|
2995
3011
|
extension.entry_point_target)
|
|
2996
3012
|
|
|
2997
3013
|
if not preferred_managers:
|
|
2998
3014
|
raise errors.HardwareManagerNotFound
|
|
2999
3015
|
|
|
3000
|
-
|
|
3016
|
+
hwms = sorted(preferred_managers,
|
|
3017
|
+
key=functools.cmp_to_key(_compare_managers))
|
|
3018
|
+
|
|
3019
|
+
_global_managers = hwms
|
|
3001
3020
|
|
|
3002
3021
|
return _global_managers
|
|
3003
3022
|
|
|
@@ -3191,20 +3210,14 @@ def deduplicate_steps(candidate_steps):
|
|
|
3191
3210
|
all managers, key=manager, value=list of steps
|
|
3192
3211
|
:returns: A deduplicated dictionary of {hardware_manager: [steps]}
|
|
3193
3212
|
"""
|
|
3194
|
-
support =
|
|
3195
|
-
|
|
3213
|
+
support = {hwm['name']: hwm['support']
|
|
3214
|
+
for hwm in get_managers_detail()}
|
|
3196
3215
|
|
|
3197
3216
|
steps = collections.defaultdict(list)
|
|
3198
3217
|
deduped_steps = collections.defaultdict(list)
|
|
3199
3218
|
|
|
3200
3219
|
for manager, manager_steps in candidate_steps.items():
|
|
3201
3220
|
# We cannot deduplicate steps with unknown hardware support
|
|
3202
|
-
if manager not in support:
|
|
3203
|
-
LOG.warning('Unknown hardware support for %(manager)s, '
|
|
3204
|
-
'dropping steps: %(steps)s',
|
|
3205
|
-
{'manager': manager, 'steps': manager_steps})
|
|
3206
|
-
continue
|
|
3207
|
-
|
|
3208
3221
|
for step in manager_steps:
|
|
3209
3222
|
# build a new dict of steps that's easier to filter
|
|
3210
3223
|
step['hwm'] = {'name': manager,
|
|
@@ -34,12 +34,14 @@ class TestCleanExtension(base.IronicAgentTest):
|
|
|
34
34
|
}
|
|
35
35
|
self.version = {'generic': '1', 'specific': '1'}
|
|
36
36
|
|
|
37
|
+
@mock.patch('ironic_python_agent.hardware.get_managers_detail',
|
|
38
|
+
autospec=True)
|
|
37
39
|
@mock.patch('ironic_python_agent.hardware.get_current_versions',
|
|
38
40
|
autospec=True)
|
|
39
41
|
@mock.patch('ironic_python_agent.hardware.dispatch_to_all_managers',
|
|
40
42
|
autospec=True)
|
|
41
43
|
def test_get_clean_steps(self, mock_dispatch, mock_version,
|
|
42
|
-
mock_cache_node):
|
|
44
|
+
mock_managers, mock_cache_node):
|
|
43
45
|
mock_version.return_value = self.version
|
|
44
46
|
|
|
45
47
|
manager_steps = {
|
|
@@ -118,13 +120,17 @@ class TestCleanExtension(base.IronicAgentTest):
|
|
|
118
120
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
'
|
|
125
|
-
|
|
123
|
+
# NOTE(JayF): The real dict also has manager: hwm-object
|
|
124
|
+
# but we don't use it in the code under test
|
|
125
|
+
hwms = [
|
|
126
|
+
{'name': 'SpecificHardwareManager', 'support': 3},
|
|
127
|
+
{'name': 'FirmwareHardwareManager', 'support': 4},
|
|
128
|
+
{'name': 'DiskHardwareManager', 'support': 4},
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
mock_dispatch.side_effect = [manager_steps]
|
|
132
|
+
mock_managers.return_value = hwms
|
|
126
133
|
|
|
127
|
-
mock_dispatch.side_effect = [manager_steps, hardware_support]
|
|
128
134
|
expected_return = {
|
|
129
135
|
'hardware_manager_version': self.version,
|
|
130
136
|
'clean_steps': expected_steps
|
|
@@ -32,12 +32,14 @@ class TestDeployExtension(base.IronicAgentTest):
|
|
|
32
32
|
}
|
|
33
33
|
self.version = {'generic': '1', 'specific': '1'}
|
|
34
34
|
|
|
35
|
+
@mock.patch('ironic_python_agent.hardware.get_managers_detail',
|
|
36
|
+
autospec=True)
|
|
35
37
|
@mock.patch('ironic_python_agent.hardware.get_current_versions',
|
|
36
38
|
autospec=True)
|
|
37
39
|
@mock.patch('ironic_python_agent.hardware.dispatch_to_all_managers',
|
|
38
40
|
autospec=True)
|
|
39
41
|
def test_get_deploy_steps(self, mock_dispatch, mock_version,
|
|
40
|
-
mock_cache_node):
|
|
42
|
+
mock_managers, mock_cache_node):
|
|
41
43
|
mock_version.return_value = self.version
|
|
42
44
|
|
|
43
45
|
manager_steps = {
|
|
@@ -116,13 +118,17 @@ class TestDeployExtension(base.IronicAgentTest):
|
|
|
116
118
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
'
|
|
123
|
-
|
|
121
|
+
# NOTE(JayF): The real dict also has manager: hwm-object
|
|
122
|
+
# but we don't use it in the code under test
|
|
123
|
+
hwms = [
|
|
124
|
+
{'name': 'SpecificHardwareManager', 'support': 3},
|
|
125
|
+
{'name': 'FirmwareHardwareManager', 'support': 4},
|
|
126
|
+
{'name': 'DiskHardwareManager', 'support': 4},
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
mock_dispatch.side_effect = [manager_steps]
|
|
130
|
+
mock_managers.return_value = hwms
|
|
124
131
|
|
|
125
|
-
mock_dispatch.side_effect = [manager_steps, hardware_support]
|
|
126
132
|
expected_return = {
|
|
127
133
|
'hardware_manager_version': self.version,
|
|
128
134
|
'deploy_steps': expected_steps
|
|
@@ -81,12 +81,22 @@ BLK_DEVICE_TEMPLATE_PARTUUID_DEVICE = [
|
|
|
81
81
|
]
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
class FakeHardwareManager(hardware.
|
|
85
|
-
def __init__(self, hardware_support):
|
|
86
|
-
self._hardware_support = hardware_support
|
|
87
|
-
|
|
84
|
+
class FakeHardwareManager(hardware.HardwareManager):
|
|
88
85
|
def evaluate_hardware_support(self):
|
|
89
|
-
return self.
|
|
86
|
+
return self.support
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _create_mock_hwm(name, support):
|
|
90
|
+
def set_support(self, x):
|
|
91
|
+
self.support = x
|
|
92
|
+
|
|
93
|
+
# note(JayF): This code creates a subclass of FakeHardwareManager with
|
|
94
|
+
# a unique name. Since we actually use the class name in IPA
|
|
95
|
+
# code as an identifier, we need to have a new class for each
|
|
96
|
+
# mock.
|
|
97
|
+
hwm = type(name, (FakeHardwareManager,), {'_set_support': set_support})()
|
|
98
|
+
hwm._set_support(support)
|
|
99
|
+
return hwm
|
|
90
100
|
|
|
91
101
|
|
|
92
102
|
class TestHardwareManagerLoading(base.IronicAgentTest):
|
|
@@ -104,17 +114,58 @@ class TestHardwareManagerLoading(base.IronicAgentTest):
|
|
|
104
114
|
fake_ep.attrs = ['fake attrs']
|
|
105
115
|
ext1 = extension.Extension(
|
|
106
116
|
'fake_generic0', fake_ep, None,
|
|
107
|
-
|
|
117
|
+
_create_mock_hwm("fake_generic0",
|
|
118
|
+
hardware.HardwareSupport.GENERIC))
|
|
108
119
|
ext2 = extension.Extension(
|
|
109
120
|
'fake_mainline0', fake_ep, None,
|
|
110
|
-
|
|
121
|
+
_create_mock_hwm("fake_mainline0",
|
|
122
|
+
hardware.HardwareSupport.MAINLINE))
|
|
111
123
|
ext3 = extension.Extension(
|
|
112
|
-
'
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
'fake_serviceprovider0', fake_ep, None,
|
|
125
|
+
_create_mock_hwm("fake_serviceprovider0",
|
|
126
|
+
hardware.HardwareSupport.SERVICE_PROVIDER))
|
|
127
|
+
# Note(JayF): Ensure these are added in an order other than priority
|
|
128
|
+
# order or else you may invalidate the entire test :)
|
|
115
129
|
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
|
|
116
130
|
ext1, ext2, ext3
|
|
117
131
|
])
|
|
132
|
+
self.expected_detail_response = [
|
|
133
|
+
{'name': 'fake_serviceprovider0',
|
|
134
|
+
'support': hardware.HardwareSupport.SERVICE_PROVIDER,
|
|
135
|
+
'manager': ext3.obj},
|
|
136
|
+
{'name': 'fake_mainline0',
|
|
137
|
+
'support': hardware.HardwareSupport.MAINLINE,
|
|
138
|
+
'manager': ext2.obj},
|
|
139
|
+
{'name': 'fake_generic0',
|
|
140
|
+
'support': hardware.HardwareSupport.GENERIC,
|
|
141
|
+
'manager': ext1.obj},
|
|
142
|
+
]
|
|
143
|
+
self.expected_get_managers_response = [ext3.obj, ext2.obj, ext1.obj]
|
|
144
|
+
|
|
145
|
+
@mock.patch.object(hardware, '_get_extensions', autospec=True)
|
|
146
|
+
def test_get_managers(self, mock_extensions):
|
|
147
|
+
"""Test to ensure get_managers sorts and returns a list of HWMs.
|
|
148
|
+
|
|
149
|
+
The most meaningful part of this test is ensuring HWMs are in priority
|
|
150
|
+
order, with the highest hardware support value coming earlier in the
|
|
151
|
+
list of classes.
|
|
152
|
+
"""
|
|
153
|
+
mock_extensions.return_value = self.fake_ext_mgr
|
|
154
|
+
expected_names = [x.__class__.__name__
|
|
155
|
+
for x in self.expected_get_managers_response]
|
|
156
|
+
actual_names = [x.__class__.__name__
|
|
157
|
+
for x in hardware.get_managers()]
|
|
158
|
+
self.assertEqual(actual_names, expected_names)
|
|
159
|
+
|
|
160
|
+
@mock.patch.object(hardware, '_get_extensions', autospec=True)
|
|
161
|
+
def test_get_managers_detail(self, mock_extensions):
|
|
162
|
+
"""ensure get_manager_details returns a list of HWMs + metadata
|
|
163
|
+
|
|
164
|
+
These also need to be sorted in priority order
|
|
165
|
+
"""
|
|
166
|
+
mock_extensions.return_value = self.fake_ext_mgr
|
|
167
|
+
self.assertEqual(hardware.get_managers_detail(),
|
|
168
|
+
self.expected_detail_response)
|
|
118
169
|
|
|
119
170
|
|
|
120
171
|
@mock.patch.object(hardware, '_udev_settle', lambda *_: None)
|
|
@@ -22,6 +22,7 @@ import shutil
|
|
|
22
22
|
import subprocess
|
|
23
23
|
import tarfile
|
|
24
24
|
import tempfile
|
|
25
|
+
import time
|
|
25
26
|
from unittest import mock
|
|
26
27
|
|
|
27
28
|
from ironic_lib import utils as ironic_utils
|
|
@@ -877,6 +878,7 @@ class TestClockSyncUtils(ironic_agent_base.IronicAgentTest):
|
|
|
877
878
|
self.assertEqual(0, mock_execute.call_count)
|
|
878
879
|
|
|
879
880
|
|
|
881
|
+
@mock.patch.object(utils, '_unmount_any_config_drives', autospec=True)
|
|
880
882
|
@mock.patch.object(utils, '_booted_from_vmedia', autospec=True)
|
|
881
883
|
@mock.patch.object(utils, '_check_vmedia_device', autospec=True)
|
|
882
884
|
@mock.patch.object(utils, '_find_vmedia_device_by_labels', autospec=True)
|
|
@@ -887,7 +889,8 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
887
889
|
|
|
888
890
|
def test_vmedia_found_not_booted_from_vmedia(
|
|
889
891
|
self, mock_execute, mock_mount, mock_copy,
|
|
890
|
-
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia
|
|
892
|
+
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia,
|
|
893
|
+
mock_unmount_config):
|
|
891
894
|
mock_booted_from_vmedia.return_value = False
|
|
892
895
|
mock_find_device.return_value = '/dev/fake'
|
|
893
896
|
utils.copy_config_from_vmedia()
|
|
@@ -896,10 +899,12 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
896
899
|
mock_copy.assert_not_called()
|
|
897
900
|
mock_check_vmedia.assert_not_called()
|
|
898
901
|
self.assertTrue(mock_booted_from_vmedia.called)
|
|
902
|
+
self.assertTrue(mock_unmount_config.called)
|
|
899
903
|
|
|
900
904
|
def test_no_vmedia(
|
|
901
905
|
self, mock_execute, mock_mount, mock_copy,
|
|
902
|
-
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia
|
|
906
|
+
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia,
|
|
907
|
+
mock_unmount_config):
|
|
903
908
|
mock_booted_from_vmedia.return_value = True
|
|
904
909
|
mock_find_device.return_value = None
|
|
905
910
|
utils.copy_config_from_vmedia()
|
|
@@ -908,10 +913,12 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
908
913
|
mock_copy.assert_not_called()
|
|
909
914
|
mock_check_vmedia.assert_not_called()
|
|
910
915
|
self.assertFalse(mock_booted_from_vmedia.called)
|
|
916
|
+
self.assertTrue(mock_unmount_config.called)
|
|
911
917
|
|
|
912
918
|
def test_no_files(
|
|
913
919
|
self, mock_execute, mock_mount, mock_copy,
|
|
914
|
-
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia
|
|
920
|
+
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia,
|
|
921
|
+
mock_unmount_config):
|
|
915
922
|
mock_booted_from_vmedia.return_value = True
|
|
916
923
|
temp_path = tempfile.mkdtemp()
|
|
917
924
|
self.addCleanup(lambda: shutil.rmtree(temp_path))
|
|
@@ -925,10 +932,12 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
925
932
|
'/dev/something')
|
|
926
933
|
mock_copy.assert_not_called()
|
|
927
934
|
self.assertTrue(mock_booted_from_vmedia.called)
|
|
935
|
+
self.assertTrue(mock_unmount_config.called)
|
|
928
936
|
|
|
929
937
|
def test_mounted_no_files(
|
|
930
938
|
self, mock_execute, mock_mount, mock_copy,
|
|
931
|
-
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia
|
|
939
|
+
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia,
|
|
940
|
+
mock_unmount_config):
|
|
932
941
|
|
|
933
942
|
mock_booted_from_vmedia.return_value = True
|
|
934
943
|
mock_execute.return_value = '/some/path', ''
|
|
@@ -939,11 +948,13 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
939
948
|
mock_copy.assert_not_called()
|
|
940
949
|
mock_mount.assert_not_called()
|
|
941
950
|
self.assertTrue(mock_booted_from_vmedia.called)
|
|
951
|
+
self.assertTrue(mock_unmount_config.called)
|
|
942
952
|
|
|
943
953
|
@mock.patch.object(os, 'makedirs', autospec=True)
|
|
944
954
|
def test_copy(
|
|
945
955
|
self, mock_makedirs, mock_execute, mock_mount, mock_copy,
|
|
946
|
-
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia
|
|
956
|
+
mock_find_device, mock_check_vmedia, mock_booted_from_vmedia,
|
|
957
|
+
mock_unmount_config):
|
|
947
958
|
|
|
948
959
|
mock_booted_from_vmedia.return_value = True
|
|
949
960
|
mock_find_device.return_value = '/dev/something'
|
|
@@ -982,12 +993,14 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
982
993
|
mock.call(mock.ANY, '/etc/ironic-python-agent.d/ironic.conf'),
|
|
983
994
|
], any_order=True)
|
|
984
995
|
self.assertTrue(mock_booted_from_vmedia.called)
|
|
996
|
+
self.assertTrue(mock_unmount_config.called)
|
|
985
997
|
|
|
986
998
|
@mock.patch.object(os, 'makedirs', autospec=True)
|
|
987
999
|
def test_copy_mounted(
|
|
988
1000
|
self, mock_makedirs, mock_execute, mock_mount,
|
|
989
1001
|
mock_copy, mock_find_device, mock_check_vmedia,
|
|
990
|
-
mock_booted_from_vmedia
|
|
1002
|
+
mock_booted_from_vmedia,
|
|
1003
|
+
mock_unmount_config):
|
|
991
1004
|
mock_booted_from_vmedia.return_value = True
|
|
992
1005
|
mock_find_device.return_value = '/dev/something'
|
|
993
1006
|
path = tempfile.mkdtemp()
|
|
@@ -1023,6 +1036,7 @@ class TestCopyConfigFromVmedia(testtools.TestCase):
|
|
|
1023
1036
|
], any_order=True)
|
|
1024
1037
|
mock_mount.assert_not_called()
|
|
1025
1038
|
self.assertTrue(mock_booted_from_vmedia.called)
|
|
1039
|
+
self.assertTrue(mock_unmount_config.called)
|
|
1026
1040
|
|
|
1027
1041
|
|
|
1028
1042
|
@mock.patch.object(requests, 'get', autospec=True)
|
|
@@ -1143,3 +1157,20 @@ class TestCheckEarlyLogging(ironic_agent_base.IronicAgentTest):
|
|
|
1143
1157
|
expected_calls = [mock.call('Early logging: %s', 'line 1.'),
|
|
1144
1158
|
mock.call('Early logging: %s', 'line 2 message')]
|
|
1145
1159
|
info.assert_has_calls(expected_calls)
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
class TestUnmountOfConfig(ironic_agent_base.IronicAgentTest):
|
|
1163
|
+
|
|
1164
|
+
@mock.patch.object(utils, '_early_log', autospec=True)
|
|
1165
|
+
@mock.patch.object(os.path, 'ismount', autospec=True)
|
|
1166
|
+
@mock.patch.object(utils, 'execute', autospec=True)
|
|
1167
|
+
@mock.patch.object(time, 'sleep', autospec=True)
|
|
1168
|
+
def test__unmount_any_config_drives(self, mock_sleep, mock_exec,
|
|
1169
|
+
mock_ismount, mock_log,):
|
|
1170
|
+
mock_ismount.side_effect = iter([True, True, False])
|
|
1171
|
+
utils._unmount_any_config_drives()
|
|
1172
|
+
self.assertEqual(2, mock_sleep.call_count)
|
|
1173
|
+
self.assertEqual(2, mock_log.call_count)
|
|
1174
|
+
mock_exec.assert_has_calls([
|
|
1175
|
+
mock.call('umount', '/mnt/config'),
|
|
1176
|
+
mock.call('umount', '/mnt/config')])
|
ironic_python_agent/utils.py
CHANGED
|
@@ -311,18 +311,27 @@ def copy_config_from_vmedia():
|
|
|
311
311
|
['config-2', 'vmedia_boot_iso'])
|
|
312
312
|
if not vmedia_device_file:
|
|
313
313
|
_early_log('No virtual media device detected')
|
|
314
|
+
_unmount_any_config_drives()
|
|
314
315
|
return
|
|
315
316
|
if not _booted_from_vmedia():
|
|
316
317
|
_early_log('Cannot use configuration from virtual media as the '
|
|
317
318
|
'agent was not booted from virtual media.')
|
|
319
|
+
_unmount_any_config_drives()
|
|
318
320
|
return
|
|
319
321
|
# Determine the device
|
|
320
322
|
mounted = _find_mount_point(vmedia_device_file)
|
|
321
323
|
if mounted:
|
|
324
|
+
# In this case a utility like a configuration drive tool
|
|
325
|
+
# has *already* mounted the device we believe to be the
|
|
326
|
+
# configuration drive.
|
|
322
327
|
_copy_config_from(mounted)
|
|
323
328
|
else:
|
|
324
329
|
with ironic_utils.mounted(vmedia_device_file) as vmedia_mount_point:
|
|
330
|
+
# In this case, we use a temporary folder and extract the contents
|
|
331
|
+
# for our configuration.
|
|
325
332
|
_copy_config_from(vmedia_mount_point)
|
|
333
|
+
# As a last act, just make sure there is nothing else mounted.
|
|
334
|
+
_unmount_any_config_drives()
|
|
326
335
|
|
|
327
336
|
|
|
328
337
|
def _get_cached_params():
|
|
@@ -917,3 +926,22 @@ def rescan_device(device):
|
|
|
917
926
|
except processutils.ProcessExecutionError as e:
|
|
918
927
|
LOG.warning('Something went wrong when waiting for udev '
|
|
919
928
|
'to settle. Error: %s', e)
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
def _unmount_any_config_drives():
|
|
932
|
+
"""Umount anything mounted to /mnt/config
|
|
933
|
+
|
|
934
|
+
As part of the configuration drive model, utilities like cloud-init
|
|
935
|
+
and glean leverage a folder at /mnt/config to convey configuration
|
|
936
|
+
to a booting OS.
|
|
937
|
+
|
|
938
|
+
The possibility exists that one of the utilties mounted one or multiple
|
|
939
|
+
such folders, even if the configuration was not used, and this can
|
|
940
|
+
result in locked devices which can prevent rebuild operations from
|
|
941
|
+
completing successfully as as long as the folder is mounted, it is
|
|
942
|
+
a "locked" device to the operating system.
|
|
943
|
+
"""
|
|
944
|
+
while os.path.ismount('/mnt/config'):
|
|
945
|
+
_early_log('Issuing an umount command for /mnt/config...')
|
|
946
|
+
execute('umount', '/mnt/config')
|
|
947
|
+
time.sleep(1)
|
|
@@ -9,7 +9,7 @@ ironic_python_agent/efi_utils.py,sha256=rUKCpb6E96D28g8OBczeI5PNHRh2NglAdtqWyjdK
|
|
|
9
9
|
ironic_python_agent/encoding.py,sha256=qwYVri8CaOiy_sm_RgaqW7sO9ZIuFDEKJBdrGo1lVFg,2692
|
|
10
10
|
ironic_python_agent/errors.py,sha256=MZvsnHKgyrVYYPg33-fZ44iIYKxiHxFFEAPRJKKiDjw,12184
|
|
11
11
|
ironic_python_agent/format_inspector.py,sha256=qfO4WAwAaCFr_n3F-hnR8A0E_IkRqufYvZB1ihCGoaE,39159
|
|
12
|
-
ironic_python_agent/hardware.py,sha256=
|
|
12
|
+
ironic_python_agent/hardware.py,sha256=TRduUYx5IIx92Zff1vCHTqwBYw5A9Eiev6djDLxyPa0,139009
|
|
13
13
|
ironic_python_agent/inject_files.py,sha256=zf1_M-tw2d8Q-v0Vs4aySZLBSObufBHY1SPw2TETiyk,9476
|
|
14
14
|
ironic_python_agent/inspect.py,sha256=fCvpS7X9NJDxegoPMjCa7n4k36MBbzZ2GfDV7CBi9xQ,5148
|
|
15
15
|
ironic_python_agent/inspector.py,sha256=iYyLitjzS7q52HXY37HLN_nfhPiCP2FiBd2M93SpdI8,13636
|
|
@@ -20,7 +20,7 @@ ironic_python_agent/partition_utils.py,sha256=c-C1KnnDoQIFg5-9J5C9tvaudVK9kyzua_
|
|
|
20
20
|
ironic_python_agent/qemu_img.py,sha256=UJtDTttNwXMygblAny6o1JvyEhrddzJRPcK9uTwc7XQ,6009
|
|
21
21
|
ironic_python_agent/raid_utils.py,sha256=2gGrz8jTUMfJbsw-L1L3RlP3nL0-aEfnYzdhezIuhog,18235
|
|
22
22
|
ironic_python_agent/tls_utils.py,sha256=IEiTZF_y1k6Q90yaB8ITXhJB4grUU_5BwRFbS5Lm45I,4771
|
|
23
|
-
ironic_python_agent/utils.py,sha256=
|
|
23
|
+
ironic_python_agent/utils.py,sha256=LucwNI1OWu0uDcO3vwHR3ysN0slSn0Oiy3WvLVeOfBc,34107
|
|
24
24
|
ironic_python_agent/version.py,sha256=7EinnHTBHWpbgJF5yaobeBEKiwTq1nfXxeDMFIMz_c4,754
|
|
25
25
|
ironic_python_agent/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
ironic_python_agent/api/app.py,sha256=4riUa41KKD_NvO6bmxpI6E5sd3A4IulJsI80vxvnK9U,8659
|
|
@@ -46,7 +46,7 @@ ironic_python_agent/tests/functional/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeu
|
|
|
46
46
|
ironic_python_agent/tests/functional/base.py,sha256=SrQ71CqrhVPtdfD-U_6fAVYKGLxfLGGWHw1qa_WA3RY,3838
|
|
47
47
|
ironic_python_agent/tests/functional/test_commands.py,sha256=U1YBJWRpXcAGVTh4wd5TjgPF6gz_nT3W5DAypb4LkxY,3656
|
|
48
48
|
ironic_python_agent/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
|
-
ironic_python_agent/tests/unit/base.py,sha256=
|
|
49
|
+
ironic_python_agent/tests/unit/base.py,sha256=n6gfBVQxxUrJVtU-ajKIBG2sowKECDE07ucQnU2dI5g,3383
|
|
50
50
|
ironic_python_agent/tests/unit/dmi_inspector_data.py,sha256=mET88ujAb9LIVSMo4tD3cPSefyRtKqY61YquRIga66E,22841
|
|
51
51
|
ironic_python_agent/tests/unit/test_agent.py,sha256=sYyvO9bLqnVu_c2ERSYbFQohVWfZ34aJeYdh4iakGuY,50981
|
|
52
52
|
ironic_python_agent/tests/unit/test_api.py,sha256=auw2RSzzmEKKt4WPC5SgMxjDkNMu0IW82OAffBKYzUY,13193
|
|
@@ -58,7 +58,7 @@ ironic_python_agent/tests/unit/test_dmi_inspector.py,sha256=vbobkICrQ97e5gEARikc
|
|
|
58
58
|
ironic_python_agent/tests/unit/test_efi_utils.py,sha256=Zcox1f0trVJVfNd56auXK0nQEIG5_OKo74kknvQ6U8A,25270
|
|
59
59
|
ironic_python_agent/tests/unit/test_encoding.py,sha256=teEdsitbc9fgg93_xAaL30_gBKtZ6BJTiSon_zyyXc8,2763
|
|
60
60
|
ironic_python_agent/tests/unit/test_errors.py,sha256=bm0kDx7BshIdeuQK3Hm-2sAHUGkPehCELKZEsDRQv5c,6022
|
|
61
|
-
ironic_python_agent/tests/unit/test_hardware.py,sha256=
|
|
61
|
+
ironic_python_agent/tests/unit/test_hardware.py,sha256=mltdxEk4oFG-PI9OPPcuGwsczFT4u2OOb0-2AJw7DRY,282770
|
|
62
62
|
ironic_python_agent/tests/unit/test_inject_files.py,sha256=jPo5A0vlSmTfvJfzyiYRobeWgyDQNOXUxpkBX8cNKxw,17824
|
|
63
63
|
ironic_python_agent/tests/unit/test_inspector.py,sha256=jKa0B8i_aMApmXLSnh2B1gmJGW3uL9N_ys3plC9OVPQ,22517
|
|
64
64
|
ironic_python_agent/tests/unit/test_ironic_api_client.py,sha256=00v6Gn-NfrVvL9i8CL5-1rz_4CU6x-ZelcOLtkanODk,24336
|
|
@@ -70,11 +70,11 @@ ironic_python_agent/tests/unit/test_partition_utils.py,sha256=doMxfFuuqMfU4_12Y0
|
|
|
70
70
|
ironic_python_agent/tests/unit/test_qemu_img.py,sha256=KXIS2uuN5Oqs1goF3ZdIDvXaTEGOYbyiC3p-ZqT3ic4,14894
|
|
71
71
|
ironic_python_agent/tests/unit/test_raid_utils.py,sha256=68VfLhXNPxMCFa4TAeHMUuqmuh4CTDMqb2wBM3FnLLk,18467
|
|
72
72
|
ironic_python_agent/tests/unit/test_tls_utils.py,sha256=4OqtyeFK07E3qZhi_Y-Ed5Y-0CqcwTjygycrZewlJZc,3340
|
|
73
|
-
ironic_python_agent/tests/unit/test_utils.py,sha256=
|
|
73
|
+
ironic_python_agent/tests/unit/test_utils.py,sha256=zfYIgWRKyBOz15eLqlghbIhR2J1UuySCIYD9oIB-uWk,51046
|
|
74
74
|
ironic_python_agent/tests/unit/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
75
|
ironic_python_agent/tests/unit/extensions/test_base.py,sha256=87KYTvT8fKcUxnDyc-Zu9_repsvkQH9AXHUrEBAifdE,10145
|
|
76
|
-
ironic_python_agent/tests/unit/extensions/test_clean.py,sha256
|
|
77
|
-
ironic_python_agent/tests/unit/extensions/test_deploy.py,sha256=
|
|
76
|
+
ironic_python_agent/tests/unit/extensions/test_clean.py,sha256=-Xe5OZtRBV5kHGQ49Ph2SQJluwbxExJ9JovKSUlHRao,12152
|
|
77
|
+
ironic_python_agent/tests/unit/extensions/test_deploy.py,sha256=mW_zS-n0aapn0sQn7gJdp5AJ7Dze85pDsebuBkyo9tw,12164
|
|
78
78
|
ironic_python_agent/tests/unit/extensions/test_flow.py,sha256=_Hk51jkmK2_Co2dGiGan4y4ULox_93qpRd2LFogB2Gg,4358
|
|
79
79
|
ironic_python_agent/tests/unit/extensions/test_image.py,sha256=VTzjwgdp1VFe7VfEm8kOZF7VdPuHZS4HT36A1pzrM6g,110879
|
|
80
80
|
ironic_python_agent/tests/unit/extensions/test_log.py,sha256=bufFrUIs8lkpcATCg0s_yXuQxZBpattJChGexBjjrAI,1398
|
|
@@ -87,11 +87,11 @@ ironic_python_agent/tests/unit/hardware_managers/test_mlnx.py,sha256=IfxAm35Rqg5
|
|
|
87
87
|
ironic_python_agent/tests/unit/hardware_managers/nvidia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
88
88
|
ironic_python_agent/tests/unit/hardware_managers/nvidia/test_nvidia_fw_update.py,sha256=nJytEoa6-qFXriwz8TyubLunj5XNCJC38wEVIRLt5UM,51518
|
|
89
89
|
ironic_python_agent/tests/unit/samples/hardware_samples.py,sha256=1Jt7njCkIaz0u62F7wGllUNhuMHVlExZXL70DRiUla8,50622
|
|
90
|
-
ironic_python_agent-9.4.
|
|
91
|
-
ironic_python_agent-9.4.
|
|
92
|
-
ironic_python_agent-9.4.
|
|
93
|
-
ironic_python_agent-9.4.
|
|
94
|
-
ironic_python_agent-9.4.
|
|
95
|
-
ironic_python_agent-9.4.
|
|
96
|
-
ironic_python_agent-9.4.
|
|
97
|
-
ironic_python_agent-9.4.
|
|
90
|
+
ironic_python_agent-9.4.3.dist-info/AUTHORS,sha256=ep78uIJ1g9TqQl2xZdNKvDnQ3mA6UaAKkwj_JgMKNq4,8005
|
|
91
|
+
ironic_python_agent-9.4.3.dist-info/LICENSE,sha256=eYI6Jl-hPXZGT4fIcb4joP6fMoYRKf_oONHtLMiPfkQ,561
|
|
92
|
+
ironic_python_agent-9.4.3.dist-info/METADATA,sha256=5gzBqry_tZqpqZvvV3d25OkmMkme85lV-uEAyRe-wE0,3872
|
|
93
|
+
ironic_python_agent-9.4.3.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
|
|
94
|
+
ironic_python_agent-9.4.3.dist-info/entry_points.txt,sha256=5qJnPUS6yThusiOUgKFWtmWvSfz1QfjlgZl8UibXuqw,1432
|
|
95
|
+
ironic_python_agent-9.4.3.dist-info/pbr.json,sha256=TBJ3OmPsOGiNvzvIRCmDCagWe4V35It2Q8un5SyB4ew,46
|
|
96
|
+
ironic_python_agent-9.4.3.dist-info/top_level.txt,sha256=4UvmXY2TkynkLeFUThJX8rC4AWARHl7GtqmajaXD-tw,20
|
|
97
|
+
ironic_python_agent-9.4.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"git_version": "0869bf1", "is_release": true}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"git_version": "a1da3c9", "is_release": true}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ironic_python_agent-9.4.2.dist-info → ironic_python_agent-9.4.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|