Fix Nova rescheduling tear down problem

If something fails in the spawn() method (e.g driver parameters, node
in maintenance mode) nova will try to rescheduler the instance (in case
the retry filter is enabled) as part of the rescheduling process nova
will call destroy() on that instance which was cause another problem
when Ironic tried to undeploy a node that wasn't deployed. This patch
is fixing the tear down problem by checking the provision_state of the
node before requesting Ironic to undeploy the node.

Also, the relevant code and tests underwent some refactoring to make
the code shorter and less nested.

Closes-Bug: #1300288
Co-Authored-By: Dmitry Tantsur <dtantsur@redhat.com>
Change-Id: I4c7037d6c7b99548a646ef6665b29479277fb4d5
Reduce logging output from non-Ironic libraries

The service logs (especially for conductor), are littered with
debug output from other libraries when run with DEBUG verbosity.
This makes it extremely difficult to read the logs. This turns
off the noisiest offenders.

Change-Id: Id779506a7bebe7c7a13fadaeac34807050d1ce04
Fix grammar in error string in pxe driver

Noted during translation, the string fixed here suffered
from a grammar error.

Change-Id: Ic0b0acf2ee10bef4536ec664accf5a8d9108ba09
Move duplicated _get_node(s)_mac_addresses()

Move duplicated _get_node(s)_mac_addresses() from pxe and ssh drivers
to a common place.

Change-Id: I27d1df6d3b63f3421d59d14d2b5b9f2c874d6580
Show maintenance field in GET /nodes

Before the maintenance field was only shown if client issued a GET on
a specific node (node-show), but this is an important attribute to have
listed in a GET /nodes (node-list), it's a good info to know which nodes
from that list are in maintenance mode or not, and the Nova Ironic Driver
also need this information to determine which nodes are available to be
exposed to Nova or not.

Change-Id: Icc31a312130a1c2d5853da64bd9091a93221363c
Fix self.fields on API Node object

All fields from objects.Node were being added to self.fields in
the API Node object. Because of this, when someone would POST, there'd
be an entry for {'id': None} in the dictionary passed to
dbapi.create_node(). We should only set fields we're exposing.

This also required fixing PATCH to not try to look at fields not set
on the API Node object when mapping to objects.Node.

A later patchset removes the direct dbapi call to create_node() in
flavor of using the objects.Node object where trying to set 'id' of None
would fail prior to this fix.

Change-Id: I92c03d9ff2a56e7999a685f9de38efec5aacbe47
Add Node.instance_info field

This is necessary for instance-level info accessed by drivers.

Related to blueprint add-node-instance-info

Change-Id: I4688676767a80ac6f1f3d571f0df4ea78bc756e1
Sync base object code with Nova's

This brings Ironic's base object code more in line with nova's since the
time it was copied. There's still a large difference in the field/type
declarations that we should resolve at some point. (Would be helpful if
this was in oslo, maybe. :)

A couple of these changes are needed for my future patchsets for object
cleanup.

Change-Id: I7e233fb448e9ce56f707d230dc5b2558bdb0a1f9
Change admin_url help in ironic driver

Replace ironic driver's admin_url ('Ironic pulic api endpoint')
with 'Kestoyne API endpoint.'

Change-Id: I3ac43251efff74001aa0e881c34a0c36eb2968ca
Closes-Bug: #1298077
Use xargs -0 instead of --null

This gives compatibility with OS X in the test.

Change-Id: I483b4279d0d6a5a6fe4f81b9fb07a838e17e1b0f
Merge "Fix grammar in error string in pxe driver"
Refactor nova.virt.ironic.driver get_host_stats

Refactor the get_host_stats() method to be cleaner
and easier to maintain.

This patch does not change any APIs or functionality.

The unit test for get_host_stats() no longer made sense,
so it was removed.

Co-Authored-By: David Shrewsbury <shrewsbury.dave@gmail.com>

Change-Id: I1b49accfef546d87044f65dcb42b9bef8ab05c6d
Fix messages formatting for _sync_power_states

Missing '%' symbols for string formatting

Change-Id: Ib51c307f81fecbfd81a9b7241180b9b36c874652
Merge "Change admin_url help in ironic driver"
Merge "Reduce logging output from non-Ironic libraries"
Updated from global requirements

Change-Id: I850c1b0f3aa28814d99b17d705a0814d4fe3a7df
Merge "Refactor nova.virt.ironic.driver get_host_stats"
Merge "Fix messages formatting for _sync_power_states"
Merge "Updated from global requirements"
Update tox.ini to also run nova tests

This updates testr.conf to allow passing of the tests directory as an
environment variable (defaulting to ironic/tests/). Also updates tox.ini
to run testr once for ironic/tests and once for ironic/nova/tests/, then
combine subunit output.

test-requirements.txt is updated to pull in Nova from a tarball, as well
as mox and python-ironicclient.

Updates the existing Nova driver unit tests to account for recent
refactoring and changes in the Nova virt API.

Change-Id: Ibefa2e0d3f97512f4da9ace780703fe47467232e
Closes-bug: #1299312