Commit Graph

16 Commits

Author SHA1 Message Date
Vladyslav Drok c3b316677c Do not reset FSM when ironic ports cant be queried
It can cause problems, as if a single sync fails, FSM state will be
reset and not put back to initialized state until inspector restart.

Change-Id: I24b08612c4ffc6aca60ca08f3ff5cc769c7c041d
Story: #2008971
Task: #42611
2021-06-14 17:14:54 +03:00
Harald Jensås 7a067a97a8 pxe filter - option to always block unknown hosts
It is not always desired to open the DHCP server for any host
just because introspection is active. Add an option to ensure
that only nodes being introspected are added to the DHCP servers
allow list.

Also adds ethoib support in the dnsmasq PXE filter.

Also fix a typo in ethoib_interfaces option help text.

Change-Id: I4cd7f4f0a449dcc23897ec9288cb57ec9bd647d7
2020-09-28 12:18:00 +02:00
Harald Jensås a1f8926cd1 Remove non-inclusive language in pxe filter
Replaces the use of black/white-list with deny/allow-list
in the pxe filter.

Change-Id: I84e6343fc13e4c4c02521499632a07e782088057
2020-07-09 12:06:03 +02:00
Sean McGinnis a9f7f67de5
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: Ic67f09a223ae2d0cb460771a10a4122307afa05b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 16:15:28 -05:00
Riccardo Pittau 3accdfbbc6 Use openstacksdk for ironic module
This patches removes the ironic-client dependency from the
ironic module in favor of openstacksdk.

Increase minimum required version of openstacksdk to use
recent added features.

Change-Id: I31964179835ad454e8205a59f483b419de4fb62d
2020-03-23 14:28:09 +01:00
Riccardo Pittau 9b1450398c 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: Ic443c7e4d5a5a849c4dc220207f8957e4c90bf53
2019-12-17 09:23:01 +01:00
Tao Li d13d8144bb Replace assertEqual(True/False, *) with assertTrue/assertFalse in tests
In UT Test,It provides assertTrue(*) and assertFalse(*) to check the
returned value. It is not necessary to use assertEqual(True, *) or
assertEqual(False, *)

Change-Id: I335e5f542861c31ee5fa75953926e97701e50c77
Story: #2003776
Task: #26469
2018-09-17 09:10:46 +00:00
Thomas Goirand 2459cd8531 Python 3.7: fix os.errno -> errno
In Python 3.7, there's no longer a os.errno, it's now available directly
from the root instead.

This patch therefore, tries to "import errno", and fallsback to
"import os.errno as errno" if it fails. Then in the content of the code,
we simply use the errno module directly.

Change-Id: Ibf385ab32a8098e936c019303633de38a848076c
2018-08-30 10:22:19 +02:00
Harald Jensås c4abd6783b PXE Filter dnsmasq: manage macs not in ironic
This changes the dnsmasq PXE filter so that it keeps
macs that are no longer in ironic blacklisted unless
introspection is active or node_not_found_hook is set.

Replacing the previous behaviour that would
exclusively whitelist macs that are no longer in
ironic.

Story: 2001979
Task: 19589
Change-Id: Ib417089116dcbfb25f759708ee3cddcb88ae2111
2018-07-06 11:04:16 +00:00
Harald Jensås 2c5cf4e667 Fix dnsmasq filter nits
This patch fixes a couple of nits in the unit tests.
Also removes an entry from the docstring of
_configure_unknown_hosts that is not valid.

Change-Id: I3785bfedf5441e7b21a96b49b05ec910270358e4
2018-05-08 06:33:12 +02:00
Harald Jensås 5e54e72136 PXE Filter dnsmasq: blacklist unknown host
Unless one or more nodes are on introspection and
node_not_found_hook is not set a dhcp_hostsdir ignore
record for wildcard mac '*:*:*:*:*:*' is maintained.

The iptables filter driver blocks DHCP requests on the
Inspector interface unless one or more nodes are on
introspection and node_not_found_hook is not set.

This change brings the dnsmasq filter driver to parity
by implementing logic similar to the iptables driver.

Related: rhbz#1574672
Story: 2001970
Task: 16864
Change-Id: Ibdd2210ecb3833a0d91205a7919122b7c0576b9e
2018-05-07 18:07:03 +02:00
Dmitry Tantsur 5c63f1490c Prevent mocks in test_dnsmasq_pxe_filter from conflicting with oslo.config
oslo.config starts using os.path functions in the next release in set_override.
This change modifies unit tests to prevent mocks from clashing with it.

Change-Id: I6096cb61ef9733e761a5d3d7a24109575f685fe9
Closes-Bug: #1754026
2018-03-12 12:39:58 +01:00
Dmitry Tantsur 3237511cc6 Retry port lists on failure in PXE filter periodic sync
These calls are subject to transient network problems, we should
not abort ironic-inspector process in this case. Also due to
bug 1748893 the port listing API can sometimes return HTTP 400.

This change retries port listing 5 times with 1 second break
before aborting the periodic task and thus the process.

This change introduces a dependency on the retrying library,
which is already widely used in OpenStack (including ironic).

Change-Id: I92fd70ca5692ce9f6798eedf9e540d5aa7c6f1af
Closes-Bug: #1748893
2018-02-14 15:10:39 +01:00
Julia Kreger b88823a771 Fix Py2/Py3 differences in write locking code
In Py2, a file object write method returns NoneType.

In Py3, a file object write method returns a count of
bytes written, which can be used to interpret success.

As this code, at least for now, still needs to work
on Py2 without raising what appears to be errors, we
need to remove the assumption that data is returned
upon write.

Should a write fail, IOError is still raised in Py2,
which means the existing exception handling should be
sufficent.

Also, added an explicit flush for before we release the file
lock, just to ensure that the data is actually written out of
python's buffers before the lock is released.

Change-Id: I1cae8f1cd2f7da39600d72a84fe041ff0a97e580
Closes-Bug: #1741035
2018-01-11 14:42:51 +00:00
dparalen 4ff0213e87 Allow concurrect updating of dnsmasq configuration
This allows multiple instances of inspector to try updating dnsmasq
configuration simultaneously.  The goal is to be able to (test) run an HA
inspector on a single node.

A new config option `dnsmasq_pxe_filter.purge_dhcp_hostsdir` is introduced to
be able to disable purging of the dhcp hosts directory in case multiple
inspector instances are expected to run on the same node.

Change-Id: I2f7b8d3172f375cf65e759c9b881fcf41649c2f0
Closes-Bug: #1722267
2017-11-27 18:54:55 +01:00
dparalen 8ddfacdf34 Introducing a dnsmasq PXE filter driver
A PXE filter driver is introduced that works by configuring and controlling
the dnsmasq service.

Closes-Bug: 1693813
Related-Bug: 1665666
Change-Id: I63fe91ee4f9ac3021bcfd9a4a378af56af800fac
2017-11-22 15:08:23 +01:00