77 Commits

Author SHA1 Message Date
Jenkins
858c643777 Merge "Add disk_label support for partition images" 2016-03-23 10:53:35 +00:00
Jenkins
16265a6c8b Merge "iscsi: wipe part table before starting the target" 2016-03-22 19:21:06 +00:00
Gonéri Le Bouder
0b1f01db94 iscsi: wipe part table before starting the target
If the local disk has already a partition table, it must be clean up
before the disk is exposed through iscsi. Otherwise this disk partition
can create a conflict during the grub installation.

How reproducible:

1. Inject an image on the root disk, like for example ipxe.usb or ipxe.iso
2. Try to deploy a system on the node using Ironic
3. The node is properly deployed but the grub installation has failed
   with the following error:
     attempting to install grub to a disk with multiple partition labels

A simple sgdisk -Z /dev/vdX is not enough because grub-install will
inspect the disk and will still detect a remaining partition.

This commit makes use of the ironic-lib to do the clean up of the disk.
The additional review Id59fa5a06b9115c0f9afc09aae95daaac97e2fac increase
the amount of data to wipe.

References:
https://bugzilla.redhat.com/show_bug.cgi?id=1310883

Partial-Bug: 1550604

Change-Id: Ie68cb6296c782e904d40f6e9de0faa52ab2af2bf
2016-03-22 13:28:21 -04:00
Nisha Agarwal
4ec49be8e2 Add disk_label support for partition images
This commit adds the disk_label support for partition
images. It also fixes the node_uuid info passed to the
ironic_lib.

Partial-Bug: 1560560
Change-Id: I8b8ef20787468c1b8dc6fbc0b8905abd285325e1
2016-03-22 16:59:38 +00:00
Nisha Agarwal
936b2e4c4a Fixes the agent message for uefi netboot for partition image
The agent returns "efi_system_partition_uuid=None" in the
status message for uefi netboot for partition images.
This commit fixes to remove this unwanted message
from the status message as efi partition is created only
for localboot.

Closes-bug: 1526289

Change-Id: I6376406cdde29493619f50b0a6cd8b6ce3784d6e
2016-03-21 18:11:32 +00:00
Jenkins
4f1caf11e9 Merge "Add sync() command to the standby module" 2016-03-21 09:51:44 +00:00
Lucas Alvares Gomes
4b802c47b5 Add sync() command to the standby module
This patch is adding a new command called sync to the standby module of
IPA. The new command runs synchronously and it's responsible for
flushing file system buffers to the disks.

The initial intention for this command is to use it as part of the fix
for the bug #1512492 where some hardware/firmwares do have problems to
come back online after a soft ACPI power off, therefore we need to call
sync() to make sure all file system buffers have been synced and then
issue a hard power off (e.g via the BMC).

Partial-Bug: #1512492
Change-Id: I5cd1d1b821426e995dc584452494b93ab23917e0
2016-03-18 15:20:48 +00:00
Faizan Barmawer
944595a69d Add support for partition images in agent driver.
It also adds the ironic-lib in the requirements
list of the IPA package.

Partial-bug: 1526289
Depends-On: I22bc29a39bf5c35f3eecb6d4e51cebd6aee0ce19
Change-Id: I37908470484744bb720f741d378106d1cb1227a3
2016-03-18 08:21:01 +00:00
Nisha Agarwal
bb605784dd Fixes programmatic error in _install_grub()
The patch defines the variables before they are used in the
code.

Closes-bug: 1555547
Change-Id: I27c5e926cf4001211c4edd794a09b26559c63f71
2016-03-11 21:09:37 +00:00
Jenkins
2a71a94208 Merge "Replace all the 'self.log' calls with global LOG" 2016-02-29 16:05:09 +00:00
Zhenguo Niu
7fe40bb559 Replace all the 'self.log' calls with global LOG
Change-Id: Iae917e1139c8c95a1bad5466df8a607656b9de5c
2016-02-24 09:51:01 +08:00
Zhenguo Niu
c716293cbf Catch OSError as well to return a better error message
When neither tgt nor linux-io are available, we only get error
message like 'No such file or directory', this situation should
be detected and return a better error instead.

