193 Commits

Author SHA1 Message Date
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
Josh Gachnang
d6afe62e94 Fix using non-existent mock method
Mock 1.1.0 throws an error when using assert* methods that don't
exist.

Change-Id: I3fff6df417a29882f1e8672c309edc6d4201cdc2
2015-07-10 10:03:25 -07:00
Jenkins
a0f7485460 Merge "Convert Int to String for shred execute" 2015-07-06 23:49:37 +00:00
Jacob McCann
c0769691bd Convert Int to String for shred execute
Was running into 'expected string, int found' when calling
shred with an Int for iterations.

Change-Id: Iffce247caba5b0d62ac89b6411402c8d975cfd2f
Closes-Bug: #1469838
2015-07-01 15:08:18 +00:00
Sergey Vilgelm
64fd0fe37f Switch to oslo.service
oslo.service has graduated, so ironic should consume it.

Change-Id: I4560f3050bd8ce7e0c40a5cd5fb6a5a1b410f728
Partial-Bug: #1466851
2015-06-24 11:19:07 +02:00
Jenkins
4c1d2cdb19 Merge "IPA:'shred' utility to use configured iterations" 2015-06-22 10:11:11 +00:00
Mathieu Mitchell
63851b72ee Use host_device mode for qemu-img
When writing to a host device, possibly one that does not support holes,
it is preferable to use host_device instead of the raw mode. Not doing so
means holes are simply skipped and the deployed image is invalid.

Change-Id: I24f8b4daf099af8bb03c3a4f6417b6c87bd49021
Closes-Bug: #1466632
2015-06-18 16:00:25 -04:00
Anusha Ramineni
02f78453b2 IPA:'shred' utility to use configured iterations
Today, there is no option to configure number of iterations to be
done for shred block device erasing and defaults it to 1. This patch
adds a configuration option to change the number of passes to be done
to erase a block device.

Change-Id: I1921d33a6b364c4682b6c9baaf61ac092cfa11d7
Partial-Bug:#1465130
2015-06-18 09:26:36 +00: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
Jenkins
0a416af0c8 Merge "Make sure sysrq functions are enabled in reboot.sh" 2015-06-08 15:38:07 +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
Ramakrishnan G
8faa3ae9d5 Make sure sysrq functions are enabled in reboot.sh
This commit echoes '1' to >/proc/sys/kernel/sysrq to
make sure that sysrq functions are enabled before
invoking them.

Change-Id: I88697efbc1bd0dec5ed4cbcd8d89b0b5d0734bdd
2015-06-02 12:41:06 +00:00
Jenkins
8a94a8979c Merge "Use mkdtemp for mounting virtual media device" 2015-05-14 17:56:49 +00:00
Anusha Ramineni
8cef029d0d Fix error in in-band disk erase using shred
in-band disk erase using shred fails with error "'module' object has no
attribute 'ProcessExecutionError'". This commit is to fix the issue.

Change-Id: Ia0c426074b2f0e9d534ed96a3e213933160edc61
Closes-Bug:#144799
2015-05-08 15:02:36 +05:30
Anusha Ramineni
efba46a8a2 Fix inband disk erase using agent_ilo driver
In-band disk erase using shred fails for agent_ilo driver as it tries to
erase the virtual floppy device attached.This fix is to skip the virtual
media devices and continue with other disks.

Change-Id: I26745985382d440f7d4b3fbfffb14545067fcca6
Closes-Bug:#1450298
2015-05-07 09:51:11 +05:30
Ramakrishnan G
b735b3c9d1 Use mkdtemp for mounting virtual media device
When using virtual media, restarting ironic-python-agent
leads to errors like 'File exists'.  This is because
we use static directory (/vmedia_mnt) as mount path
and we don't remove it. It's better to use mkdtemp to create
a temporary directory for mounting virtual media
device.

Change-Id: Ibb4c3d3a2024cf51ef198bd396fb9e86ad72a320
2015-05-06 02:47:48 -07:00
Jenkins
a1c87672ea Merge "Fix Sphinx Autodoc WARNING/ERROR in docs build" 2015-04-01 00:39:21 +00:00
Jenkins
499a212f92 Merge "Add sphinx build + basic documentation" 2015-04-01 00:32:18 +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
Jay Faulkner
be97525975 Add sphinx build + basic documentation
This adds and configures a sphinx doc builder. This is based on the code
in Ironic to build documentation.

The goal is for this to contain development documentation relevant to
hacking on the agent, including how to make custom HardwareManagers.

Change-Id: Ib6cecb9959f4ad5c71440fb37827b996582a9545
2015-03-31 16:22:12 -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
Ghe Rivero
98b92f960b Sync from oslo.incubator
Update imports from oslo.incubator and remove old modules no longer
used.

Change-Id: Ibb71a7287f46709bb76c3dac5ce4be7a2f4818a3
2015-03-24 08:41:32 +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
Jay Faulkner
79790171bc Call partprobe+partx before writing configdrive
partx -u $DEVICE doesn't work in some cases, but partprobe $DEVICE fails
in virtual environments (like devstack). For now, run both commands and
ignore partprobe failures.

Moving forward, this shell should be factored into python and share code
with the other partition-modifying code added this cycle.

