Commit Graph

90 Commits

Author SHA1 Message Date
Takashi Kajinami ea9ad2891c Remove dependency on pytz
pytz will be removed from RHEL/CentOS 10 because of the built-in
zoneinfo[1].

Because the current usage of pytz can be very easily replaced, this
removes the dependency on pytz.

[1] https://issues.redhat.com/browse/RHEL-219

Change-Id: Iafcaf2f1095cd7c738dac391a9af10622806e932
2024-01-27 10:42:39 +00:00
Julia Kreger 836ba11b9b Use UTC for the timezone in functional tests
The prior code uses the local time zone, in my case
prsently 'PST' which pytz doesn't grok, however it does
grok UTC, and CI runs in UTC, and the API, as far as I know,
conveys in UTC. So this should just be for consistency.

Change-Id: Ia47b6adfc18be54f8e9623b34ef34b66436828dc
2023-02-21 08:38:26 -08:00
Anton Arefiev 3fe42b53fd SQLAlchemy 2.0 Support
Primarily remove the workaround added in
Ia6d512ff2ae417bab938cb095fbb0884d195010a which added
continued use of autocommit, which is incompatible with
SQLAlchemy 2.0.

Also set the environment for unit tests to report compatability
warnings, although it appears none are being reported at this time.

Also cuts out the db upgrade cruft to only use the online database
migration code through oslo_db's enginefacade, which has the smarts
to handle online or offline migrations.

And then, retools unit/functional test data storage to utlize sqlite,
and in that re-tooled the queries to prevent locking conditions
which could exist with queries, and some additional refactoring/cleanup.

Also, don't mock and test time.sleep().

Additionally, it looks like we have discovered the root cause of the
memory/connection leakage issue which has been observed, due to the
way lists of nodes are processed/returned.

This change was based upon the work in
I506da42a9891a245831f325e34bec92e0a3f33f0 which is included in
this commit as the entire database structure and interaction
has been modified for ironic-inspector.

Co-Authored-By: aarefiev <aarefiev@mirantis.com>
Story: 2009727
Task: 44132
Change-Id: Ic88eb9dec5fddc924a72d9a23c17a304954ebf46
2022-12-15 09:28:55 -08:00
LiZekun fe2abe1130 Remove unicode literal from code
All strings are considered as unicode literal string from Python 3.

This patch drops the explicit unicode literal (u'...')
appearances from the unicode strings.

Change-Id: I662c72686a7e0404da62fb677c666885ff5ac65a
2022-10-27 11:31:43 -07:00
Zuul 5a9221459e Merge "Follow up to incorrect pxe-enabled was set" 2020-08-17 14:51:19 +00:00
Dmitry Tantsur cc7fcf4332 Add support for retrieving unprocessed data
Change-Id: I3c0070d0c1f5d12e98f914be44f4ed52b01ea043
2020-07-28 12:19:19 +02:00
Julia Kreger 6e2cb60e77 Respond so Apache HTTPd doesn't think the request failed
When sending a literal empty response, Flask does not include a
ContentType in the response. While in many cases, we don't need
need a ContentType nor expect one on the API client, Apache
webserver can treat this as an error and generate an Error
indicating a Bad Gateway. When doing this, we also now include
an empty JSON body in the response for 202 messages. For 204
message errors, the message body is expected to be empty.

However, when this Bad Gateway error occurs, the API/Conductor
were proceeding like there was no issue. The API client on the
other hand thinks that a hard failure has occured.

Also adds some additional catches to provide additional logging
which turned out not to be needed in this case, but it would be
useful for others.

Change-Id: If2e7697e3fde58ab0a4193787e29d3acdca81ebf
2020-07-22 10:18:00 -07:00
Kaifeng Wang 6732d5edb9 Follow up to incorrect pxe-enabled was set
Previous change [1] only covered patch requests, this patch adds
coverage for create_ports so that for a fresh introspection we also
don't have incorrect pxe_enabled set.

[1] https://review.opendev.org/#/c/737129/

Change-Id: If809826cbaaee5efaf7b7ad4617fa17e9b232a1f
2020-07-01 17:02:54 +08:00
Kaifeng Wang b31888a4ee Fix incorrect pxe-enabled was set during introspection
Morden bare metals usually support PXEs from all NICs, in
our current logic only the port matching mac address in the
BOOTIF will be set to pxe-enabled. This does not work for UEFI
nor user friendly to bonding.

This patch adds a configuration option [processing]update_pxe_enabled
to control whether this field should be updated according to
introspection data, defaults to False to keep backwards compatibility.

Change-Id: I6f3b00180f62dc6f500ac2cdb5d8f8cc7c7190cf
2020-06-22 23:05:50 +08: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
Zuul 717479c4a3 Merge "Added scope to introspection rules." 2020-04-02 06:39:34 +00:00
Zygimantas Matonis e2c8f9fd7b Added scope to introspection rules.
Added 'scope' property to IntrospectionRule and logic to check if a node
falls in the same scope.This allows introspection rules to be applied on
selected nodes instead of every one of them.

Story: 2006995
Task: 37763