Change-Id: I334717a1a8a728aa6da6024ff9fc6d817399a41f
Closes-Bug: #1540958
2016-02-22 15:10:57 +08:00
Jenkins
1e30946835 Merge "Allow hardware managers to override clean step priority" 2016-01-28 05:36:12 +00:00
Josh Gachnang
61b4387b95 Allow hardware managers to override clean step priority
If two hardware managers have the same clean step, for example
'erase_devices' in the GenericHardwareManager and a custom manager,
IPA must determine which step should be kept and which should be run
in order to prevent running the step multiple times.

This patch uses the following filtering logic to decide which step
"wins":
- Keep the step that belongs to HardwareManager with highest
  HardwareSupport (larger int) value.
- If equal support level, keep the step with the higher defined
  priority (larger int).
- If equal support level and priority, keep the step associated with
  the HardwareManager whose name comes earlier in the alphabet.

Other than individual step priority, picking which step to keep does
not actually impact the cleaning run. However, in order to make
testing easier, this change ensures deterministic, predictable
results.

Co-Authored-By: Mario Villaplana <mario.villaplana@gmail.com>
Co-Authored-By: Jay Faulkner <jay@jvf.cc>
Co-Authored-By: Brad Morgan <brad@morgabra.com>
Change-Id: Iaeea4200c38ee22cab72ba81c1dbae3389e675e4
2016-01-14 13:12:52 -08:00
Kan
dcdb06d812 Replace deprecated LOG.warn with LOG.warning
Change-Id: I0ca31eac70afaccda73e7819c582af0b226b8442
Closes-Bug: #1508442
2016-01-05 05:37:09 +00:00
Dmitry Tantsur
4cd64e28aa Delete the Linux-IO target before setting up local boot
Otherwise it fails with "device already mounted".

Change-Id: If959ba5a10e97f84be2f7498bed7589d13fa30c2
Closes-Bug: #1526304
2015-12-15 15:20:03 +01:00
Dmitry Tantsur
c474a5ac6c Support Linux-IO in addition to tgtd
The iSCSI extension now tries to use Linux-IO first (via rtslib)
and falls back to tgtd if Linux-IO can't be used (e.g. in the CoreOS-based
image which uses containers).

Change-Id: I9cc7a30d9c93c445a66d183146e9260c2b096d33
Closes-Bug: #1504562
2015-11-30 18:38:03 +01:00
Lucas Alvares Gomes
e320bb8942 Add support for streaming raw images directly onto the disk
This patch adds support for streaming a raw image directly onto the disk,
that means no more time spent writing the image to a tmpfs partition prior
to copying it to the disk. Checksum computation is also done as the image
is being streamed. Streaming raw images is disabled by default, however
this behavior can be enabled by passing a key called "stream_raw_images"
with the value of True to the prepare_image() command of IPA.

For non-raw images this may not be possible, not sure about all image
file formats, but common types such as qcow2 requires random access to
the image file in order to be converted to raw.

Closes-Bug: #1505685
Change-Id: Iddf67907bc9b54bbd3065a97064cb5a3602cfe18
2015-11-18 11:19:40 +00:00
Lucas Alvares Gomes
65053b7737 Refactor the image download and checksum computation bits
Prior to this patch downloading and computing the checksum of the image
were done in different stages, after the download the file would need
to be re-read and the checksum was computed. This patch is changing it
by creating a ImageDownload class which computes the checksum at the same
time the image is being downloaded, this saves time and also make the
code more portable.

Related-Bug: #1505685
Change-Id: I71f9f2bd9a62a6a6cc474d0ae519591cea6381d6
2015-11-18 11:19:38 +00:00
Jenkins
39bdbdd357 Merge "determine tgtd ready status through tgtadm" 2015-11-17 23:40:08 +00:00
Vladyslav Drok
54c901e8d5 Support proxies for image download
This change adds proxies parameter to requests.get method when
downloading images, and also sets no_proxy environment variable,
as requests does not support such parameter directly.

Implements: blueprint agent-image-proxy

