Use the namedtuple class to improve code readability by creating a Host
class with namedtuple to store the 'hostname' and 'port'
Replace foo[0] with foo.hostname, and foo[1] with foo.port to make code
more readable.
Change-Id: Ie2b5f9cf89e7ccbbcf0a2573dab6f6c5d14c018b
Following OpenStack Style Guidelines [1], I changed:
assertFalse(sth in sth) to assertNotIn(sth, sth).
After this change, a more specific message is shown on error.
[1]: http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises
Change-Id: I5d47d775dcff194693d97db6b797b7b027cbab56
Following OpenStack Style Guidelines[1]:
http://docs.openstack.org/developer/hacking/#unit-tests-and-assertraises
[H203] Unit test assertions tend to give better messages for more specific assertions.
As a result, assertIsNone(...) is preferred over assertEqual(None, ...)
Change-Id: I53c6d6d3e53d9fac38c50faf065c131d3aa55224
Re-initialization of the API client causes the identification
of an older ironic API to be forgotten.
As such, we need to re-use the API client from the initial lookup
for the heartbeat.
Tested with current master branch and stable/mitaka ipa
in noauth mode, and was able to deploy without any issues.
Closes-Bug: #1616461
Change-Id: I3ae1e2ce83f614b5b936a3cbb1b9587c6c55a89a
This will make sure the socket list and the interface list are
always in sync, and the select call is on the right list of
sockets.
Co-Authored-By: Dmitry Tantsur <dtantsur@redhat.com>
Closes-Bug: #1533892
Change-Id: Id6710f4648203b7d476a2a16ea647224baca1bb9
Prior to this patch the ironic-python-agent service would only fallback
to use the old endpoints for /lookup and /heartbeat on a 404 error but,
since Ironic will check auth (if enabled) before it routes the requests
a 401 (Unauthorized) was returned.
Closes-Bug: #1612696
Change-Id: Idba5fed587e77aaa683d2c2b2126a520214712ce
Falls back to vendor passthru on receiving 404.
Also fixes logging around lookup: log traceback on unexpected
exceptions, log successful lookup and replace % with ,
Change-Id: I7160c99ca63585fc333482fa578fdf5e0962b2b6
Depends-On: I9080c07b03103cd7a323e2fc01be821733b07eea
Partial-Bug: #1570841
This utilizes the new metrics support in ironic-lib to allow the agent to
report timing metrics for agent API methods as configured in ironic-lib.
Additionally, this adds developer docs on how to use metrics in IPA,
including some caveats specific to ironic-lib.metrics use in IPA.
Co-Authored-By: Jay Faulkner <jay@jvf.cc>
Co-Authored-By: Alex Weeks <alex.weeks@gmail.com>
Change-Id: Ic08d4ff78b6fb614b474b956a32eac352a14262a
Partial-bug: #1526219
This patch is adding a new cleaning step called "erase_devices_metadata"
to the GenericHardwareManager. This step is responsible for erasing the
metadata of the disks present in the node (partition tables, signatures,
filesystem identifiers etc...).
It's important to note that the "erase_devices" cleaning step will also
remove all these metadatas (because it will zero/shred the whole disk)
but, it takes a lot of time to run and for some usages of Ironic only
cleaning the device metadata and leaving the data from previous tenants
on the disk after the machine is recycled is fine. That's the use case
for systems using Ironic just to install the same base image onto many
nodes which will run another cloud on top afterwards (TripleO).
The new cleaning step has a default priority of 99, so it should run
before the "erase_devices" cleaning step so that we can guarantee that
the metadata was removed even in case of a failure when cleaning the
disks.
The version of the GenericHardwareManager was bumped to "1.1" with the
addition of this new clean step.
This patch make use of the "destroy_disk_metadata" method from ironic-lib
to get rid of the metadata.
Closes-Bug: #1603411
Change-Id: I3d7b39d5ee3e03ce63185e4168b1ac954a896c93
This was testing that _check_for_iscsi was called, which is part of
evaluate_hardware_support for the in-tree hardware manager.
evaluate_hardware_support is called at hardware manager instantiation,
which can happen when dispatch_to_managers is called. The hardware
manager instances are cached, so calling dispatch_to_managers won't
always invoke _check_for_iscsi. As such, these tests were intermittently
failing.
Mock _check_for_iscsi at the class level for these tests (since it's
unrelated), and don't check that it was called.
Change-Id: Iefca50c4c231c5eafd199bf8da6649bc3008a8fa
Address some comments on the original review, mainly changing
the release note to be more specific.
Change-Id: I0af397fab174e4a7b426fdc69e50dffce5578577
stevedore no longer raises a KeyError when there's an entrypoint
missing. Instead we must supply a callback that handles that error.
Update inspection code to work with this.
Also bumps stevedore minimum to 1.16 ahead of the global-requirements
bot.
Closes-Bug: #1603542
Change-Id: I12af23f2525ac90e577bdd10bbfbbd9788e9551c
Depends-On: I8aa1ee52ff7de50488acb86e8920da89ddb05771
Per Doug's email[0], 'warnerrors' in setup.cfg hasn't actually been
working for some time now, and we've piled up a few warnings. Fix these
before a pbr release to unbreak it gets pushed out and breaks our doc
builds.
[0] http://lists.openstack.org/pipermail/openstack-dev/2016-June/097849.html
Change-Id: I6576a56234918febb21e7e4860544eb952123c09
When matching the root device hints passed to Ironic and the devices
present in the disk, the logic to the "size" attribute was different was
outside the main loop. This patch refactors that uses the same loop for
matching the size attribute, improving a little the readability.
This patch also makes sure that we convert the value of "size" to
integer before attempting to match it.
Change-Id: I619153232b9b58696369185ad5be90ccfd38a4ed
It is required to issue iscsistart -b on those hardware in order for
/dev/sda /dev/sdb etc to be exposed to the OS.
On this type of hw, without the fix
introspection fails with - missing: ['local_gb']' err.
Change-Id: If6667b123e9b890d97c03612596fb78ee2b0ae85
Closes-Bug: 1590606
This patch is extending the root device hints to also consider if a disk
is a rotational device or not. This hint makes it easier to separate
SSDs and HDDs when selecting the device to deploy the image onto.
Partial-Bug: #1599517
Change-Id: I270fe57df825929bdef7911b3a6757cf7163a5f1
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
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
Documentation follow-up to the LLDP patch, commit
a7f0af722f96950e3bf67e26b922f80c1bd503ab. Provide the meaning of the
acronymns TLV and LLDP.
Change-Id: Icce3eb5519dfcfc9b6f7e23003cf056646da6c50
Adds a new collector, which gathers list of PCI devices.
Each entry is a dictionary containing 2 keys:
- vendor-id
- product-id
Such information can then be used by the inspector to distinguish
appropriate PCI devices.
Change-Id: Id7521d66410e7d408d7eada692b6123e769ce084
Partial-Bug: #1580893
This replaces dict.get(key) with dict[key] in the unit tests,
since we should be explicit about whether we expect the key to
exist or not. (These are tests, after all.)
Change-Id: Ide98ceba325214e55cab2063d9ace150d63f9617
Closes-Bug: #1590808
To support multi-tenant networking in Ironic we need to be able to
discover not just the NICs a baremetal machine has but also the physical
connectivity to switches in the network.
This patch collects LLDP (Link Layer Discovery Protocol) data as part of
the list interfaces stage of the generic hardware manager. This
information can then be processed by the ironic inspector to populate
the local link information on each ironic port.
The processing done on this data in ironic python agent is limited, this
is to allow for server side processing hooks to process as much or as
little of the data as they want. This is to allow for multi-vendor
environments that might use different parts of the LLDP packet to use a
generic ramdisk and configure the processing server side using inspector
plugins.
Reserved fields switch_port_descr and switch_chassis_descr have been
deprecated for removal in Ocata in favor of passing the whole packet.
Change-Id: Idae9b1ede1797029da1bd521501b121957ca1f1a
Partial-Bug: #1526403
The functional tests in IPA were broken because the configuration
options weren't loaded prior to starting the service. This patch does
now register the configuration option at the base class.
Closes-Bug: #1595145
Change-Id: Iaaa16fddd093075e7f995fb82ad3abb64e8e5794
This patch replace assertRaisesRegexp with
assertRaisesRegex which is deprecated in python3
https://docs.python.org/3.2/library/unittest.html
Also it update the base tests to be oslotest
BaseTestCase for python2.7 and python3 compatibility
Change-Id: I02571946f0643247e208d98dc91ea78cd9d351ee
https://review.openstack.org/#/c/320295/ introduced two internal
variables: _DISK_WAIT_ATTEMPTS and _DISK_WAIT_DELAY. These values are
hardcoded. This patch adds configuration options for these so
that an operator can change them based on their own needs/fleet of
hardware.
Change-Id: I2ba97669ec710fb4a435307466cd8add9c2293ba
Closes-Bug: #1585663
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, 'arg = [] if arg is None else arg'.
TrivialFix
Change-Id: I384b24e81543999a8b873e3223cd409ed799ffa0
Tests should use:
self.assertIn(value, list)
self.assertNotIn(value, list)
instead of:
self.assertTrue(value in list)
self.assertFalse(value in list)
because assertIn and assertNotIn raise more meaningful errors:
self.assertIn(3, [1, 2]
>>> MismatchError: 3 not in [1, 2]
self.assertTrue(3 in [1, 2])
>>> AssertionError: False is not true
Change-Id: I2d1c78fe71fe03e350b1035123b0a48b7186a6ec
Closes-Bug: #1510007
During node look up sometimes IPA sends hardware inventory information before
the interfaces are up, resulting in empty interfaces information being sent
to the conductor. This causes conductor to throw exceptions and polluting
the log until the real interfaces information is populated. This change makes
IPA to wait for at least one interface to be up before trying for node lookup.
Change-Id: Ifdb91298eaa5c725f108fa722263ed925691ecda
Closes-Bug: #1562786
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