Change-Id: I77034f032ea0ec16886afdd928546eb801f7a90a
2020-03-26 21:40:43 +01: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
Zuul 11a49630a1 Merge "Active node introspection for nodes not in cache" 2019-07-23 10:32:28 +00:00
Julia Kreger 0c9447d53b Active node introspection for nodes not in cache
When an active node introspection is performed
where an entry already exists in ironic, but inspector
has never seen the node before, we enter a state where
we should allow introspection to occur, but that we don't
have a cache record.

As a result of no cache entry, we presently fail hard claiming
the node's port already exists. In the case of active nodes,
This will always be the case, so we need to add a cache
entry and allow the process to... somewhat continue as if
normal introspeciton is occuring.

Co-Authored-By: Dmitry Tantsur <dtantsur@redhat.com>
Change-Id: Ib20b4a4e4d46ba23b8a4d87791cf30a957f1f9f9
Story: 2006233
Task: 35834
2019-07-19 17:08:56 +02:00
Dmitry Tantsur 0c154991ce Use the database data backend in functional tests
This allows testing real introspection data, not mocked swift.

Change-Id: I168378c0da0fdff493ee10ac6afef805da7cb9a5
2019-07-19 13:20:28 +02:00
Dmitry Tantsur 4f578169c7 Allow running a specific functional test via CLI
Change-Id: I5897d8121b7cc992d64f948f73f1f846615f6e46
2019-07-18 14:25:41 +02:00
Kaifeng Wang 59a4c64670 Move dbsync to the correct path
command line script should be placed in the cmd directory.

Change-Id: Ifc3a9c81b0c61d8b5c9d9f4009164ec3c91ce042
2019-07-05 15:44:34 +08:00
Kaifeng Wang 29d8515f50 Support reapply with supplied introspection data
This patch adds support to provide unprocessed introspection data
to reapply a node. The provided introspection data will be save to
current introspection storage backend.

Change-Id: I969ae9c32f53f89c006a64a006388ddea9542aa5
Story: 1564863
Task: 11344
2019-04-15 15:04:33 +00:00
Kaifeng Wang a228912827 Wrap rpc server into oslo.service
This patch is part of work splitting inspector api and worker.
The rpc server is wrapped into oslo.service, and launched from
api process.

Now api and worker belongs to separate thread, functional tests
use the fake messaging driver, while devstack jobs use rabbitmq.

Change-Id: Ie03d16f9d115c3561723463dea6a57d2a763bcc6
Story: #2001842
Task: #23109
2018-10-23 09:17:42 +08:00
Dmitry Tantsur e7c3218f71 Add manage_boot parameter to introspection API
Adds a new node field "manage_boot" to store this value. When it is set
to False, neither boot device nor power state are touched for this node.
Instead, we expect a 3rd party to handle them.

We still manage the PXE filter because the node may need DHCP.

Change-Id: Id3585bd32138a069dfcfc0ab04ee4f5f10f0a5ea
Story: #1528920
Task: #11338
2018-06-25 12:09:17 +02:00
Zuul c6ad0f0ead Merge "Introduce oslo.messaging and sync rpc call" 2018-06-01 02:32:42 +00:00
Harald Jensås 868965c340 Fix pycodestyle warnings/errors now visible with hacking 1.1.0
This fixes the warning/errors except for the C901 Function is
too complex in the ironic_inspector/rules.py's create method.

Bump's max-complexity to 18 in tox.ini to workaround the C901.

Story: 2001985
Task: 19604
Change-Id: I6c76a43353b1beb572dbde78dba4b4a839d45ea7
2018-05-08 23:46:05 +02:00
Kaifeng Wang 6469a1fc0f Introduce oslo.messaging and sync rpc call
Adds oslo.messaging to ironic-inspector, and convert
inspect, abort and reapply to synchronized rpc calls.

This is the first step of API and worker seperation.

Change-Id: I15e86d7feb623b6b2889891b9700e5de6b3164cd
Story: #2001842
Task: # 12609
2018-05-06 21:07:25 +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
dparalen 7b27585463 Refactoring the firewall
Adopting the PXE filter interface/driver concept

Related-Bug: 1665666
Change-Id: If83db978080b9c4e5d51ba50bbe8ed26e29abe83
2017-10-19 16:38:15 +02:00
Jenkins 095b4e3d72 Merge "Completely remove support for setting IPMI credentials" 2017-05-31 15:04:49 +00:00
Dmitry Tantsur e05257035c Completely remove support for setting IPMI credentials
This experimental feature was deprecated in the Ocata release,
as it was found unstable, untested and dangerous.

API version is bumped to 1.12 to indicate this change to users.

Change-Id: I1aad6ddfd03946edc19ae510accd6c8daf5fc268
Closes-Bug: #1654318
2017-05-26 14:29:13 +02:00
Anton Arefiev 50ed0bdbae Preparing for service splitting
Creates new WSGIService class which keeps base API sercice
initialization functionality and serve flask application. Also
it will configure application for wsgi container[1].

Also creates new `cmd` directory for storing console scripts.

[1] https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html