Change-Id: I000ff9d0d4f5bde4766d085dc5a1c6cea1949bc5
2015-11-17 11:12:12 -08:00
dparalen
fb920f41ed determine tgtd ready status through tgtadm
The intention of the iscsi extension _wait_for_iscsi_daemon function
is to wait till the tgtd process boots completely before running any
iscsi commands through the tgtadm command line utility.  The tgtd
process utilises a unix socket for communication with the user and the
_wait_for_iscsi_daemon function asserts the tgtd process status based
on the socket presence.  The socket name/path to use is not specified
by iscsi extension configuration but rather falls-back to a
(system-wide) default value[1].  Since tgtd version 1.0.60, this path
changed from /var/run/tgtd.ipc_abstract_namespace to
/var/run/tgtd/socket[2] and now causes a false-negative while waiting
for the tgtd process to boot[3].

This patch follows implementation suggestion from the bug report[3] to
avoid relying on the socket presence but rather to check the tgtd
status by trying to communicate through the tgtadm tool.

[1] https://github.com/openstack/ironic-python-agent/blob/
5bbb9ded082f2cfde5e8877e9f33294eb93a5fb7/
ironic_python_agent/extensions/iscsi.py#L47 [2]
https://github.com/fujita/tgt/commit/
d1aa4dcfd691c9409dbad5db49ce6754ce9c1b5a
[3] https://bugs.launchpad.net/ironic-python-agent/+bug/1505923

Closes-Bug: #1505923
Change-Id: If3284e0b441fe6c2da507640c08a4bbefd9dad2b
2015-10-20 04:52:59 +02:00
Dan Prince
ebd7b076a5 Use mount -t sysfs to avoid host /sys dependencies
This patch updates the _install_grub2 function in image.py
so that we use 'mount -t sysfs' instead of bind mounting
the hosts /sys into the chroot.

This resolves issues which can occur with unmounting
the chroot mounts where 'target is busy' errors
may occur when you are debugging things with a serial
console.

Change-Id: I5c9a6546d048cbf54695329d9744fda55127bd30
Closes-bug: #1503385
2015-10-07 03:29:18 +00:00
Dan Prince
5bbb9ded08 Fix log formatting error in iscsi.py
This fixes a ValueError exception that would occur if
log debug was enabled in IPA.

Change-Id: Id95f291dd77d69e7d4dd4f945c6c151db7a0646b
Closes-bug: #1503354
2015-10-06 22:47:54 +00:00
John L. Villalovos
dcbba2b121 Enforce all flake8 rules except E129
Bring ironic-python-agent in line with the other ironic projects.

Stop ignoring all E12* errors except E129
Stop ignoring E711

Change-Id: Icb9bc198473d1b5e807c20869eb2af7f4d7ac360
2015-10-02 10:01:00 -07:00
Jenkins
19d21eb999 Merge "Add more info to checksum exception" 2015-09-22 13:46:48 +00:00
Josh Gachnang
e17129dbad Add more info to checksum exception
If an image cannot be downloaded for some reason, it is helpful for
operators to have the image path, checksum, and calculated checksums
available easily from the API.

Change-Id: I6a2fb46726245cebd730b5c51d4f25f8465f1658
2015-09-21 15:54:02 -07:00
John L. Villalovos
1285baee1c Create a SerializableComparable class
Create a SerializableComparable class derived from the Serializable
class.

Added the following functions to the SerializableComparable class:
  '__eq__'
  '__ne__'

Disable the '__hash__' function in the SerializableComparable class as
some derived classes are mutable.

Use the SerializableComparable class in hardware.py and
extensions/base.py

This should make unit testing users of the class easier when doing a
self.assertEqual() or self.assertNotEqual()

Added some initial unit testing for encoding.py

Change-Id: If0f14b3bfe7f1391f65dd730a16a534afed0da82
2015-09-11 13:44:09 -07:00
Josh Gachnang
46eb0dfa35 Tuples returned by clean steps cause API error
If a clean step returns a tuple (like the output of
processutils.execute), WSME raises an error about the type. Casting
the result as a list seems to make it work. This is almost certainly
a bug in WSME, but after digging a bit I couldn't find one.

