summaryrefslogtreecommitdiff
path: root/ironic_python_agent/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Force immediate NTP time sync with chronyd at IPA startup7.0.2Arne Wiebalck2021-08-101-15/+5
| | | | | | | | | | | | | | | In order to make sure we have the correct time early, e.g. by the time we create a TLS certificate, this patch proposes to force an immediate NTP update when using chronyd. While the previous approach uses the passed NTP server as well, the update may happen only after chronyd has performed measurements (which may be too late). Story: #2009058 Task: #42843 Change-Id: I6edafe8edeb8549f324959e7a1ec175c3049a515 (cherry picked from commit 5531d5cee744f90ff24231a9ef467282b254adc2)
* Reduce logging verbosity when collecting logsDmitry Tantsur2021-06-141-2/+1
| | | | | | | | | It's not uncommon that some commands fail when collecting logs. We already log all failures in utils.execute, no need to duplicate them with a non-fatal ERROR logging. Change-Id: If151b3a3be979bd2b3ce01030e5d6242ad74eaa3 (cherry picked from commit 2fcf35e56d578d98d77ffc97b6441f83548d7704)
* Capture the early loggingJulia Kreger2021-04-081-1/+12
| | | | | | | | | | | | _early_log prints to stdout, which is fine in some cases, however in other cases it gets lost in the shuffle of process launch by things like systemd. Lets try to save everything, and re-log it so it is easy to debug early issues. Change-Id: I334a9073d17cccec4c669fae82edc3e388debc5c (cherry picked from commit df418984f037856813b6bc5e495ef602a6737ee3)
* Fix incorrect lsblk tag and add a virtual media jobDmitry Tantsur2021-03-301-2/+2
| | | | | | | | | | | Follow-up to 8dd6589e66d03e45e1d510601da9531a30842cff: PATH is not a valid lsblk tag, we need to use KNAME with -p flag. Also add a vmedia job to avoid breakages in the future. It's added non-voting because we have a deadlock with this change: https://review.opendev.org/c/openstack/ironic/+/783722 Change-Id: Ifffeac9c1c4d394526d655eaa14c9fe7bd3a1e5e
* Validate vmedia for vmedia usageJulia Kreger2021-03-291-16/+123
| | | | | | | | | | | | | | | | Virtual media devices based logic needs to be guarded from being used or considered based upon if the machine actually booted from virtual media, or not. At the same time, actual devices need to be checked in order to make sure they align with what we expect in order to prevent consideration of content which should not be leveraged. Change-Id: If2d5c6f4815c9e42798a2d96d59015e1b1dbd457 Story: 2008749 Task: 42108
* Refactor: use mounted from ironic-libDmitry Tantsur2021-03-231-28/+2
| | | | Change-Id: I0b597ddbc71c133abe6c0acfd8f49e3af4e896bb
* Use try_execute from ironic-libRiccardo Pittau2021-02-251-20/+0
| | | | | | Also adapt unit tests Change-Id: I37d050877daabc9dc0a5821cf20a689652b26f34
* New deploy step for injecting arbitrary filesDmitry Tantsur2021-02-161-0/+41
| | | | | | | | | This change adds a deploy step inject_files that adds a flexible way to inject files into the instance. Change-Id: I0e70a2cbc13744195c9493a48662e465ec010dbe Story: #2008611 Task: #41794
* Remove lldp-timeout supportKaifeng Wang2021-01-151-7/+0
| | | | | | The kernel parameter lldp-timeout was deprecated removed in this patch. Change-Id: I98da49e61d9ed3236cc495d1ab351eba0931473b
* Handle situation when a configdrive is already mountedDmitry Tantsur2020-12-161-23/+39
| | | | | | | Glean mounts the configdrive and does not unmount it afterwards. If a mount point already exists, just use it. Change-Id: Ia62279afbb9fd9770864942dc40629b69ae8f4ae
* Copy any configuration from the virtual mediaDmitry Tantsur2020-11-231-29/+82
| | | | | | | | | | | | | | | For ramdisk TLS (and other potential future enhancements) we need to be able to inject configuration and certificates into the ramdisk. Since we cannot pass files through kernel parameters, we need to put them on the generated ISO or (in the future) config drive. This change detects IPA configuration and copies it into the ramdisk early enough for any configuration files to get picked. Changed /dev/disk/by-label to blkid since the former may not exist on all ramdisks (e.g. tinyIPA). Change-Id: Ic64d7842a59795bbf02f194221dedc07c6b56e8c
* Fix confusing logging when running asynchronous commandsDmitry Tantsur2020-06-261-4/+3
| | | | | | | | | We log them as completed when they start executing. Also fix a problem in remove_large_keys that prevented items with defaultdict from being logged. Change-Id: I34a06cc85f55c693416f8c4c9877d55d6affafc9
* Split and move logic for partition tablesRiccardo Pittau2020-05-251-0/+20
| | | | | | | Move and split the logic to create the partition tables when applying raid configuration. Change-Id: Ic76dd2067ace02dd02351caca0c7f9b05571e510
* A boot partition on a GPT disk should be considered an EFI partitionDmitry Tantsur2020-04-151-12/+10
| | | | | | | | | | | | | DIB builds instance images with EFI partitions that only have the boot flag, but not esp. According to parted documentation, boot is an alias for esp on GPT, so accept it as well. To avoid complexities when parsing parted output, the implementation is switched to existing utils and ironic-lib functions. Change-Id: I5f57535e5a89528c38d0879177b59db6c0f5c06e Story: #2007455 Task: #39423
* Software RAID: Add UEFI supportRaphael Glon2020-04-021-0/+156
| | | | | | | | | | | | | | | | The proposed changes concern two steps: First, when creating the RAID configuration, have a GPT partition table type (this is not necessary, but more natural with UEFI). Also, leave some space, either for the EFI partitions or the BIOS boot partitions, outside the Software RAID. Secondly, when installing the bootloader, make sure the correct boot partitions are created or relocated. Change-Id: Icf0a76b0de89e7a8494363ec91b2f1afda4faa3b Story: #2006379 Task: #37635
* Bump hacking to 3.0.0Riccardo Pittau2020-03-301-2/+2
| | | | Change-Id: I1032ea6a2e9d79aeaecb1458c319cbeb15ac1fff
* Add NTP time syncJulia Kreger2020-03-071-0/+90
| | | | | | | | | | | Attempt to sync the clock and save it to the hardware clock. This feature supports use of chrony or ntpdate. Sem-Ver: feature Change-Id: I178d7614429d582e742d9cba6d0fa3ae099775e3 Story: 1619054 Task: 11591
* Avoid grub2-install when on UEFI boot modeIury Gregory Melo Ferreira2020-01-161-1/+1
| | | | | | | | | | | | | | This patch changes the workflow for whole disk images when using uefi. If we can identify the bootloader and it's valid we can update using efibootmgr since grub2-install have problems specially on secure boot mode. We also updated the regex to search for the uefi partition on the disk, since in some cases the parted command output can be without the FS for the partition with esp Flag. Change-Id: I7167e71e5d2352a045565289b200e5530d0ba11d Story: #2006847 Task: #37435
* Omit configdrive and system_logs from loggingDmitry Tantsur2020-01-131-0/+17
| | | | | | Since they are large and base64-encoded, they bloat ramdisk logs. Change-Id: I2e995ef356075be2a7f5b0a1906d02f90fe98a06
* Merge "Collect lsblk and /proc/mdstat with ramdisk logs"Zuul2020-01-101-0/+6
|\
| * Collect lsblk and /proc/mdstat with ramdisk logsDmitry Tantsur2019-10-141-0/+6
| | | | | | | | | | | | This should improve debugability of partitioning problems. Change-Id: I3c7ae3f2831c9900a3f0d24daec6dd6b8bea6a60
* | Search for efi partitionIury Gregory Melo Ferreira2019-12-041-0/+22
| | | | | | | | | | | | | | | | | | This patch adds a function that will be responsible to identify the efi partition on a give device, this is necessary on the Software Raid scenario and when installing bootloader. Change-Id: I5f326db2d37b2a15090ec84e477e63f7d92e7447 Co-Authored-By: Raphael Glon <raphael.glon@corp.ovh.com>
* | Stop using six libraryRiccardo Pittau2019-11-291-12/+0
|/ | | | | | | | | | Since we've dropped support for Python 2.7, it's time to look at the bright future that Python 3.x will bring and stop forcing compatibility with older versions. This patch removes the six library from requirements, not looking back. Change-Id: I4795417aa649be75ba7162a8cf30eacbb88c7b5e
* Fixes get_holder disks with nvme drivesRaphael Glon2019-08-131-0/+17
| | | | Change-Id: I195ffdeeb3c13bdec5fc1735b82efa53c8d9d3de
* Stop logging lshw output, collect it with other logs insteadDmitry Tantsur2019-06-171-0/+1
| | | | | | | | | The lshw output is huge even on virtual machines, and it pollutes the debug logging. This change silences it. Instead, the lshw output is collected as part of the ramdisk logs. Depends-On: https://review.opendev.org/#/c/665635/ Change-Id: I6a3015b2d8d09f6f48b5cbd39dc84bd75b72f909
* Fix docs job failure due to malformated docstringKaifeng Wang2019-04-091-3/+2
| | | | Change-Id: Ic3532e51481fd07e2f816aeacb07ded2d56791ee
* Add secondary sorting by name when guessing root diskArne Wiebalck2019-02-111-5/+8
| | | | | | | | | | | As some BIOSes try to boot only from the "first" disk, Ironic should order potential disks not only by size, but also by name. This patch proposes to add secondary sorting by device name when identifying the root disk. Change-Id: I4017c839eeb9d00d2b4ad5b90e4e9b65b74296c7 Story: #2004976 Task: #29434
* When ouputting to /dev/null should open in write modeJohn L. Villalovos2018-02-061-1/+1
| | | | | | | | | | | | | Even though it was working opening the file in 'read' mode, it really should be opened in 'write' mode, since we are redirecting the output to the file. Interestingly it does fail in 'read' mode if the command is: echo something But passes in 'write' mode. Change-Id: Ic67091881e0be377e527b78d270ab48962881ae0
* Fix logs encoding in py3zackchen2017-03-141-1/+1
| | | | | | | | | Make sure that logs are encoded as text (not byte strings) in python3 to allow theirs serialization in JSON. Closes-Bug: #1668533 Change-Id: I3d0d87ca766146457d905f89c26331a415bd54f8
* Configure and use SSL-related requests optionsPavlo Shchelokovskyy2017-01-131-0/+17
| | | | | | | | | | | | | | | | | This patch adds standard SSL options to IPA config and makes use of them when making HTTP requests. For now, a single set of certificates is used when needed. In the future configuration can be expanded to allow per-service certificates. Besides, the 'insecure' option (defaults to False) can be overridden through kernel command line parameter 'ipa-insecure'. This will allow running IPA in CI-like environments with self-signed SSL certificates. Change-Id: I259d9b3caa9ba1dc3d7382f375b8e086a5348d80 Closes-Bug: #1642515
* Use oslo_serialization.base64 to follow OpenStack Python3Luong Anh Tuan2016-12-161-2/+2
| | | | | | | | | | | | | | | | This patch replaces python standard base64 library call to oslo_serialization.base64 to follow OpenStack Python3 porting standard [1]. Use base64 encoding takes 8-bit binary byte data and encodes it. On Python3, A string is a sequence of Unicode characters thus base64 has no idea what to do with Unicode data, it's not 8-bit[2]. We use oslo_serialization.base64 for both python2 and python3. [1] https://wiki.openstack.org/wiki/Python3 [2] http://stackoverflow.com/questions/8908287/base64-encoding-in-python-3 Change-Id: I1dafe878a71f37d223eaf58ea8e2e8c6b4422a14
* Fix two typos, "messsage" and "containg"Nam Nguyen Hoai2016-11-221-1/+1
| | | | | | | | This patch set updated two wrong words: + In error.py file, it should be changed from "messsage" to "message" + In utils.py file, it should be changed from "containg" to "contaning" Change-Id: I5ad121ec58ccc6e5f3cc499eca50d16e691f217e
* Use ironic_lib's execute()Ruby Loo2016-07-271-18/+4
| | | | | | | Use ironic_lib's execute() instead of copying that code. Change-Id: If40c2da5423d0f90cc6661f8cdf2bec9567e1f7d Partial-Bug: #1587199
* Replace the ps options when collecting logsLucas Alvares Gomes2016-07-071-1/+1
| | | | | | | | | This patch is replacing the "-ax" options of the ps command when collecting the logs to "au". The "-x" option is not supported by the BusyBox in the TinyIPA ramdisk. Closes-Bug: #1599839 Change-Id: Id0c86db6aa16c63550890e1cd488994025f5dd68
* Add a log extensionLucas Alvares Gomes2016-06-281-0/+125
| | | | | | | | | | | | | | | | | | | The log extension is responsible for retrieving logs from the system, if journalctl is present the logs will come from it, otherwise we fallback to getting the logs from the /var/log directory + dmesg logs. In the coreos ramdisk, we need to bind mount /run/log in the container so the IPA service can have access to the journal. For the tinyIPA ramdisk, the logs from IPA are now being redirected to /var/logs/ironic-python-agent.log instead of only going to the default stdout. Inspector now shares the same method of collecting logs, extending its capabilities for non-systemd systems. Partial-Bug: #1587143 Change-Id: Ie507e2e5c58cffa255bbfb2fa5ffb95cb98ed8c4
* lldp-timeout kernel parameter missing ipa- prefixYosef Hoffman2016-06-031-0/+7
| | | | | | | | | | | | Every other Ironic python agent kernel parameter is prefixed with "ipa-". This patch allows users to use the old "lldp-timeout" parameter or the new "ipa-lldp-timeout" parameter. Warning message is logged if "lldp-timeout" parameter is used. (Also fixed typo while I'm at it.) Change-Id: Icc05ead31506628e4926be6549916a19cad48db3 Closes-Bug: #1588325
* Remove unused SUPPORTED_ROOT_DEVICE_HINTSRuby Loo2016-05-301-2/+0
| | | | | | | | utils.SUPPORTED_ROOT_DEVICE_HINTS is no longer being used so delete it. (The method that used it was removed in 33535cd572b90a817b9c96b42a0d2fe54751351d). Change-Id: Ibb675d4496d7814778f3bab9c161734013479116
* Get root device hints from the node objectLucas Alvares Gomes2016-05-261-38/+0
| | | | | | | | | | | | | | | | | | | | | | | In order to support a more complex syntax for root device hints (e.g operators: greater than, less than, in, etc...) we need to stop relying on the kernel command line for passing the root device hints. This patch changes this approach by getting the root device hints from a cached node object that was set in the hardware module. Two new functions: "cache_node" and "get_cached_node" were added to the hardware module. The idea is to facilitate the access to a node object representation from the hardware extension methods without changing method signatures, which would break compatibility with out-of-tree hardware managers. Note that the new "get_cached_node" is just a guard function to facilitate the tests for the code. The function parse_root_device_hints() and its tests were removed since it's not used/needed anymore. Partial-Bug: #1561137 Change-Id: I830fe7da1a59b46e348213b6f451c2ee55f6008c
* Stop trying to log stdout when fetching logs during inspectionDmitry Tantsur2016-03-081-1/+5
| | | | | | | | | | | | Logging the whole journalctl output is not the best idea. Fortunately, it does not work right now and fails with a traceback :) This change adds a new log_stdout argument to utils.execute() and uses it in the "logs" inspection collector. Also do not log the logs while logging the collected data. Change-Id: Ibc726ac2c4f5eb06c73ac4765bb400077b84a6cc
* Fix vfd mount for capitalized device nameNaohiro Tamura2016-02-081-2/+7
| | | | | | | | | | | | This patch enables virtual media deploy even if the expected virtual floppy device name "/dev/disk/by-label/ir-vfd-dev" is capitalized to "/dev/disk/by-label/IR-VFD-DEV". This change is necessary because some bare metal hardware such as FUJITSU RX1330 series create the capitalized virtual floppy device name. Change-Id: I436b3f9524a83814e082f8dd421df3e53b33f792 Closes-Bug: #1541167
* Update typosSwapnil Kulkarni (coolsvap)2016-01-131-1/+1
| | | | Change-Id: Ia0992ebc7a9355d5ea99d0cde28e03fc0d2a1346
* Add param docstring into the normalize funcNaohiro Tamura2015-10-141-0/+1
| | | | | | | | This patch adds a missing param docstring into the normalize function in util.py. Change-Id: I91ecc0970fc386163657ab521d8cdd898694a426 Partial-bug: 1367915
* Merge "Ensure all methods in utils.py have docstrings"Jenkins2015-10-131-5/+31
|\
| * Ensure all methods in utils.py have docstringsJay Faulkner2015-10-091-5/+31
| | | | | | | | | | | | | | | | Previous some of these methods were not well documented. Hopefully they now are. Change-Id: If73987a2dd234b71a1c2af9b764becc34aee4496 Partial-bug: 1367915
* | Enforce all flake8 rules except E129John L. Villalovos2015-10-021-2/+2
| | | | | | | | | | | | | | | | | | Bring ironic-python-agent in line with the other ironic projects. Stop ignoring all E12* errors except E129 Stop ignoring E711 Change-Id: Icb9bc198473d1b5e807c20869eb2af7f4d7ac360
* | Add support for inspection using ironic-inspectorDmitry Tantsur2015-09-071-0/+70
|/ | | | | | | | | | | | | Adds a new module ironic_python_agent.inspector and new entry point for extensions, which will allow vendor-specific inspection. Inspection is run on service start up just before the lookup. Due to this early start, and due to the fact we don't even know MAC address of nodes on inspection (to say nothing about IP addresses), exception handling is a bit different from other agent features: we try hard not to error out until we send at least something to inspector. Change-Id: I00932463d41819fd0a050782e2c88eddf6fc08c6
* Remove ordereddict as 2.6 is no longer supportedJay Faulkner2015-09-031-10/+0
| | | | | | | | ordereddict, and a related workaround method, were removed as we no longer support python 2.6. Collections contains ordereddict on newer python versions. Change-Id: I48cc55a5c56fbc1f71442fc858eb4905f0213988
* Extend hardware manager with data needed for inspectorDmitry Tantsur2015-08-211-0/+8
| | | | | | | | | | | | | | | | | * Added NetworkInterface.ip4_address * Added HardwareManager.get_bmc_address() * Added Memory.physical_mb This is total memory as reported by dmidecode, and yes, it's different from total, as it includes kernel reserved space. * Added CPU.architecture As a side effect, get_cpus was switched to lscpu. Also fixes problem when get_cpus reported the current frequency instead of maximum one. Change-Id: I4080d4d551eb0bb995a94ef9a300351910c09fb9
* Remove openstack.common packageSergey Vilgelm2015-08-031-5/+3
| | | | | | | ironic_python_agent contains unused oslo-incubator modules, so let's remove them. Change-Id: I2b8f84bf8a68d155fe123487f9b5624bb94e806b
* Add Python3 supportLucas Alvares Gomes2015-07-151-1/+1
| | | | | | | | | This patch add Python 3 support for IPA. We still need to enable it on gate to avoid code breaking the support from sneaking in. Partial-Bug: #1474896 Depends-On: I5a774eaa8d978f4d50faca4dc1b03a87fb194ce2 Change-Id: If47c0797b63d2914b3c47aba62ec5201301b6c33