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
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
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
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
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()"
Allow more time for API requests to be completed

We currently poll for success, but physical machines can take a while
to respond to IPMI etc. The current defaults reliably fail to complete
with 5 workers (which is the desired default). Until we have event
based logic from Ironic -> Nova we need to try harder, or be
unreliable. 60 retries of 2 seconds each means 2 minutes before a
truely hard fail (as opposed to queue backlog) is reported. Note that
deploys can starve deletes at the moment, so this fix is not enough to
stop spurious reports of problems.

Change-Id: I917a4430e5e77936deb82343ff057b9adc9822ec
Partial-Bug: #1319858
Merge "Rework make_partitions logic when preserve_ephemeral is set"
Merge "Return the HTTP Location for accepted requestes"
Merge "Work around iscsiadm delete failures"
Merge "Allow more time for API requests to be completed"