Commit Graph

72 Commits

Author SHA1 Message Date
likui e5f7e052ac Fix Reopen Web Console Duplicate Sol Session
Reopen web console may occasionally result in duplicated
sol session. get_console action open
one console process while another sol session remains.

This patch adds "sol deactivate" action before get
console. Make sure the current connection always a success.

Change-Id: Ie5d9c94a3e9e3561b6aa1a52462d6739662d4eb0
2024-03-07 15:41:32 -08:00
Julia Kreger 76c075269d Enable vendor interfaces to be called as steps
Adds the logic and testing to handle vendor interfaces to be able
to be called as steps, as well as adds the ipmitool send_raw
vendor passthru  method to be able to be called as a step.

Change-Id: I741a4173f1d150298008d3190e4c3998402a8b86
2023-07-13 07:40:53 -07:00
Kaifeng Wang c9c9b3100d Fixes console port conflict occurs in certain path
The dynamically allocated console port for a node is saved
into database and reused on subsequent console operations.
In certain code path the port record cann't be trusted and
we should do a re-allocation.

This patch fixes the issue by ignores previous allocation
record. The extra cleanup in the takeover is not required
anymore and removed as well.

Change-Id: I1a07ea9b30a2c760af7a6a4e39f3ff227df28fff
Story: 2010489
Task: 47061
2023-02-15 17:42:37 +00:00
taoruizhe a2160f13af Fix Node Console Duplicate Sol Session
Restart node console may occasionally result in duplicated
sol session. Especially, when a cluster deployed with multi
ironic-conductor backends, stop_console action shutdown
only one console process while another sol session remains.

This patch adds "sol deactivate" action before start node
console. Make sure the current connection always a success.

Story: 2009762
Task: 44233
Change-Id: I5bc8666ff0b4ceab61ed6a8c794d6882783d6bce
2022-01-20 18:42:14 +00:00
Julia Kreger 493b4f0caf Yoga: Change default boot mode to uefi
Change the default boot mode to UEFI, as discussed during the end
of the Wallaby release cycle and previously agreed a very long time
ago by the Ironic community.

Change-Id: I6d735604d56d1687f42d0573a2eed765cbb08aec
2021-10-04 11:57:55 -07:00
Iury Gregory Melo Ferreira b029fb3770 Automaticaly set cipher suite
In some cases the operator can't specify `ipmi_cipher_suite`
for each node and the problem with session can still occour:
`Error in open session response message : no matching cipher suite`

This patch adds a new configuration option that will take a list
of possible cipher suite versions that can be used when the error
occurs and the node doesn't have the `ipmi_cipher_suite` set.

Story: 2008739
Task: 42093
Change-Id: I6788585a83268e20ff6447e570995871bc9c25d5
2021-03-29 05:50:25 +02:00
Dmitry Tantsur 121b3348c8 Refactor vendor detection and add Redfish implementation
Get rid of the TODO in the code and prepare for more management
interfaces supporting detect_vendor(). Vendor detecting now runs
during transition to manageable and on power state sync (essentially
same as before but for all drivers not only IPMI).

Update the IPMI implementation to no longer hide exceptions since
they're not handled on the upper level. Simplify the regex and fix
the docstring.

Add the Redfish implementation as a foundation for future
vendor-specific changes.

Change-Id: Ie521cf2295613dde5842cbf9a053540a40be4b9c
2021-01-28 16:41:45 +01:00
Zuul 2d70e6e26e Merge "IPMI: Handle vendor set boot device differences" 2020-12-14 21:03:02 +00:00
Julia Kreger a7ac9ce8cd IPMI: Handle vendor set boot device differences
Supermicro machines, when in UEFI mode, have a different
device number, in binary, to represent the hard disk from
other vendors such as Fujitsu which actually has somewhat
similar code in their driver.

This means we need to be somewhat cognizent of the vendor of
the BMC and possibly update the device mapping based upon that
vendor.

This may ultimately fix a number of IPMI related problems, because
there is a reliance upon the text output of ipmitool, which only
reads the bytes retured by the BMC, which may not be reality after
the next reset, espescialy if ipmitool doesn't know of the UEFI
operating difference.

Change-Id: Ie19db9e0cf1eafdfc9bb46248f4d457337821f94
Story: 2008241
Task: 41085
2020-12-14 12:00:38 +00:00
Steve Baker 1de3db3b16 Fix ipmitool timing argument calculation
Calculating the ipmitool `-N` and `-R` arguments from ironic.conf
[ipmi] `command_retry_timeout` and `min_command_interval` now takes
into account the 1 second interval increment that ipmitool adds on
each retry event.

