Commit Graph

28 Commits

Author SHA1 Message Date
Jakub Jelinek 5ab429d528 Introduce skip list to inspector
Follow the same process of root device selection as in IPA
which changed in https://review.opendev.org/c/openstack/ironic-python-agent/+/850861
The change introduces 'skip_block_devices' field into properties which
contains a list of hints pointing to devices that cannot be root devices

Change-Id: I94c8607ef9c610eadf1b5bce4fb154e97939a643
2022-09-20 11:18:36 +01:00
Francois Rigault 22853a74b5 Fix port id vs uuid in ValidateInterfacesHook
follow-up to Icd3de82877c6a53d32b4c9fd3e500d3cd9d7fb17

Use id attribute instead of uuid. This caused an exception when an unexpected
port was being deleted.

Story: 2008698
Task: 42007
Change-Id: Ib4978f5e3e4f1b64faa1bfae3cdcf46199bb2f21
2021-03-06 16:47:30 +01:00
Dmitry Tantsur 95e103d21c Do not try to set local_gb to -1 when the matched root device size is 0
Apparently, virtual floppies on some machines are represented as normal
block devices, but with size = 0. We should filter them out in ironic-lib,
but for now at least don't fail miserably.

Story: #2007907
Task: #40308
Change-Id: Ia96a9a8b85841612fb13616754bfdbf651b212d8
2020-07-09 16:40:22 +02:00
Kaifeng Wang 71666178f4 Accept IPv6 link local address during interface validation
Link local address is a valid address on IPv6 network when we are using
SLAAC instead of DHCPv6, current interface validation bypass link local
address and fails the introspection.
Interfaces without link carrier don't have link local addresses so this
should be fine.

Change-Id: I4cf195fc8906a2d91989df3f588e1e96ca9684b1
Story: 2007816
Task: 40094
2020-06-17 14:20:41 +08:00
Dmitry Tantsur cee5922674 Hacking: enforce usage of autospec=True in tests
Using autospec ensures that mocked functions are called with correct
arguments, so it's highly desired to have it.

Change-Id: I9c8395adf852495d2ef6db732d727990e8abd5d7
2020-04-28 12:27:41 +02:00
Harald Jensås 079b458db0 Use autospec=True in mocks
This is a follow up to comments on https://review.opendev.org/720010.
Adding autospect=True requires an update to ironic_inspector.test.\
base.BaseTest.assertCalledWithPatch.

Also add autospec=True in several mocks where it was not used.

Change-Id: Ia340d7a8ecde1c8cf191555de87b11b19b30f06c
2020-04-22 14:10:53 +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
Serena Ziviani 78dbcf603a Do not update/delete ports upon inspection of active nodes
Short-circuit the port update logic for active nodes to allow only
for the addition of new ports.

Story: #2006956
Task: #37645

Change-Id: Ifd870a8465b6643578299dc86e2eae023db6ae43
2019-12-03 15:30:00 +01:00
Dmitry Tantsur 463d0a2f54 Stop failing on missing memory or CPU
They have been optional for scheduling since Pike and are not used
by Nova at all since Stein.

Change-Id: Idd4d727d3bbcbb8898a0d989d3c496070bc41d8a
2019-06-14 10:10:02 +02:00
zhengyong a1c44d29e6 Support IPv6 address when validating interfaces
When processing introspection data from IPA, ironic inspector only accept IPv4
address of an interface. In a IPv6 environment, the port will not be collected
if processing.add_ports is not set to 'all'.

Story: #1744073
Task: #11374

Co-Authored-By: Kaifeng Wang <kaifeng.w@gmail.com>
Change-Id: I0e1839df4d0e3b89f182ab98549486199d64c4ad
2018-11-19 11:06:37 +08:00
Pavlo Shchelokovskyy 918775cb01 Add keystoneauth adapters
Inspector sets API urls for ironic and swift from the config.
The better way would be to discovery them from the keystone
catalog.

Supporting this requires to register keystoneauth adapter
options to all config sections for service clients auth.
swiftclient still does not support adapter session client, so
pass all options from adapter explicitly.

New options were added 'service_type`, `service_name`, `region_name`
`endpoint_override`, `interfaces`.

Related-Bug: #1699547
Change-Id: I2e7ec02fdeeea21ef43136ddeabc98d499a8ba7f
Co-Authored-By: Anton Arefiev <aarefiev@mirantis.com>
2018-01-16 18:06:10 +00:00
John L. Villalovos 2064742523 Update version of flake8-import-order package
Use latest version of flake8-import-order package, like we do in
openstack/ironic

Fix the issues detected by new version.

Change-Id: I3b016e35f98c8f88500824e612838f9923b4c3b9
2017-12-14 11:38:27 -08:00
Dmitry Tantsur 6e82571cf3 Move processing of local_gb to root_disk_selection hook
The scheduling hook will be deprecated, so handling local_gb (useful
e.g. for image size validation) needs a new home.

Change-Id: I29041879dea8a2d7f2abc6a988d4814ee121442e
2017-11-02 12:39:37 +01:00
Chris Krelle f61a75aaa0 add disabled option to VALID_ADD_PORTS_VALUES
This allows inspector to create nodes without creating ports for the node.

