418 Commits

Author SHA1 Message Date
John L. Villalovos
abf98ae84a Use namedtuple to improve code readability
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
2016-08-30 16:12:29 -07:00
Jenkins
aa4c889a06 Merge "Using assertIsNone() is preferred over assertEqual()" 2016-08-29 18:43:18 +00:00
Gábor Antal
4facf2c385 Changed an assert to more specific assert method
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
2016-08-29 15:40:44 +02:00
Luong Anh Tuan
814b60def3 Using assertIsNone() is preferred over assertEqual()
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
2016-08-29 05:22:33 +00:00
Julia Kreger
95f31be108 Re-use API client for Heartbeat operations
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
2016-08-26 12:53:30 +00:00
Robert Li
9e4b769055 Build socket list right before select call
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
2016-08-17 16:35:07 +02:00
Lucas Alvares Gomes
09d5d0c377 Fallback to the old /lookup endpoint on 401
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
2016-08-12 16:41:51 +01:00
Jenkins
dfaf92b611 Merge "Add metrics support to IPA" 2016-08-09 16:15:29 +00:00
Jenkins
c1b1d7e670 Merge "Add erase_devices_metadata cleaning step" 2016-08-09 11:06:01 +00:00
Jenkins
87b2b82478 Merge "Use new agent API if available" 2016-08-07 02:44:48 +00:00
Dmitry Tantsur
09265ba4b5 Use new agent API if available
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
2016-08-05 12:02:41 +02:00
Josh Gachnang
fd874652e3 Add metrics support to IPA
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
2016-08-03 11:24:54 -07:00
Lucas Alvares Gomes
d528728090 Add erase_devices_metadata cleaning step
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
2016-07-28 11:14:11 +01:00
Ruby Loo
81ca8a8744 Use ironic_lib's execute()
Use ironic_lib's execute() instead of copying that code.

Change-Id: If40c2da5423d0f90cc6661f8cdf2bec9567e1f7d
Partial-Bug: #1587199
2016-07-27 16:28:43 -04:00
Jim Rollenhagen
7ab53e34b0 Fix races in advertise_address unit tests
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
2016-07-26 10:22:41 -04:00
Jenkins
e9dd5d3db0 Merge "Follow-up text changes for 327807" 2016-07-21 17:38:47 +00:00
Jenkins
5d012b43bd Merge "Handle diskless hardware connected to remote iscsi" 2016-07-21 14:39:36 +00:00
Julia Kreger
f50a14dd1b Follow-up text changes for 327807
Address some comments on the original review, mainly changing
the release note to be more specific.

Change-Id: I0af397fab174e4a7b426fdc69e50dffce5578577
2016-07-21 09:54:51 -04:00
Jenkins
ad60806f93 Merge "Small refactor in the root device loop matching logic" 2016-07-19 10:10:28 +00:00
Jenkins
04c880f6f2 Merge "Fix doc warnings" 2016-07-18 13:58:51 +00:00
Jim Rollenhagen
62743fec6a Update to work with latest stevedore
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
2016-07-17 14:38:00 -04:00
Jim Rollenhagen
2e10d7b32c Fix doc warnings
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
2016-07-14 14:37:02 -04:00
Lucas Alvares Gomes
5f09bd03e1 Small refactor in the root device loop matching logic
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
2016-07-12 10:15:48 +01:00
Yossi Ovadia
90424fad0a Handle diskless hardware connected to remote iscsi
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
2016-07-11 09:42:20 -07:00
Lucas Alvares Gomes
080e413b9c Extend root device hints to support "rotational"
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
2016-07-11 14:30:35 +01:00
Lucas Alvares Gomes
f26f902603 Replace the ps options when collecting logs
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
2016-07-07 14:19:42 +01:00
Jenkins
9c069a88e8 Merge "Add a log extension" 2016-07-01 17:23:50 +00:00
Lucas Alvares Gomes
af81914ce7 Add a log extension
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
2016-06-28 17:02:11 +01:00
Jenkins
56eea51564 Merge "Documentation follow-up to the LLDP patch" 2016-06-27 16:17:01 +00:00
Jenkins
0ba66c27ea Merge "Add PCI devices collector to inspector" 2016-06-25 10:29:01 +00:00
John L. Villalovos
d89dfb1b26 Documentation follow-up to the LLDP patch
Documentation follow-up to the LLDP patch, commit
a7f0af722f96950e3bf67e26b922f80c1bd503ab. Provide the meaning of the
acronymns TLV and LLDP.

Change-Id: Icce3eb5519dfcfc9b6f7e23003cf056646da6c50
2016-06-24 13:00:32 -07:00
Szymon Borkowski
f7e080c8bf Add PCI devices collector to inspector
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
2016-06-24 14:50:58 +02:00
Ruby Loo
50ddb894b4 Replace dict.get(key) with dict[key] in tests
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
2016-06-23 17:41:23 -04:00
Jenkins
0c5a1cfd56 Merge "Replace assertRaisesRegexp with assertRaisesRegex" 2016-06-23 11:25:08 +00:00
Jenkins
7231485d85 Merge "Support LLDP data as part of interfaces in inventory" 2016-06-22 19:10:48 +00:00
Sam Betts
a7f0af722f Support LLDP data as part of interfaces in inventory
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
2016-06-22 18:26:04 +01:00
Lucas Alvares Gomes
45e10805d8 Fix functional tests
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
2016-06-22 12:24:23 +01:00
Jenkins
99a053f654 Merge "Add configuration options for DISK_WAIT" 2016-06-22 02:29:46 +00:00
Moshe Levi
1ef8c32de0 Replace assertRaisesRegexp with assertRaisesRegex
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
2016-06-22 00:47:37 +00:00
Yosef Hoffman
13a8c6321e Add configuration options for DISK_WAIT
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
2016-06-20 18:47:26 -04:00
Jenkins
d63820af12 Merge "Removes the use of mutables as default args" 2016-06-20 17:25:29 +00:00
Edan David
438c69af7c Removes the use of mutables as default args
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
2016-06-20 02:08:12 -04:00
Edan David
1e8652a8d0 Use assertIn and assertNotIn
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
2016-06-17 12:01:43 -04:00
Jenkins
d7eccc43df Merge "Wait for at least one interface before node lookup" 2016-06-14 17:47:53 +00:00
Edan David
fda09be319 Remove unused parameter
unit.test_api have an unused parameter in _make_app.

Change-Id: I1e313803e43a0e69c547695333116cc0432043da
2016-06-14 10:21:26 -04:00
vmud213
09db71d640 Wait for at least one interface before node lookup
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
2016-06-14 12:36:52 +00:00
Jenkins
927ee98eed Merge "lldp-timeout kernel parameter missing ipa- prefix" 2016-06-06 06:19:46 +00:00
Yosef Hoffman
90c15e10cb lldp-timeout kernel parameter missing ipa- prefix
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
2016-06-03 12:17:55 -04:00
Jenkins
031593614e Merge "Add boot information into the inventory" 2016-06-02 19:11:35 +00:00
Jenkins
90ba6452ef Merge "Remove unused SUPPORTED_ROOT_DEVICE_HINTS" 2016-06-02 09:04:16 +00:00