Return the HTTP Location for newly created resources

To provide information about the location of a newly created resource
(201) the Ironic API now returns the URI for the new object in the HTTP
Location header.

A new function build_url() was created in the link.py by factoring out
part of the the Link.make_link() method so that we can reuse that part
of the code to build a URL without having to create a new Link object.

Partial-Bug: #1317044
Change-Id: I88b033d446aaed93fc90ab6497578d5cd729dea8
Return the HTTP Location for accepted requestes

After the server accepts a request (202) it now returns an URI in the
HTTP Location header so that clients will know how to track the status
of the request.

Closes-Bug: #1317044
Change-Id: I5286ed762426dea02a6513c0e31cbc9a8023f803
Fix the logging message to identify node by uuid

The logging message of _build_pxe_config method in
ironic/drivers/modules/pxe.py is like below:
Building PXE config for deployment 4.

"4" is a ID of the node, but users don't know ID of the node
even if using CLI or API.
Users can know only uuid of the node.
So that, uuid of the node should be written in the logging message.

This patch makes identify node by uuid not by id.

Change-Id: Ida220a97d5fc8f6c5adc5b5acf239bbee14ff847
Closes-bug: #1327085
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
Fix AttributeError when calling create_engine()

The module which contains the create_engine() method is the sqlalchemy,
not slqalchemy.api.

Change-Id: I0b9e2f5b25f0c8ea9f7e55d863fa170cc9c09564
Partial-Bug: #1327225
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
Skip migrations test_walk_versions instead of pass

When there is no db engine configured for the migration tests,
the test_walk_versions test was passing, rather than skipping,
because it contained a for-loop and no check for the length of the
sequence being iterated over.

This patch checks the length of the configured engines and
properly skips the test when there are no engines.

Change-Id: I8a5c0a66f65a99c5169b251be02a8fbe6c727641
Closes-bug: #1327397
Mock seamicroclient lib in unit tests if not present

Mock the python-seamicroclient library from within ironic/tests/drivers
so that test_seamicro.py can import ironic/drivers/modules/seamicro.py
and run the unit tests on it, even when the external library is not
present.

Change-Id: I4f2cd75b2c64a5a280a5d45d5cea058fd432815b
Closes-bug: #1312321
Work around iscsiadm delete failures

Attempting to delete an iSCSI target immediately after the initiator has
logged out of the session can sometimes cause iscsiadm's database update
to fail.  This allows the delete command to be retried up to 5 times on
failure.  We also accept exit code 21 (no records found) as success.

Closes-bug: #1324670
Change-Id: I064fcd01e3bd713b0ec19cc1fdb562ca7fd8b666
Remove 'fake' and 'ssh' drivers from default enabled list

Remove the 'fake' and 'ssh' drivers, since they should not show up in
production, and it is better to have production-oriented sane defaults.

Updates the option doc string with a lengthy description.

Updates the developer documentation with a link to the wiki page,
where a list of CI-tested drivers will be maintained.

Change-Id: I1151ace22752efdf6a8a43e279a57d728ea6cce2
Update Nova driver's list_instance_uuids()

list_instance_uuid() was dependent on list_instances().  The latter
was fixed to return the correct results but the former was not,
causing nova-compute start up failures.  This updates it accordingly
to return the expected output via a client API call.

Change-Id: I27651ca01dbdcc95ca729da7dbbeafdc616eec4e
Closes-bug: #1326988
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
Merge "Fix AttributeError when calling create_engine()"
Merge "Fix the logging message to identify node by uuid"
Rework make_partitions logic when preserve_ephemeral is set

This patch reworks the logic around make_partitions when rebuilding an
instance with preserve_ephemeral set to true. The reworked logic will
no longer wipe the current partitions when rebuilding an instance with
preserve_ephemeral set.

Partial-Bug: 1317647
Change-Id: I15fc0d6323698eaa4c30b8aaa7fb740f51c035bc
Merge "Return the HTTP Location for newly created resources"
Merge "Update Nova driver's list_instance_uuids()"
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