Change-Id: Ife4c06d20e9217f0a308fef19177884596c6cf2d
Closes-Bug: #1693892
2017-06-23 10:09:45 -07:00
Jenkins 68cbd1286f Merge "Set pxe_enabled on new and existing ports on introspection" 2017-04-25 16:32:34 +00:00
Javier Pena dffdf36ebd Remove unneeded validation code in ValidateInterfacesHook
oslo.config now sets enforce_type=True by default since [1], so
there is no need to check in ValidateInterfacesHook that the value
set in the config file is one of the valid values.

[1] https://review.openstack.org/328692

Closes-Bug: #1683732
Change-Id: I5830466cb21f200ae1c33021cce4d166a26456be
2017-04-19 14:37:46 +02:00
Dmitry Tantsur 782ee92c45 Set pxe_enabled on new and existing ports on introspection
Set it to True for the PXE-booting port, to False for all the others.
Create an extended functional tests covering various operations with ports.

Change-Id: I435a5c04884b6c4da70cb7260b305fbde23eebc0
Closes-Bug: #1667472
2017-04-18 10:20:49 +00:00
Dmitry Tantsur 9575d31920 Move port creation to validate_interfaces hook
Currently port logic is placed inconsistently: port creation is in core processing,
while port deletion is in validate_interfaces before_update. This changes moves
port creation there as well. This should only affect deployments that tamper with
validation_interfaces hook, as previously port creation was run just before running
before_update hooks.

This allows deployments to replace port creation logic by replacing the
validate_interfaces hook.

Change-Id: Idd8f748fdf31fc694bd7b554837e509024716c18
Partial-Bug: #1667472
2017-04-11 17:58:56 +02:00
Dmitry Tantsur 6e2ea6242d Allow diskless nodes introspection
There is a demand to use introspection on diskless nodes to figure out
what is possible to figure out.

We might need more changes to properly support diskless nodes, this
change is just to allow people to play with it.

The property ``local_gb == 0`` for a diskless node.

Change-Id: I21b2f2c069fdbf767367ec3d1fbf77bab6292b25
Partial-Bug: #1554243
2017-01-26 17:08:56 +01:00
Lucas Alvares Gomes 891639612b Use the device hints matching mechanism from ironic-lib
This patch is replacing the ironic-inspector own implementation for
validating the root device hints in favor of the standard one from
ironic-lib.

The implementation in ironic-lib is flexible enough and fits in
ironic-inspector well so no big updates to functional or unittests
are needed.

A new dependency for ironic-lib was added to requirements.txt.

Change-Id: I0f2b8f463232d0d5b42d0b6e343d5c6e336d32c7
Closes-Bug: #1648133
2016-12-16 16:55:51 +00:00
dparalen 3ddc0615e5 Introducing node introspection state management
Currently, state of a node introspection isn't kept in the database.
This change introduces:

* a new database column to keep the node introspection state
* an automaton to manage the node introspection state
* a decorator to declare a function performing an introspection state
  transition
* a version_id column is added, to enhance database consistency, that
  is consulted whenever node_info is committed

This change is part of the HA_Inspector effort[1]

[1] https://specs.openstack.org/openstack/ironic-inspector-specs/specs/HA_inspector.html

Closes-Bug: #1618835
Partial-Bug: #1525218
Change-Id: I18cb45f0d1194414715ccbe826d8a95610ec718d
2016-12-15 00:20:27 +01:00
Moshe Levi 027642246f Replace assertRaisesRegexp with assertRaisesRegex
assertRaisesRegexp is deprecated in python3
https://docs.python.org/3.2/library/unittest.html

Co-Authored-By: edan david <edand@mellanox.com>

Change-Id: I9446e745239d64ac9adf8fd1a8f95b5befc8cf06
2016-09-05 08:57:47 -04:00
Dmitry Tantsur 0b58e31e3e Remove support for the old bash ramdisk
From now on only rely on the IPA inventory and 2 additional fields:
boot_interface and root_device.

Also updated unit tests to use one inventory example.
Also removed duplicating unit tests and checks in test_process.
Also removed devstack support for the old ramdisk.

Change-Id: Ib382328295fc2c1b9143171b1047304febadcaca
2016-06-06 13:36:05 +02:00
Dmitry Tantsur 8fe0344cfd Always convert the size root device hints to an integer
This matches the IPA behaviour and is more user-friendly.

Change-Id: Ic7134c338e703361fedbf9917a3484c0bcc9d493
Closes-Bug: #1580664
2016-05-23 13:05:18 +02:00
Dmitry Tantsur b65ab065ea Store ramdisk logs on all processing failures, not only reported by the ramdisk
Previously the ramdisk logs were only stored if the ramdisk reported an error.
However, we are moving from ramdisk-side validation to server-side, so we need
ramdisk logs to be available if processing fails too.

This change moves storing ramdisk logs from a ramdisk_error plugin to core
processing code. As before, it can be disabled by setting ramdisk_logs_dir to
an empty value.

Change-Id: Ib3742ee1c1d4f2f96d29466626e1121694610dc3
Closes-Bug: #1564448
2016-05-04 12:46:59 +02:00
Anton Arefiev 30ae1e72f1 Move unit tests to "unit" directory
This refoctor is needed for tempest test work as tempest tests
will placed in test dir. So move unit tests to separate directory
"unit" under test.

Change-Id: Ic99df6111ef30947148a9e38b9435a54f3d37064
2016-04-05 11:15:29 +03:00