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
Wipe any metadata from a nodes disk

Ensure that a nodes disk is wiped of any metadata. This Patch only
deals with the wiping of the metadata per review comments.

Closes-Bug: #1317647

Change-Id: I3bc2da3a12362bad12957d6f34e7ee7807813300
Add unique constraint to instance_uuid

Add a unique constraint to the instance_uuid column of the nodes table
and a migration script. The old node_instance_uuid index was dropped in
favor of the new unique index.

Partial-Bug: #1326364
Change-Id: I005d3b3f252b18c506bab3297b1a5e3c7e7534d2
Set instance default_ephemeral_device

Duplicate the old nova-bm logic of setting the default ephemeral device
to /dev/sda1 (first partition on the disk) when an ephemeral partition
is being used. This is a short-term solution to fix the majority of cases
that depend on this value being present in the instance metadata
(e.g., cloud-init). Longer term, we should consider using something
like udev by-label names (/dev/disk/by-label/NNN) or similar.

Closes-Bug: #1324286

Change-Id: Ia85f0fd0bfa5cca0320db0e8c7f1e0e2b61b4ef6
Stop ipmitool.validate from touching the BMC

Stop the IPMITool driver from calling 'mc guid' in validate().

Validate is currently called synchronously when API requests are sent to
  GET /v1/node/NNN/validate

While work is ongoing to make the API more asynchronous, this presents
a particular issue in that a user can spam this URL and overwhelm the
hardware node's BMC.

Furthermore, validate() is called internally in several places, which is
further contributing to BMC instability as reported in the related
bug 1320513.

Change-Id: I2414d2b07e2ab86c85ca18bc033368ddf43f7f43
Closes-bug: #1314954
Related-bug: #1320513
remove default=None for config options

In the cfg module default=None is set as the default value, there are a 
lot of StrOpts but few with default=None, to be more unify and clear, we 
should remove it.

Change-Id: I2a5dab763fe9cc07e6c1dbed4628e9cf2ca28bcd
Closes-Bug: #1323975
Merge "Set instance default_ephemeral_device"
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
Merge "Stop ipmitool.validate from touching the BMC"
Merge "remove default=None for config options"
Merge "Wipe any metadata from a nodes disk"
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
Sync processutils from oslo code

Sync openstack/common/processutils.py:
    cdcc19c1d78a4a88daabfb64b27abd4924aa442d
    2a4d15dda6f2c32cce322d82f1a81de6b50853f0
    8a0f5678485076fbe0ea1f318c7fd49bac3f1df8
    51778f9eef2dd88a949679f0280f69ee99fd5567
    fcf517d72cb81f972fad20caa9ff0341e9b4aa9c
    af4159266f6e366a3cd7366a672f8f8b38a2f0f2
    f773ea298cd9f322023b91247e688726cf674cd5
    8b2b0b743e84ceed7841cf470afed6a5da8e1d07
    3b71f46628822c74c66d37cae8eca9e7d8679d0d
    12bcdb71ffbe9ee1688beed1f0ddb0c198822682
    a4dab739a780a38c5263b02a670a1d0d009f829e
    d6a963e911b8456c06dceb5ee3cc88a70c08bf82
    aa5b6588292e804557c7ff7f24a88f0ea97acca8
    1a2df89c05d33495d7e057dcdf0714d05beb1fc8
    7119e29cb535426c587eaf2cfc2cfcd11a422df0
    2f013887c20310c522f9494ed854554e6f8c7aa4
    a51469326e84ed977ecc4e57fd3d46cdc21aa08f

Change-Id: I50439ced3adec1e6befcb7cb65fe558852f2611a
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
Merge "Add unique constraint to instance_uuid"
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