Failure-path ipmitool run duration will now be just less than
`command_retry_timeout` instead of much longer.

Change-Id: Ia3d8d85497651290c62341ac121e2aa438b4ac50
2020-10-14 19:33:50 +00:00
Dmitry Tantsur 2773c5fb25 Allow configuring IPMI cipher suite
Negotiation fails for some hardware, let's allow an explicit setting.

Change-Id: I04a3391f85412dcabc6105bd91beb1da25bdfc19
2020-09-16 15:52:07 +02:00
Kaifeng Wang 07a7a269bb Fix console auto port allocation under IPv6
By default _verify_port() only works for IPv4 network, the same port can be
allocated to multiple nodes in a IPv6 network because the port checking
passed and be used for other nodes.

This fix passes the socat_address to the port validation and use the
correct address family to do the socket binding.

Story: 2007946
Task: 40412

Change-Id: I1355afaa551baee7b9fd7883d2d29342d059c5a0
2020-08-05 22:46:24 +08:00
Zuul b5ae75a406 Merge "Use native oslo.concurrency execution timeout in ipmitool" 2020-07-22 15:58:19 +00:00
Bob Fournier a7445d9f85 Use min_command_interval when ironic does IPMI retries
For certain BMCs the default of 1 second is too short for the ipmitool
minimum command interval (-N).  The configured
``[ipmi]min_command_interval`` should be used.

Story: 2007914
Task: 40317

Change-Id: I07f17a7321582e9829ac422efb51b571a17c5ca8
2020-07-10 09:36:57 -04:00
Dmitry Tantsur 737076fae2 Use native oslo.concurrency execution timeout in ipmitool
This change replaces custom Popen-based code with the new argument
(backed by the corresponding stdlib argument).

Story: #2004449
Task: #40283
Change-Id: I6840b1caffd272ef12ab2b259a02376ec185bc3f
2020-07-06 18:35:44 +02:00
Bob Fournier 3ae7e6880d Change default to ``False`` for ``use_ipmitool_retries``
A new configuration parameter was introduced in
https://review.opendev.org/#/c/731676/ to work around an
issue with some BMCs that don't support the Cipher
Suites command.  This changes the default value to
``False`` so that Ironic will do the retries by default.

Note that this should not be backported to avoid changing
the behaviour in stable branches.

Change-Id: I34bf7e5d79defc23161213aa8942edace4b87b78
Story: 2007632
Task: 39676
2020-05-29 08:54:20 -04:00
Bob Fournier 6520b373f4 New configuration parameter to use ipmitool retries
Add a new ``[ipmi]use_ipmitool_retries`` option. When set to
``True`` and timing is supported by ipmitool, the number of
retries and command interval will be passed to ipmitool so
that ipmitool will do the retries.  When set to ``False``,
ironic will do the retries.

The default is ``True``, so this will not change the current
behaviour which is to have ipmitool do the retries when
timing is supported.

Setting to ``False`` will help with certain BMCs which do
not support the Cipher Suites command.  In this case ipmitool
can take up to 10 seconds for each retry which results in a
total time exceeding ``[ipmi]command_retry_timeout``.

Change-Id: I1d0194e7c7ae9fcdd4665e6115ee26d10b14e480
Story: 2007632
Task: 39676
2020-05-28 08:21:32 -04:00
Riccardo Pittau c5543b572b Enforce autospec in some unit tests modules
Also changed filters in tox.ini to be more granular and allow
working in small batches.

Change-Id: Id0d3db5d4faeb317272885dd9e98527e15c33c12
2020-05-06 18:20:01 +02:00
Iury Gregory Melo Ferreira d6e7552457 Switch to unittest mock
Python3 have a standard library for mock in the unittest module,
let's drop the mock requirement and switch tests to unittest mock.

Change-Id: I4f1b3e25c8adbc24cdda51c73da3b66967f7ef23
2020-04-30 19:04:17 +02:00
Julia Kreger 1e514b6440 Move ipmi logging to a separate option
The IPMI verbose output being turned on by the debug option
is confusing and misleading, and since many operators run
ironic in debug mode anyway, it doesn't make much sense
to spam logs with errors and information that can be
misleading to a less experienced operator.

Also... less logging output.

Change-Id: I0fae7bad5613865dfd4d1c663be08d40debe157a
2020-03-13 06:11:17 -07:00
Kaifeng Wang b3721ce4ff Automatic port allocation for the serial console
Introduces [console]port_range configuration option and implements
the feature of automatic port allocation for IPMI based serial console.