Change-Id: I7e4c010e260be2a23dcc894bc0c1b30aea949084
Partial-bug: 1433812
2015-03-19 11:25:35 -07:00
Jay Faulkner
a17c824288 Add fallback secure erase using shred
This prevents devices from failing cleaning if they don't support ATA
security erase. Instead, the device will be erased by overwriting using
GNU shred.

Change-Id: Ie4f88b97c8c34efe2397538662622abd0b963aea
2015-03-18 14:57:28 -07: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
Jenkins
be44ac8d4d Merge "Use labels for virtual media dev in agent ramdisk" 2015-03-17 02:50:47 +00:00
Devananda van der Veen
4f2ad2104e Fix nit in test_get_agent_params_from_cache
Address a nit in previous review: test_get_agent_params_from_cache
should assert that _set_cached_params is never called.

Change-Id: I4724bd15ee923a9272aa872641430f3dfbef3fec
2015-03-16 11:00:24 -07:00
Ramakrishnan G
c7b3c73d65 Cache agent parameters for later invocations
When parameters are passed to agent through virtual
media, the device might be connected only for a short
while (dur to swift temp-url expiration, ironic removing
the floppy image, etc).  This change will enable agent
to cache the parameters and use it for any time later on.
After caching, the agent parameters need not be re-read
from /proc/cmdline or from the virtual media device.

Implements: blueprint ipa-as-default-ramdisk
Change-Id: Ia8c7020c91c987ec884c5640421f0583dbf1c3d9
2015-03-16 16:41:26 +00:00
Jenkins
1287b9ce4f Merge "Add dispatch to all managers" 2015-03-13 21:09:22 +00:00
Jenkins
d769b15b4e Merge "Add support for root device hints" 2015-03-13 14:02:56 +00:00
Lucas Alvares Gomes
5a529ca489 Add support for root device hints
This patch add support for root device hints on IPA. Instead of picking
the first disk >= 4G, if the hints are specified IPA will look at it
to decide which device it should pick for the deployment. The initial
patch supports the following hints: Size, model, WWN, serial, vendor.

Implements: blueprint ipa-as-default-ramdisk
Implements: blueprint root-device-hints
Change-Id: I2b00b3fb3b61001033750dd8951f9353d6f2e361
2015-03-13 10:42:12 +00:00
Josh Gachnang
3e6b57a8bc Add dispatch to all managers
This allows the agent to call a method on all hardware managers
that support the hardware and return a list of their responses. This
will be useful for implementing get_clean_steps() in cleaning.

Also fixes a leaky test in dispatch_to_managers. The function
wrapper was holding global state, which leaked into other tests
if a function was called again later, messing up the call count.

Implements blueprint implement-cleaning-states
Change-Id: I76bf8ec18df1dc16c4b9d942800b8a1efcde9e65
2015-03-12 15:16:02 -07:00
Ramakrishnan G
d0d319d65f Use labels for virtual media dev in agent ramdisk
This commit changes agent deploy ramdisk to find out
the virtual media device by using labels instead of
looking at the model of block device.  This helps in
finding out the device irrespective of the hardware.

Corresponding Ironic change is
If5b78d9af7048f2631d050ee5ce01ab7a67e2354.

Closes-Bug: 1429340
Change-Id: Ib6cc226dc4fb341d913f707737493c31a3f77152
2015-03-12 04:45:52 +00:00
Jenkins
1fc7136235 Merge "os.path.exists should be mocked in test case" 2015-03-11 21:57:07 +00:00
Ramakrishnan G
d1b30a14d2 os.path.exists should be mocked in test case
This commit mocks os.path.exists in the test case
test_start_iscsi_target_fail_wait_daemon in
extensions.iscsi.TestISCSIExtension.  If this isn't
mocked, the file can coincidentally exist on the
environment and can cause failure.

Change-Id: Ibaa8fcae51faaaefc2764411d02621f347d99c03
2015-03-11 17:16:46 +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
c6cd3a8190 Move _get_agent_params() to a common place
The function _get_agent_params() parse the parameters passed to the agent
via kernel cmdline or vmedia. Other parts of the code needs to access
these parameters as well, so this patch is moving _get_agent_params()
and the related functions to a common place (utils.py).

Change-Id: I860f84d1d13511fff56d4aa56358ee597a9760d5
2015-03-10 17:43:17 +00:00
Jenkins
e09cd11fe1 Merge "Add the image extension (for local boot)" 2015-03-05 19:51:42 +00:00
Jenkins
9aa5e08da8 Merge "Fix incorrect IPA log message" 2015-03-04 17:39:00 +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
Josh Gachnang
65fe55a81f Fix incorrect IPA log message
Change-Id: I520250287ae64495604e575b13a11481d03b79b2
2015-03-03 12:54:35 -08:00
Jay Faulkner
ff5b0643d2 Enable setting standalone mode via APARAMS
All other IPA options are settable via APARAMS (kernel command line
or the kernel commandline-like interface provided by virtualmedia).
Being able to set this at PXE time allows for operators to boot
and functionally test new agent images without having to recompile
post testing (to change standalone setting).

Change-Id: Ie796a98c995704db09945b6f890e9bf4d07eaa1a
Closes-bug: 1426546
2015-02-27 14:25:13 -06: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
Jenkins
ee93744b9a Merge "Log required troubleshooting info on image dl fail" 2015-02-13 02:17:15 +00: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