Change-Id: I91cb7a989ab56c0942469e03937945d4a590ad95
Partial-bug: #1493554
2015-09-08 13:44:23 -07:00
Jenkins
8165e18949 Merge "Remove ordereddict as 2.6 is no longer supported" 2015-09-05 20:54:07 +00:00
Jay Faulkner
ac040f5152 Add docstrings for cmd/agent and extensions/clean
Adding documentation for methods in these files that were missing
docstrings.

Change-Id: I2ad9f85605720ab2295dec3d0436ff0af07847c2
Partial-bug: 1367915
2015-09-03 16:15:54 -07:00
Jay Faulkner
d29b9af748 Remove ordereddict as 2.6 is no longer supported
ordereddict, and a related workaround method, were removed as we no
longer support python 2.6. Collections contains ordereddict on newer
python versions.

Change-Id: I48cc55a5c56fbc1f71442fc858eb4905f0213988
2015-09-03 13:15:55 -07:00
Joshua Harlow
e9d2bfe580 Three attempts message is incorrect
The code that is covered in this exception block
does not actually retry three times, so it seems better
to have the message not reference that it does.

Change-Id: I0cc19aab65aa9ba4d73a8842390b712f7f63925c
2015-09-02 16:27:43 -07:00
Josh Gachnang
50875381d8 Fix logging levels
This is a fixup patch for bde6ed557034bc2eac633ff84f2e9515a5ef14d6,
and should follow the OpenStack Logging Standards.

Change-Id: Ie277c5742ab736f4c5cee1ee1badedf055323515
2015-08-04 09:29:44 -07:00
Josh Gachnang
59281ecda8 Improve IPA logging and exception handling
Debugging the agent is a huge pain point. Tracebacks are rarely logged,
error messages are often only returned via the API, and lack of
info logging makes it hard to determine where some failures occur.
Some errors only return a 500 with no error message or logs.

Change-Id: I0a127de6e4abf62e20d5c5ad583ba46738604d2d
2015-07-28 09:37:43 -07:00
Lucas Alvares Gomes
06eed473fb Add Python3 support
This patch add Python 3 support for IPA. We still need to enable it on
gate to avoid code breaking the support from sneaking in.

Partial-Bug: #1474896
Depends-On: I5a774eaa8d978f4d50faca4dc1b03a87fb194ce2
Change-Id: If47c0797b63d2914b3c47aba62ec5201301b6c33
2015-07-15 17:12:08 +01:00
Ramakrishnan G
be36ed6903 Add power_off command in standby extension
This commit adds a new command power_off to
standby extension which runs shutdown -h now
on the system. This commit also adds mappings
for /proc and /sys in cloud-config.yml for the
agent service spawned.

Partial-Bug: #1451310
Change-Id: I2a5f984af26bbbe03002bb8c367c8c6af8d91434
2015-06-09 23:44:08 +00:00
Jim Rollenhagen
601201d120 Update hacking and fix hacking violations
This does a few things:

* Update hacking to the version in global-requirements. Old hacking was
  installing a version of pbr that was breaking other packages.

* Fix all the hacking/pep8 rules that updating hacking raised.

* Do some general docstring cleanup, while already in there cleaning up
  a bunch of docstrings due to H405 violations.

Change-Id: I1fc1e59d4c3d7b14631f8b576e3f3854bc452188
Closes-Bug: #1461717
2015-06-03 16:58:57 -07:00
Jenkins
a1c87672ea Merge "Fix Sphinx Autodoc WARNING/ERROR in docs build" 2015-04-01 00:39:21 +00:00
Jay Faulkner
8bad5bbac3 Fix Sphinx Autodoc WARNING/ERROR in docs build
The docstrings here were all giving WARNINGs or ERRORs during the docs
build, and were generally making unappealing looking developer
documentation. I corrected the syntax and did what was neccessary to
make the build come out clean.

Change-Id: I74b00a7f125770b0468cff3bdf26d0d52cd054d7
(cherry picked from commit c0921cdff372ce1fd6df1c4ab4eb5463e2cba0e4)
2015-03-31 16:22:57 -07:00
Ghe Rivero
10a3a800e7 Use oslo_log lib
Module 'log' from oslo-incubator was removed after release of oslo_log
library.