The ipmi_terminal_port in driver_info takes precedance if specified,
otherwise ironic will allocate free port from configured port range
for underlying serial proxy tools.

The implementation deviation with the original proposal is this patch
doesn't validate whether user specified ipmi_terminal_port falls in the
range, based on following considerations:
a. ipmi_terminal_port is considered a resort for backwards compatibility,
we will remove this eventually.
b. different conductors may have different port range configured (rare,
but could happen).
c. force ipmi_terminal_port in the port range could raise the
possibility of conflicts with ports in the configured range, this is not
a desired result, so leave the choice to the end users.

Change-Id: If8722d09dc74878f4da2e4a7f059d9b079c3e472
Story: 2007099
Task: 38135
2020-02-10 16:09:12 +08:00
Riccardo Pittau 78c121a5d7 Stop using six library
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: Ib546f16965475c32b2f8caabd560e2c7d382ac5a
2019-12-23 09:38:25 +01:00
Vladyslav Drok 68a5e31a54 Mock out the correct greenthread sleep method
It seems at some point oslo_service loopingcall started using
eventletutils from oslo_utils to sleep during the loopingcall
retries, and some untittests started taking up to 40 seconds
to complete. This change mocks out the correct method offering
significant speedup to unittests' run time.

The EventletEvent class is introduced to eventletutils in version
3.38.0 so lower constraints are bumped as well.

Change-Id: Id7e6ff2a4748b5301e2259acdc760ac7f56b96c3
2019-11-20 17:52:33 +01:00
Vladyslav Drok a3ac25f299 Allow to configure additional ipmitool retriable errors
This change allows to configure more retriable errors for ipmitool
execution that are specific to the environment it is run in.

Task: 36296
Story: 2006410
Change-Id: I4bd06ad405f87f5fb974777fc3d84e4874b4f5bb
2019-08-16 16:44:05 +02:00
Julia Kreger 418a5668a4 ipmi: Ignore sensor debug data
When the conductor has debugging enabled, that command is
passed to ipmitool to enable debugging of other commands.

However, this means tons of extra data is dumped as part of
the sensor data collection for ironic, which breaks string
parsing and ultimately metrics collection.

Since we can identify these lines, lets ignore them.

Change-Id: Ife77707210f8289d8f2e0223fb9ee1909d798546
Story: 2005332
Task: 30267
2019-03-29 17:37:21 +00:00
Nikolay Fedotov 82704e6d8d Kg key for IPMIv2 authentication
Support for the -y option of ipmitool

Quote from docs:
-y <hex key>
Use supplied Kg key for IPMIv2 authentication. The key is expected
in hexadecimal format and can be used to specify keys with non-printable
characters. E.g. '-k PASSWORD' and '-y 50415353574F5244' are equivalent.
The default is not to use any Kg key.

Change-Id: Ie6a9fc1a41d924e30eff526b3eae929ce6e085c6
Story: #2005158
Task: #29876
2019-03-14 19:41:21 +00:00
Lars Kellogg-Stedman 70d7bb369a honor ipmi_port in serial console drivers
teach the ipmitool driver about _get_ipmitool_args and use that in all
cases that we want to build an ipmitool command line.   this solves
the problem that the serial console drivers were failing to honor the
ipmi_port setting in driver_info, while it was being correctly used
for power state, etc.

Change-Id: Ifbf6a92c2305567985cfbc41dbf76a076ecb8a7b
Story: 2005138
Task: 29826
2019-03-13 11:00:12 +01:00
Tony Breeds 03375f003f Make ipmi_force_boot_device more user friendly
Look for boolean and string like booleans in driver_info['ipmi_force_boot_device']
to make setting the option more user friendly / less error prone.

Change-Id: I2917761055db5286183ce265089c19dea98947ad
Story: 2004444
2019-01-15 13:20:45 +11:00
Kaifeng Wang d379357cad Introduce configuration option [ipmi]ipmi_disable_timeout
Some type of BMCs don't support an IPMI option that disable the
behavior of boot device timeout, which makes them never get booted
from PXE.

This patch extends the fix [1] by adding a configuration option,
which provides the default ipmi behavior.

[1] https://review.openstack.org/#/c/616053

Additionally revising the variable/setting names based upon review
feedback and discussion that took place during the 20181210 weekly
ironic team meeting.

