Reuse validate_instance_and_node() Nova ironic Driver

The driver already counts with a function called
validate_instance_and_node() that checks which node is associated to
a given instance and raises InstanceNotFound if the instance UUID is
not found in Ironic. The same functionality was being duplicate in many
other parts of the driver, this patch simply update those parts to use
the validate_instance_and_node() function.

Change-Id: I9a2f90c7cdd0fdfcc00d49a49581c61e4f073888
Improving unit tests for _do_sync_power_state

Improve the unit tets coverage, and tightening up existing
tests surrounding the _do_sync_power_state method.

Change-Id: I9fd4c4c42936fcf8fc4f36bf35b6e691c495b8b0
Closes-bug: #1297404
Update IronicHostManager tests to better match how code works

This is the first in a series of patches to prepare Ironic for the
removal of capabilities in Nova HostManager.

IronicHostManager used to rely on capabilities info to decide which
host state class to use, VM or baremetal. This has been broken since
host capabilities reporting were removed in Nova, resulting in Nova
HostState class always being used.

IronicBareMetal tests make use of an internal Nova HostManager variable
in a way that hides the fact that IronicNodeState class is no longer
used. This patch rewrites tests to better reflect how Ironic/Nova code
now works and prepares for further changes that needs to land in Ironic
before Nova HostManager capabilities can be removed.

Change-Id: I795eaed58f6587585d89366d8f1e521588866a58
Partial-Bug: #1260265
Add missing stats to IronicNodeState

This is the second in a series of patches to prepare Ironic for the
removal of capabilities in Nova HostManager.

IronicHostManager used to rely on capabilities info to decide which
host state class to use, VM or baremetal. This has been broken since
host capabilities reporting were removed in Nova, resulting in Nova
HostState class always being used.

Before IronicNodeState class can be used again, it must be updated to
store host stats as this is needed by ComputeCapabilitiesFilter to
correctly filter hosts or this filter will return no hosts.

Change-Id: I1661107883722bf14a488842373fd3027dc7a62c
Partial-Bug: #1260265
Fix host manager node detection logic

This is the last in a series of patches to prepare Ironic for the
removal of capabilities in Nova HostManager.

IronicHostManager used to rely on capabilities info to decide which
host state class to use, VM or baremetal. This has been broken since
host capabilities reporting were removed in Nova, resulting in Nova
HostState class always being used.

This patch fixes the detection logic in IronicHostManager to correctly
choose IronicHostState class for use with baremetal nodes. Tests are
added to verify that the correct class is used for both vm and
baremetal nodes.

In reality, the new detection logic will not start to deliver the
correct HostState class until the Nova HostManager change has landed.

Change-Id: Ifa47d721835cfea87e9d0bce87c7853dd6724b98
Closes-Bug: #1260265
Fix utils.execute() for consistency with Oslo code

Oslo processutils.execute() can use non-string command line
arguments, they convert to strings internally.
This patch fix utils.execute(), non-string arguments can be
used as in Oslo execute without error.

Change-Id: I4f640582375b244e23a6641c3b94157c49c8ee3b
Use .png instead of .gif images

This replaces the two image files used in the Admin Guide, "Introduction
to Ironic" page. The images were in .gif and are being replaced with
their .png counterparts, because .png is a better format.

Change-Id: Iec831d37f58f4e159b0cfc197bac5dad433d32cf
Driver interface's validate should return nothing

Some of the driver interface's validate(), eg pxe.VendorPassthru.validate()
returns True. The expected behaviour is for them to raise an exception if
validation isn't successful, or return nothing if validation succeeds.

This is fixed.

The docstrings for the validate functions in the base class have been updated
to mention that they should return None.

Change-Id: Ic8fb626874ed6cb11494c84dc184d70686441b0f
Closes-Bug: #1288363
Let ipmitool natively retry commands

Instead of calling ipmitool multiple times on failure via
  utils.execute(*args, attempts=3)
allow ipmitool to use its own native retry behavior with -N.. -R..
if those options are supported by the installed version of ipmitool.
This will fall back to a single run of ipmitool on older versions,
which should be fine -- it defaults to retry several times anyway.

This patch adds a configurable min time between retries, which is used,
in conjunction with the ipmi retry time, to determine these option's
values. It will be further leveraged in a subsequent patch as well.

It also adds a note in the deployer docs about known issues with
the openipmi project.

Change-Id: I7a4ff941144a03bd441459561efb68760391da1a
Partial-bug: #1320513
Factoring out PXE and TFTP functions

Multiple drivers need to support neutron and Ironic's PXE and TFTP
server. Factoring them out into a common file will make that
transition possible. This moves all the generic calls into neutron
and reconfigures the PXE driver to work with the new functions.

Change-Id: I181ffabe673636b628329592e623e6425da54d6d
Merge "Driver interface's validate should return nothing"
Merge "Let ipmitool natively retry commands"
Replace mknod() with chmod()

Using mknod() can be troublesome on Macs since the underlying system
call requires super-user privileges. Since its main use here
is to set the mode of the file (the subsequent call to open() is
enough to create it), we remove it and replace it with the less
troublesome chmod().

Partial-Bug: #1329077

Change-Id: I30c767792f44d27c6c0179474112015c5ab9bac3
Test for membership should be 'not in'

Enabled check for PEP8 issue E713.

Change-Id: Id41f5f19796a7af8cf4cb52dd7afc2e6ec1ccbc4
Remove 'node' parameter from the validate() methods

The node parameter is redundant since the node object is an attribute
of the task object.

Closes-Bug: #1312632
Change-Id: Ia4193ea561a31e54754049d9964c6c9021474caf
Merge "Test for membership should be 'not in'"
Enforce a minimum time between all IPMI commands

This patch enforces the min_command_interval option, which was added in
the previous patch, to ensure that any given BMC is never "poked" more
frequently than this interval, regardless of the calling method.

Closes-Bug: #1320513

Change-Id: Id3849aadf3908133a92157b3e96dd752610533e9
VendorPassthru.validate()s call _parse_driver_info

ipmitool's and seamicro's VendorPassthru methods use the parameters that
their _parse_driver_info() validates. Yet their VendorPassthru.validate()'s
weren't calling _parse_driver_info() to make sure that needed parameters
were specified/valid.

ipmitool's and seamicro's VendorPassthru.validate()s now call
 _parse_driver_info().

Change-Id: Ic6196bcc13024b914c04d35868f3d5f10e73f420
Closes-Bug: #1312383
Merge "Remove 'node' parameter from the validate() methods"
Merge "Reuse validate_instance_and_node() Nova ironic Driver"