440 Commits

Author SHA1 Message Date
Jenkins
f330dac837 Merge "Remove old lookup/heartbeat from IPA" 2016-11-13 13:03:39 +00:00
Jenkins
b2e608a94c Merge "Add bash scripts style checking for IPA" 2016-11-10 12:48:26 +00:00
John L. Villalovos
13c9350699 Clarify test comment to minimize confusion
Wording was a little confusing. Try to make it more clear.

Change-Id: Iad280314bf4929b18b1493bd7e9a26fc58297ee1
2016-11-09 14:59:30 -08:00
Jenkins
a6d6e477e3 Merge "Fix several errors in LLDP handling code" 2016-11-09 22:33:22 +00:00
OpenStack Proposal Bot
c40575e4e0 Add bash scripts style checking for IPA
Updated file tox.ini allows to check code style in all ".sh" files
included in Ironic Python Agent. Checking can be invoked by calling either
"tox" or "tox -e pep8".

Change-Id: Ie76605737c7db10a064f2aebfda388372a4c0591
Closes-Bug: #1625215
2016-11-09 14:14:40 -08:00
Pavlo Shchelokovskyy
b033bfd933 Remove old lookup/heartbeat from IPA
Lookup/Heartbeat via vendor passthru was deprecated in Newton.

This patch removes the corresponding functionality from IPA,
and also removes handling of 'ipa-driver-name' kernel parameter,
as it was only used in code related to old passthru.

Change-Id: I2c7989063ab3e4c0bae33f05d6d2ed857a2d9944
Closes-Bug: #1640533
2016-11-09 16:34:44 +00:00
Dmitry Tantsur
b864a8c566 Fix several errors in LLDP handling code
* Stop silencing exceptions in raw socket context manager
* Correctly handle receiving packages with odd size and too small ones
* Fix a unit test that was testing nothing due to bad mocking

Change-Id: Ic8626d10618f52d50667d2698f34a92f5dcac33e
Closes-Bug: #1640238
2016-11-09 15:02:54 +01:00
John L. Villalovos
0b8763e332 Update to hacking 0.12.0 and use new checks
Use hacking 0.12.0

Use the new checks that are available:
    [H106] Don’t put vim configuration in source files.
    [H203] Use assertIs(Not)None to check for None.
    [H904] Delay string interpolations at logging calls.

Fix code so tests pass.

Change-Id: If22ad272c332f30624ce10861408d377908b152b
Depends-On: I2aa44b62f900d4dfd67701b01eadd0523fbfaf07
2016-11-08 11:31:18 -08:00
Luong Anh Tuan
ef6c1cb9ce Replaces uuid.uuid4 with uuidutils.generate_uuid()
Openstack common has a wrapper for generating uuids.We should
use that function when generating uuids for consistency.

Change-Id: Ifb7b15fc8634338fc535de8043053e41aa93968a
Closes-Bug: #1082248
2016-11-08 09:06:45 +00:00
Shivanand Tendulker
7471d4004e Remove duplicated logging in configdrive creation
Ironic-lib logs a message when configdrive is created
successfully. Remove duplicate message from IPA.

Change-Id: I2af81cdfda4cfc004288f44d14a5c127639cc1f1
2016-10-26 02:47:53 -07:00
Jenkins
0727443b1a Merge "Use ironic-lib to create configdrive" 2016-10-21 15:42:59 +00:00
Shivanand Tendulker
3665306dfb Use ironic-lib to create configdrive
Shell script to create config drive being replaced with python
code in ironic-lib.

Closes-Bug: #1493328

Change-Id: I31108f1173db3fb585386b2949ec880a95305fb6
2016-10-21 03:39:06 +00:00
Jenkins
c393214528 Merge "Install grub in the EFI "Fallback path"" 2016-10-20 16:18:49 +00:00
Derek Higgins
cc5556d06b Install grub in the EFI "Fallback path"
In systems where the nvram may have been reset, add
\EFI\BOOT\BOOTx64.EFI to the EFI system partition so that
the image continues to boot. This will be particularly useful
if the NVRAM wasn't written correctly or if the baremetal
server is be simulated on virt and the NVRAM was been reset
on start (as is the case in libvirt).

Change-Id: I5005ae02c283cdc01540ea46c341a7b0bf9d4c42
Closes-Bug: #1632637
2016-10-20 13:50:02 +00:00
Vladyslav Drok
7bda3408f5 Fix config drive writing script
When the deployment happens on a GPT disk with config drive, writing
it to disk fails. Three reasons for that:

* parted should be used instead of partprobe to determine the type of
  the disk;
* gdisk -l sorts the partitions by their number, sort them by start
  sector instead;
* after sgdisk completion, the configdrive device is not immediately
  visible in the /dev folder, udevadm settle needed here too.

Closes-Bug: #1633063
Change-Id: Ifed89e343f9db4cf303baf7f8823342f6041f202
2016-10-18 00:28:04 +03:00
Lucas Alvares Gomes
cca1cd48ef Add support for root device hints with operators
This patch is updating IPA to use the match_root_device_hints() method
provided by ironic-lib version 2.2.0.

Partial-Bug: #1561137
Depends-On: I1d9dc7a57ea391a3419710c289242b39a4201463
Change-Id: Id93dd0360137df600f5a656348279e56c6b84bf9
2016-10-11 15:43:50 -03:00
John L. Villalovos
20d960ff98 Remove Python 2.6 format style
In Python 2.6 it was required to use {0}, {1}...{n} when using the
string format function. In Python 2.7 and Python 3 it it not required.

Change {N} to {} in code.

This brings the code in style alignment with other projects like
ironic and ironic-lib.

Change-Id: I81c4bb67b0974f73905f14b589b3dd0a7131650d
Depends-On: I8f0e5405f3e2d6e35418c73f610ac6b779dd75e5
2016-10-06 09:05:26 -07:00
Jenkins
6f98e534f5 Merge "Add vendor, product to interface information" 2016-09-21 15:43:10 +00:00
Moshe Levi
fe3b630360 Add vendor, product to interface information
This patch updates the interfaces JSON to include
vendor and  product
u'interfaces': [
    {
        u'mac_address': u'00:0c:29:8c:11:b1',
        u'name': u'eth0',
        u'ipv4_address': None,
        u'switch_chassis_descr': None,
        u'switch_port_descr': None,
        u'lldp': None,
        u'vendor': u'0x15b3',
        u'product': u'0x1014,
    }]

Co-Authored-By: yogananth subramanian <ysubrama@redhat.com>

Closes-Bug: #1611856

Change-Id: I8fa58dde29601abee959f74b69b692ed9eaffb94
2016-09-21 10:14:26 -04:00
Galyna Zholtkevych
993149cfb4 Improve error message while download image
Collecting warning logs in the case of download failure
and write them to error logs in the end. This will help
a user to diagnose a problem when warning log was not
enabled.

Change-Id: I4198d7be08fc11b616b3f95c595ff53794436e24
Partial-Bug: 1512186
2016-09-21 10:02:22 -04:00
Jenkins
c4c7115d4f Merge "Fix IPA for stable/mitaka with noauth mode" 2016-09-01 09:19:52 +00:00
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
fb1cbbdafc Fix IPA for stable/mitaka with noauth mode
In noauth mode when running stable/mitaka, Ironic responds to the
initial lookup request with code 406, NOT_ACCEPTABLE, due to the client
supplied microversion of 1.22 by IPA.

As such, we should fallback upon receiving the 406 error code.

Related-Bug: #1616461
Change-Id: Ief9c151cf27a3c38c33a837bb7d6581868a3dc22
2016-08-26 13:06:34 +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