Related-Bug: #1525218
Change-Id: Ia64228c47a79a3008d435e8323a964f2bc45dfa7
2017-05-26 11:59:35 +03:00
dparalen 00635e2344 Follow up: conditions optional fields
This is a follow-up on the patch:

  I08606cea676ecf57bbb3b73077c4832240fbe0d2

As requested in the reviews.
Wondering why I didn't fix it right away :D

Change-Id: Iab377f5fa4a1d448615914e1e9aa5a49053da693
2017-05-18 14:28:22 +02:00
Annie Lezil 33a28f34f8 Inspector rules API does not return all attributes
When using the Inspector rules API to query existing introspection
rules, inspector does not return 'invert' or 'multiple' attributes of
conditions associated with the rules.

Change-Id: I08606cea676ecf57bbb3b73077c4832240fbe0d2
Closes-Bug: #1670372
2017-05-05 20:01:53 +02:00
Jenkins 75219a1758 Merge "Adds node state to the API response data" 2017-04-27 13:32:18 +00:00
yaojun fc2e029fa6 Adds node state to the API response data
This adds the node state when the GET /v1/introspection/<node uuid or
name> API is performed.

Change-Id: I81c6834933f789cb644a854313aacaf49a4856a7
Closes-Bug: #1665664
2017-04-27 16:35:47 +08: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 f1990e4fb0 Mock ironic client per test in functional tests
Currently it is mocked once per whole functional tests run, which
may allow side effects on tests on other tests.

Change-Id: Iaabe35290f207c37333726c43aa86b48ce892920
2017-04-13 15:30:36 +02:00
Anton Arefiev aa2bd671d4 Trivial: don't create unused temporary directory
Functional tests create unused temp directory, drop it.

Change-Id: I97cfe5def1229491bbb09ca14db29c0574bb1c15
2017-03-28 12:54:59 +03:00
Jenkins 34eb861913 Merge "Reapply doesn't update started_at time" 2017-03-09 22:58:00 +00:00
Annie Lezil 43c89efcb7 Reapply doesn't update started_at time
The reapply API/Action(openstack baremetal introspection reprocess UUID)
doesn't update the started_at time when Ironic Inspector begins processing
the node.

This adds the started_at time when the reapply API/Action is performed.

Change-Id: Ic79db4ba9305841fb662afcb56f556ad4a57a500
Closes-Bug: #1625180
2017-03-07 21:28:13 +00:00
Anton Arefiev f35ab5defb Functional tests: set introspection_delay to 0
There is no needs to wait before sending the next node on introspection
in functional tests, so set configuration introspection_delay -> 0.

Also functional tests contain explicit sleeps.

Change-Id: If57a34d41cf31e2a436d7b9c66ff954b6321d7de
2017-02-27 19:55:44 +02:00
John L. Villalovos ea97d2b733 Use flake8-import-order
Use the flake8 plugin flake8-import-order to check import ordering. It
can do it automatically and don't need reviewers to check it.

Change-Id: I9ced9c297273db0eec6ab3995b663b1e8dffe87d
2017-02-16 10:11:06 -08:00
Jenkins b455e238cd Merge "Add plugin to process basic management LLDP TLVs" 2017-02-03 11:17:44 +00:00
Moshe Levi 1dce3b12d3 Adding InfiniBand Support
InfiniBand is computer-networking communications standard
used in high-performance computing, features very high
throughput and very low latency.
This patch allow ironic-inspector to add the client_id
to ironic port extra. The client_id option allow pxe boot
from InfiniBand interface.

Closes-Bug: #1532534
Depends-On: Ifad453977e5d3be64b34e544f269835a72b4d73f
Change-Id: I479d54c29bcacb6bd5c1ab20033ae6e428b0e744
2017-02-01 08:34:38 -05:00
Bob Fournier 8834927d4c Add plugin to process basic management LLDP TLVs
This adds a plugin to process the raw LLDP TLVs stored in Swift for
the Basic Mgmt, 802.1, and 802.3 data sets and store the parsed data
back in Swift.  It implements the TLV processing as described in the
specification:
http://specs.openstack.org/openstack/ironic-inspector-specs/specs/lldp-reporting.html

Change-Id: I854826787ff045ffb2807970deaba8b77cbe277d
Closes-Bug: 1647515
Related-Bug: 1626253
2017-01-31 19:51:39 -05: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
dparalen e28b0b229d Functional test node remove
The functional tests create nodes but never remove them.  This patch
introduces a Base.tearDown() method to remove nodes created during the
testcase setup.

Change-Id: I480d89512f265e1b459a009e464077b3771f0a66
2017-01-16 15:51:36 +01: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
dparalen 7cb40d5fec Add API for listing all introspection statuses
This patch introduces an API endpoint to list introspection statuses.  The
endpoint supports pagination with an uuid-marker and a limit query string
fields.  Due to the pagination, this change introduces a new configuration
option: ``api_max_limit``.

APIImpact

Change-Id: I74d02698801d5290619161b2d8d7181ab51a0a5e
Partial-Bug: #1525238
2016-11-21 15:58:24 +01:00