ironic-python-agent 9.3.0__py3-none-any.whl → 9.4.1__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/config.py +5 -0
- ironic_python_agent/efi_utils.py +11 -4
- ironic_python_agent/extensions/standby.py +44 -11
- ironic_python_agent/hardware_managers/mlnx.py +52 -0
- ironic_python_agent/hardware_managers/nvidia/nvidia_fw_update.py +933 -0
- ironic_python_agent/ironic_api_client.py +25 -2
- ironic_python_agent/partition_utils.py +95 -3
- ironic_python_agent/raid_utils.py +68 -44
- ironic_python_agent/tests/unit/extensions/test_image.py +25 -20
- ironic_python_agent/tests/unit/extensions/test_standby.py +53 -2
- ironic_python_agent/tests/unit/hardware_managers/nvidia/__init__.py +0 -0
- ironic_python_agent/tests/unit/hardware_managers/nvidia/test_nvidia_fw_update.py +1131 -0
- ironic_python_agent/tests/unit/hardware_managers/test_mlnx.py +36 -0
- ironic_python_agent/tests/unit/samples/hardware_samples.py +30 -0
- ironic_python_agent/tests/unit/test_efi_utils.py +46 -39
- ironic_python_agent/tests/unit/test_ironic_api_client.py +27 -0
- ironic_python_agent/tests/unit/test_partition_utils.py +228 -1
- ironic_python_agent/tests/unit/test_raid_utils.py +23 -3
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/AUTHORS +1 -0
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/METADATA +1 -1
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/RECORD +26 -23
- ironic_python_agent-9.4.1.dist-info/pbr.json +1 -0
- ironic_python_agent-9.3.0.dist-info/pbr.json +0 -1
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/LICENSE +0 -0
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/WHEEL +0 -0
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/entry_points.txt +0 -0
- {ironic_python_agent-9.3.0.dist-info → ironic_python_agent-9.4.1.dist-info}/top_level.txt +0 -0
ironic_python_agent/config.py
CHANGED
|
@@ -326,6 +326,11 @@ cli_opts = [
|
|
|
326
326
|
'cleaning from inadvertently destroying a running '
|
|
327
327
|
'cluster which may be visible over a storage fabric '
|
|
328
328
|
'such as FibreChannel.'),
|
|
329
|
+
cfg.BoolOpt('config_drive_rebuild',
|
|
330
|
+
default=False,
|
|
331
|
+
help='If the agent should rebuild the configuration drive '
|
|
332
|
+
'using a local filesystem, instead of letting Ironic '
|
|
333
|
+
'determine if this action is necessary.'),
|
|
329
334
|
]
|
|
330
335
|
|
|
331
336
|
CONF.register_cli_opts(cli_opts)
|
ironic_python_agent/efi_utils.py
CHANGED
|
@@ -275,8 +275,15 @@ def get_boot_records():
|
|
|
275
275
|
|
|
276
276
|
:return: an iterator yielding pairs (boot number, boot record).
|
|
277
277
|
"""
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
# Invokes binary=True so we get a bytestream back.
|
|
279
|
+
efi_output = utils.execute('efibootmgr', '-v', binary=True)
|
|
280
|
+
# Bytes must be decoded before regex can be run and
|
|
281
|
+
# matching to work as intended.
|
|
282
|
+
# Also ignore errors on decoding, as we can basically get
|
|
283
|
+
# garbage out of the nvram record, this way we don't fail
|
|
284
|
+
# hard on unrelated records.
|
|
285
|
+
cmd_output = efi_output[0].decode('utf-16', errors='ignore')
|
|
286
|
+
for line in cmd_output.split('\n'):
|
|
280
287
|
match = _ENTRY_LABEL.match(line)
|
|
281
288
|
if match is not None:
|
|
282
289
|
yield (match[1], match[2])
|
|
@@ -293,7 +300,7 @@ def add_boot_record(device, efi_partition, loader, label):
|
|
|
293
300
|
# https://linux.die.net/man/8/efibootmgr
|
|
294
301
|
utils.execute('efibootmgr', '-v', '-c', '-d', device,
|
|
295
302
|
'-p', str(efi_partition), '-w', '-L', label,
|
|
296
|
-
'-l', loader)
|
|
303
|
+
'-l', loader, binary=True)
|
|
297
304
|
|
|
298
305
|
|
|
299
306
|
def remove_boot_record(boot_num):
|
|
@@ -301,7 +308,7 @@ def remove_boot_record(boot_num):
|
|
|
301
308
|
|
|
302
309
|
:param boot_num: the number of the boot record
|
|
303
310
|
"""
|
|
304
|
-
utils.execute('efibootmgr', '-b', boot_num, '-B')
|
|
311
|
+
utils.execute('efibootmgr', '-b', boot_num, '-B', binary=True)
|
|
305
312
|
|
|
306
313
|
|
|
307
314
|
def _run_efibootmgr(valid_efi_bootloaders, device, efi_partition,
|
|
@@ -82,8 +82,8 @@ def _download_with_proxy(image_info, url, image_id):
|
|
|
82
82
|
timeout=CONF.image_download_connection_timeout)
|
|
83
83
|
if resp.status_code != 200:
|
|
84
84
|
msg = ('Received status code {} from {}, expected 200. '
|
|
85
|
-
'Response body: {}').format(
|
|
86
|
-
|
|
85
|
+
'Response body: {} Response headers: {}').format(
|
|
86
|
+
resp.status_code, url, resp.text, resp.headers)
|
|
87
87
|
raise errors.ImageDownloadError(image_id, msg)
|
|
88
88
|
except (errors.ImageDownloadError, requests.RequestException) as e:
|
|
89
89
|
if (attempt == CONF.image_download_connection_retries
|
|
@@ -292,6 +292,8 @@ class ImageDownload(object):
|
|
|
292
292
|
self._time = time_obj or time.time()
|
|
293
293
|
self._image_info = image_info
|
|
294
294
|
self._request = None
|
|
295
|
+
self._bytes_transferred = 0
|
|
296
|
+
self._expected_size = None
|
|
295
297
|
|
|
296
298
|
# Determine the hash algorithm and value will be used for calculation
|
|
297
299
|
# and verification, fallback to md5 if algorithm is not set or not
|
|
@@ -331,6 +333,8 @@ class ImageDownload(object):
|
|
|
331
333
|
LOG.info("Attempting to download image from %s", url)
|
|
332
334
|
self._request = _download_with_proxy(image_info, url,
|
|
333
335
|
image_info['id'])
|
|
336
|
+
self._expected_size = self._request.headers.get(
|
|
337
|
+
'Content-Length')
|
|
334
338
|
except errors.ImageDownloadError as e:
|
|
335
339
|
failtime = time.time() - self._time
|
|
336
340
|
log_msg = ('URL: {}; time: {} '
|
|
@@ -363,7 +367,13 @@ class ImageDownload(object):
|
|
|
363
367
|
# this code.
|
|
364
368
|
if chunk:
|
|
365
369
|
self._last_chunk_time = time.time()
|
|
366
|
-
|
|
370
|
+
if isinstance(chunk, str):
|
|
371
|
+
encoded_data = chunk.encode()
|
|
372
|
+
self._hash_algo.update(encoded_data)
|
|
373
|
+
self._bytes_transferred += len(encoded_data)
|
|
374
|
+
else:
|
|
375
|
+
self._hash_algo.update(chunk)
|
|
376
|
+
self._bytes_transferred += len(chunk)
|
|
367
377
|
yield chunk
|
|
368
378
|
elif (time.time() - self._last_chunk_time
|
|
369
379
|
> CONF.image_download_connection_timeout):
|
|
@@ -400,6 +410,18 @@ class ImageDownload(object):
|
|
|
400
410
|
self._expected_hash_value,
|
|
401
411
|
checksum)
|
|
402
412
|
|
|
413
|
+
@property
|
|
414
|
+
def bytes_transferred(self):
|
|
415
|
+
"""Property value to return the number of bytes transferred."""
|
|
416
|
+
return self._bytes_transferred
|
|
417
|
+
|
|
418
|
+
@property
|
|
419
|
+
def content_length(self):
|
|
420
|
+
"""Property value to return the server indicated length."""
|
|
421
|
+
# If none, there is nothing we can do, the server didn't have
|
|
422
|
+
# a response.
|
|
423
|
+
return self._expected_size
|
|
424
|
+
|
|
403
425
|
|
|
404
426
|
def _download_image(image_info):
|
|
405
427
|
"""Downloads the specified image to the local file system.
|
|
@@ -423,7 +445,9 @@ def _download_image(image_info):
|
|
|
423
445
|
msg = 'Unable to write image to {}. Error: {}'.format(
|
|
424
446
|
image_location, str(e))
|
|
425
447
|
raise errors.ImageDownloadError(image_info['id'], msg)
|
|
426
|
-
|
|
448
|
+
image_download.verify_image(image_location)
|
|
449
|
+
except (errors.ImageDownloadError,
|
|
450
|
+
errors.ImageChecksumError) as e:
|
|
427
451
|
if attempt == CONF.image_download_connection_retries:
|
|
428
452
|
raise
|
|
429
453
|
else:
|
|
@@ -438,10 +462,12 @@ def _download_image(image_info):
|
|
|
438
462
|
|
|
439
463
|
totaltime = time.time() - starttime
|
|
440
464
|
LOG.info("Image downloaded from %(image_location)s "
|
|
441
|
-
"in %(totaltime)s seconds"
|
|
465
|
+
"in %(totaltime)s seconds. Transferred %(size)s bytes. "
|
|
466
|
+
"Server originaly reported: %(reported)s.",
|
|
442
467
|
{'image_location': image_location,
|
|
443
|
-
'totaltime': totaltime
|
|
444
|
-
|
|
468
|
+
'totaltime': totaltime,
|
|
469
|
+
'size': image_download.bytes_transferred,
|
|
470
|
+
'reported': image_download.content_length})
|
|
445
471
|
|
|
446
472
|
|
|
447
473
|
def _validate_image_info(ext, image_info=None, **kwargs):
|
|
@@ -588,7 +614,12 @@ class StandbyExtension(base.BaseAgentExtension):
|
|
|
588
614
|
msg = ('Unable to write image to device {}. '
|
|
589
615
|
'Error: {}').format(device, str(e))
|
|
590
616
|
raise errors.ImageDownloadError(image_info['id'], msg)
|
|
591
|
-
|
|
617
|
+
# Verify the checksum of the streamed image is correct while
|
|
618
|
+
# still in the retry loop, so we can retry should a checksum
|
|
619
|
+
# failure be detected.
|
|
620
|
+
image_download.verify_image(device)
|
|
621
|
+
except (errors.ImageDownloadError,
|
|
622
|
+
errors.ImageChecksumError) as e:
|
|
592
623
|
if attempt == CONF.image_download_connection_retries:
|
|
593
624
|
raise
|
|
594
625
|
else:
|
|
@@ -603,9 +634,11 @@ class StandbyExtension(base.BaseAgentExtension):
|
|
|
603
634
|
|
|
604
635
|
totaltime = time.time() - starttime
|
|
605
636
|
LOG.info("Image streamed onto device %(device)s in %(totaltime)s "
|
|
606
|
-
"seconds
|
|
607
|
-
|
|
608
|
-
|
|
637
|
+
"seconds for %(size)s bytes. Server originaly reported "
|
|
638
|
+
"%(reported)s.",
|
|
639
|
+
{'device': device, 'totaltime': totaltime,
|
|
640
|
+
'size': image_download.bytes_transferred,
|
|
641
|
+
'reported': image_download.content_length})
|
|
609
642
|
# Fix any gpt partition
|
|
610
643
|
try:
|
|
611
644
|
disk_utils.fix_gpt_partition(device, node_uuid=None)
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
+
|
|
14
15
|
import os
|
|
15
16
|
|
|
16
17
|
from oslo_log import log
|
|
17
18
|
|
|
18
19
|
from ironic_python_agent import errors
|
|
19
20
|
from ironic_python_agent import hardware
|
|
21
|
+
from ironic_python_agent.hardware_managers.nvidia import nvidia_fw_update
|
|
20
22
|
from ironic_python_agent import netutils
|
|
21
23
|
|
|
22
24
|
LOG = log.getLogger()
|
|
@@ -111,3 +113,53 @@ class MellanoxDeviceHardwareManager(hardware.HardwareManager):
|
|
|
111
113
|
vendor=vendor,
|
|
112
114
|
product=hardware._get_device_info(interface_name, 'net', 'device'),
|
|
113
115
|
client_id=client_id)
|
|
116
|
+
|
|
117
|
+
def get_clean_steps(self, node, ports):
|
|
118
|
+
"""Get a list of clean steps with priority.
|
|
119
|
+
|
|
120
|
+
:param node: The node object as provided by Ironic.
|
|
121
|
+
:param ports: Port objects as provided by Ironic.
|
|
122
|
+
:returns: A list of cleaning steps, as a list of dicts.
|
|
123
|
+
"""
|
|
124
|
+
return [{'step': 'update_nvidia_nic_firmware_image',
|
|
125
|
+
'priority': 0,
|
|
126
|
+
'interface': 'deploy',
|
|
127
|
+
'reboot_requested': True,
|
|
128
|
+
'abortable': False,
|
|
129
|
+
'argsinfo': {
|
|
130
|
+
'images': {
|
|
131
|
+
'description': 'Json blob contains a list of images,'
|
|
132
|
+
' where each image contains a map of '
|
|
133
|
+
'url: to firmware image (file://, '
|
|
134
|
+
'http://), '
|
|
135
|
+
'checksum: of the provided image, '
|
|
136
|
+
'checksumType: md5/sha512/sha256, '
|
|
137
|
+
'componentProfile: PSID of the nic, '
|
|
138
|
+
'version: of the FW',
|
|
139
|
+
'required': True,
|
|
140
|
+
}, }
|
|
141
|
+
},
|
|
142
|
+
{'step': 'update_nvidia_nic_firmware_settings',
|
|
143
|
+
'priority': 0,
|
|
144
|
+
'interface': 'deploy',
|
|
145
|
+
'reboot_requested': True,
|
|
146
|
+
'abortable': False,
|
|
147
|
+
'argsinfo': {
|
|
148
|
+
'settings': {
|
|
149
|
+
'description': 'Json blob contains a list of '
|
|
150
|
+
'settings per device ID, where each '
|
|
151
|
+
'settings contains a map of '
|
|
152
|
+
'deviceID: device ID '
|
|
153
|
+
'globalConfig: global config '
|
|
154
|
+
'function0Config: function 0 config '
|
|
155
|
+
'function1Config: function 1 config',
|
|
156
|
+
'required': True,
|
|
157
|
+
}, }
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
def update_nvidia_nic_firmware_image(self, node, ports, images):
|
|
162
|
+
nvidia_fw_update.update_nvidia_nic_firmware_image(images)
|
|
163
|
+
|
|
164
|
+
def update_nvidia_nic_firmware_settings(self, node, ports, settings):
|
|
165
|
+
nvidia_fw_update.update_nvidia_nic_firmware_settings(settings)
|