7 Commits

Author SHA1 Message Date
Dmitry Tantsur
8e0fa1be20 Migrate more trivial code from ironic-lib
* The dd and is_http_url code is trivial, inline it.
* Migrate mounted (cannot be used in Ironic since it requires root).
* Remove the leftovers of run_as_root.

Change-Id: Ic6b117e34ccc7f55ebac5f808d2765305c4b317f
2024-10-30 12:55:02 -07:00
Jay Faulkner
70aa08dad8 Remove use of ironic_lib i18n module
We traditionally have not done any translations for IPA, but some of the
code carried over from ironic_lib -- as well as a single hardware
manager -- were using the i18n wrappers. This removes them from
everywhere for consistency.

Change-Id: I85a607d7cfb50d605cc62ac8c5e3937802b4d2af
2024-10-30 12:55:02 -07:00
Jay Faulkner
c3e7f3bece Cleanup usage of imported-from-ironic-lib disk_utils
- Removes unused methods from disk_utils
- Unifies all image writing via populate_image

Change-Id: I860744458e52a45a4cb2882e4a59e0db9fbcb93d
2024-10-30 12:54:57 -07:00
Jay Faulkner
4553b5c025 Migrate to oslo.utils-based format_inspector
This replaces the copied-in version of format_inspector with the shared
version located in oslo.utils.

Change-Id: I62b3876f4507f28c8582cd4ba80e9f7c4e0b71ef
2024-10-18 12:33:16 -07:00
Jay Faulkner
e303a369dc Inspect non-raw images for safety
When IPA gets a non-raw image, it performs an on-the-fly conversion
using qemu-img convert, as well as running qemu-img frequently to get
basic information about the image before validating it.

Now, we ensure that before any qemu-img calls are made, that we have
inspected the image for safety and pass through the detected format.

If given a disk_format=raw image and image streaming is enabled
(default), we retain the existing behavior of not inspecting it in
any way and streaming it bit-perfect to the device. In this case, we
never use qemu-based tools on the image at all.

If given a disk_format=raw image and image streaming is disabled, this
change fixes a bug where the image may have been converted if it was not
actually raw in the first place. We now stream these bit-perfect to the
device.

Adds two config options:
- [DEFAULT]/disable_deep_image_inspection, which can be set to "True" in
  order to disable all security features. Do not do this.
- [DEFAULT]/permitted_image_formats, default raw,qcow2, for image types
  IPA should accept.

Both of these configuration options are wired up to be set by the lookup
data returned by Ironic at lookup time.

This uses a image format inspection module imported from Nova; this
inspector will eventually live in oslo.utils, at which point we'll
migrate our usage of the inspector to it.

Closes-Bug: #2071740
Change-Id: I5254b80717cb5a7f9084e3eff32a00b968f987b7
2024-09-04 09:11:28 -07:00
Tudor Domnescu
ceec5a7367 destroy_disk_metadata: support 4096 sector size
A sector size of 512 was assumed and hardcoded, causing dd to fail when
it tried to write in chunks smaller than the sector size for disks with
4096 bytes sectors. The size of GPT in sectors also depends on sector size.

Change-Id: Ide5318eb503d728cff3221c26bebbd1c214f6995
2024-04-24 20:37:44 +00:00
Dmitry Tantsur
f824930bbd
Import disk_{utils,partitioner} from ironic-lib
With the iscsi deploy long gone, these modules are only used in IPA and
in fact represent a large part of its critical logic. Having them
separately sometimes makes fixing issues tricky if an interface of
a function needs changing.

This change imports the code mostly as it is, just removing run_as_root and
a deprecated function, as well as moving configuration options to config.py.

Also migrates one relevant function from ironic_lib.utils.

Change-Id: If8fae8210d85c61abb85c388b300e40a75d0531c
2024-03-15 18:45:04 +01:00