Change-Id: Ie049bbaf45aeab54c1272d1d561c5a6ca00dc34a
Story: 2002977
Task: 22985
2018-12-10 14:04:02 -08:00
Zuul d2627ec78a Merge "Kill misbehaving `ipmitool` process" 2018-12-05 21:33:54 +00:00
Ilya Etingof 9efb9e313d Kill misbehaving `ipmitool` process
We can't trust ipmitool to terminate in time. We may have to kill
the process if it's running for longer than we asked it to.

On the other hand, abrupt IPMI exchange termination is said to be
dangerous to the state of the BMC being managed. Therefore this patch
only kills timed out IPMI "power status" call.

For the purpose of killing hung `ipmitool` we inject the time-capped
`popen.wait` call before the uncapped `popen.communicate` is called
internally. Then just kill stuck `ipmitool` process and go on.

Story: 2004449
Task: 28127
Change-Id: I7e1eafb334fe3a3337926aca27c14fe559ce0e39
2018-12-05 09:19:59 +01:00
Tony Breeds eb29465bd5 Add ipmi_disable_timeout to avoid problematic IPMI command
The IPMI driver unconditionally instructed the BMC not automatically
clear boot flag valid bit if Chassis Control command not received within
60-second timeout (countdown restarts when a Chassis Control command is
received).  Some BMCs do not support setting this.  Sending the command
aborts the node boot.

A new driver option ``ipmi_disable_timeout`` is added to bypass
sending this command.

Change-Id: I1dda3cf3e4b7b888ed9d8931c8ede3a918dd01f4
Story: 2004266
2018-11-28 01:29:04 +00:00
Kaifeng Wang 86d26e7cbe Remove deprecated option [ipmi]retry_timeout
The option [ipmi]retry_timeout is deprecated at Pike, now it's time
to remove it from the tree.

Change-Id: I921661db2a6f0c85e717e1a80e5f0c8b6c91d369
Story: #2003028
Task: #23052
2018-07-21 14:36:36 +08:00
Ilya Etingof e3d66818fa Move boot-related code to boot_mode_utils.py
This change collects boot-relalated functions into
the `boot_mode_utils.py` module to improve code clarity.

Change-Id: I1a2225d503deb382ba6021a6073c81cd03ca3175
Story: 1734131
Task: 10640
2018-06-20 11:37:11 +02:00
Dmitry Tantsur 495d738fb9 Remove the fake_ipmitool, fake_ipmitool_socat and fake_snmp drivers
Change-Id: I05f228f3724486351c04bf2b4b55e950fe20d724
2018-06-12 10:37:22 +02:00
Zuul dea701e8c3 Merge "Adds more `ipmitool` errors as retryable" 2018-06-11 05:14:25 +00:00
Ilya Etingof 4d020a68fb Adds more `ipmitool` errors as retryable
This change extends the list of `ipmitool` errors that
ironic treats as retryable on failure.

Change-Id: I5fddc95404a1725f03bd26da51932c3ece5a5a35
Story: 2001989
Task: 19611
2018-06-06 13:15:24 +02:00
Dmitry Tantsur 86a5a1698f Remove excessive usage of mock_the_extension_manager in unit tests - part 1
This function does not work properly with hardware types, and is not
needed in the most cases where it is used. The enabled_drivers option
is changed instead where needed.

This change covers only a (randomly selected) part of files. Other files
will be updated separately.

Change-Id: Iae40ed6c5d37bb2d2af3219d2f94922a2b32d78d
2018-05-15 15:37:14 +02:00
John L. Villalovos cb5f513c3a cleanup: Remove usage of some_dict.keys()
There is usually no need to use some_dict.keys(). Cleanup the code by
removing this unneeded usage of keys()

Change-Id: I755de2e610ecad568c2265e10bd0a6ff1275888c
2018-02-05 20:45:04 -08:00
Jenkins b8a38d9731 Merge "ipmitool: reboot: Don't power off node if already off" 2017-10-08 13:19:25 +00:00
Akhila Kishore a06a2fee3d Follow-up patch 'Cleanup unit tests for ipmittool'
Addressing nits.
In commit 43fbc5dc6a there were some issues
pointed out during review. This is a follow-up patch to address
those issues.
Change-Id: I7155a2cdc90b8c4f4162318ec0a5ee291e169379
2017-10-03 22:18:51 +00:00
John L. Villalovos 8ceaad42ff ipmitool: reboot: Don't power off node if already off
Commit ee5d4942a1 changed the existing
behavior so that if an ipmitool command fails when attempting to set
the power state it causes a failure.  The problem with that approach
is that on some systems if the system is already in the desired power
state, an error will be generated when ipmitool tries to change it to
the desired power state.