Change-Id: Ia00e26071fc0cab4fd3f3334ca94860bc7b1c75c
2015-03-24 08:43:35 +01:00
Ramakrishnan G
ccda38a86e Do udevadm settle after running partx in image extn
This commit adds running 'udevadm settle' after
running partx so that the partition table is re-read
properly by lsblk which follows it.

Closes-bug: 1432918
Change-Id: I1c7dddd3ed8cab175e608e09ecc4ae7f289cfc31
2015-03-23 02:06:24 -07:00
Jenkins
173f86963a Merge "Add cleaning/zapping support to IPA" 2015-03-20 23:19:54 +00:00
Josh Gachnang
5f4fa7f27e Add cleaning/zapping support to IPA
This will add support for in band cleaning operations to IPA and
replace the decom API that was unused.

Adds API support for get_clean_steps, which returns a list of
supported clean steps for the node, execute_clean_step, to execute
one of the steps returned by get_clean_steps.

Adds versioning and naming for hardware managers, so if a new hardware
manager version is deployed in the middle of cleaning/zapping, the
cleaning/zapping will be restarted to avoid incompatabilities.

blueprint implement-cleaning-states
blueprint inband-raid-configuration
blueprint implement-zaping-states
Depends-On: Ia2500ed5afb72058b4c5e8f41307169381cbce48
Change-Id: I750b80b9bf98b3ddc5643bb4c14a67d2052239af
2015-03-17 17:07:04 -07:00
Ramakrishnan G
ac4e9901d6 Add uefi support in image extension
This commit adds support for uefi systems in the image
extension so that grub can be installed onto efi system
partition for uefi machines.

Implements: blueprint local-boot-support-with-partition-images
Change-Id: I8fbb4b2ebdff991d41c7b618a4d654af26311a56
2015-03-17 18:21:22 +00:00
Ramakrishnan G
1e04c8fffb SyncCommandResult should store actual exception
This commit changes ExecuteCommandMixin to store the
actual exception in SyncCommandResult instead of just
the message in the exception. This is required in the
API side where the result.command_error is trasformed
to base.ExceptionType.

Closes-bug: 1430896
Change-Id: I222bfc11868e73c7da03c84723f1450e38aa1a2f
2015-03-11 16:44:12 +00:00
Lucas Alvares Gomes
d23e0170de Add the image extension (for local boot)
Initially this extension supports installing a bootloader so the user
image can boot from the local disk.

Change-Id: Ia588aafc240b55119c02f1254addc0cf796f88c5
2015-03-04 16:34:17 +00:00
Lucas Alvares Gomes
d3aa7c93aa Add iscsi extension
This extension allows IPA to be used with the PXE/iSCSI methodology of
deployment in Ironic.

Change-Id: I32ec9fa74182c0d03c7ef1b698b1d0c0e3007773
2015-02-26 12:13:00 +00:00
Kyle Stevenson
f1dec5c2e2 Add additional logging and return results for IPA extensions
Some of the extensions in IPA currently do not return any values
from their respective command methods. This results in a lack of a
paper trail of the command_result value to the point where it is
not possible to know more information than a boolean result of if
a command succeeded or failed.

This change adds more logging to the extensions and provides return
values which are used in the command_result property on
(Async|Sync)CommandResult instances to provide useful debug info.

While creating this patch several unit tests for *CommandResult objects
were found to be using invalid data that would not pass validation
if returned in API results. Those have been corrected in this patch.

Change-Id: I23bae25a83881e7013c93d73f858c622ea941253
Closes-Bug: 1408080
2015-02-18 13:12:44 -08:00
Jay Faulkner
e5d88be8cb Log required troubleshooting info on image dl fail
Currently, we only log the image ID and attempted URL. Now, we log the
status code recieved and detailed information about how and when things
failed.

Change-Id: I718c7facbe1500d98be78b7b6137e92fdfb2fdf1
Closes-bug: 1420981
Depends-On: I69f6f6eef4ad573f406d64d579a9811c70ac5d28
2015-02-12 07:35:11 -08:00