Now when doing a reboot command we check beforehand to see if the node
is already off, if so then don't attempt to power off the node again.

Also optimize ironic/conductor/utils.py node_power_action() so that it
only checks a node's power status if it might perform an action based
on the node's power status.

Change-Id: If838aae871753ebfbdf359e0bbe3afcc54c4b559
Closes-Bug: #1718794
2017-09-27 17:19:46 -07:00
John L. Villalovos 43fbc5dc6a Cleanup unit tests for ipmittool
By having a mock patch on the testcase class it was requiring 40+
functions to have 'mock_sleep' in their argument list. When we are
only checking the mock about five times. Instead put it into the
setUp() function.

Also fix mistakes introduced by previous patches that did not realize
that:
    @mock.patch.object(ipmi, '_make_password_file', _make_password_file_stub)
    def some_func(self, mock_pass): ...

The mock.patch.object() is defining the object completely and thus it
(mock_pass) is not actually passed as an argument to the function.
When removing the 'mock_sleep' mock I discovered this issue.

Change-Id: Iac5dfa8382d04bead745260598d5228c6114b70d
2017-09-25 12:31:39 -07:00
Béla Vancsics 09adb96836 Use more specific asserts in tests
Instead of assertTrue and assertFalse use more specific asserts.
They are compatible with Python 2.7[1] and 3.4[2]

[1]: https://docs.python.org/2.7/library/unittest.html
[2]: https://docs.python.org/3.4/library/unittest.html

Change-Id: Iea7306f8ab6e3253fd68007829b7e8b51afb790a
2017-08-04 08:42:39 +02:00
Vladyslav Drok 54d5335edd Mock random generator for BackoffLoopingCall in IPMI unittests
Set power state methods now use BackoffLoopingCall to wait for the
desired power state. It uses random.SystemRandom gauss distribution
to determine the amount of time to wait for the next check. This
change adds a method to mock the result of the pseudo-random sleep
interval generation, so that the value to wait between power state
checks is 1.

Closes-Bug: 1702859
Change-Id: I9270a187fa0f413ba8a8a14f859b0fd65c439b6e
2017-07-07 14:14:24 +03:00
Julian Edwards ee5d4942a1 Don't retry power status if power action fails
The old code blindly required power status even if the power action
failed. Now, it will retry the power action only when it detects a
retryable failure, and will only poll for power status if the power
action is successful. This patch also moves the logic for handling
waiting for power status into the conductor so that the logic is
standardised between drivers.

Change-Id: Ib48056e05d359848386ac057b58921f40b7bdd60
Co-Authored-By: Sam Betts <sam@code-smash.net>
Related-Bug: #1675529
Closes-Bug: #1692895
2017-06-27 12:10:47 +01:00
Ruby Loo 62c6377adf Node should reflect what was saved
After a node is saved to the database, we weren't updating the
Node object to reflect what was saved. This caused a problem
where the node's update_at field was incorrect. It was fixed
in 065326c0f5 by explicitly
setting node.update_at. However, that doesn't address other
node fields that may be out of sync.

The more correct fix would be to do a similar thing that (most
of) the other Objects do, which is for the node to update itself
via ._from_db_object().

Doing this revealed several incorrect tests and code in the conductor
and agent where changes to the node's dictionaries were incorrectly
being set and thus, not being saved. Those are fixed in this patch.

Change-Id: Ia84cd60c1a4eabcc1ad0a756124c338fa9f644c8
Closes-Bug: #1679297
Related-Bug: #1281638
2017-04-04 09:19:31 -04:00
Jenkins 31d889a7c4 Merge "Ipmitool management driver for Inject NMI" 2017-01-23 16:45:09 +00:00
Naohiro Tamura 22a3a5a271 Ipmitool management driver for Inject NMI
This patch enhances ipmitool management driver to support Inject NMI.

Partial-Bug: #1526226
Change-Id: I6def498a6f242b34f647bb670d3fbfcb99fb667a
2017-01-20 13:09:01 +09:00
Naohiro Tamura ed6c599083 Ipmitool power driver for soft reboot and soft power off
This patch enhances ipmitool power driver to support SOFT_REBOOT
and SOFT_POWER_OFF.

Partial-Bug: #1526226
Change-Id: If01721625c22a578b4311b82104cd895139e3a01
2017-01-13 11:40:20 +09:00